Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Add unit test to confirm that question groups keep questions in page …
Browse files Browse the repository at this point in the history
…ordering.

	Change on 2013/08/14 by jorr <jorr@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=50876694
  • Loading branch information
psimakov committed Aug 15, 2013
1 parent bb93baf commit c9b011e
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</div>
</div>
</li>
<li>
<li class="qt-question-item">
<div>
<div id="qg-0-sa-0" class="qt-sa-question qt-embedded">
<div class="qt-question">Enter 'falafel'</div>
Expand All @@ -106,3 +106,77 @@
<div class="qt-feedback qt-hidden"></div>
</div>

<!--
A question group consisting of a multiple choice, followed by a short answer,
followed by a multiple choice.
-->
<div id="qg-1" class="qt-question-group">
<div class="qt-introduction">Introduction</div>
<ol class="qt-question-list">
<li class="qt-question-item">
<div>
<div id="qg-1-mc-0" class="qt-mc-question qt-embedded">
<div class="qt-question">Pick 'a'</div>
<div class="qt-choices">
<div>
<input type="radio" name="qg-1-mc-0" id="qg-1-mc-0-0"/>
<label for="qg-1-mc-0-0">a</label>
</div>
<div>
<input type="radio" name="qg-1-mc-0" id="qg-1-mc-0-1"/>
<label for="qg-1-mc-0-1">b</label>
</div>
</div>
<div class="qt-check-answer">
<button class="gcb-button">Check Answer</button>
</div>
<div class="qt-feedback qt-hidden"></div>
</div>
</div>
</li>
<li class="qt-question-item">
<div>
<div id="qg-1-sa-0" class="qt-sa-question qt-embedded">
<div class="qt-question">Enter 'falafel'</div>
<div class="qt-response">
<textarea rows="3" cols="30"></textarea>
</div>
<div class="qt-check-answer">
<button class="gcb-button qt-check-answer-button">Check Answer</button>
<button class="gcb-button qt-skip-and-show-answer-button">
Skip and Show Answer
</button>
</div>
<div class="qt-feedback qt-hidden">
</div>
</div>
</div>
</li>
<li class="qt-question-item">
<div>
<div id="qg-1-mc-1" class="qt-mc-question qt-embedded">
<div class="qt-question">Pick 'a'</div>
<div class="qt-choices">
<div>
<input type="radio" name="qg-1-mc-1" id="qg-1-mc-1-0"/>
<label for="qg-1-mc-1-0">a</label>
</div>
<div>
<input type="radio" name="qg-1-mc-1" id="qg-1-mc-1-1"/>
<label for="qg-1-mc-1-1">b</label>
</div>
</div>
<div class="qt-check-answer">
<button class="gcb-button">Check Answer</button>
</div>
<div class="qt-feedback qt-hidden"></div>
</div>
</div>
</li>
</ol>
<div class="qt-check-answer">
<button class="gcb-button qt-check-answer-button">Check Answer</button>
</div>
<div class="qt-feedback qt-hidden"></div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,41 @@ describe('assessment tags', function() {
qg.makeReadOnly();
expectDisabled(true, true, true);
});
it('loads the questions in the order they appear on the page', function () {
var el = $('#qg-1');
var questionData0 = {choices: [
{score: '1', feedback: 'yes'},
{score: '0', feedback: 'no'}]};
var questionData1 = {
hint: 'it\s \'falafel\'',
graders: [{
matcher: 'case_insensitive',
response: 'falafel',
score: '1.0',
feedback: 'good'
}]
};
var questionData2 = {choices: [
{score: '1', feedback: 'yes'},
{score: '0', feedback: 'no'}]};
var questionData = {
'qg-1': {
'qg-1-mc-0': {'weight': '10'},
'qg-1-sa-0': {'weight': '15'},
'qg-1-mc-1': {'weight': '20'},
},
'qg-1-mc-0': questionData0,
'qg-1-sa-0': questionData1,
'qg-1-mc-1': questionData2
};
var qg = new QuestionGroup(el, questionData, MESSAGES);
expect(qg.questions[0] instanceof McQuestion).toBe(true);
expect(qg.questions[1] instanceof SaQuestion).toBe(true);
expect(qg.questions[2] instanceof McQuestion).toBe(true);
expect(qg.questions[0].data).toBe(questionData0);
expect(qg.questions[1].data).toBe(questionData1);
expect(qg.questions[2].data).toBe(questionData2);
});
});

function initTwoQuestions() {
Expand Down

0 comments on commit c9b011e

Please sign in to comment.