Skip to content

Commit

Permalink
Log answers seen when submitting final answer
Browse files Browse the repository at this point in the history
Add answers seen to data returned on final submit

Fix test to incorporate other answers seen

Fix bug with anchoring after Step 2
  • Loading branch information
jleong-openedx committed Aug 3, 2017
1 parent 8857b8a commit 7f32b3b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ubcpi/static/html/ubcpi.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h3 id="pi-question-h" class="question-text" style="display:inline;">{{display_n
</div>
</div>

<input data-ng-disabled="answerForm.$invalid" type='button' class='ubcpi_submit' value="{{ 'Next Step' | translate }} &rarr;" name='ubcpi_next_step' data-ng-click="rc.clickSubmit($event); location.href='#reflecting;'" aria-describedby="button-disabled-reason ubcpi-next-inline-hints" onclick="location.href='#reflecting'"/>
<input data-ng-disabled="answerForm.$invalid" type='button' class='ubcpi_submit' value="{{ 'Next Step' | translate }} &rarr;" name='ubcpi_next_step' data-ng-click="rc.clickSubmit($event);" aria-describedby="button-disabled-reason ubcpi-next-inline-hints" onclick=""/>

</form>

Expand Down
8 changes: 6 additions & 2 deletions ubcpi/static/js/src/ubcpi.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ angular.module('UBCPI', ['ngSanitize', 'ngCookies', 'gettext'])
}
}])

.controller('ReviseController', ['$scope', 'notify', 'backendService', '$q', 'gettext',
function ($scope, notify, backendService, $q, gettext) {
.controller('ReviseController', ['$scope', 'notify', 'backendService', '$q', 'gettext', '$location', '$anchorScroll', '$timeout',
function ($scope, notify, backendService, $q, gettext, $location, $anchorScroll, $timeout) {
var self = this;
var data = $scope.config.data;

Expand Down Expand Up @@ -154,6 +154,10 @@ angular.module('UBCPI', ['ngSanitize', 'ngCookies', 'gettext'])
self.submitting = true;
return backendService.submit(self.answer, self.rationale, self.status()).then(function(data) {
assignData(self, data);
$timeout(function() {
$location.hash('others-responses');
$anchorScroll();
});
}, function(error) {
notify('error', {
'title': gettext('Error submitting answer!'),
Expand Down
16 changes: 16 additions & 0 deletions ubcpi/test/data/submit_answer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@
"correct_answer": 0,
"correct_rationale": {
"text": "This is correct."
},
"other_answers": {
"answers": [
{
"option": 0,
"rationale": "This is seed1"
},
{
"option": 1,
"rationale": "This is seed2"
},
{
"option": 2,
"rationale": "This is seed3"
}
]
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions ubcpi/ubcpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
MAX_RATIONALE_SIZE = 32000
MAX_RATIONALE_SIZE_IN_EVENT = settings.TRACK_MAX_EVENT / 4

otr_answers = {}

def truncate_rationale(rationale, max_length=MAX_RATIONALE_SIZE_IN_EVENT):
"""
Expand Down Expand Up @@ -533,6 +534,9 @@ def record_response(self, answer, rationale, status):
self.sys_selected_answers, answer, rationale,
student_item['student_id'], self.algo, self.options)

otr_answers['other_answers'] = get_other_answers(
self.sys_selected_answers, self.seeds, self.get_student_item_dict, self.algo, self.options)
event_dict['other_student_responses'] = otr_answers.get("other_answers")
self.publish_event_from_dict(
self.event_namespace + '.original_submitted',
event_dict
Expand All @@ -548,6 +552,9 @@ def record_response(self, answer, rationale, status):
# Send the grade
self.runtime.publish(self, 'grade', {'value': grade, 'max_value': 1})

event_dict['other_student_responses'] = otr_answers.get("other_answers")

print(event_dict['other_student_responses'])
self.publish_event_from_dict(
self.event_namespace + '.revised_submitted',
event_dict
Expand Down Expand Up @@ -612,11 +619,11 @@ def get_persisted_data(self):
"rationale_revised": answers.get_rationale(1),
}
if answers.has_revision(0) and not answers.has_revision(1):
ret['other_answers'] = get_other_answers(
self.sys_selected_answers, self.seeds, self.get_student_item_dict, self.algo, self.options)
ret['other_answers'] = otr_answers.get("other_answers")

# reveal the correct answer in the end
if answers.has_revision(1):
ret['other_answers'] = otr_answers.get("other_answers")
ret['correct_answer'] = self.correct_answer
ret['correct_rationale'] = self.correct_rationale

Expand Down

0 comments on commit 7f32b3b

Please sign in to comment.