Skip to content

Commit

Permalink
documentation added to and exact_correct_code_okay boolean added
Browse files Browse the repository at this point in the history
  • Loading branch information
sahilkamboj3 authored and inducer committed Feb 21, 2022
1 parent 1e615de commit 1b1a5c1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions course/page/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,11 @@ class CodeQuestion(PageBaseWithTitle, PageBaseWithValue):
example of a local build. The Docker image should already be loaded
on the system (RELATE does not pull the image automatically).
.. attribute:: exact_correct_code_okay
Optional. A Boolean that controls whether identical submissions to the
correct_code are allowed for code questions. If set to False, an error
is shown. Setting this to True will silence the error.
* ``data_files``: A dictionary mapping file names from :attr:`data_files`
to :class:`bytes` instances with that file's contents.
Expand Down Expand Up @@ -589,7 +594,8 @@ def __init__(self, vctx, location, page_desc, language_mode):
"While you're at it, consider adding "
"access_rules/add_permssions/see_correctness."))

self.identical_okay = getattr(page_desc, "identical_okay", False)
self.exact_correct_code_okay = getattr(page_desc,
"exact_correct_code_okay", False)

def required_attrs(self):
return super().required_attrs() + (
Expand All @@ -611,7 +617,7 @@ def allowed_attrs(self):
("docker_image", str),
("data_files", list),
("single_submission", bool),
("identical_okay", bool),
("exact_correct_code_okay", bool),
)

def _initial_code(self):
Expand Down Expand Up @@ -890,7 +896,7 @@ def normalize_code(s):

if (normalize_code(user_code)
== normalize_code(self.page_desc.correct_code)
and not self.identical_okay):
and not self.exact_correct_code_okay):
feedback_bits.append(
"<p><b>%s</b></p>"
% _("It looks like you submitted code that is identical to "
Expand Down Expand Up @@ -1238,6 +1244,11 @@ class PythonCodeQuestion(CodeQuestion):
based on its :attr:`access_rules` (not the ones of the flow), a warning
is shown. Setting this attribute to True will silence the warning.
.. attribute:: exact_correct_code_okay
Optional. A Boolean that controls whether identical submissions to the
correct_code are allowed for code questions. If set to False, an error
is shown. Setting this to True will silence the error.
The following symbols are available in :attr:`setup_code` and :attr:`test_code`:
* ``GradingComplete``: An exception class that can be raised to indicated
Expand Down

0 comments on commit 1b1a5c1

Please sign in to comment.