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 committed Feb 4, 2021
1 parent 849bd7e commit f96d3c5
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 @@ -548,6 +548,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 @@ -593,7 +598,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(CodeQuestion, self).required_attrs() + (
Expand All @@ -615,7 +621,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 @@ -894,7 +900,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 @@ -1202,6 +1208,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 f96d3c5

Please sign in to comment.