Skip to content

Commit

Permalink
Merge pull request #918 from UCL-INGI/fix_909
Browse files Browse the repository at this point in the history
[problem_types] Adding a centralized feedback feature for match problem
  • Loading branch information
anthonygego committed Mar 6, 2023
2 parents 9f645aa + f769064 commit 79c784f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
7 changes: 5 additions & 2 deletions inginious/common/tasks_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ def __init__(self, problemid, content, translations, taskfs):
if not "answer" in content:
raise Exception("There is no answer in this problem with type==match")
self._answer = str(content["answer"])
self._centralize = content.get("centralize", False)

@classmethod
def get_type(cls):
Expand All @@ -428,12 +429,14 @@ def input_type(self):

def check_answer(self, task_input, language):
if task_input[self.get_id()].strip() == self._answer:
return True, None, ["_correct_answer"], 0, ""
return True, None, ["_correct_answer"] if not self._centralize else None, 0, ""
else:
return False, None, ["_wrong_answer"], 0, ""
return False, None, ["_wrong_answer"] if not self._centralize else None, 0, ""

@classmethod
def parse_problem(self, problem_content):
if "centralize" in problem_content:
problem_content["centralize"] = True
return Problem.parse_problem(problem_content)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion inginious/frontend/static/js/all-minified.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions inginious/frontend/static/js/studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ function studio_init_template_file(well, pid, problem)
*/
function studio_init_template_match(well, pid, problem)
{
if("centralize" in problem && problem["centralize"])
$('#centralize-' + pid, well).attr('checked', true);
if("answer" in problem)
$('#answer-' + pid, well).val(problem["answer"]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@
<input type="text" class="form-control" id="answer-PID" name="problem[PID][answer]" placeholder="{{ _('Answer of this question') }}"/>
</div>
</div>
<div class="form-group row">
<label for="centralize-PID" class="col-sm-2 control-label">{{ _("Count error only at top of the page?") }}</label>
<div class="col-sm-10">
<div class="checkbox"><label>
<input type="checkbox" id="centralize-PID" name="problem[PID][centralize]"/>&nbsp;
</label></div>
</div>
</div>

0 comments on commit 79c784f

Please sign in to comment.