2 var CorrectResponse = '[strGuessCorrect]';
\r
3 var IncorrectResponse = '[strGuessIncorrect]';
\r
4 var YourScoreIs = '[strYourScoreIs]';
\r
5 var DivWidth = 600; //default value
\r
6 var FeedbackWidth = 200; //default
\r
7 var ExBGColor = '[strExBGColor]';
\r
8 var PageBGColor = '[strPageBGColor]';
\r
9 var TextColor = '[strTextColor]';
\r
10 var TitleColor = '[strTitleColor]';
\r
13 var TimeOver = false;
\r
15 var ShuffleQs = [boolShuffleQs];
\r
16 var QsToShow = [QsToShow];
\r
18 var DragWidth = 200;
\r
19 var LeftColPos = 100;
\r
20 var RightColPos = 500;
\r
22 var Finished = false;
\r
24 //Fixed and draggable card arrays
\r
28 function onEndDrag(){
\r
29 //Is it dropped on any of the fixed cards?
\r
31 var DropTarget = DroppedOnFixed(CurrDrag);
\r
32 if (DropTarget > -1){
\r
33 //If so, send home any card that is currently docked there
\r
34 for (var i=0; i<DC.length; i++){
\r
35 if (DC[i].tag == DropTarget+1){
\r
41 //Dock the dropped card
\r
42 DC[CurrDrag].DockToR(FC[DropTarget]);
\r
43 D[CurrDrag][2] = F[DropTarget][1];
\r
44 DC[CurrDrag].tag = DropTarget+1;
\r
48 if (Docked == false){
\r
49 DC[CurrDrag].GoHome();
\r
50 DC[CurrDrag].tag = 0;
\r
55 function DroppedOnFixed(DNum){
\r
57 var OverlapArea = 0;
\r
59 for (var i=0; i<FC.length; i++){
\r
60 Temp = DC[DNum].Overlap(FC[i]);
\r
61 if (Temp > OverlapArea){
\r
77 PreloadImages([PreloadImageList]);
\r
78 [/inclPreloadImages]
\r
80 //Calculate page dimensions and positions
\r
82 DivWidth = Math.floor((pg.W*4)/5);
\r
83 DragWidth = Math.floor((DivWidth*3)/10);
\r
84 LeftColPos = Math.floor(pg.W/15);
\r
85 RightColPos = pg.W - (DragWidth + LeftColPos);
\r
86 DragTop = parseInt(document.getElementById('CheckButtonDiv').offsetHeight) + parseInt(document.getElementById('CheckButtonDiv').offsetTop) + 10;
\r
92 //Reduce array if required
\r
93 if (QsToShow < F.length){
\r
97 //Shuffle the left items if required
\r
98 if (ShuffleQs == true){
\r
102 //Shuffle the items on the right
\r
105 var CurrTop = DragTop;
\r
109 var CardContent = '';
\r
110 for (var i=0; i<F.length; i++){
\r
111 CardContent = F[i][0];
\r
112 FC[i] = new Card('F' + i, 10);
\r
113 FC[i].elm.innerHTML = CardContent;
\r
114 if (FC[i].GetW() > Widest){
\r
115 Widest = FC[i].GetW();
\r
119 if (Widest > DragWidth){Widest = DragWidth;}
\r
123 DragWidth = Math.floor((DivWidth-Widest)/2) - 24;
\r
124 RightColPos = DivWidth + LeftColPos - (DragWidth + 14);
\r
126 var WidestRight = 0;
\r
128 for (i=0; i<D.length; i++){
\r
129 DC[i] = new Card('D' + i, 10);
\r
130 CardContent = D[i][0];
\r
131 // if (CardContent.indexOf('<img ') > -1){CardContent += '<br clear="all" />';} //used to be required for Navigator rendering bug with images
\r
132 DC[i].elm.innerHTML = CardContent;
\r
133 if (DC[i].GetW() > DragWidth){DC[i].SetW(DragWidth);}
\r
134 DC[i].css.cursor = 'move';
\r
135 DC[i].css.backgroundColor = '[strExBGColor]';
\r
136 DC[i].css.color = '[strTextColor]';
\r
137 TempInt = DC[i].GetH();
\r
138 if (TempInt > Highest){Highest = TempInt;}
\r
139 TempInt = DC[i].GetW();
\r
140 if (TempInt > WidestRight){WidestRight = TempInt;}
\r
143 var HeightToSet = Highest;
\r
144 if (C.gecko||C.ie5mac){HeightToSet -= 12;}
\r
145 var WidthToSet = WidestRight;
\r
146 if (C.gecko||C.ie5mac){WidthToSet -= 12;}
\r
148 for (i=0; i<D.length; i++){
\r
149 DC[i].SetT(CurrTop);
\r
150 DC[i].SetL(RightColPos);
\r
151 if (DC[i].GetH() < Highest){
\r
152 DC[i].SetH(HeightToSet);
\r
154 if (DC[i].GetW() < WidestRight){
\r
155 DC[i].SetW(WidthToSet);
\r
159 CurrTop = CurrTop + DC[i].GetH() + 5;
\r
164 for (var i=0; i<F.length; i++){
\r
165 FC[i].SetW(Widest);
\r
166 if (FC[i].GetH() < Highest){
\r
167 FC[i].SetH(HeightToSet);
\r
169 FC[i].SetT(CurrTop);
\r
170 FC[i].SetL(LeftColPos);
\r
172 TempInt = FC[i].GetH();
\r
173 CurrTop = CurrTop + TempInt + 5;
\r
177 //Slide any elements that should be in position over
\r
178 for (i=0; i<D.length; i++){
\r
180 DC[i].tag = D[i][1];
\r
183 //Find the right target element
\r
185 for (var j=0; j<F.length; j++){
\r
186 if (F[j][1] == D[i][1]){
\r
190 var TargetLeft = FC[TargItem].GetR() + 5;
\r
191 var TargetTop = FC[TargItem].GetT();
\r
193 if (TargetTop < DC[i].GetT()){
\r
197 if (TargetTop > DC[i].GetT()){
\r
201 Slide(i, TargetLeft, TargetTop, TopChange);
\r
202 D[i][2] = F[TargItem][1];
\r
203 DC[i].tag = TargItem+1;
\r
213 function Slide(MoverNum, TargL, TargT, TopChange){
\r
214 var TempInt = DC[MoverNum].GetL();
\r
215 if (TempInt > TargL){
\r
216 DC[MoverNum].SetL(TempInt - 5);
\r
218 TempInt = DC[MoverNum].GetT();
\r
219 if (TempInt != TargT){
\r
220 DC[MoverNum].SetT(TempInt + TopChange);
\r
222 if ((DC[MoverNum].GetL() > TargL)||(DC[MoverNum].GetT() != TargT)){
\r
223 setTimeout('Slide('+MoverNum+','+TargL+','+TargT+','+TopChange+')', 1);
\r
226 DC[MoverNum].SetL(TargL);
\r
237 function ReduceItems2(){
\r
240 while (F.length > QsToShow){
\r
241 ItemToDump = Math.floor(F.length*Math.random());
\r
242 for (j=ItemToDump; j<(F.length-1); j++){
\r
245 for (j=ItemToDump; j<(D.length-1); j++){
\r
248 F.length = F.length-1;
\r
249 D.length = D.length-1;
\r
253 function TimerStartUp(){
\r
254 setTimeout('StartUp()', 300);
\r
257 function CheckAnswers(){
\r
258 if (Locked == true){return;}
\r
259 //Set the default score and response
\r
260 var TotalCorrect = 0;
\r
264 //for each fixed, check to see if the tag value for the draggable is the same as the fixed
\r
266 for (i=0; i<D.length; i++){
\r
267 if ((D[i][2] == D[i][1])&&(D[i][2] > 0)){
\r
271 //Change made for version 6.0.3.41: don't send wrong items home,
\r
272 //show them in a more conspicuous way.
\r
274 DC[i].SetL(DC[i].GetL() + 10);
\r
279 Score = Math.floor((100*(TotalCorrect-Penalties))/F.length);
\r
281 var AllDone = false;
\r
283 if (TotalCorrect == F.length) {
\r
287 if (AllDone == true){
\r
288 Feedback = YourScoreIs + ' ' + Score + '%.';
\r
289 ShowMessage(Feedback + '<br />' + CorrectResponse);
\r
292 Feedback = IncorrectResponse + '<br />' + YourScoreIs + ' ' + Score + '%.';
\r
293 ShowMessage(Feedback);
\r
294 Penalties++; // Penalty for inaccurate check
\r
296 //If the exercise is over, deal with that
\r
297 if ((AllDone == true)||(TimeOver == true)){
\r
299 setTimeout('SendResults(' + Score + ')', 50);
\r
302 window.clearInterval(Interval);
\r
307 setTimeout('Finish()', SubmissionTimeout);
\r
308 WriteToInstructions(Feedback);
\r
313 function TimesUp() {
\r
314 document.getElementById('Timer').innerHTML = '[strTimesUp]';
\r
315 [inclPreloadImages]
\r
317 [/inclPreloadImages]
\r