forked from GitHub/gf-core
Translation Quiz: fix for race condition on page load
This commit is contained in:
@@ -47,6 +47,7 @@ function Minibar(server,opts,target) {
|
|||||||
this.surface=div_id("surface");
|
this.surface=div_id("surface");
|
||||||
this.extra=div_id("extra");
|
this.extra=div_id("extra");
|
||||||
this.menubar=div_id("menubar");
|
this.menubar=div_id("menubar");
|
||||||
|
this.quizbar=div_id("quizbar");
|
||||||
this.words=div_id("words");
|
this.words=div_id("words");
|
||||||
this.translations=div_id("translations");
|
this.translations=div_id("translations");
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ function Minibar(server,opts,target) {
|
|||||||
|
|
||||||
//modified for quiz
|
//modified for quiz
|
||||||
with(this) {
|
with(this) {
|
||||||
appendChildren(minibar,[menubar]);
|
appendChildren(minibar,[menubar, quizbar]);
|
||||||
appendChildren(minibar_contin,[surface,words]);
|
appendChildren(minibar_contin,[surface,words]);
|
||||||
append_extra_buttons(extra,options);
|
append_extra_buttons(extra,options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ function pre_start()
|
|||||||
var quiz_mode=empty_id("select","quiz_mode");
|
var quiz_mode=empty_id("select","quiz_mode");
|
||||||
|
|
||||||
//adds the "Quiz Mode" and "Restart Quiz" and "End Quiz" and "Start Quiz"
|
//adds the "Quiz Mode" and "Restart Quiz" and "End Quiz" and "Start Quiz"
|
||||||
appendChildren(minibar.menubar,
|
appendChildren(minibar.quizbar,
|
||||||
[empty("br"),
|
[text(" Quiz Mode: "), quiz_mode,
|
||||||
text(" Quiz Mode: "), quiz_mode,
|
|
||||||
button("Restart Quiz","restart_quiz()","R"),
|
button("Restart Quiz","restart_quiz()","R"),
|
||||||
button("End Quiz","end_quiz(true)","E"),
|
button("End Quiz","end_quiz(true)","E"),
|
||||||
button("Start Quiz","start_quiz()","S")]);
|
button("Start Quiz","start_quiz()","S")]);
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
<body onLoad="pre_start()">
|
|
||||||
|
|
||||||
<div id = "info" >
|
<div id = "info" >
|
||||||
<a href="javascript:popUp('quiz_about.html', 'about')">About GF Translation Quiz</a>
|
<a href="javascript:popUp('quiz_about.html', 'about')">About GF Translation Quiz</a>
|
||||||
@@ -151,7 +150,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var minibar=new Minibar(server,minibar_options,"minibar1");
|
var minibar=new Minibar(server,minibar_options,"minibar1");
|
||||||
|
|
||||||
|
pre_start();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ function start_quiz()
|
|||||||
answer_lang= minibar.to_menu.value;
|
answer_lang= minibar.to_menu.value;
|
||||||
|
|
||||||
//removes the start button
|
//removes the start button
|
||||||
minibar.menubar.removeChild(minibar.menubar.lastChild);
|
minibar.quizbar.removeChild(minibar.quizbar.lastChild);
|
||||||
|
|
||||||
set_mode();
|
set_mode();
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ function restart_quiz()
|
|||||||
reset_mode();
|
reset_mode();
|
||||||
|
|
||||||
//add the start button
|
//add the start button
|
||||||
appendChildren(minibar.menubar,[ button("Start Quiz","start_quiz()","S")]);
|
appendChildren(minibar.quizbar,[ button("Start Quiz","start_quiz()","S")]);
|
||||||
|
|
||||||
//removes the History button
|
//removes the History button
|
||||||
var history_bar=element("history_bar");
|
var history_bar=element("history_bar");
|
||||||
@@ -380,9 +380,10 @@ function parse_answer(right_answer)
|
|||||||
server.parse(question_lang,right_answer[0].text, parse_answer2);
|
server.parse(question_lang,right_answer[0].text, parse_answer2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var trees_to_go;
|
||||||
function parse_answer2(parsed_answer)
|
function parse_answer2(parsed_answer)
|
||||||
{
|
{
|
||||||
parsed_trees = parsed_answer[0].trees.length;
|
trees_to_go = parsed_trees = parsed_answer[0].trees.length;
|
||||||
var j =0;
|
var j =0;
|
||||||
for (j= 0; j < parsed_trees ; j++)
|
for (j= 0; j < parsed_trees ; j++)
|
||||||
{
|
{
|
||||||
@@ -400,7 +401,8 @@ function collect_answers(lin_answer)
|
|||||||
all_answers[next]= lin_answer[0].texts[i];
|
all_answers[next]= lin_answer[0].texts[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( all_answers.length > (parsed_trees - 1) * i)
|
trees_to_go--;
|
||||||
|
if(trees_to_go == 0)
|
||||||
continue_checking();
|
continue_checking();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user