Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Assign grade based on correct answer #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"chai": "^3.2.0",
"chai-as-promised": "^5.1.0",
"cucumber": "^0.5.2",
"d3": "~3.3",
"d3": "~3.5.17",
"jasmine-core": "^2.3.4",
"jquery": "~2.2",
"karma": "^0.13",
Expand All @@ -29,7 +29,7 @@
"phantomjs": "^1.9.17",
"protractor": "~2.5",
"request": "^2.60.0",
"uglify-js": "2.3.6"
"uglify-js": "2.6.0"
},
"scripts": {
"test": "./node_modules/karma/bin/karma start --reporters progress,coverage"
Expand Down
5 changes: 5 additions & 0 deletions ubcpi/static/html/ubcpi.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ <h5 id="correct-option-heading" ng-if="options.length == rc.correct_answer && rc
<span ng-if="rc.correct_answer !== rc.answer_revised && rc.correct_answer !== options.length" class="ubcpi-initial-option-text ubcpi-incorrect-final-answer ubcpi-show-incorrect">{{options[rc.answer_revised].text}} </span>
<span ng-if="rc.correct_answer === options.length" class="ubcpi-initial-option-text ubcpi-correct-final-answer">{{options[rc.answer_revised].text}} </span>
<span class="ubcpi-initial-option-num">({{'Option' | translate }} {{rc.answer_revised + 1}})</span>
<span ng-if="rc.correct_answer === rc.answer_revised" class="ubcpi-initial-option-text ubcpi-correct-final-answer ubcpi-show-correct">1/1 </span>
<span ng-if="rc.correct_answer !== rc.answer_revised && rc.correct_answer !== options.length && gradingOption == 1" class="ubcpi-initial-option-text ubcpi-incorrect-final-answer ubcpi-show-incorrect">0/1 </span>
<span ng-if="rc.correct_answer !== rc.answer_revised && rc.correct_answer !== options.length && gradingOption == 0" class="ubcpi-initial-option-text ubcpi-correct-final-answer ubcpi-show-correct">1/1 </span>
<span ng-if="rc.correct_answer !== rc.answer_revised && rc.correct_answer !== options.length && gradingOption == 0"> (problem graded based on participation)</span>
<span ng-if="rc.correct_answer === options.length" class="ubcpi-initial-option-text ubcpi-correct-final-answer">1/1 </span>
</p>
<span class="sr" translate>Student Rationale</span><i aria-hidden="true" class="icon fa fa-user"></i><span class="ubcpi-solution-your-final-rationale ubcpi-solution-rationales">"{{rc.rationale_revised}}"</span>
</li>
Expand Down
9 changes: 8 additions & 1 deletion ubcpi/static/html/ubcpi_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@
<label class="label setting-label pi-setting-label" for="pi-option-correct" aria-describedby="pi-option-correct-tip" translate>Correct Answer <font color="red">*</font></label>
<span id="pi-option-correct-tip" class="tip setting-help" translate>Choose the answer you consider correct, or select "n/a" if there is no correct answer.</span>
</div>
<select name="pi-option-correct" id="pi-option-correct" ng-model="esc.data.correct_answer" ng-model-options="{ debounce: 500 }" ng-options="esc.makeOptions().indexOf(opt) as opt for opt in esc.makeOptions()" required></select>
<select name="pi-option-correct" id="pi-option-correct" ng-change="esc.data.correct_answer==esc.data.options.length ? esc.data.gradingOption=0 : esc.data.gradingOption=esc.data.gradingOption" ng-model="esc.data.correct_answer" ng-model-options="{ debounce: 500 }" ng-options="esc.makeOptions().indexOf(opt) as opt for opt in esc.makeOptions()" required></select>
</div>
<div class="wrapper-comp-setting pi-wrapper-comp-setting">
<div class="pi-label-and-hint">
<label class="label setting-label pi-setting-label" for="pi-option-correct" aria-describedby="pi-option-correct-tip" translate>Grading <font color="red">*</font></label>
<span id="pi-option-correct-tip2" class="tip setting-help" translate>Determine how the problem will be graded. "By Participation" means that students will get full marks by completing the problem.</span>
</div>
<select name="pi-grading-option" id="pi-grading-option" ng-disabled="esc.data.correct_answer==esc.data.options.length" ng-model="esc.data.gradingOption" ng-model-options="{ debounce: 500 }" ng-options="esc.makeGradingOptions().indexOf(opt) as opt for opt in esc.makeGradingOptions()" required></select>
</div>
<div class="wrapper-comp-setting pi-wrapper-comp-setting">
<div class="pi-label-and-hint">
Expand Down
1 change: 1 addition & 0 deletions ubcpi/static/js/src/ubcpi.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ angular.module('UBCPI', ['ngSanitize', 'ngCookies', 'gettext'])
$scope.display_name = data.display_name;
$scope.user_role = data.user_role;
$scope.collapse = false;
$scope.gradingOption = data.gradingOption;

// all status of the app. Passed it from backend so we have a synced status codes
self.ALL_STATUS = data.all_status;
Expand Down
8 changes: 8 additions & 0 deletions ubcpi/static/js/src/ubcpi_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ angular.module("ubcpi_edit", ['ngMessages', 'ngSanitize', 'ngCookies', 'gettext'
return options;
};

self.makeGradingOptions = function() {
var gradingOptions = [];
gradingOptions.push("By Participation");
gradingOptions.push("By Correct Answer");
return gradingOptions;
};

self.algos = data.algos;
self.data = {};
self.data.display_name = data.display_name;
Expand All @@ -85,6 +92,7 @@ angular.module("ubcpi_edit", ['ngMessages', 'ngSanitize', 'ngCookies', 'gettext'
self.image_position_locations = data.image_position_locations;

self.data.options = data.options;
self.data.gradingOption = data.gradingOption;
self.data.correct_answer = data.correct_answer;
if (data.correct_rationale)
self.data.correct_rationale = data.correct_rationale;
Expand Down
3 changes: 2 additions & 1 deletion ubcpi/test/data/update_xblock.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"rationale": "dsfsdafsd"
}
],
"weight": 1
"weight": 1,
"gradingOption": 0
}
}
20 changes: 18 additions & 2 deletions ubcpi/ubcpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ class PeerInstructionXBlock(XBlock, MissingDataFetcherMixin, PublishEventMixin):
help=_("The correct option for the question"),
)

# 0 is "By Participation", 1 is "By Correct Answer"
gradingOption = Integer(
default=0, scope=Scope.content,
help=_("The grading option for the question"),
)

correct_rationale = Dict(
default={'text': _("Photosynthesis")}, scope=Scope.content,
help=_("The feedback for student for the correct answer"),
Expand Down Expand Up @@ -301,6 +307,7 @@ def studio_view(self, context=None):
'display_name': self.ugettext(self.display_name),
'weight': self.weight,
'correct_answer': self.correct_answer,
'gradingOption': self.gradingOption,
'correct_rationale': self.correct_rationale,
'rationale_size': self.rationale_size,
'question_text': self.question_text,
Expand Down Expand Up @@ -341,6 +348,7 @@ def studio_submit(self, data, suffix=''):
self.correct_rationale = data['correct_rationale']
self.algo = data['algo']
self.seeds = data['seeds']
self.gradingOption = data['gradingOption']

return {'success': 'true'}

Expand Down Expand Up @@ -477,6 +485,7 @@ def student_view(self, context=None):
'user_role': self.get_user_role(),
'all_status': {'NEW': STATUS_NEW, 'ANSWERED': STATUS_ANSWERED, 'REVISED': STATUS_REVISED},
'lang': translation.get_language(),
'gradingOption': self.gradingOption,
}
if answers.has_revision(0) and not answers.has_revision(1):
js_vals['other_answers'] = get_other_answers(
Expand Down Expand Up @@ -559,9 +568,16 @@ def get_grade(self):
"""
Return the grade

Only returns 1 for now as a completion grade.
"""
return 1
if self.gradingOption==0:
return 1
else:
answers = self.get_answers_for_student()
student_answer = answers.get_vote(1) # retrieve revised/final option chosen
if student_answer == self.correct_answer:
return 1
else:
return 0

def get_current_stats(self):
"""
Expand Down