Repository navigation
Expand file tree
/
Copy pathtest.php
More file actions
86 lines (74 loc) · 3.9 KB
/
Copy pathtest.php
File metadata and controls
86 lines (74 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
session_start();
include_once 'classes.php';
include_once 'header.php';
if (isset($_REQUEST["go"])) {
// we've had an answer
foreach ($_REQUEST as $param_name => $param_val) {
${$param_name}=$param_val;
//echo "$param_name = $param_val<br/>\n";
};
$w = new word();
$w->update($id, $points);
//echo "updated id $id with score $points<p>";
}
$w = new word();
if (isset($_SESSION["test"])) {
$test = unserialize($_SESSION["test"]);
$total = $_SESSION["total"];
array_shift($test);
if (count($test)<1) {
$test = $w->getWords(); // we've run out of words. get some more
//echo "Run out of words, got ".count($test)." more...";
$total=count($test);
}
} else {
$test = $w->getWords();
$total = count($test);
//echo "Not cached. Got ".count($test)." words...";
}
if (count($test)>0) {
$_SESSION["test"]=serialize($test);
$_SESSION["total"]=$total;
$percent = (int) (($total - count($test)) / $total * 100);
echo '<div class="progress">';
echo ' <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40"';
echo " aria-valuemin='0' aria-valuemax='100' style='width:$percent%'>";
echo "$percent% Complete";
echo " </div> </div>";
$currentWord=$test[0];
echo '<div class="jumbotron '.$currentWord->language.'-flag text-center" id="the-question">';
echo "<h1><div class='question' data-attempts='0' data-wrong-answers='0' data-answer='$currentWord->translation' data-id='$currentWord->id' name='question' id='question'>$currentWord->word</div></h1>\n";
echo "</div>\n";
echo '<div class="unanswered" id="answer-box">'."\n";
echo "<form onSubmit='return checkAnswer();'>\n"; // if result of checkAnswer is false form will not submit
echo '<div class="row"><div class="col-sm-2"></div><div class="col-sm-8"><div class="input-group">';
echo '<input class="long-press form-control" type="text" name="answer" id="answer" placeholder="Translate '.$currentWord->word.'" autofocus value="" autocorrect="off" autocomplete="off" autocapitalize="none" spellcheck="false">'."\n";
echo '<span class="input-group-btn"><button type="submit" id="go" name="go" class="btn btn-primary">Check</button></span>'."\n";
echo '</div></div><div class="col-sm-2"></div></div>';
echo '<input type="hidden" name = "points" id="points" value="0">'."\n";
echo "<input type='hidden' name = 'id' id='id' value='$currentWord->id'>\n";
echo '</form></div>'."\n";
echo '<div class="note" id="note">'."\n";
echo "$currentWord->Notes\n";
echo '</div>'."\n";
echo '<div class="text-center feedback hidden-answer correct-answer" id="the-answer">'."\n";
echo "CORRECT! $currentWord->word <span id='joiner'>is<span> <span class='text-uppercase'><b>$currentWord->translation</b><span>\n";
echo '</div>'."\n";
echo '<div class="text-center feedback hidden-answer almost-correct-answer" id="the-almost-answer">'."\n";
echo "Correct. $currentWord->word is <b>$currentWord->translation</b>, but you didn't get the accents quite right.\n";
echo '</div>'."\n";
echo '<div class="text-center feedback hidden-answer wrong-answer" id="the-wrong-answer">'."\n";
echo "NOPE! $currentWord->word is <b>$currentWord->translation</b>.\n";
echo '</div>'."\n";
echo '<div class="text-center feedback hidden-answer almost-correct-answer" id="the-scrambled-answer">'."\n";
echo "CLOSE!\n";
echo '</div>'."\n";
include_once 'footer.php';
echo "<script >$(function(){ startTime=new Date(); document.getElementById('answer').focus();});</script>"; // make a note of the time the page was shown
} else {
echo '<div class="jumbotron text-center" id="the-question">';
echo "<h1><div class='question' data-attempts='0' data-wrong-answers='0' name='question' id='question'>You're done! Add some new words...</div></h1>\n";
echo "</div>\n";
}
?>