Commit 4091595b by Stephen Sanchez

Merge pull request #619 from edx/sanchez/mathjax

MathJax Integration
parents c0923489 7533a112
......@@ -109,6 +109,16 @@
</div>
<p class="setting-help">{% trans "Specify whether students can submit an image file along with their text response." %}</p>
</li>
<li id="openassessment_submission_latex_wrapper" class="field comp-setting-entry">
<div class="wrapper-comp-setting">
<label for="openassessment_submission_latex_editor" class="setting-label">{% trans "Allow Latex Responses"%}</label>
<select id="openassessment_submission_latex_editor" class="input setting-input" name="latex submission">
<option value="0">{% trans "False"%}</option>
<option value="1" {% if allow_latex %} selected="true" {% endif %}>{% trans "True"%}</option>
</select>
</div>
<p class="setting-help">{% trans "Specify whether students can write Latex formatted strings"%}</p>
</li>
<li id="openassessment_leaderboard_wrapper" class="field comp-setting-entry">
<div class="wrapper-comp-setting">
<label for="openassessment_leaderboard_editor" class="setting-label">{% trans "Top Responses" %}</label>
......
{% load i18n %}
{% spaceless %}
<li id="openassessment__grade" class="openassessment__steps__step step--grade is--complete has--grade">
<li id="openassessment__grade" class="openassessment__steps__step step--grade is--complete has--grade {% if allow_latex %}allow--latex{% endif %}">
<header class="step__header ui-toggle-visibility__control">
<h2 class="step__title">
<span class="wrapper--copy">
......
{% load i18n %}
{% spaceless %}
<li id="openassessment__leaderboard" class="openassessment__steps__step step--leaderboard is--complete">
<li id="openassessment__leaderboard" class="openassessment__steps__step step--leaderboard is--complete {% if allow_latex %} allow--latex{% endif %}">
<header class="step__header">
<h2 class="step__title">
<span class="wrapper--copy">
......
{% load tz %}
{% load i18n %}
{% block list_item %}
<li id="openassessment__peer-assessment" class="openassessment__steps__step step--peer-assessment ui-toggle-visibility">
<li id="openassessment__peer-assessment" class="openassessment__steps__step step--peer-assessment ui-toggle-visibility {% if allow_latex %} allow--latex {%endif%}">
{% endblock %}
{% spaceless %}
......
......@@ -103,6 +103,24 @@
</h3>
</div>
</li>
{% if allow_latex %}
<li class="list--actions__item">
<button type="submit" id="submission__preview" class="action action--save submission__save is--disabled">{% trans "Preview in Latex"%}</button>
<div id="response__preview_explanation" class="response__submission__status">
<h3 class="response__submission__status__title">
{% trans "Click to preview your submission in Latex"%}
</h3>
</div>
</li>
<li id = "submission__preview__item" class="list--actions__item">
<article class="submission__answer__display">
<h3 class="submission__answer__display__title">Preview Response</h3>
<div class="submission__answer__display__content">
<p id="preview_content"></p>
</div>
</article>
</li>
{% endif %}
</ul>
</div>
</form>
......
......@@ -2,7 +2,7 @@
{% load i18n %}
{% block list_item %}
<li id="openassessment__response" class="openassessment__steps__step step--response is--complete ui-toggle-visibility is--collapsed">
<li id="openassessment__response" class="openassessment__steps__step step--response is--complete ui-toggle-visibility is--collapsed {% if allow_latex %}allow--latex{%endif%}">
{% endblock %}
{% block title %}
......
......@@ -2,7 +2,7 @@
{% load i18n %}
{% block list_item %}
<li id="openassessment__response" class="openassessment__steps__step step--response is--complete ui-toggle-visibility is--collapsed">
<li id="openassessment__response" class="openassessment__steps__step step--response is--complete ui-toggle-visibility is--collapsed {% if allow_latex %}allow--latex{%endif%}">
{% endblock %}
{% block title %}
......
......@@ -2,7 +2,7 @@
{% load tz %}
{% spaceless %}
{% block list_item %}
<li id="openassessment__self-assessment" class="openassessment__steps__step step--self-assessment ui-toggle-visibility">
<li id="openassessment__self-assessment" class="openassessment__steps__step step--self-assessment ui-toggle-visibility {% if allow_latex %}allow--latex{%endif%}">
{% endblock %}
<header class="step__header ui-toggle-visibility__control">
......
......@@ -2,7 +2,7 @@
{% load tz %}
{% spaceless %}
{% block list_item %}
<li id="openassessment__student-training" class="openassessment__steps__step step--student-training ui-toggle-visibility">
<li id="openassessment__student-training" class="openassessment__steps__step step--student-training ui-toggle-visibility {% if allow_latex %}allow--latex{%endif%}">
{% endblock %}
<header class="step__header ui-toggle-visibility__control">
......
......@@ -137,6 +137,7 @@ class GradeMixin(object):
'rubric_criteria': self._rubric_criteria_grade_context(peer_assessments, self_assessment),
'has_submitted_feedback': has_submitted_feedback,
'allow_file_upload': self.allow_file_upload,
'allow_latex': self.allow_latex,
'file_url': self.get_download_url_from_submission(student_submission)
}
......
......@@ -80,7 +80,9 @@ class LeaderboardMixin(object):
else:
score['content'] = ""
context = { 'topscores': scores }
context = { 'topscores': scores,
'allow_latex': self.allow_latex,
}
return ('openassessmentblock/leaderboard/oa_leaderboard_show.html', context)
def render_leaderboard_incomplete(self):
......
......@@ -122,6 +122,12 @@ class OpenAssessmentBlock(
help="File upload allowed with submission."
)
allow_latex = Boolean(
default=False,
scope=Scope.settings,
help="Latex rendering allowed with submission."
)
title = String(
default="",
scope=Scope.content,
......@@ -399,6 +405,7 @@ class OpenAssessmentBlock(
block.title = config['title']
block.prompt = config['prompt']
block.allow_file_upload = config['allow_file_upload']
block.allow_latex = config['allow_latex']
block.leaderboard_show = config['leaderboard_show']
return block
......
......@@ -156,7 +156,8 @@ class PeerAssessmentMixin(object):
context_dict = {
"rubric_criteria": self.rubric_criteria_with_labels,
"estimated_time": "20 minutes" # TODO: Need to configure this.
"estimated_time": "20 minutes", # TODO: Need to configure this.
"allow_latex": self.allow_latex,
}
if self.rubric_feedback_prompt is not None:
......
......@@ -73,6 +73,7 @@ EDITOR_UPDATE_SCHEMA = Schema({
Required('submission_start'): Any(datetime_validator, None),
Required('submission_due'): Any(datetime_validator, None),
Required('allow_file_upload'): bool,
Required('allow_latex'): bool,
Required('leaderboard_show'): int,
Required('assessments'): [
Schema({
......
......@@ -51,7 +51,7 @@ class SelfAssessmentMixin(object):
SubmissionError: Error occurred while retrieving the current submission.
SelfAssessmentRequestError: Error occurred while checking if we had a self-assessment.
"""
context = {}
context = {'allow_latex': self.allow_latex}
path = 'openassessmentblock/self/oa_self_unavailable.html'
problem_closed, reason, start_date, due_date = self.is_closed(step="self-assessment")
......
......@@ -137,6 +137,9 @@ class StaffInfoMixin(object):
# Include release/due dates for each step in the problem
context['step_dates'] = list()
# Include Latex setting
context['allow_latex'] = self.allow_latex
steps = ['submission'] + self.assessment_steps
for step in steps:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -69,6 +69,8 @@ OpenAssessment.ResponseView.prototype = {
var handlePrepareUpload = function(eventData) { view.prepareUpload(eventData.target.files); };
sel.find('input[type=file]').on('change', handlePrepareUpload);
// keep the preview as display none at first
sel.find('#submission__preview__item').hide();
// Install a click handler for submission
sel.find('#step--response__submit').click(
......@@ -88,6 +90,21 @@ OpenAssessment.ResponseView.prototype = {
}
);
// Install click handler for the preview button
sel.find('#submission__preview').click(
function(eventObject) {
eventObject.preventDefault();
// extract typed-in response and replace newline with br
var preview_text = sel.find('#submission__answer__value').val();
var preview_container = sel.find('#preview_content');
preview_container.html(preview_text.replace(/\r\n|\r|\n/g,"<br />"));
// Render in mathjax
sel.find('#submission__preview__item').show();
MathJax.Hub.Queue(['Typeset', MathJax.Hub, preview_container[0]]);
}
);
// Install a click handler for the save button
sel.find('#file__upload').click(
function(eventObject) {
......@@ -174,6 +191,19 @@ OpenAssessment.ResponseView.prototype = {
},
/**
Enable/disable the preview button.
Works exactly the same way as saveEnabled method.
**/
previewEnabled: function(enabled) {
var sel = $('#submission__preview', this.element);
if (typeof enabled === 'undefined') {
return !sel.hasClass('is--disabled');
} else {
sel.toggleClass('is--disabled', !enabled);
}
},
/**
Set the save status message.
Retrieve the save status message.
......@@ -289,6 +319,7 @@ OpenAssessment.ResponseView.prototype = {
// only if the response has changed
if (this.responseChanged()) {
this.saveEnabled(isBlank);
this.previewEnabled(isBlank);
this.saveStatus(gettext('This response has not been saved.'));
this.unsavedWarningEnabled(true);
}
......
......@@ -55,6 +55,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
)
**/
render: function(component) {
var that = this;
var url = this.url('render_' + component);
return $.Deferred(function(defer) {
$.ajax({
......@@ -63,6 +64,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
dataType: "html"
}).done(function(data) {
defer.resolveWith(this, [data]);
that.renderLatex(data);
}).fail(function(data) {
defer.rejectWith(this, [gettext('This section could not be loaded.')]);
});
......@@ -70,6 +72,20 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
},
/**
Render Latex for all new DOM elements with class 'allow--latex'.
Args:
element: The element to modify.
**/
renderLatex: function(element) {
$('.allow--latex', element).each(
function() {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, this]);
}
);
},
/**
Render the Peer Assessment Section after a complete workflow, in order to
continue grading peers.
......@@ -85,6 +101,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
)
**/
renderContinuedPeer: function() {
var view = this;
var url = this.url('render_peer_assessment');
return $.Deferred(function(defer) {
$.ajax({
......@@ -94,6 +111,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
data: {continue_grading: true}
}).done(function(data) {
defer.resolveWith(this, [data]);
view.renderLatex(data);
}).fail(function(data) {
defer.rejectWith(this, [gettext('This section could not be loaded.')]);
});
......@@ -419,6 +437,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
criteria (list of object literals): The rubric criteria.
assessments (list of object literals): The assessments the student will be evaluated on.
imageSubmissionEnabled (boolean): TRUE if image attachments are allowed.
latexEnabled: TRUE if latex rendering is enabled.
leaderboardNum (int): The number of scores to show in the leaderboard.
Returns:
......@@ -439,6 +458,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
assessments: kwargs.assessments,
editor_assessments_order: kwargs.editorAssessmentsOrder,
allow_file_upload: kwargs.imageSubmissionEnabled,
allow_latex: kwargs.latexEnabled,
leaderboard_show: kwargs.leaderboardNum
});
return $.Deferred(function(defer) {
......
......@@ -36,4 +36,15 @@ if (typeof window.Logger === 'undefined') {
window.Logger = {
log: function(event_type, data, kwargs) {}
};
}
// Stub MathJax is the runtime doesn't provide it
if (typeof window.MathJax === 'undefined') {
window.MathJax = {
Hub: {
Typeset: function(data){},
Queue: function(list){}
}
};
}
\ No newline at end of file
......@@ -194,6 +194,7 @@ OpenAssessment.StudioView.prototype = {
submissionDue: view.settingsView.submissionDue(),
assessments: view.settingsView.assessmentsDescription(),
imageSubmissionEnabled: view.settingsView.imageSubmissionEnabled(),
latexEnabled: view.settingsView.latexEnabled(),
leaderboardNum: view.settingsView.leaderboardNum(),
editorAssessmentsOrder: view.settingsView.editorAssessmentsOrder()
}).done(
......
......@@ -141,6 +141,25 @@ OpenAssessment.EditSettingsView.prototype = {
},
/**
Enable / disable latex rendering.
Args:
isEnabled(boolean, optional): if provided enable/disable latex rendering
Returns:
boolean
**/
latexEnabled: function(isEnabled) {
var sel = $('#openassessment_submission_latex_editor', this.settingsElement);
if (isEnabled !== undefined) {
if (isEnabled) {
sel.val(1);
} else {
sel.val(0)
}
}
return (sel.val() == 1);
},
/**
Get or set the number of scores to show in the leaderboard.
If set to 0, the leaderboard will not be shown.
......
......@@ -102,6 +102,7 @@
li {
margin-bottom: 0 !important;
margin-top: 5px !important;
}
button, .button, .action {
......
......@@ -541,6 +541,7 @@
display: block;
text-align: center;
margin-bottom: ($baseline-v/2);
min-width: 215px;
@include media($bp-ds) {
display: inline-block;
......
......@@ -72,6 +72,9 @@ class StudentTrainingMixin(object):
context = {}
template = 'openassessmentblock/student_training/student_training_unavailable.html'
# add allow_latex field to the context
context['allow_latex'] = self.allow_latex
if not workflow_status:
return template, context
......
......@@ -121,6 +121,7 @@ class StudioMixin(object):
'feedbackprompt': self.rubric_feedback_prompt,
'feedback_default_text': feedback_default_text,
'allow_file_upload': self.allow_file_upload,
'allow_latex': self.allow_latex,
'leaderboard_show': self.leaderboard_show,
'editor_assessments_order': [
make_django_template_key(asmnt)
......@@ -213,6 +214,7 @@ class StudioMixin(object):
self.submission_start = data['submission_start']
self.submission_due = data['submission_due']
self.allow_file_upload = bool(data['allow_file_upload'])
self.allow_latex = bool(data['allow_latex'])
self.leaderboard_show = data['leaderboard_show']
return {'success': True, 'msg': self._(u'Successfully updated OpenAssessment XBlock')}
......
......@@ -337,6 +337,7 @@ class SubmissionMixin(object):
context["submission_due"] = due_date
context['allow_file_upload'] = self.allow_file_upload
context['allow_latex'] = self.allow_latex
context['has_peer'] = 'peer-assessment' in self.assessment_steps
context['has_self'] = 'self-assessment' in self.assessment_steps
......
......@@ -5,6 +5,7 @@
"feedback_prompt": "Feedback prompt",
"feedback_default_text": "Feedback default text",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -29,6 +30,7 @@
"feedback_prompt": "Feedback prompt",
"feedback_default_text": "Feedback default text",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -78,6 +80,7 @@
"no_feedback_prompt": {
"prompt": "Test prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -129,6 +132,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -179,6 +183,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -231,6 +236,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -283,6 +289,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -327,6 +334,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -370,6 +378,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "prompty",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
[]
......@@ -392,6 +401,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -435,6 +445,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -464,6 +475,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -502,6 +514,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -545,6 +558,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -587,6 +601,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": 6,
"allow_latex": false,
"criteria": [
{
"order_num": 0,
......@@ -628,6 +643,7 @@
"feedback_default_text": "Feedback default text",
"prompt": "Test Prompt",
"allow_file_upload": null,
"allow_latex": false,
"criteria": [
{
"order_num": 0,
......@@ -699,6 +715,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -755,6 +772,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -809,6 +827,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -866,6 +885,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -923,6 +943,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -974,6 +995,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -1032,6 +1054,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -1082,6 +1105,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -1133,6 +1157,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -1160,6 +1185,7 @@
"feedback_prompt": "Feedback prompt",
"feedback_default_text": "Feedback default text",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -1210,6 +1236,7 @@
"feedback_prompt": "Feedback prompt",
"feedback_default_text": "Feedback default text",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -1260,6 +1287,7 @@
"feedback_prompt": "Feedback prompt",
"feedback_default_text": "Feedback default text",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......@@ -1333,6 +1361,7 @@
"feedback_prompt": "Feedback prompt",
"feedback_default_text": "Feedback default text",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"criteria": [
{
......
......@@ -6,6 +6,7 @@
"training_num_current": 1,
"training_num_available": 2,
"training_essay": "This is my answer.",
"allow_latex": false,
"training_rubric": {
"criteria": [
{
......
......@@ -32,6 +32,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -83,6 +84,7 @@
"submission_start": "4014-02-10T09:46",
"title": "ɯʎ uǝʍ ʇıʇןǝ",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -134,6 +136,7 @@
"submission_start": "4014-02-10T09:46",
"title": "My new title.",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"assessments": [
{
......@@ -196,6 +199,7 @@
"submission_due": "4014-02-27T09:46",
"submission_start": "4014-02-10T09:46",
"allow_file_upload": false,
"allow_latex": false,
"leaderboard_show": 0,
"title": "My new title.",
"assessments": [
......
......@@ -171,7 +171,8 @@ class TestLeaderboardRender(XBlockHandlerTransactionTestCase):
xblock,
'openassessmentblock/leaderboard/oa_leaderboard_show.html',
{
'topscores': scores
'topscores': scores,
'allow_latex': xblock.allow_latex,
},
workflow_status='done'
)
......
......@@ -237,6 +237,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'rubric_criteria': xblock.rubric_criteria,
'must_grade': 5,
'review_num': 1,
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_unavailable.html', expected_context
......@@ -252,6 +253,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'rubric_criteria': xblock.rubric_criteria,
'must_grade': 5,
'review_num': 1,
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_closed.html', expected_context
......@@ -267,6 +269,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'rubric_criteria': xblock.rubric_criteria,
'must_grade': 5,
'review_num': 1,
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_unavailable.html', expected_context
......@@ -285,6 +288,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'must_grade': 5,
'review_num': 1,
'submit_button_text': 'submit your assessment & move to response #2',
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_waiting.html',
......@@ -324,6 +328,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'allow_file_upload': False,
'peer_file_url': '',
'submit_button_text': 'submit your assessment & move to response #2',
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_assessment.html',
......@@ -345,6 +350,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'must_grade': 5,
'review_num': 1,
'submit_button_text': 'submit your assessment & move to response #2',
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_closed.html',
......@@ -380,6 +386,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'must_grade': 5,
'review_num': 1,
'submit_button_text': 'submit your assessment & move to response #2',
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_closed.html',
......@@ -407,6 +414,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'rubric_criteria': xblock.rubric_criteria,
'must_grade': 5,
'review_num': 1,
'allow_latex': False,
}
self._assert_path_and_context(
......@@ -436,6 +444,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'review_num': 1,
'rubric_criteria': xblock.rubric_criteria,
'submit_button_text': 'Submit your assessment & review another response',
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_turbo_mode_waiting.html',
......@@ -463,6 +472,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'review_num': 1,
'rubric_criteria': xblock.rubric_criteria,
'submit_button_text': 'Submit your assessment & review another response',
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_turbo_mode.html',
......@@ -484,6 +494,7 @@ class TestPeerAssessmentRender(XBlockHandlerTestCase):
'review_num': 1,
'rubric_criteria': xblock.rubric_criteria,
'submit_button_text': 'Submit your assessment & review another response',
'allow_latex': False,
}
self._assert_path_and_context(
xblock, 'openassessmentblock/peer/oa_peer_unavailable.html',
......
......@@ -167,7 +167,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
self._assert_path_and_context(
xblock,
'openassessmentblock/self/oa_self_unavailable.html',
{'self_start': datetime.datetime(5999, 1, 1).replace(tzinfo=pytz.utc)}
{'self_start': datetime.datetime(5999, 1, 1).replace(tzinfo=pytz.utc), 'allow_latex': False}
)
@scenario('data/self_assessment_closed.xml', user_id='Bob')
......@@ -176,14 +176,14 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
self._assert_path_and_context(
xblock,
'openassessmentblock/self/oa_self_closed.html',
{'self_due': datetime.datetime(2000, 1, 1).replace(tzinfo=pytz.utc)}
{'self_due': datetime.datetime(2000, 1, 1).replace(tzinfo=pytz.utc), 'allow_latex': False}
)
@scenario('data/self_assessment_open.xml', user_id='Bob')
def test_open_no_submission(self, xblock):
# Without making a submission, this step should be unavailable
self._assert_path_and_context(
xblock, 'openassessmentblock/self/oa_self_unavailable.html', {}
xblock, 'openassessmentblock/self/oa_self_unavailable.html', {'allow_latex': False}
)
@scenario('data/self_assessment_open.xml', user_id='James Brown')
......@@ -195,7 +195,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
# Should still not be able to access self-assessment
self._assert_path_and_context(
xblock, 'openassessmentblock/self/oa_self_unavailable.html', {}
xblock, 'openassessmentblock/self/oa_self_unavailable.html', {'allow_latex': False}
)
@scenario('data/self_assessment_open.xml', user_id='James Brown')
......@@ -207,7 +207,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
xblock.get_student_item_dict(), u"𝓟𝓪𝓼𝓼 𝓽𝓱𝓮 𝓹𝓮𝓪𝓼"
)
self._assert_path_and_context(
xblock, 'openassessmentblock/self/oa_self_complete.html', {},
xblock, 'openassessmentblock/self/oa_self_complete.html', {'allow_latex': False},
workflow_status='waiting',
status_details={
'self': {'complete': True},
......@@ -224,7 +224,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
# In the self --> peer configuration, self can be complete
# if our status is "peer"
self._assert_path_and_context(
xblock, 'openassessmentblock/self/oa_self_complete.html', {},
xblock, 'openassessmentblock/self/oa_self_complete.html', {'allow_latex': False},
workflow_status="peer",
status_details={
'self': {'complete': True},
......@@ -239,7 +239,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
xblock.get_student_item_dict(), u"Ⱥɨn'ŧ ɨŧ fᵾnꝁɏ"
)
self._assert_path_and_context(
xblock, 'openassessmentblock/self/oa_self_complete.html', {},
xblock, 'openassessmentblock/self/oa_self_complete.html', {'allow_latex':False},
workflow_status='done'
)
......@@ -257,6 +257,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
'self_submission': submission,
'allow_file_upload': False,
'self_file_url': '',
'allow_latex': False,
},
workflow_status='self',
submission_uuid=submission['uuid']
......@@ -277,7 +278,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
create_rubric_dict(xblock.prompt, xblock.rubric_criteria)
)
self._assert_path_and_context(
xblock, 'openassessmentblock/self/oa_self_complete.html', {},
xblock, 'openassessmentblock/self/oa_self_complete.html', {'allow_latex': False},
workflow_status='self',
submission_uuid=submission['uuid']
)
......@@ -292,7 +293,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
self._assert_path_and_context(
xblock,
'openassessmentblock/self/oa_self_closed.html',
{'self_due': datetime.datetime(2000, 1, 1).replace(tzinfo=pytz.utc)},
{'self_due': datetime.datetime(2000, 1, 1).replace(tzinfo=pytz.utc), 'allow_latex': False},
workflow_status='self',
submission_uuid=submission['uuid']
)
......@@ -319,7 +320,7 @@ class TestSelfAssessmentRender(XBlockHandlerTestCase):
# we ALWAYS show complete, even if the workflow tells us we're still have status 'self'.
self._assert_path_and_context(
xblock, 'openassessmentblock/self/oa_self_complete.html',
{'self_due': datetime.datetime(2000, 1, 1).replace(tzinfo=pytz.utc)},
{'self_due': datetime.datetime(2000, 1, 1).replace(tzinfo=pytz.utc), 'allow_latex': False},
workflow_status='self',
submission_uuid=submission['uuid']
)
......
......@@ -24,7 +24,6 @@ class StudentTrainingTest(XBlockHandlerTestCase):
'submission': u'Thé őbjéćt őf édúćátíőń íś tő téáćh úś tő ĺővé ẃhát íś béáútífúĺ.'
}
def assert_path_and_context(self, xblock, expected_path, expected_context):
"""
Render the student training step and verify that the expected template
......@@ -49,7 +48,7 @@ class StudentTrainingTest(XBlockHandlerTestCase):
else:
self.assertEqual(context[key], expected_context[key])
# Verify that we render without error
# Verify that we render without error
resp = self.request(xblock, 'render_student_training', json.dumps({}))
self.assertGreater(len(resp), 0)
......@@ -163,7 +162,7 @@ class StudentTrainingAssessTest(StudentTrainingTest):
# Expect that we were correct
self.assertTrue(resp['success'], msg=resp.get('msg'))
self.assertFalse(resp['corrections'])
expected_context = {}
expected_context = {"allow_latex": False}
expected_template = "openassessmentblock/student_training/student_training_complete.html"
self.assert_path_and_context(xblock, expected_template, expected_context)
......@@ -290,7 +289,8 @@ class StudentTrainingRenderTest(StudentTrainingTest):
xblock.create_submission(xblock.get_student_item_dict(), self.SUBMISSION)
expected_template = "openassessmentblock/student_training/student_training_closed.html"
expected_context = {
'training_due': "2000-01-01T00:00:00+00:00"
'training_due': "2000-01-01T00:00:00+00:00",
'allow_latex': False,
}
self.assert_path_and_context(xblock, expected_template, expected_context)
......@@ -307,6 +307,7 @@ class StudentTrainingRenderTest(StudentTrainingTest):
xblock.create_submission(xblock.get_student_item_dict(), self.SUBMISSION)
expected_template = "openassessmentblock/student_training/student_training_unavailable.html"
expected_context = {
'training_start': datetime.datetime(3000, 1, 1).replace(tzinfo=pytz.utc)
'training_start': datetime.datetime(3000, 1, 1).replace(tzinfo=pytz.utc),
'allow_latex': False,
}
self.assert_path_and_context(xblock, expected_template, expected_context)
......@@ -23,6 +23,7 @@ class StudioViewTest(XBlockHandlerTestCase):
"submission_start": "4014-02-10T09:46",
"submission_due": "4014-02-27T09:46",
"allow_file_upload": False,
"allow_latex": False,
"leaderboard_show": 4,
"assessments": [{"name": "self-assessment"}],
"editor_assessments_order": [
......
......@@ -102,7 +102,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'allow_file_upload': False,
'submission_start': dt.datetime(4999, 4, 1).replace(tzinfo=pytz.utc),
'has_peer': True,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......@@ -123,7 +124,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'student_submission': submission,
'allow_file_upload': False,
'has_peer': True,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......@@ -138,7 +140,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'submit_enabled': False,
'submission_due': dt.datetime(2999, 5, 6).replace(tzinfo=pytz.utc),
'has_peer': True,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......@@ -152,7 +155,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'save_status': 'This response has not been saved.',
'submit_enabled': False,
'has_peer': True,
'has_self': False
'has_self': False,
'allow_latex': False,
}
)
......@@ -172,7 +176,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'submit_enabled': True,
'submission_due': dt.datetime(2999, 5, 6).replace(tzinfo=pytz.utc),
'has_peer': True,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......@@ -189,7 +194,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'student_submission': submission,
'allow_file_upload': False,
'has_peer': True,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......@@ -201,7 +207,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'allow_file_upload': False,
'submission_due': dt.datetime(2014, 4, 5).replace(tzinfo=pytz.utc),
'has_peer': False,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......@@ -218,7 +225,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'student_submission': submission,
'allow_file_upload': False,
'has_peer': False,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......@@ -243,7 +251,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'student_submission': submission,
'allow_file_upload': False,
'has_peer': True,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......@@ -268,7 +277,8 @@ class SubmissionRenderTest(XBlockHandlerTestCase):
'student_submission': submission,
'allow_file_upload': False,
'has_peer': False,
'has_self': True
'has_self': True,
'allow_latex': False,
}
)
......
......@@ -108,6 +108,7 @@ class TestSerializeContent(TestCase):
self.oa_block.rubric_criteria = data.get('criteria', copy.deepcopy(self.BASIC_CRITERIA))
self.oa_block.rubric_assessments = data.get('assessments', copy.deepcopy(self.BASIC_ASSESSMENTS))
self.oa_block.allow_file_upload = data.get('allow_file_upload')
self.oa_block.allow_latex = data.get('allow_latex')
self.oa_block.leaderboard_show = data.get('leaderboard_show', 0)
@ddt.file_data('data/serialize.json')
......@@ -408,6 +409,7 @@ class TestParseFromXml(TestCase):
'criteria',
'assessments',
'allow_file_upload',
'allow_latex',
'leaderboard_show'
]
for field_name in expected_fields:
......
......@@ -624,6 +624,9 @@ def serialize_content_to_xml(oa_block, root):
if oa_block.allow_file_upload is not None:
root.set('allow_file_upload', unicode(oa_block.allow_file_upload))
if oa_block.allow_latex is not None:
root.set('allow_latex', unicode(oa_block.allow_latex))
# Open assessment displayed title
title = etree.SubElement(root, 'title')
title.text = unicode(oa_block.title)
......@@ -746,6 +749,10 @@ def parse_from_xml(root):
if 'allow_file_upload' in root.attrib:
allow_file_upload = _parse_boolean(unicode(root.attrib['allow_file_upload']))
allow_latex = False
if 'allow_latex' in root.attrib:
allow_latex = _parse_boolean(unicode(root.attrib['allow_latex']))
# Retrieve the title
title_el = root.find('title')
if title_el is None:
......@@ -785,6 +792,7 @@ def parse_from_xml(root):
'submission_start': submission_start,
'submission_due': submission_due,
'allow_file_upload': allow_file_upload,
'allow_latex': allow_latex,
'leaderboard_show': leaderboard_show
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment