Skip to content

Commit

Permalink
add exam intro/outro text
Browse files Browse the repository at this point in the history
You can write some text which appears on the front page.
You can also give a list of (percentage, message) pairs to be shown on the results page. The message with the highest percentage less than or equal to the student's score is shown.

see numbas/Numbas#443 and numbas/Numbas#447
  • Loading branch information
christianp committed Jul 26, 2016
1 parent dbb5020 commit c176df5
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 160 deletions.
155 changes: 0 additions & 155 deletions editor/static/css/exam/edit.css
Expand Up @@ -4,158 +4,3 @@
list-style: none;
background: #eee;
}

/*
#exam-name {
font-size: 2em;
height: 1.5em;
}
.exam-author {
font-weight: bold;
}
.editable-message {
font-style: italic;
}
#content .question {
line-height: 1.5em !important;
padding: 0 2em 0.5em 44px !important;
clear: both;
background: #eee;
min-height: 44px;
margin-bottom: 0.5em;
position: relative;
}
#content .question .details {
margin-bottom: 1em;
}
#content .question .author {
font-size: smaller;
line-height: 1em;
}
#content .question .handle {
margin-left: -44px;
height: 100%;
position: absolute;
padding-top: 0;
padding-bottom: 0;
}
#content .question .number {
font-weight: bold;
}
#content .questions {
padding-bottom: 1em;
overflow-x: hidden;
}
#content .questions .questionList {
width: 100%;
display: inline-block;
padding-left: 0;
border: 1px dashed;
list-style-type: none;
}
#content .question .controls {
float: right;
margin-top: 0.5em;
margin-left: 1em;
margin-right: -1em;
width: 16px;
}
#content .question .controls .delete {
margin: 0;
}
#content .question .title {
}
#content .question .number {
font-weight: bold;
}
#content .question .description {
line-height: 1.2em;
font-size: 80%;
padding-bottom: 0.5em;
overflow-y: hidden;
}
#content .question .description p {
margin: 0;
}
#content .questions .searchBox {
display: inline-block;
vertical-align: top;
}
#content .questions .results, #content .questions .questionList {
padding: 0;
height: 25em;
overflow-y: auto;
}
.questionResult {
margin-bottom: 0.5em;
}
.questionResult .handle {
width: 16px;
background-image: url(../../images/plus_alt_16x16.png);
padding-left: 20px;
cursor: pointer;
}
#content .question .preview {
background-image: url(../../images/play_alt_16x16.png);
width: 16px;
height: 16px;
display: inline-block;
}
#content .question .preview:hover {
background-color: #06f;
border-radius: 50%;
}
#content .question .copy {
background-image: url(../../images/loop_alt1_16x12.png);
width: 16px;
height: 12px;
display: inline-block;
border: none;
padding: 0;
margin: 0;
background-color: transparent;
}
#content .question .copy:hover {
background-color: #f90;
}
#content .question.ui-sortable-helper {
background: white;
opacity: 0.8;
}
#content .question.ui-sortable-helper .number {
display: none;
}
li.questionResult.ui-draggable-dragging, li.question.ui-sortable-helper {
border: 1px dashed black;
}
.upload-theme {
font-size: small;
text-align: right;
}
*/
13 changes: 13 additions & 0 deletions editor/static/js/editor.js
Expand Up @@ -1310,6 +1310,19 @@ $(document).ready(function() {
}
}

/** update the value of an observable when the input event is triggered
* augments the value binding
*/
ko.bindingHandlers.inputValue = {
init: function(element,valueAccessor) {
var value = valueAccessor();
$(element).on('input',function() {
value($(element).val());
});
ko.applyBindingsToNode(element,{value:value});
}
}

var Subject = Editor.Subject = function(data) {
this.pk = data.pk;
this.name = data.name;
Expand Down
37 changes: 35 additions & 2 deletions editor/static/js/exam/edit.js
Expand Up @@ -61,6 +61,13 @@ $(document).ready(function() {
this.allowrevealanswer = ko.observable(true);
this.advicethreshold = ko.observable(0);

this.intro = ko.observable('');
this.feedbackMessages = ko.observableArray([]);

this.addFeedbackMessage = function() {
e.feedbackMessages.push(new FeedbackMessage());
}

this.questionTabs = ko.observableArray([
new Editor.Tab('basket','Basket','shopping-cart'),
new Editor.Tab('mine','Recent Questions','time')
Expand Down Expand Up @@ -231,7 +238,9 @@ $(document).ready(function() {
showtotalmark: this.showtotalmark(),
showanswerstate: this.showanswerstate(),
allowrevealanswer: this.allowrevealanswer(),
advicethreshold: this.advicethreshold()
advicethreshold: this.advicethreshold(),
intro: this.intro(),
feedbackmessages: this.feedbackMessages().map(function(f){return f.toJSON()})
}
};
},
Expand Down Expand Up @@ -265,7 +274,10 @@ $(document).ready(function() {

if('feedback' in content)
{
tryLoad(content.feedback,['showactualmark','showtotalmark','showanswerstate','allowrevealanswer','advicethreshold'],this);
tryLoad(content.feedback,['showactualmark','showtotalmark','showanswerstate','allowrevealanswer','advicethreshold','intro'],this);
if('feedbackmessages' in content.feedback) {
this.feedbackMessages(content.feedback.feedbackmessages.map(function(d){var f = new FeedbackMessage(); f.load(d); return f}));
}
}

if('custom_theme' in data && data.custom_theme) {
Expand Down Expand Up @@ -396,6 +408,27 @@ $(document).ready(function() {
}
}

function FeedbackMessage() {
this.message = ko.observable('');
this.threshold = ko.observable(0);
}
FeedbackMessage.prototype = {
toJSON: function() {
return {
message: this.message(),
threshold: this.threshold()
}
},

load: function(data) {
this.message(data.message);
this.threshold(data.threshold || 0);
},
remove: function() {
viewModel.feedbackMessages.remove(this);
}
}

Numbas.queueScript('start-editor',['jme-display','jme-variables','jme','editor-extras'],function() {
try {
viewModel = new Exam(item_json.itemJSON);
Expand Down
3 changes: 2 additions & 1 deletion editor/templates/editor-controls/percentproperty.html
Expand Up @@ -9,7 +9,8 @@
<input
{% if not editable %}disabled{% endif%}
data-bind="
value: {{property}},
value: {{property}},
inputValue: {{property}}
"
type="range"
step="5"
Expand Down
46 changes: 44 additions & 2 deletions editor/templates/exam/edit.html
Expand Up @@ -210,13 +210,54 @@ <h4 class="panel-title">Add questions to this exam</h4>
<!-- Feedback -->
<section class="tab-pane" data-bind="css: {active: ko.unwrap($root.currentTab().id)=='feedback'}">
<form class="form-horizontal" data-bind="submit: Editor.noop">
{% with form_label_class='col-sm-3' form_control_class='col-sm-6' %}
{% with form_label_class='col-sm-3' form_control_class='col-sm-6' form_offset_class='col-sm-offset-3' %}
{% booleanproperty 'showactualmark' 'Show current score?' help_url='http://numbas-editor.readthedocs.io/en/latest/exam/reference.html#term-show-current-score' %}
{% booleanproperty 'showtotalmark' 'Show maximum score?' help_url='http://numbas-editor.readthedocs.io/en/latest/exam/reference.html#term-show-maximum-score' %}
{% booleanproperty 'showanswerstate' 'Show answer state?' help_url='http://numbas-editor.readthedocs.io/en/latest/exam/reference.html#term-show-answer-state' %}
{% booleanproperty 'allowrevealanswer' 'Allow reveal answer?' help_url='http://numbas-editor.readthedocs.io/en/latest/exam/reference.html#term-allow-reveal-answer' %}
{% percentproperty 'advicethreshold' 'Advice threshold' help_url='http://numbas-editor.readthedocs.io/en/latest/exam/reference.html#term-advice-threshold' %}

<div class="form-group">
<label class="{{form_label_class}} control-label">
Introduction
{% helplink 'http://numbas-editor.readthedocs.io/en/latest/exam/reference.html#term-introduction' subject='the exam introduction' %}
</label>
<div class="{{form_control_class}}">
<div {% if not editable %}disabled{% endif %} data-bind="writemaths: intro"></div>
<p class="help-block">
Give any information applying to the whole exam, which the student will see before they begin.
</p>
</div>
</div>

<h4>Feedback messages</h4>
<ul class="feedback-messages list-unstyled list-group" data-bind="foreach: feedbackMessages">
<li class="feedback-message list-group-item clearfix">
<div class="form-group">
<label class="{{form_label_class}} control-label">
If the student's score is at least
</label>
<div class="{{form_control_class}} form-inline">
<input type="range" data-bind="inputValue: threshold" step="1" min="0" max="100"> <span class="percentproperty value" data-bind="text: ko.unwrap(threshold)+'%', valueUpdate: 'input'"></span>
</div>
</div>
<div class="form-group">
<label class="{{form_label_class}} control-label">
Show this message
</label>
<div class="{{form_control_class}}">
<div {% if not editable %}disabled{% endif %} data-bind="writemaths: message"></div>
</div>
</div>
<div class="{{form_control_class}} {{form_offset_class}}">
{% if editable %}<button type="button" type="button" class="delete btn btn-sm btn-danger" data-bind="click:remove"><span class="glyphicon glyphicon-remove"></span> Delete this feedback message</button>{% endif %}
</div>
</li>
</ul>
{% if editable %}<button type="button" class="btn btn-primary" data-bind="click: addFeedbackMessage"><span class="glyphicon glyphicon-plus"></span> Add a feedback message</button>{% endif %}

{% endwith %}


</form>

{% if editable %}
Expand All @@ -232,6 +273,7 @@ <h4 class="panel-title">Add questions to this exam</h4>
</ul>
</nav>
{% endif %}

</section>

{% endblock main_tab_content %}
Expand Down

0 comments on commit c176df5

Please sign in to comment.