Skip to content

Commit

Permalink
Multiple attempts Text correction
Browse files Browse the repository at this point in the history
  • Loading branch information
mussaf committed Jun 2, 2019
1 parent fe16079 commit c6eb65f
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 27 deletions.
Expand Up @@ -15,4 +15,9 @@

#question{
padding-bottom: 10px;
}
}

#attempts{
margin-top: 5%;
padding-bottom: 0;
}
Expand Up @@ -75,6 +75,8 @@
this.init = function() {
var hadExited = false;



this.weighting = 1.0;
if(x_currentPageXML.getAttribute("trackingWeight") != null){
this.weighting = x_currentPageXML.getAttribute("trackingWeight");
Expand Down Expand Up @@ -120,6 +122,9 @@
}
}

var $attempts = $("#attempts");
var amountofTries = x_currentPageXML.getAttribute("amountOfTries");

var $pageContents = $("#pageContents");

var $textHolder = $("#textHolder");
Expand Down Expand Up @@ -161,51 +166,105 @@

var answerLabel = x_currentPageXML.getAttribute("answerLabel");

var attemptLabel = x_currentPageXML.getAttribute("attemptLabel");
if( x_currentPageXML.getAttribute("attemptLabel") == null){
attemptLabel = "Attempt";
}

$attempts.html(attemptLabel+ ": "+ amountofTries);

// pageScore
var correctIcon = $("<div>").addClass("fa").addClass("fa-fw").addClass("fa-x-tick");

var incorrectICon = $("<div>").addClass("fa").addClass("fa-fw").addClass("fa-x-cross");
// if (checkBtnTxt == undefined) {
// checkBtnTxt = "Check";
// }
var attempt = 1;
$("#checkButton")
.button({
label: checkButtonTxt
})
.click(function () {
debugger;
var tries = parseInt(x_currentPageXML.getAttribute("amountOfTries"));

$correctOrNot.html("");

amountofTries -= 1;

if(amountofTries > 0) {
$attempts.html(attemptLabel+ ": "+ amountofTries);
}else{
$attempts.html("");
}

$(checkButton).button("disable");

XTEnterInteraction(x_currentPage, 0, "text", x_GetTrackingTextFromHTML(x_currentPageXML.getAttribute("introduction"), ""), "",answer, FurtherClarification);


//get value of text area
var input = $(".answer textarea").val();
textCorrection.input = input;
$correctOrNot.html("");
//get value of text area
if(attempt < tries) {
$(checkButton).button("enable");

// decide if it is correct or not
$correctOrNot.append("<h3>"+resultLabel+"</h3>");
if (input === "") {
$correctOrNot.append(incompleet);
$correctOrNot.append(incorrectICon)
}

if(input !== "") {
if (input === answer) {
$correctOrNot.append(correct);
$correctOrNot.append(correctIcon)
}else{
$correctOrNot.append(incorrect);
textCorrection.input = input;

$correctOrNot.append("<h3>"+resultLabel+"</h3>");
if (input === "") {
$correctOrNot.append(incompleet);
$correctOrNot.append(incorrectICon)
}

if (!hadExited) {
textCorrection.exitTrackTextCorrection();
hasExited = true;
if(input !== "") {
if (input === answer) {
$correctOrNot.append(correct);
$correctOrNot.append(correctIcon)
}else{
$correctOrNot.append(incorrect);
$correctOrNot.append(incorrectICon)
}

if (!hadExited) {
textCorrection.exitTrackTextCorrection();
hasExited = true;
}
textCorrection.hasExited = hadExited;

}else{
$(checkButton).button("disable");
}
textCorrection.hasExited = hadExited;
// show feedback
}else{
$(checkButton).button("enable");
}

attempt ++;

if(input === answer|| attempt > tries){
$(checkButton).button("disable");
$correctOrNot.html("");
$attempts.html("");
$correctOrNot.append("<h3>"+resultLabel+"</h3>");
if (input === "") {
$correctOrNot.append(incompleet);
$correctOrNot.append(incorrectICon)
}

if(input !== "") {
if (input === answer) {
$correctOrNot.append(correct);
$correctOrNot.append(correctIcon)
} else {
$correctOrNot.append(incorrect);
$correctOrNot.append(incorrectICon)
}

if (!hadExited) {
textCorrection.exitTrackTextCorrection();
hasExited = true;
}
}
if (x_currentPageXML.getAttribute("FurtherClarification") !== null) {
$FurtherClarification.append("<h3>" + FurtherClarificationLabel + "</h3>");
$FurtherClarification.append(FurtherClarification);
Expand All @@ -216,8 +275,7 @@
$answer.append("<h3>" + answerLabel + "</h3>");
$answer.append(x_currentPageXML.getAttribute("answer"))
}
}else{
$(checkButton).button("enable");

}

});
Expand Down Expand Up @@ -245,6 +303,7 @@
<div class="answer"><textarea rows="4" cols="50"></textarea></div>
</div>
<button id="checkButton"></button>
<div id="attempts"></div>
<div id="correctOrNot"></div>
<div id="FurtherClarification"></div>
<div id ="answer"></div>
Expand Down
Expand Up @@ -301,6 +301,11 @@
}
}

var attemptLabel = x_currentPageXML.getAttribute("attemptLabel");
if( x_currentPageXML.getAttribute("attemptLabel") == null){
attemptLabel = "Attempt";
}

var instruction = x_currentPageXML.getAttribute("instruction");
$textHolder.html(instruction);

Expand Down
Expand Up @@ -172,7 +172,7 @@
PersonalAvgLabel = "Avg. of your attempts"
PersonalLastLabel = "Your last attempt"
AvgLabel = "Avg. of all attempts"
></showGraph>]]></showGraph><slideshow><![CDATA[<slideshow name="Enter Page Title" text="Enter text for the page here" panelWidth="Medium" nextBtnTip="Next" priorBtnTip="Previous" slideCount="Slide {i} of {n}"/>]]></slideshow><stopTracking><![CDATA[<stopTracking name="Enter Page Title" textIntro="Instruction" buttonLbl="Stop and finish tracking of this session" textAfter="You can now close the window">Enter text for the page here</stopTracking>]]></stopTracking><summary><![CDATA[<summary name="Enter Page Title" summaryHeader="Summary" summary="Summarise the key points" nextstepsHeader="Next Steps" nextsteps="Suggest how the knowledge can be applied and any useful next steps"/>]]></summary><tabNav><![CDATA[<tabNav name="Enter Page Title" text="Enter text for the page here" panelWidth="Medium"/>]]></tabNav><tabNavExtra><![CDATA[<tabNavExtra name="Enter Page Title" panelWidth="Large"/>]]></tabNavExtra><table><![CDATA[<table name="Enter Page Title" text="Enter text for the page here" align="left"><tableData name="Table Name" data="data|data" size="medium" borders="simple" header="header" shadeHeader="true" shade="true"/></table>]]></table><text><![CDATA[<text name="Enter Page Title">Enter text for the page here</text>]]></text><textCorrection><![CDATA[<textCorrection name="Enter Page Title" align="Left" introduction="Enter the introduction for the page here" FurtherClarification="Enter here further clarification" wrongText="Enter the wrong text here" answer="Enter the correct text here" feedback="Enter the feedback here" panelWidth="Medium" checkBtn="Check" textRight="You passed this test" textWrong="Your answer is wrong" resultLabel="Result" FurtherClarificationLabel="Further Clarification" answerLabel="Answer" textIncomplete="You have not filled the question. Please try again."/>]]></textCorrection><textDrawing><![CDATA[<textDrawing name="Enter Page Title" desc="Enter a description" align="left" interactivity="off"> </textDrawing>]]></textDrawing><textGraphics><![CDATA[<textGraphics name="Enter Page Title" align="Left" imagesize="auto" url="Select an Image" tip="Enter a Description for Accessibility" transcriptbuttonlabel="Transcript">Enter text for the page here</textGraphics>]]></textGraphics><textMatch><![CDATA[<textMatch name="Enter Page Title" text="Provide Instructions here" maxAttempts="3" correctMessage="Correct answers are shown" submitBtnTxt="Submit" feedback="Enter feedback here" allWrong="You have not placed any labels correctly. Try again." allWrongTracking="You have not placed any labels correctly." score="You have scored {i} out of {n}. Try again." scoreTracking="You have scored {i} out of {n}." incomplete="Complete the exercise." />]]></textMatch><textSWF><![CDATA[<textSWF name="Enter Page Title" align="Left" url="Select a SWF File" tip="Enter a Description for Accessibility" >Enter text for the page here</textSWF>]]></textSWF><textVideo><![CDATA[<textVideo name="Enter Page Title" align="Left" url="Select a Video" tip="Enter a Description for Accessibility" transcriptTabTxt="Transcript" >Enter text for the page here</textVideo>]]></textVideo><thumbnailViewer><![CDATA[<thumbnailViewer name="Enter Page Title" text="Enter text for the page" nextBtnTip="Next" priorBtnTip="Previous"/>]]></thumbnailViewer><timeline><![CDATA[<timeline name="Enter Page Title" text="Enter text for the page here" interactivity="Timeline" feedback="Enter feedback here" checkBtnTxt="Check Answers" allWrong="You have not placed any labels correctly. Try again." allWrongTracking="You have not placed any labels correctly." score="You have scored {i} out of {n}. Try again." scoreTracking="You have scored {i} out of {n}." incomplete="Complete the exercise." />]]></timeline><title><![CDATA[<title name="Enter Page Title" size="30">Enter title here</title>]]></title><topXQ><![CDATA[<tXQ name="Enter Page Title" instruction = "Enter Your Instruction" amountOfTries="1" answers="Show everything" SuccessRate="60" prompt= "Enter Your Question" align = "Left" panelWidth = "Medium" numberAnswers = "Enter amount of fields" feedbackLabel="Feedback" attemptLabel="Attempts" correctAnswersLabel="Correct answers" passed="You passed the question!" failed="You did not pass the question"
></showGraph>]]></showGraph><slideshow><![CDATA[<slideshow name="Enter Page Title" text="Enter text for the page here" panelWidth="Medium" nextBtnTip="Next" priorBtnTip="Previous" slideCount="Slide {i} of {n}"/>]]></slideshow><stopTracking><![CDATA[<stopTracking name="Enter Page Title" textIntro="Instruction" buttonLbl="Stop and finish tracking of this session" textAfter="You can now close the window">Enter text for the page here</stopTracking>]]></stopTracking><summary><![CDATA[<summary name="Enter Page Title" summaryHeader="Summary" summary="Summarise the key points" nextstepsHeader="Next Steps" nextsteps="Suggest how the knowledge can be applied and any useful next steps"/>]]></summary><tabNav><![CDATA[<tabNav name="Enter Page Title" text="Enter text for the page here" panelWidth="Medium"/>]]></tabNav><tabNavExtra><![CDATA[<tabNavExtra name="Enter Page Title" panelWidth="Large"/>]]></tabNavExtra><table><![CDATA[<table name="Enter Page Title" text="Enter text for the page here" align="left"><tableData name="Table Name" data="data|data" size="medium" borders="simple" header="header" shadeHeader="true" shade="true"/></table>]]></table><text><![CDATA[<text name="Enter Page Title">Enter text for the page here</text>]]></text><textCorrection><![CDATA[<textCorrection name="Enter Page Title" amountOfTries="1" align="Left" introduction="Enter the introduction for the page here" FurtherClarification="Enter here further clarification" wrongText="Enter the wrong text here" answer="Enter the correct text here" feedback="Enter the feedback here" panelWidth="Medium" checkBtn="Check" textRight="You passed this test" textWrong="Your answer is wrong" resultLabel="Result" FurtherClarificationLabel="Further Clarification" answerLabel="Answer" attemptLabel="Attempts" textIncomplete="You have not filled the question. Please try again."/>]]></textCorrection><textDrawing><![CDATA[<textDrawing name="Enter Page Title" desc="Enter a description" align="left" interactivity="off"> </textDrawing>]]></textDrawing><textGraphics><![CDATA[<textGraphics name="Enter Page Title" align="Left" imagesize="auto" url="Select an Image" tip="Enter a Description for Accessibility" transcriptbuttonlabel="Transcript">Enter text for the page here</textGraphics>]]></textGraphics><textMatch><![CDATA[<textMatch name="Enter Page Title" text="Provide Instructions here" maxAttempts="3" correctMessage="Correct answers are shown" submitBtnTxt="Submit" feedback="Enter feedback here" allWrong="You have not placed any labels correctly. Try again." allWrongTracking="You have not placed any labels correctly." score="You have scored {i} out of {n}. Try again." scoreTracking="You have scored {i} out of {n}." incomplete="Complete the exercise." />]]></textMatch><textSWF><![CDATA[<textSWF name="Enter Page Title" align="Left" url="Select a SWF File" tip="Enter a Description for Accessibility" >Enter text for the page here</textSWF>]]></textSWF><textVideo><![CDATA[<textVideo name="Enter Page Title" align="Left" url="Select a Video" tip="Enter a Description for Accessibility" transcriptTabTxt="Transcript" >Enter text for the page here</textVideo>]]></textVideo><thumbnailViewer><![CDATA[<thumbnailViewer name="Enter Page Title" text="Enter text for the page" nextBtnTip="Next" priorBtnTip="Previous"/>]]></thumbnailViewer><timeline><![CDATA[<timeline name="Enter Page Title" text="Enter text for the page here" interactivity="Timeline" feedback="Enter feedback here" checkBtnTxt="Check Answers" allWrong="You have not placed any labels correctly. Try again." allWrongTracking="You have not placed any labels correctly." score="You have scored {i} out of {n}. Try again." scoreTracking="You have scored {i} out of {n}." incomplete="Complete the exercise." />]]></timeline><title><![CDATA[<title name="Enter Page Title" size="30">Enter title here</title>]]></title><topXQ><![CDATA[<tXQ name="Enter Page Title" instruction = "Enter Your Instruction" amountOfTries="1" answers="Show everything" SuccessRate="60" prompt= "Enter Your Question" align = "Left" panelWidth = "Medium" numberAnswers = "Enter amount of fields" feedbackLabel="Feedback" attemptLabel="Attempts" correctAnswersLabel="Correct answers" passed="You passed the question!" failed="You did not pass the question"
checkBtnTxt="Check"/>]]></topXQ><transcriptReader><![CDATA[<transcriptReader name="Enter Page Title" sound="Select a Sound File" text="Enter text for the page here" panelWidth="Medium"/>]]></transcriptReader><videoSynch><![CDATA[<videoSynch name="Enter Page Title" url="Select a Video" text="Enter text for the page here" pause="True" erase="True"/>]]></videoSynch><wiki><![CDATA[<wiki name="Enter Page Title" text="Enter Page text" url="Enter Article URL" align="Left"/>]]></wiki><wordsearch><![CDATA[<wordsearch name="Enter Page Title" text="Enter Page text" words="Enter words here, placing each on a new line" solveBtnTxt="Solve Puzzle" retryBtnTxt="Restart Puzzle"
/>]]></wordsearch><xerteModel><![CDATA[<xerteModel name="Enter Page Title" modelFile="Select a Model" errorTxt="You can not view this type of content in the HTML viewer." />]]></xerteModel><youtube><![CDATA[<youtube name="Enter Page Title" text="Enter text for the page here" >Enter Embed Code Here</youtube>]]></youtube><youtuberss><![CDATA[<youtuberss name="Enter Page Title" text="Enter text for the page here" url="Enter Search Term" results="20" panelWidth="Medium"
resultsTxt="YouTube results for term"/>]]></youtuberss></newNodes>
Expand Down Expand Up @@ -4289,13 +4289,15 @@
<introduction label="Introductory Text" type="TextArea" height="100"/>
<wrongText label="Incorrect Text" type="TextArea" height="150"/>
<answer label="Correct Text" type="TextArea" height="150"/>
<amountOfTries label="Tries" type="TextInput" defaultValue="1"/>
<FurtherClarification label="Further Clarification" type="TextArea" height="50" optional="true" devaultValue="true"/>
<panelWidth label="Panel Width" options="Small,Medium,Large,Full" type="ComboBox" data="Small,Medium,Large,Full" defaultValue="Medium" width="100"/>
<showAnswers label="Show Answers" defaultValue="true" type="CheckBox" optional="true"/>



<checkBtn label="Check Button Text" type="TextInput" wysiwyg="true" language="true"/>
<attemptLabel label="Attempt Label" type="TextInput" wysiwyg="false" language="true"/>
<textRight label="Passed the test" type="TextInput" wysiwyg="true" language="true"/>
<textWrong label="Failed the test" type="TextInput" wysiwyg="true" language="true"/>
<textIncomplete label="Text Incomplete" type="TextInput" wysiwyg="true" language="true"/>
Expand Down

0 comments on commit c6eb65f

Please sign in to comment.