Skip to content

Commit

Permalink
Fixed bugs in glossary:
Browse files Browse the repository at this point in the history
- terms can now appear within other terms (e.g. 'xerte' & 'xerte online toolkits')
- correct definition now shows if a link is clicked (previously showed last shown definition instead)

Added new optional property to quiz & mcq pages (disableGlossary) so tooltips can be turned off if they make a question too easy.
  • Loading branch information
FayCross committed Jan 7, 2015
1 parent 72a311c commit 04340a6
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 13 deletions.
Expand Up @@ -443,6 +443,8 @@ function x_setUp() {

$x_pageDiv
.on("mouseenter", ".x_glossary", function(e) {
$(this).trigger("mouseleave");

var $this = $(this),
myText = $this.text(),
myDefinition, i, len;
Expand Down Expand Up @@ -473,14 +475,17 @@ function x_setUp() {
})
.on("mouseleave", ".x_glossary", function(e) {
$x_mainHolder.off("click.glossary");
$x_glossaryHover.remove();

if ($x_glossaryHover != undefined) {
$x_glossaryHover.remove();
}

// Put back the title attribute
$this = $(this);
$this.attr('title', $this.data('title'));
})
.on("mousemove", ".x_glossary", function(e) {
var leftPos,
var leftPos,
topPos = e.pageY + 20;

if (x_browserInfo.mobile == false) {
Expand Down Expand Up @@ -1328,13 +1333,13 @@ function x_insertText(node) {
if (x_glossary.length > 0) {
for (var k=0, len=x_glossary.length; k<len; k++) {
var regExp = new RegExp('(^|\\s)(' + x_glossary[k].word + ')([\\s\\.,!?]|$)', 'i');
// tempText = tempText.replace(regExp, '$1{|{'+k+'::$2}|}$3');
tempText = tempText.replace(regExp, '$1<a class="x_glossary" href="#" def="' + x_glossary[k].definition.replace(/\"/g, "'") + '">$2</a>$3');
tempText = tempText.replace(regExp, '$1{|{'+k+'::$2}|}$3');
}
for (var k=0, len=x_glossary.length; k<len; k++) {
var regExp = new RegExp('(^|\\s)(\\{\\|\\{' + k + '::(.*?)\\}\\|\\})([\\s\\.,!?]|$)', 'i');
//tempText = tempText.replace(regExp, '$1<a class="x_glossary" href="#" title="' + x_glossary[k].definition + '">$3</a>$4');
tempText = tempText.replace(regExp, '$1<a class="x_glossary" href="#" def="' + x_glossary[k].definition.replace(/\"/g, "'") + '">$3</a>$4');
}
//for (var k=0, len=x_glossary.length; k<len; k++) {
// var regExp = new RegExp('(^|\\s)(\\{\\|\\{' + k + '::(.*?)\\}\\|\\})([\\s\\.,!?]|$)', 'i');
// tempText = tempText.replace(regExp, '$1<a class="x_glossary" href="#" title="' + x_glossary[k].definition + '">$3</a>$4');
//}
}

// check text for LaTeX tags - if found replace with image
Expand Down
10 changes: 6 additions & 4 deletions modules/xerte/parent_templates/Nottingham/data.xwd
Expand Up @@ -1002,7 +1002,7 @@
<bgColour label="Background Colour" type="ComboBox" options="White,Black,Blue" width="120" optional="true"/>
<initSpin label="Spin" type="CheckBox" optional="true"/>
<xyz2 label="2nd Model File" type="Media" optional="true"/>
<newNodes>
<jmolOption><![CDATA[<jmolOption name="Enter option label here" script="Enter Jmol script here"/>]]></jmolOption>
</newNodes>
Expand Down Expand Up @@ -1116,6 +1116,7 @@
<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 text="here is an option" feedback="feedback for this option" correct="false"/>]]></option>
Expand Down Expand Up @@ -1171,8 +1172,8 @@
<copyShortcutTxt label="Copy Shortcut Text" type="textInput" language="true"/>
<closeBtnTxt label="Close Button Label" type="textInput" language="true"/>

<copypasteinfo label="Copy &amp; paste info" defaultValue="Note: the instruction and question, your response and the example answer, have been copied to the clipboard which you can paste (ctrl + v) into another application such as Open Office, Word or an email to save for future reference." type="TextArea" height="50" optional="true"/>
<copypasteinfo2 label="Copy &amp; paste info (HTML)" defaultValue="Note: Click the 'Select Text' button to highlight the instruction, question, your response and the example answer and then Ctrl + C to copy this text to the clipboard. You can then paste (Ctrl + V) into another application such as Open Office, Word or an email to save for future reference." type="TextArea" height="50" optional="true"/>
<copypasteinfo label="Copy and paste info" defaultValue="Note: the instruction and question, your response and the example answer, have been copied to the clipboard which you can paste (ctrl + v) into another application such as Open Office, Word or an email to save for future reference." type="TextArea" height="50" optional="true"/>
<copypasteinfo2 label="Copy and paste info (HTML)" defaultValue="Note: Click the 'Select Text' button to highlight the instruction, question, your response and the example answer and then Ctrl + C to copy this text to the clipboard. You can then paste (Ctrl + V) into another application such as Open Office, Word or an email to save for future reference." type="TextArea" height="50" optional="true"/>
<label label="Button Label" defaultValue="deprecated - for backward compatibility only" type="TextInput" optional="true"/>
<image label="Image" type="media" optional="true"/>
<tooltip label="Image Tooltip" type="TextInput" optional="true"/>
Expand All @@ -1189,7 +1190,7 @@
<copyBtnTip label="Copy Button Tip" type="textInput" language="true"/>
<copyBtnWidth label="Copy Button Width" type="NumericStepper" min="80" max="250" step="10" width="100" defaultValue="130" language="true"/>
<copyBtnLabel label="Select Button Label" type="textInput" language="true"/>
<copypasteinfo label="Copy &amp; Paste Info" type="TextArea" height="50" language="true"/>
<copypasteinfo label="Copy and Paste Info" type="TextArea" height="50" language="true"/>

<narrationNavigate label="Navigate on narration" type="CheckBox" defaultValue="false" optional="true"/>
<playNarration label="Auto-play narration" type="CheckBox" defaultValue="false" optional="true"/>
Expand Down Expand Up @@ -1351,6 +1352,7 @@
<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="Enter a unique ID so that Connector Pages can find this page" type="TextInput" 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>
<question><![CDATA[<question prompt="Here is a prompt" type="Single Answer" />]]></question>
Expand Down
18 changes: 18 additions & 0 deletions modules/xerte/parent_templates/Nottingham/models_html5/mcq.html
Expand Up @@ -72,6 +72,11 @@
$splitScreen.remove();
} else {
$textHolder.html(x_addLineBreaks(x_currentPageXML.getAttribute("instruction")));

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$textHolder.find("a.x_glossary").contents().unwrap();
}

var textAlign = x_currentPageXML.getAttribute("align");
if (textAlign != "Right") {
if (panelWidth == "Small") {
Expand Down Expand Up @@ -100,6 +105,10 @@
}

$("#question").html(x_addLineBreaks(x_currentPageXML.getAttribute("prompt")));

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$("#question").find("a.x_glossary").contents().unwrap();
}

var $optionHolder = $("#optionHolder");
if (x_currentPageXML.getAttribute("type") == "Multiple Answer") {
Expand Down Expand Up @@ -174,6 +183,10 @@
.attr("for", "option" + i)
.data("option", $thisOption)
.html(thisOption.text);

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$thisOptionTxt.find("a.x_glossary").contents().unwrap();
}
});


Expand Down Expand Up @@ -264,6 +277,11 @@
feedbackLabel = "Feedback";
}
$("#feedback").html("<h3>" + feedbackLabel + "</h3>" + generalFeedback);

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$("#feedback").find("a.x_glossary").contents().unwrap();
}

$(this).hide().show(); // hack to take care of IEs inconsistent handling of clicks

// Queue reparsing of MathJax - fails if no network connection
Expand Down
22 changes: 22 additions & 0 deletions modules/xerte/parent_templates/Nottingham/models_html5/quiz.html
Expand Up @@ -134,6 +134,10 @@
infoString = newString + infoString;
}
$("#qTxt").html(x_addLineBreaks(infoString));

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$("#qTxt").find("a.x_glossary").contents().unwrap();
}

$("#feedback").html("");

Expand Down Expand Up @@ -211,6 +215,10 @@
.attr("for", "option" + i)
.data("option", $thisOption)
.html(x_addLineBreaks(thisOption.text));

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$thisOptionTxt.find("a.x_glossary").contents().unwrap();
}
});
XTEnterInteraction(x_currentPage, this.questions[this.currentQ], 'multiplechoice', $thisQ.getAttribute("prompt"), correctOptions.join(';'), correctAnswer.join(';'), correctFeedback.join(';'));

Expand All @@ -233,6 +241,11 @@
}

$("#qTxt").html(fbTxt);

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$("#qTxt").find("a.x_glossary").contents().unwrap();
}

$("#optionHolder, #nextBtn, #checkBtn").hide();
if (XTGetMode() != "normal")
{
Expand Down Expand Up @@ -272,6 +285,11 @@
$splitScreen.remove();
} else {
$textHolder.html('<p>' + x_addLineBreaks(x_currentPageXML.getAttribute("instructions")) + '</p>');

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$textHolder.find("a.x_glossary").contents().unwrap();
}

var textAlign = x_currentPageXML.getAttribute("align");
if (textAlign != "right" || (x_currentPageXML.getAttribute("video") != undefined && x_currentPageXML.getAttribute("video") != "")) {
if (panelWidth == "Small") {
Expand Down Expand Up @@ -455,6 +473,10 @@
if (quiz.showfeedback)
{
$("#feedback").html(answerFeedback);

if (x_currentPageXML.getAttribute("disableGlossary") == "true") {
$("#feedback").find("a.x_glossary").contents().unwrap();
}

$("#nextBtn").removeAttr("disabled");
$(this).attr("disabled", "disabled");
Expand Down
Expand Up @@ -1116,6 +1116,7 @@
<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 text="here is an option" feedback="feedback for this option" correct="false"/>]]></option>
Expand Down Expand Up @@ -1351,6 +1352,7 @@
<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="Enter a unique ID so that Connector Pages can find this page" type="TextInput" 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>
<question><![CDATA[<question prompt="Here is a prompt" type="Single Answer" />]]></question>
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" checkBtnTip="Check Answer" checkBtnWidth="100"/>]]></mcq> </newNodes> </pageWizard> <!-- MCQ PAGE============================== --> <mcq menu="Interactivity" menuItem="Multiple Choice Question" hint="Poses an multiple answer question with multiple 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"/> <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" divider="true" language="true" /> <singleRight label="Single Answer Correct" type="textInput" language="true" /> <singleWrong label="Single Answer Wrong" type="textInput" language="true" /> <multiRight label="Multi Answer Correct" type="textInput" language="true" /> <multiWrong label="Multi Answer Wrong" type="textInput" language="true" /> <checkBtnTxt label="Check Button Label" type="textInput" language="true" /> <checkBtnTip label="Check Button Tip" type="textInput" language="true" /> <checkBtnWidth label="Check Button Width" type="NumericStepper" min="100" max="250" step="10" width="100" defaultValue="100" language="true" /> <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" /> <newNodes> <option><![CDATA[<option text="here is an option" feedback="feedback for this option" correct="false"/>]]></option> </newNodes> </mcq> <option menuItem="Option" icon="icBullet"> <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" checkBtnTip="Check Answer" checkBtnWidth="100"/>]]></mcq> </newNodes> </pageWizard> <!-- MCQ PAGE============================== --> <mcq menu="Interactivity" menuItem="Multiple Choice Question" hint="Poses an multiple answer question with multiple 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"/> <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" divider="true" language="true" /> <singleRight label="Single Answer Correct" type="textInput" language="true" /> <singleWrong label="Single Answer Wrong" type="textInput" language="true" /> <multiRight label="Multi Answer Correct" type="textInput" language="true" /> <multiWrong label="Multi Answer Wrong" type="textInput" language="true" /> <checkBtnTxt label="Check Button Label" type="textInput" language="true" /> <checkBtnTip label="Check Button Tip" type="textInput" language="true" /> <checkBtnWidth label="Check Button Width" type="NumericStepper" min="100" max="250" step="10" width="100" defaultValue="100" language="true" /> <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 text="here is an option" feedback="feedback for this option" correct="false"/>]]></option> </newNodes> </mcq> <option menuItem="Option" icon="icBullet"> <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>
Expand Down
1 change: 1 addition & 0 deletions src/Nottingham/wizards/en-GB/quiz.xwd
Expand Up @@ -52,6 +52,7 @@
<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="Enter a unique ID so that Connector Pages can find this page" type="TextInput" 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>
<question><![CDATA[<question prompt="Here is a prompt" type="Single Answer" />]]></question>
Expand Down

0 comments on commit 04340a6

Please sign in to comment.