From 7e737aedd55e28447057635b628935f49c8f546c Mon Sep 17 00:00:00 2001
From: Justin Leong
Date: Fri, 24 Nov 2017 17:08:09 -0800
Subject: [PATCH] Assign grade based on correct answer
Instructors can now set a Peer Instruction question to be graded based
on participation or correct answer. Students will receive full marks
for participation-based questions upon completion. For questions based
on correct answers, no marks will be awarded for an incorrect answer.
Questions with no correct answer are participation-based only.
Step 3 now displays points earned, with colour coding.
Adapt test as appropriate.
Update packages to handle outdated dependency and security
vulnerability.
---
package.json | 4 ++--
ubcpi/static/html/ubcpi.html | 5 +++++
ubcpi/static/html/ubcpi_edit.html | 9 ++++++++-
ubcpi/static/js/src/ubcpi.js | 1 +
ubcpi/static/js/src/ubcpi_edit.js | 8 ++++++++
ubcpi/test/data/update_xblock.json | 3 ++-
ubcpi/ubcpi.py | 20 ++++++++++++++++++--
7 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/package.json b/package.json
index cbba425..32d791c 100644
--- a/package.json
+++ b/package.json
@@ -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",
@@ -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"
diff --git a/ubcpi/static/html/ubcpi.html b/ubcpi/static/html/ubcpi.html
index 35a5486..80413cf 100644
--- a/ubcpi/static/html/ubcpi.html
+++ b/ubcpi/static/html/ubcpi.html
@@ -204,6 +204,11 @@ {{options[rc.answer_revised].text}}
{{options[rc.answer_revised].text}}
({{'Option' | translate }} {{rc.answer_revised + 1}})
+ 1/1
+ 0/1
+ 1/1
+ (problem graded based on participation)
+ 1/1
diff --git a/ubcpi/static/js/src/ubcpi.js b/ubcpi/static/js/src/ubcpi.js
index 0009f4d..45c3592 100644
--- a/ubcpi/static/js/src/ubcpi.js
+++ b/ubcpi/static/js/src/ubcpi.js
@@ -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;
diff --git a/ubcpi/static/js/src/ubcpi_edit.js b/ubcpi/static/js/src/ubcpi_edit.js
index 0d0eb7c..663415b 100644
--- a/ubcpi/static/js/src/ubcpi_edit.js
+++ b/ubcpi/static/js/src/ubcpi_edit.js
@@ -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;
@@ -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;
diff --git a/ubcpi/test/data/update_xblock.json b/ubcpi/test/data/update_xblock.json
index 4240b7c..b2dd09a 100644
--- a/ubcpi/test/data/update_xblock.json
+++ b/ubcpi/test/data/update_xblock.json
@@ -49,6 +49,7 @@
"rationale": "dsfsdafsd"
}
],
- "weight": 1
+ "weight": 1,
+ "gradingOption": 0
}
}
diff --git a/ubcpi/ubcpi.py b/ubcpi/ubcpi.py
index 4fc3d3c..dd9d49c 100644
--- a/ubcpi/ubcpi.py
+++ b/ubcpi/ubcpi.py
@@ -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"),
@@ -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,
@@ -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'}
@@ -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(
@@ -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):
"""