Skip to content

Commit f96d3c5

Browse files
committed
documentation added to and exact_correct_code_okay boolean added
1 parent 849bd7e commit f96d3c5

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

course/page/code.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,11 @@ class CodeQuestion(PageBaseWithTitle, PageBaseWithValue):
548548
example of a local build. The Docker image should already be loaded
549549
on the system (RELATE does not pull the image automatically).
550550
551+
.. attribute:: exact_correct_code_okay
552+
Optional. A Boolean that controls whether identical submissions to the
553+
correct_code are allowed for code questions. If set to False, an error
554+
is shown. Setting this to True will silence the error.
555+
551556
* ``data_files``: A dictionary mapping file names from :attr:`data_files`
552557
to :class:`bytes` instances with that file's contents.
553558
@@ -593,7 +598,8 @@ def __init__(self, vctx, location, page_desc, language_mode):
593598
"While you're at it, consider adding "
594599
"access_rules/add_permssions/see_correctness."))
595600

596-
self.identical_okay = getattr(page_desc, "identical_okay", False)
601+
self.exact_correct_code_okay = getattr(page_desc,
602+
"exact_correct_code_okay", False)
597603

598604
def required_attrs(self):
599605
return super(CodeQuestion, self).required_attrs() + (
@@ -615,7 +621,7 @@ def allowed_attrs(self):
615621
("docker_image", str),
616622
("data_files", list),
617623
("single_submission", bool),
618-
("identical_okay", bool),
624+
("exact_correct_code_okay", bool),
619625
)
620626

621627
def _initial_code(self):
@@ -894,7 +900,7 @@ def normalize_code(s):
894900

895901
if (normalize_code(user_code)
896902
== normalize_code(self.page_desc.correct_code)
897-
and not self.identical_okay):
903+
and not self.exact_correct_code_okay):
898904
feedback_bits.append(
899905
"<p><b>%s</b></p>"
900906
% _("It looks like you submitted code that is identical to "
@@ -1202,6 +1208,11 @@ class PythonCodeQuestion(CodeQuestion):
12021208
based on its :attr:`access_rules` (not the ones of the flow), a warning
12031209
is shown. Setting this attribute to True will silence the warning.
12041210
1211+
.. attribute:: exact_correct_code_okay
1212+
Optional. A Boolean that controls whether identical submissions to the
1213+
correct_code are allowed for code questions. If set to False, an error
1214+
is shown. Setting this to True will silence the error.
1215+
12051216
The following symbols are available in :attr:`setup_code` and :attr:`test_code`:
12061217
12071218
* ``GradingComplete``: An exception class that can be raised to indicated

0 commit comments

Comments
 (0)