Skip to content

Commit

Permalink
Audio feedback optional property added to Quiz & MCQ pages
Browse files Browse the repository at this point in the history
  • Loading branch information
FayCross committed Jan 15, 2016
1 parent a0d901d commit b034bb9
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 26 deletions.
3 changes: 1 addition & 2 deletions modules/xerte/parent_templates/Nottingham/data.xwd
Expand Up @@ -1218,11 +1218,10 @@

</mcq><option menuItem="Option" icon="icBullet">
<name label="Label" type="TextInput" mandatory="true" defaultValue="Option"/>

<text label="Option" type="TextArea" height="100"/>
<feedback label="Feedback" type="TextArea" height="100"/>
<correct label="Correct" options="true,false" type="ComboBox" data="true,false" defaultValue="false" width="100"/>

<audioFB label="Audio Feedback" defaultValue="Select a Sound File" type="media" optional="true"/>
</option><mediaLesson menu="Media" menuItem="Media Lesson" hint="Synchronise a variety of types of content to a piece of media." icon="icApplicationTile" thumb="thumbs/mediaLesson.jpg" remove="true">

<name label="Page Title" type="TextInput" wysiwyg="true"/>
Expand Down
38 changes: 32 additions & 6 deletions modules/xerte/parent_templates/Nottingham/models_html5/mcq.html
Expand Up @@ -40,6 +40,16 @@
var $panel = $("#pageContents .panel");
$panel.height($x_pageHolder.height() - parseInt($x_pageDiv.css("padding-top")) * 2 - parseInt($panel.css("padding-top")) * 2 - 5);
}

if ($("#pageContents .audioHolder").length > 0) {
var audioBarW = 0;
$("#pageContents .audioHolder:eq(0) .mejs-inner .mejs-controls").children().each(function() {
audioBarW += $(this).outerWidth();
});
if (audioBarW - $("#pageContents .audioHolder").parents("#mainPanel").width() < -2 || audioBarW - $("#pageContents .audioHolder").parents("#mainPanel").width() > 2) {
$x_window.resize();
}
}
}

this.startQ = function() {
Expand Down Expand Up @@ -97,7 +107,10 @@
(selectedOption.correct == "false" && !$(selected[i]).is(':checked')));
if ($(selected[i]).is(':checked')) {
answerFeedback += "<p>" + x_addLineBreaks(selectedOption.feedback) + "</p>";

if (selectedOption.audioFB != undefined && selectedOption.audioFB != "") {
answerFeedback += '<div class="audioHolder" data-audio="' + selectedOption.audioFB + '"></div>';
}

l_options.push(optionIndex+1+"");
l_answer.push(selectedOption.text);
l_feedback.push(selectedOption.feedback);
Expand Down Expand Up @@ -146,8 +159,16 @@
if (feedbackLabel == undefined) {
feedbackLabel = "Feedback";
}
$("#feedback").html("<h3>" + feedbackLabel + "</h3>" + generalFeedback);

$("#feedback")
.html("<h3>" + feedbackLabel + "</h3>" + generalFeedback)
.find(".audioHolder").each(function() {
$(this).mediaPlayer({
type :"audio",
source :$(this).data("audio"),
width :"100%"
});
});

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$("#feedback").find("a.x_glossary").contents().unwrap();
}
Expand Down Expand Up @@ -242,7 +263,8 @@
{
text: this.getAttribute("text"),
correct: this.getAttribute("correct"),
feedback: this.getAttribute("feedback")
feedback: this.getAttribute("feedback"),
audioFB: this.getAttribute("audioFB")
}
);
});
Expand Down Expand Up @@ -366,14 +388,18 @@
display: block;
}

#pageContents button {
#pageContents #checkBtn {
margin: 10px;
float: right;
}

#pageContents #feedback {
clear: both;
}

#feedback .audioHolder {
margin: 0.5em 0 1em 0;
}

</style>

Expand All @@ -384,7 +410,7 @@
<div id="textHolder" class="left" tabindex="1"></div>

<div id="infoHolder" class="right">
<div class="panel">
<div id="mainPanel" class="panel">
<h3 id="question"></h3>
<div id="optionHolder">
<div class="optionGroup">
Expand Down
55 changes: 44 additions & 11 deletions modules/xerte/parent_templates/Nottingham/models_html5/quiz.html
Expand Up @@ -49,13 +49,29 @@
this.loadVideo();
}

var resized = false;
if ($("#questionAudio").children().length > 0) {
var audioBarW = 0;
$("#questionAudio").find(".mejs-inner").find(".mejs-controls").children().each(function() {
audioBarW += $(this).outerWidth();
});
if (audioBarW < $("#questionAudio").width() - 5 || audioBarW > $("#questionAudio").width() + 5) {
$x_window.resize();
if (resized == false) {
var audioBarW = 0;
$("#questionAudio").find(".mejs-inner").find(".mejs-controls").children().each(function() {
audioBarW += $(this).outerWidth();
});
if (audioBarW < $("#questionAudio").width() - 5 || audioBarW > $("#questionAudio").width() + 5) {
resized = true;
$x_window.resize();
}
}
}
if ($("#pageContents .audioHolder").length > 0) {
if (resized == false) {
var audioBarW = 0;
$("#pageContents .audioHolder:eq(0) .mejs-inner .mejs-controls").children().each(function() {
audioBarW += $(this).outerWidth();
});
if (audioBarW - $("#pageContents .audioHolder").parents("#mainPanel").width() < -2 || audioBarW - $("#pageContents .audioHolder").parents("#mainPanel").width() > 2) {
resized = true;
$x_window.resize();
}
}
}
}
Expand Down Expand Up @@ -174,7 +190,8 @@
{
text: this.getAttribute("text"),
correct: this.getAttribute("correct"),
feedback: this.getAttribute("feedback")
feedback: this.getAttribute("feedback"),
audioFB: this.getAttribute("audioFB")
}
);
});
Expand Down Expand Up @@ -257,6 +274,10 @@
selectedOption = quiz.currentAnswers[optionIndex];

optionFeedback += "<p>" + x_addLineBreaks(selectedOption.feedback) + "</p>";
if (selectedOption.audioFB != undefined && selectedOption.audioFB != "") {
optionFeedback += '<div class="audioHolder" data-audio="' + selectedOption.audioFB + '"></div>';
}

if (correct != false && selectedOption.correct == "true") {
correct = true;
} else {
Expand Down Expand Up @@ -310,7 +331,15 @@
}
if (quiz.showfeedback)
{
$("#feedback").html(answerFeedback);
$("#feedback")
.html(answerFeedback)
.find(".audioHolder").each(function() {
$(this).mediaPlayer({
type :"audio",
source :$(this).data("audio"),
width :"100%"
});
});

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$("#feedback").find("a.x_glossary").contents().unwrap();
Expand Down Expand Up @@ -410,7 +439,7 @@
$("#infoHolder .panel").appendTo($("#pageContents"));
$splitScreen.remove();
} else {
$textHolder.html('<p>' + x_addLineBreaks(x_currentPageXML.getAttribute("instructions")) + '</p>');
$textHolder.html(x_addLineBreaks(x_currentPageXML.getAttribute("instructions")));

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$textHolder.find("a.x_glossary").contents().unwrap();
Expand Down Expand Up @@ -600,7 +629,7 @@
display: block;
}

#pageContents button {
#pageContents #buttonHolder button, #feedbackHolder #nextBtn {
margin: 10px;
float: right;
}
Expand Down Expand Up @@ -631,6 +660,10 @@
#questionAudio {
clear: both;
}

#feedback .audioHolder {
margin: 0.5em 0 1em 0;
}

</style>

Expand All @@ -641,7 +674,7 @@
<div id="textHolder" class="left" tabindex="1"></div>

<div id="infoHolder" class="right">
<div class="panel qPanel">
<div id="mainPanel" class="panel qPanel">
<h3 id="qNo"></h3>
<p id="qTxt"></p>
<div id="questionAudio"></div>
Expand Down
Expand Up @@ -1218,11 +1218,10 @@

</mcq><option menuItem="Option" icon="icBullet">
<name label="Label" type="TextInput" mandatory="true" defaultValue="Option"/>

<text label="Option" type="TextArea" height="100"/>
<feedback label="Feedback" type="TextArea" height="100"/>
<correct label="Correct" options="true,false" type="ComboBox" data="true,false" defaultValue="false" width="100"/>

<audioFB label="Audio Feedback" defaultValue="Select a Sound File" type="media" optional="true"/>
</option><mediaLesson menu="Media" menuItem="Media Lesson" hint="Synchronise a variety of types of content to a piece of media." icon="icApplicationTile" thumb="thumbs/mediaLesson.jpg" remove="true">

<name label="Page Title" type="TextInput" wysiwyg="true"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Nottingham/wizards/en-GB/mcq.xwd
@@ -1 +1 @@
<wizard menus="Interactivity"> <pageWizard remove="true" duplicate="false"> <newNodes> <mcq><![CDATA[<mcq name="Enter Page Title" instruction="Enter Instruction" prompt="Enter a Prompt" type="Single Answer" align="Left" panelWidth="Medium" feedbackLabel="Feedback" singleRight="Your answer is correct!" singleWrong="Your answer is incorrect" multiRight="You have selected all the correct answers" multiWrong="You have not selected the correct combination of answers" checkBtnTxt="Check" />]]></mcq> </newNodes> </pageWizard> <!-- MCQ PAGE============================== --> <mcq menu="Interactivity" menuItem="Multiple Choice Question" hint="Pose a question with multiple answer options. Create simple true - false questions, or more complex questions with multiple correct answers." icon="icComments" thumb="thumbs/mcq.jpg" remove="true"> <name label="Page Title" type="TextInput" wysiwyg="true"/> <align label="Align Text" options="Left,Right" type="ComboBox" data="Left,Right" defaultValue="Left" width="100"/> <instruction label="Instruction" type="TextArea" height="100"/> <prompt label="Prompt" type="TextArea" height="100"/> <type label="Question Type" options="Single Answer,Multiple Answer" type="ComboBox" data="Single Answer,Multiple Answer" defaultValue="Single Answer" width="120"/> <panelWidth label="Panel Width" options="Small,Medium,Large,Full" type="ComboBox" data="Small,Medium,Large,Full" defaultValue="Medium" width="100"/> <trackingWeight label="Tracking Score Weight (0=Off)" optional="true" type="textInput" width="120" defaultValue="1.0" /> <feedbackLabel label="Feedback Label" type="TextInput" wysiwyg="true" divider="true" language="true" /> <singleRight label="Single Answer Correct" type="TextInput" wysiwyg="true" language="true" /> <singleWrong label="Single Answer Wrong" type="TextInput" wysiwyg="true" language="true" /> <multiRight label="Multi Answer Correct" type="TextInput" wysiwyg="true" language="true" /> <multiWrong label="Multi Answer Wrong" type="TextInput" wysiwyg="true" language="true" /> <checkBtnTxt label="Check Button Label" type="TextInput" wysiwyg="true" language="true" /> <checkBtnTip label="Check Button Tip" type="textInput" language="true" deprecated="This property is no longer required"/> <checkBtnWidth label="Check Button Width" type="NumericStepper" min="100" max="250" step="10" width="100" defaultValue="100" language="true" deprecated="Width is now set automatically"/> <answerOrder label="Answer Order" options="Sequence,Random" type="comboBox" data="sequence,random" defaultValue="sequence" width="120" optional="true"/> <narrationNavigate label="Navigate on Narration" type="CheckBox" defaultValue="false" optional="true"/> <playNarration label="Auto-Play Narration" type="CheckBox" defaultValue="false" optional="true"/> <narration label="Narration" type="media" optional="true"/> <navSetting label="Navigation Buttons" options="All,Back and Next,Back Only,Next Only,None" type="ComboBox" width="120" data="all,backnext,backonly,nextonly,none" defaultValue="all" optional="true"/> <pageID label="Page ID" defaultValue="Unique ID for this page" type="TextInput" optional="true" /> <feedback type="TextArea" height="40" label="Feedback" optional="true"/> <timer label="Page Timer" defaultValue="60" type="NumericStepper" min="0" max="1200" step="1" width="100" optional="true" /> <disableGlossary label="Disable Glossary" defaultValue="false" type="CheckBox" optional="true"/> <newNodes> <option><![CDATA[<option name="Option" text="Here is an option" feedback="Feedback for this option" correct="false"/>]]></option> </newNodes> </mcq> <option menuItem="Option" icon="icBullet"> <name label="Label" type="TextInput" mandatory="true" defaultValue="Option" /> <text label="Option" type="TextArea" height="100"/> <feedback label="Feedback" type="TextArea" height="100"/> <correct label="Correct" options="true,false" type="ComboBox" data="true,false" defaultValue="false" width="100" /> </option></wizard>
<wizard menus="Interactivity"> <pageWizard remove="true" duplicate="false"> <newNodes> <mcq><![CDATA[<mcq name="Enter Page Title" instruction="Enter Instruction" prompt="Enter a Prompt" type="Single Answer" align="Left" panelWidth="Medium" feedbackLabel="Feedback" singleRight="Your answer is correct!" singleWrong="Your answer is incorrect" multiRight="You have selected all the correct answers" multiWrong="You have not selected the correct combination of answers" checkBtnTxt="Check" />]]></mcq> </newNodes> </pageWizard> <!-- MCQ PAGE============================== --> <mcq menu="Interactivity" menuItem="Multiple Choice Question" hint="Pose a question with multiple answer options. Create simple true - false questions, or more complex questions with multiple correct answers." icon="icComments" thumb="thumbs/mcq.jpg" remove="true"> <name label="Page Title" type="TextInput" wysiwyg="true"/> <align label="Align Text" options="Left,Right" type="ComboBox" data="Left,Right" defaultValue="Left" width="100"/> <instruction label="Instruction" type="TextArea" height="100"/> <prompt label="Prompt" type="TextArea" height="100"/> <type label="Question Type" options="Single Answer,Multiple Answer" type="ComboBox" data="Single Answer,Multiple Answer" defaultValue="Single Answer" width="120"/> <panelWidth label="Panel Width" options="Small,Medium,Large,Full" type="ComboBox" data="Small,Medium,Large,Full" defaultValue="Medium" width="100"/> <trackingWeight label="Tracking Score Weight (0=Off)" optional="true" type="textInput" width="120" defaultValue="1.0" /> <feedbackLabel label="Feedback Label" type="TextInput" wysiwyg="true" divider="true" language="true" /> <singleRight label="Single Answer Correct" type="TextInput" wysiwyg="true" language="true" /> <singleWrong label="Single Answer Wrong" type="TextInput" wysiwyg="true" language="true" /> <multiRight label="Multi Answer Correct" type="TextInput" wysiwyg="true" language="true" /> <multiWrong label="Multi Answer Wrong" type="TextInput" wysiwyg="true" language="true" /> <checkBtnTxt label="Check Button Label" type="TextInput" wysiwyg="true" language="true" /> <checkBtnTip label="Check Button Tip" type="textInput" language="true" deprecated="This property is no longer required"/> <checkBtnWidth label="Check Button Width" type="NumericStepper" min="100" max="250" step="10" width="100" defaultValue="100" language="true" deprecated="Width is now set automatically"/> <answerOrder label="Answer Order" options="Sequence,Random" type="comboBox" data="sequence,random" defaultValue="sequence" width="120" optional="true"/> <narrationNavigate label="Navigate on Narration" type="CheckBox" defaultValue="false" optional="true"/> <playNarration label="Auto-Play Narration" type="CheckBox" defaultValue="false" optional="true"/> <narration label="Narration" type="media" optional="true"/> <navSetting label="Navigation Buttons" options="All,Back and Next,Back Only,Next Only,None" type="ComboBox" width="120" data="all,backnext,backonly,nextonly,none" defaultValue="all" optional="true"/> <pageID label="Page ID" defaultValue="Unique ID for this page" type="TextInput" optional="true" /> <feedback type="TextArea" height="40" label="Feedback" optional="true"/> <timer label="Page Timer" defaultValue="60" type="NumericStepper" min="0" max="1200" step="1" width="100" optional="true" /> <disableGlossary label="Disable Glossary" defaultValue="false" type="CheckBox" optional="true"/> <newNodes> <option><![CDATA[<option name="Option" text="Here is an option" feedback="Feedback for this option" correct="false"/>]]></option> </newNodes> </mcq> <option menuItem="Option" icon="icBullet"> <name label="Label" type="TextInput" mandatory="true" defaultValue="Option" /> <text label="Option" type="TextArea" height="100"/> <feedback label="Feedback" type="TextArea" height="100"/> <correct label="Correct" options="true,false" type="ComboBox" data="true,false" defaultValue="false" width="100" /> <audioFB label="Audio Feedback" defaultValue="Select a Sound File" type="media" optional="true" /> </option></wizard>
Expand Down
4 changes: 2 additions & 2 deletions src/Nottingham/wizards/en-GB/quiz.xwd
Expand Up @@ -80,10 +80,10 @@

<option menuItem="Option" icon="icBullet">
<name label="Label" type="TextInput" mandatory="true" defaultValue="Option"/>

<text label="Option" type="TextArea" height="100"/>
<feedback label="Feedback" type="TextArea" height="100"/>
<correct label="Correct" options="true,false" type="ComboBox" data="true,false" defaultValue="false" width="100" />

<audioFB label="Audio Feedback" defaultValue="Select a Sound File" type="media" optional="true" />
</option>

</wizard>
3 changes: 1 addition & 2 deletions src/Nottingham/wizards/en-GB/template.xwd
Expand Up @@ -1218,11 +1218,10 @@

</mcq><option menuItem="Option" icon="icBullet">
<name label="Label" type="TextInput" mandatory="true" defaultValue="Option"/>

<text label="Option" type="TextArea" height="100"/>
<feedback label="Feedback" type="TextArea" height="100"/>
<correct label="Correct" options="true,false" type="ComboBox" data="true,false" defaultValue="false" width="100"/>

<audioFB label="Audio Feedback" defaultValue="Select a Sound File" type="media" optional="true"/>
</option><mediaLesson menu="Media" menuItem="Media Lesson" hint="Synchronise a variety of types of content to a piece of media." icon="icApplicationTile" thumb="thumbs/mediaLesson.jpg" remove="true">

<name label="Page Title" type="TextInput" wysiwyg="true"/>
Expand Down

0 comments on commit b034bb9

Please sign in to comment.