diff --git a/checkin_notes b/checkin_notes index 37260f48ae..7358bbb83b 100644 --- a/checkin_notes +++ b/checkin_notes @@ -12549,3 +12549,15 @@ David 27 Dec 2007 log_flags.C,h lib/ common_defs.h + +David 27 Dec 2007 + - upgrade script: fix it, and add --web_only option (fixes #527) + - web: replace "Result" by "Task" a couple of places + + html/ + inc/ + host.inc + user/ + hosts_user.php + tools/ + upgrade diff --git a/html/inc/bolt.inc b/html/inc/bolt.inc index 5d160cbfbf..d15bfa9f30 100644 --- a/html/inc/bolt.inc +++ b/html/inc/bolt.inc @@ -41,6 +41,7 @@ abstract class BoltUnit { class BoltIter { public $top; // topmost unit public $state; // state array + public $xset; // exercise set, if any // the following are temps public $item; // current item @@ -62,6 +63,7 @@ class BoltIter { // get current item and fraction done // function at() { + $this->xset = null; $this->top->walk($this, false, $this->frac_done); } @@ -245,6 +247,114 @@ class BoltRandom extends BoltUnit { } } +class BoltExerciseSet extends BoltUnit { + public $units; + public $reviews; + function __construct($n, $u, $n, $r) { + $this->name = $n; + $this->units = $u; + $this->is_item = false; + $this->number = $n; + $this->shuffled = false; + $this->reviews = $r; + } + + // the scheduler calls this when an exercise in this set + // has just been graded. + // - record the score + // - if this is the last exercise in the set, + // create exercise_set_result record + // and optionally create or update bolt_refresh record + // - return a structure saying what navigation info to show: + // - review + // - repeat now + // - next + // + function xset_callback($score, &$nav_info) { + } + + function walk(&$iter, $incr, &$frac_done) { + $iter->xset = $this; + $n = count($this->units); + if (array_key_exists($this->name, $iter->state)) { + $state_rec = $iter->state[$this->name]; + $child_name = $state_rec['child_name']; + $number_shown = $state_rec['number_shown']; + if (!$this->shuffled) { + srand($state_rec['seed']); + shuffle($this->units); + $this->shuffled = true; + } + + // look up unit by name + // + $child = null; + for ($i=0; $i<$n; $i++) { + $c = $this->units[$i]; + if ($c->name == $child_name) { + $child = $c; + break; + } + } + + // if not there, look up by index + // + if (!$child) { + $i = $state_rec['i']; + if ($i >= $n) { + // and if index is too big, use last unit + // + $i = $n-1; + } + $child = $this->units[$i]; + } + + // at this point, $child is the current unit, and $i is its index + // + if ($incr) { + $my_inc = false; + if ($child->is_item) { + $my_inc = true; + } else { + $my_inc = $child->walk($iter, $incr, $frac_done); + } + if ($my_inc) { + $i = ($i+1)%$n; + $number_shown++; + if ($number_shown >= $this->number) { + $frac_done = 1; + $state_rec['i'] = $i; + $state_rec['number_shown'] = 0; + $state_rec['child_name'] = null; + $iter->state[$this->name] = $state_rec; + return true; + } + } + } + } else { + $i = 0; + $number_shown = 0; + $state_rec = null; + $seed = ((double)microtime()*1000000); + srand($seed); + shuffle($this->units); + $state_rec['seed'] = $seed; + } + $child = $this->units[$i]; + $frac_done = $number_shown/$this->number; + $state_rec['i'] = $i; + $state_rec['number_shown'] = $number_shown; + $state_rec['child_name'] = $child->name; + $iter->state[$this->name] = $state_rec; + if ($child->is_item) { + $iter->item = $child; + } else { + $child->walk($iter, false, $f); + $frac_done += $f*(1/$number); + } + } +} + class BoltItem extends BoltUnit { public $filename; function __construct($name, $title, $filename) { @@ -387,7 +497,8 @@ function sequence() { if (is_subclass_of($arg, "BoltUnit")) { $units[] = $arg; } else { - echo "Unrecognized arg"; + echo "Unrecognized arg: "; + print_r($arg); } } } @@ -411,7 +522,8 @@ function random() { if (is_subclass_of($arg, "BoltUnit")) { $units[] = $arg; } else { - echo "Unrecognized arg"; + echo "Unrecognized arg: "; + print_r($arg); } } } @@ -421,7 +533,9 @@ function random() { function exercise_set() { $args = func_get_args(); $units = array(); + $reviews = array(); $name = ""; + $number = 1; foreach ($args as $arg) { if (is_array($arg)) { switch ($arg[0]) { @@ -433,12 +547,15 @@ function exercise_set() { } else if (is_object($arg)) { if (is_subclass_of($arg, "BoltUnit")) { $units[] = $arg; + } else if (get_class($arg) == "BoltReview") { + $reviews[] = $arg; } else { - echo "Unrecognized arg"; + echo "Unrecognized arg: "; + print_r($arg); } } } - return new BoltExerciseSet($name, $units, $number); + return new BoltExerciseSet($name, $units, $number, $reviews); } function enum_course($course) { diff --git a/html/inc/host.inc b/html/inc/host.inc index 94a4085d31..22d01f5c7b 100644 --- a/html/inc/host.inc +++ b/html/inc/host.inc @@ -142,7 +142,7 @@ function show_host($host, $private, $ipprivate, $user) { row2("Average CPU efficiency", $host->cpu_efficiency); } if ($host->duration_correction_factor) { - row2("Result duration correction factor", $host->duration_correction_factor); + row2("Task duration correction factor", $host->duration_correction_factor); } row2("Location", location_form($host)); if ($nresults == 0) { diff --git a/html/user/hosts_user.php b/html/user/hosts_user.php index 0511a918bf..e00f3f6938 100644 --- a/html/user/hosts_user.php +++ b/html/user/hosts_user.php @@ -34,7 +34,7 @@ function user_host_table_start($private) {