-
Notifications
You must be signed in to change notification settings - Fork 87
/
set_test_status.php
96 lines (75 loc) · 2.93 KB
/
set_test_status.php
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
87
88
89
90
91
92
93
94
95
96
<?php
/**************************************************************
"Learning with Texts" (LWT) is released into the Public Domain.
This applies worldwide.
In case this is not legally possible, any entity is granted the
right to use this work for any purpose, without any conditions,
unless such conditions are required by law.
Developed by J. Pierre in 2011.
***************************************************************/
/**************************************************************
Call: set_test_status.php?wid=[wordid]&stchange=+1/-1
set_test_status.php?wid=[wordid]&status=1..5/98/99
Change status of term while testing
***************************************************************/
include "connect.inc.php";
include "settings.inc.php";
include "utilities.inc.php";
$stchange = getreq('stchange');
$status = getreq('status');
$wid = getreq('wid') + 0;
$oldstatus = get_first_value("select WoStatus as value from words where WoID = " . $wid) + 0;
$oldscore = get_first_value('select greatest(0,round(WoTodayScore,0)) AS value from words where WoID = ' . $wid) + 0;
if ($stchange == '') {
$status = $status + 0;
$stchange = $status - $oldstatus;
if ($stchange <= 0) $stchange=-1;
if ($stchange > 0) $stchange=1;
} else {
$stchange = $stchange + 0;
$status = $oldstatus + $stchange;
if ($status < 1) $status=1;
if ($status > 5) $status=5;
}
$word = get_first_value("select WoText as value from words where WoID = " . $wid);
pagestart("Term: " . $word, false);
$m1 = runsql('update words set WoStatus = ' .
$status . ', WoStatusChanged = NOW(),' . make_score_random_insert_update('u') . ' where WoID = ' . $wid, 'Status changed');
$newscore = get_first_value('select greatest(0,round(WoTodayScore,0)) AS value from words where WoID = ' . $wid) + 0;
if ($oldstatus == $status)
echo '<p>Status ' . get_colored_status_msg($status) . ' not changed.</p>';
else
echo '<p>Status changed from ' . get_colored_status_msg($oldstatus) . ' to ' . get_colored_status_msg($status) . '.</p>';
echo "<p>Old score was " . $oldscore . ", new score is now " . $newscore . ".</p>";
$totaltests = $_SESSION['testtotal'];
$wrong = $_SESSION['testwrong'];
$correct = $_SESSION['testcorrect'];
$notyettested = $totaltests - $correct - $wrong;
if ( $notyettested > 0 ) {
if ( $stchange >= 0 )
$_SESSION['testcorrect']++;
else
$_SESSION['testwrong']++;
}
?>
<script type="text/javascript">
//<![CDATA[
var context = window.parent.frames['l'].document;
$('.word<?php echo $wid; ?>', context).removeClass('todo todosty').addClass('done<?php echo ($stchange >= 0 ? 'ok' : 'wrong'); ?>sty').attr('data_status','<?php echo $status; ?>').attr('data_todo','0');
<?php
$waittime = getSettingWithDefault('set-test-main-frame-waiting-time') + 0;
if ($waittime <= 0 ) {
?>
window.parent.frames['l'].location.reload();
<?php
} else {
?>
setTimeout('window.parent.frames[\'l\'].location.reload();', <?php echo $waittime; ?>);
<?php
}
?>
//]]>
</script>
<?php
pageend();
?>