mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
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.extra=div_id("extra");
|
||||
this.menubar=div_id("menubar");
|
||||
this.quizbar=div_id("quizbar");
|
||||
this.words=div_id("words");
|
||||
this.translations=div_id("translations");
|
||||
|
||||
@@ -57,7 +58,7 @@ function Minibar(server,opts,target) {
|
||||
|
||||
//modified for quiz
|
||||
with(this) {
|
||||
appendChildren(minibar,[menubar]);
|
||||
appendChildren(minibar,[menubar, quizbar]);
|
||||
appendChildren(minibar_contin,[surface,words]);
|
||||
append_extra_buttons(extra,options);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,8 @@ function pre_start()
|
||||
var quiz_mode=empty_id("select","quiz_mode");
|
||||
|
||||
//adds the "Quiz Mode" and "Restart Quiz" and "End Quiz" and "Start Quiz"
|
||||
appendChildren(minibar.menubar,
|
||||
[empty("br"),
|
||||
text(" Quiz Mode: "), quiz_mode,
|
||||
appendChildren(minibar.quizbar,
|
||||
[text(" Quiz Mode: "), quiz_mode,
|
||||
button("Restart Quiz","restart_quiz()","R"),
|
||||
button("End Quiz","end_quiz(true)","E"),
|
||||
button("Start Quiz","start_quiz()","S")]);
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body onLoad="pre_start()">
|
||||
<body>
|
||||
|
||||
<div id = "info" >
|
||||
<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");
|
||||
|
||||
|
||||
pre_start();
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -109,7 +109,7 @@ function start_quiz()
|
||||
answer_lang= minibar.to_menu.value;
|
||||
|
||||
//removes the start button
|
||||
minibar.menubar.removeChild(minibar.menubar.lastChild);
|
||||
minibar.quizbar.removeChild(minibar.quizbar.lastChild);
|
||||
|
||||
set_mode();
|
||||
|
||||
@@ -192,7 +192,7 @@ function restart_quiz()
|
||||
reset_mode();
|
||||
|
||||
//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
|
||||
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);
|
||||
}
|
||||
|
||||
var trees_to_go;
|
||||
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;
|
||||
for (j= 0; j < parsed_trees ; j++)
|
||||
{
|
||||
@@ -400,7 +401,8 @@ function collect_answers(lin_answer)
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user