-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathfixProgress.inc
More file actions
54 lines (48 loc) · 1.62 KB
/
fixProgress.inc
File metadata and controls
54 lines (48 loc) · 1.62 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
<?php
include_once ("lib/stopwatch.inc");
function runFix () {
global $db;
$size = 5000;
echo ("HERE");
set_time_limit(0);
$stopwatch = new stopwatch;
$sql = "truncate table repair";
$results = $db->query($sql);
echo ("<br>$sql<br>");
$sql = "select count(student.studentid) as count from studentlevel, student where student.status = \"Active\" and student.studentid = studentlevel.studentid";
$results = $db->get_results($sql, ARRAY_A);
$ct = $results[0]['count'];
// $ct = 49;
echo ("COUNT: $ct<br>");
$i = 0;
for ($j = 0; $j < $ct; $j = $j + $size) {
$stopwatch->lap("($i)");
$top = $j+$size-1;
$sql = "select *, student.studentid as id from studentlevel, student where student.status = \"Active\" and student.studentid = studentlevel.studentid limit $j, $size";
echo("<br>$sql<br>");
$results = $db->get_results($sql);
foreach ($results as $res) {
echo (fmod($i++, 100) == 0 ? "<br>." : ".");
$id = $res->id;
$sub = $res->subject;
$lvl = $res->level;
updateSingleLevelScore($id, $sub, $lvl);
/***
$score = updateOverall ($id, $sub, $lvl);
$sql = "INSERT into repair
SET studentid='$id',
subject='$sub',
level = '$lvl',
progress='$score'";
$db->get_results($sql);
****/
}
}
$stopwatch->lap("Final ($i)");
echo ("<br>Timing: " . $stopwatch->getText());
}
runFix();
/******
update studentlevel, fixRepair set studentlevel.progress = fixRepair.progress where studentlevel.studentid = fixRepair.studentid and studentlevel.subject = fixRepair.subject and studentlevel.level = fixRepair.level
*******/
?>