Skip to content

Commit

Permalink
Merge pull request #727 from edx/alangsto/add_proctoring_info_panel
Browse files Browse the repository at this point in the history
Add proctoring info panel UI
  • Loading branch information
alangsto authored Dec 9, 2020
2 parents 9ee17a7 + afcdb0d commit 85772d9
Show file tree
Hide file tree
Showing 7 changed files with 504 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Unreleased

* Changed behavior of practice exam reset to create a new exam attempt instead
of rolling back state of the current attempt.
* Added new proctoring info panel to expose onboarding exam status to learners

[2.4.9] - 2020-11-17
~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 2 additions & 0 deletions edx_proctoring/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def plugin_settings(settings):
'proctoring/js/models/proctored_exam_allowance_model.js',
'proctoring/js/models/proctored_exam_attempt_model.js',
'proctoring/js/models/proctored_exam_model.js',
'proctoring/js/models/learner_onboarding_model.js',
'proctoring/js/collections/proctored_exam_allowance_collection.js',
'proctoring/js/collections/proctored_exam_attempt_collection.js',
'proctoring/js/collections/proctored_exam_collection.js',
Expand All @@ -25,6 +26,7 @@ def plugin_settings(settings):
'proctoring/js/views/proctored_exam_allowance_view.js',
'proctoring/js/views/proctored_exam_attempt_view.js',
'proctoring/js/views/proctored_exam_view.js',
'proctoring/js/views/proctored_exam_info.js',
'proctoring/js/views/proctored_exam_instructor_launch.js',
'proctoring/js/proctored_app.js',
'proctoring/js/exam_action_handler.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(function(Backbone) {
'use strict';

var LearnerOnboardingModel = Backbone.Model.extend({
url: '/api/edx_proctoring/v1/user_onboarding/status/'
});

this.LearnerOnboardingModel = LearnerOnboardingModel;
}).call(this, Backbone);
7 changes: 6 additions & 1 deletion edx_proctoring/static/proctoring/js/proctored_app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals ProctoredExamModel:false */
/* globals ProctoredExamModel:false LearnerOnboardingModel:false */
$(function() {
'use strict';

Expand All @@ -7,5 +7,10 @@ $(function() {
proctored_template: '#proctored-exam-status-tpl',
model: new ProctoredExamModel()
});
var proctoredExamInfoView = new edx.courseware.proctored_exam.ProctoredExamInfo({
el: $('.proctoring-info-panel'),
model: new LearnerOnboardingModel()
});
proctoredExamView.render();
proctoredExamInfoView.render();
});
154 changes: 154 additions & 0 deletions edx_proctoring/static/proctoring/js/views/proctored_exam_info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
(function(Backbone, $) {
'use strict';

var examStatusReadableFormat, notStartedText, startedText, submittedText;

edx.courseware = edx.courseware || {};
edx.courseware.proctored_exam = edx.courseware.proctored_exam || {};

notStartedText = {
status: gettext('Not Started'),
message: gettext('You have not started your onboarding exam.')
};
startedText = {
status: gettext('Started'),
message: gettext('You have started your onboarding exam.')
};
submittedText = {
status: gettext('Submitted'),
message: gettext('You have submitted your onboarding exam.')
};

examStatusReadableFormat = {
created: notStartedText,
download_software_clicked: notStartedText,
ready_to_start: notStartedText,
started: startedText,
ready_to_submit: startedText,
second_review_required: submittedText,
submitted: submittedText,
verified: {
status: gettext('Verified'),
message: gettext('You can now take proctored exams in this course.')
},
rejected: {
status: gettext('Rejected'),
message: gettext('Your onboarding exam has been rejected. Please retry onboarding.')
},
error: {
status: gettext('Error'),
message: gettext('An error has occurred during your onboarding exam. Please retry onboarding.')
}
};

edx.courseware.proctored_exam.ProctoredExamInfo = Backbone.View.extend({
initialize: function() {
this.course_id = this.$el.data('course-id');
this.model.url = this.model.url + '?course_id=' + encodeURIComponent(this.course_id);
this.template_url = '/static/proctoring/templates/proctored-exam-info.underscore';
this.status = '';

this.loadTemplateData();
},

updateCss: function() {
var $el = $(this.el);
var color = '#b20610';
if (this.status === 'verified') {
color = '#008100';
} else if (['submitted', 'second_review_required'].includes(this.status)) {
color = '#0d4e6c';
}

$el.find('.proctoring-info').css({
padding: '10px',
border: '1px solid #e7e7e7',
'border-top': '5px solid ' + color,
'margin-bottom': '15px'
});

$el.find('.onboarding-status').css({
'font-weight': 'bold',
'margin-bottom': '15px'
});

$el.find('.onboarding-status-message').css({
'margin-bottom': '15px'
});

$el.find('.action').css({
display: 'block',
'font-weight': '600',
'text-align': 'center',
'text-decoration': 'none',
padding: '15px 20px',
border: 'none'
});

$el.find('.action-onboarding').css({
color: '#ffffff',
background: '#98050e',
'margin-bottom': '15px'
});

$el.find('.action-info-link').css({
border: '1px solid #0d4e6c'
});
},

getExamAttemptText: function(status) {
if (status in examStatusReadableFormat) {
return examStatusReadableFormat[status];
} else {
return {status: status || 'Not Started', message: ''};
}
},

shouldShowExamLink: function(status) {
// show the exam link if the user should retry onboarding, or if they haven't submitted the exam
var NO_SHOW_STATES = ['submitted', 'second_review_required', 'verified'];
return !NO_SHOW_STATES.includes(status);
},

render: function() {
var statusText = {};
var data = this.model.toJSON();
if (this.template) {
this.status = data.onboarding_status;
statusText = this.getExamAttemptText(data.onboarding_status);
data = {
onboardingStatus: statusText.status,
onboardingMessage: statusText.message,
showOnboardingReminder: data.onboarding_status !== 'verified',
showOnboardingExamLink: this.shouldShowExamLink(data.onboarding_status),
onboardingLink: data.onboarding_link
};

$(this.el).html(this.template(data));
}
},

loadTemplateData: function() {
var self = this;
// only load data/render if course_id is defined
if (self.course_id) {
$.ajax({url: self.template_url, dataType: 'html'})
.done(function(templateData) {
self.template = _.template(templateData);
self.hydrate();
});
}
},

hydrate: function() {
var self = this;
self.model.fetch({
success: function() {
self.render();
self.updateCss();
}
});
}
});
this.edx.courseware.proctored_exam.ProctoredExamInfo = edx.courseware.proctored_exam.ProctoredExamInfo;
}).call(this, Backbone, $, _, gettext);
Loading

0 comments on commit 85772d9

Please sign in to comment.