Skip to content
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
23 changes: 19 additions & 4 deletions runestone/assess/js/mchoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ MultipleChoice.prototype.renderMCFormOpts = function () {
if (this.random) {
this.randomizeAnswers();
}
var fieldset = document.createElement("fieldset");

var legend = document.createElement("legend");
legend.className = "sr-only";

var questionText = $(this.containerDiv).find("p").first().text();

legend.textContent = questionText;

fieldset.appendChild(legend);

for (var j = 0; j < this.answerList.length; j++) {
var k = this.indexArray[j];
Expand All @@ -192,6 +202,7 @@ MultipleChoice.prototype.renderMCFormOpts = function () {
input.value = String(k);
input.id = optid;

input.setAttribute("aria-describedby", this.divid + "_feedback");
// Create the label for the input
var label = document.createElement("label");
var labelspan = document.createElement("span");
Expand All @@ -209,11 +220,11 @@ MultipleChoice.prototype.renderMCFormOpts = function () {
this.optionArray.push(optObj);

// add the option to the form
this.optsForm.appendChild(label);
this.optsForm.appendChild(document.createElement("br"));


fieldset.appendChild(label);
fieldset.appendChild(document.createElement("br"));
}

this.optsForm.appendChild(fieldset);
};

MultipleChoice.prototype.renderMCFormButtons = function () {
Expand Down Expand Up @@ -458,9 +469,11 @@ MultipleChoice.prototype.renderMCMAFeedBack = function () {
if (this.correct) {
$(this.feedBackDiv).html(feedbackText);
$(this.feedBackDiv).attr("class", "alert alert-success");
$(this.feedBackDiv).attr("role", "alert");
} else {
$(this.feedBackDiv).html(feedbackText);
$(this.feedBackDiv).attr("class", "alert alert-danger");
$(this.feedBackDiv).attr("role", "alert");
}
};

Expand Down Expand Up @@ -500,12 +513,14 @@ MultipleChoice.prototype.renderMCMFFeedback = function (correct, feedbackText) {
if (correct) {
$(this.feedBackDiv).html(feedbackText);
$(this.feedBackDiv).attr("class", "alert alert-success");
$(this.feedBackDiv).attr("role", "alert");
} else {
if (feedbackText == null) {
feedbackText = "";
}
$(this.feedBackDiv).html(feedbackText);
$(this.feedBackDiv).attr("class", "alert alert-danger");
$(this.feedBackDiv).attr("role", "alert");
}
};

Expand Down
5 changes: 3 additions & 2 deletions runestone/assess/multiplechoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class MChoice(Assessment):
'hide_labels':directives.flag,
})


def run(self):
"""
process the multiplechoice directive and generate html for output.
Expand All @@ -190,8 +191,8 @@ def run(self):
<div class="%(divclass)s choice-question">
<div class="image-background"></div>
<div class="petlja-problem-box-icon-holder"> </div>
<img src="../_static/img/%(questionType)s-img.svg" class="petlja-problem-image %(questionType)s-image" />
<img src="../_static/img/qchoice-img.svg" class="petlja-problem-image-quiz qchoice-image" />
<img src="../_static/img/%(questionType)s-img.svg" alt="choice-question-icon" class="petlja-problem-image %(questionType)s-image" />
<img src="../_static/img/qchoice-img.svg" alt="choice-question-icon" class="petlja-problem-image-quiz qchoice-image" />
<ul data-component="multiplechoice" data-multipleanswers="%(multipleAnswers)s" data-hidelabels="%(hideLabels)s" %(random)s id="%(divid)s">
'''

Expand Down
4 changes: 2 additions & 2 deletions runestone/dragndrop/dragndrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def setup(app):
<div class="%(divclass)s dragndrop-question">
<div class="image-background"></div>
<div class="petlja-problem-box-icon-holder"> </div>
<img src="../_static/img/%(questionType)s-img.svg" class="petlja-problem-image %(questionType)s-image" />
<img src="../_static/img/qchoice-img.svg" class="petlja-problem-image-quiz qchoice-image" />
<img src="../_static/img/%(questionType)s-img.svg" alt="puzzle-icon" class="petlja-problem-image %(questionType)s-image" />
<img src="../_static/img/qchoice-img.svg" alt="quiz-icon" class="petlja-problem-image-quiz qchoice-image" />
<ul data-component="dragndrop" id="%(divid)s">
<span data-component="question">%(question)s</span>
%(feedback)s
Expand Down
3 changes: 3 additions & 0 deletions runestone/dragndrop/js/dragndrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,18 @@ DragNDrop.prototype.renderFeedback = function () {
if (!this.feedBackDiv) {
this.renderFeedbackDiv();
}
$(this.containerDiv).attr("aria-describedby", this.feedBackDiv.id);
this.feedBackDiv.style.display = "block";
var msgCorrect = $.i18n("msg_dragndrop_correct_answer");
var msgIncorrect = $.i18n($.i18n("msg_dragndrop_incorrect_answer"), this.correctNum, this.incorrectNum, this.dragNum, this.unansweredNum);
if (this.correct) {
$(this.feedBackDiv).html(msgCorrect);
$(this.feedBackDiv).attr("class", "alert alert-success draggable-feedback");
$(this.feedBackDiv).attr("role", "alert");
} else {
$(this.feedBackDiv).html(msgIncorrect + " " + this.feedback);
$(this.feedBackDiv).attr("class", "alert alert-danger draggable-feedback");
$(this.feedBackDiv).attr("role", "alert");
}
};
/*===================================
Expand Down
4 changes: 2 additions & 2 deletions runestone/fitb/fitb.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def run(self):
<div class="%(divclass)s fitb-question">
<div class="image-background"></div>
<div class="petlja-problem-box-icon-holder"> </div>
<img src="../_static/img/%(questionType)s-img.svg" class="petlja-problem-image %(questionType)s-image" />
<img src="../_static/img/qchoice-img.svg" class="petlja-problem-image-quiz qchoice-image" />
<img src="../_static/img/%(questionType)s-img.svg" alt="questionmark-icon" class="petlja-problem-image %(questionType)s-image" />
<img src="../_static/img/qchoice-img.svg" alt="questionmark-icon" class="petlja-problem-image-quiz qchoice-image" />

<div data-component="fillintheblank" id="%(divid)s">
'''
Expand Down
10 changes: 10 additions & 0 deletions runestone/fitb/js/fitb.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ FITB.prototype.renderFITBInput = function () {
// Set the class for the text inputs, then store references to them.
let ba = $(this.containerDiv).find(':input');
ba.attr('class', 'form form-control selectwidthauto');
ba.each((index, input) => {
$(input).attr('id', this.divid + "_input_" + index);
});
this.blankArray = ba.toArray();
};

Expand Down Expand Up @@ -257,6 +260,13 @@ FITB.prototype.isCompletelyBlank = function () {
};

FITB.prototype.renderFITBFeedback = function () {

$(this.feedBackDiv).attr("role", "alert");

for (var j = 0; j < this.blankArray.length; j++) {
$(this.blankArray[j]).attr("aria-describedby", this.feedBackDiv.id);
}

if (this.correct) {
$(this.feedBackDiv).attr("class", "alert alert-success");
for (var j = 0; j < this.blankArray.length; j++) {
Expand Down