From 40f594b07c49c824ae8dccd44271f1ac0f7199b3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 28 Dec 2007 05:23:52 +0000 Subject: [PATCH] - upgrade script: fix it, and add --web_only option (fixes #527) - web: replace "Result" by "Task" a couple of places svn path=/trunk/boinc/; revision=14446 --- checkin_notes | 12 ++++ html/inc/bolt.inc | 125 +++++++++++++++++++++++++++++++++++++-- html/inc/host.inc | 2 +- html/user/hosts_user.php | 2 +- tools/upgrade | 7 ++- 5 files changed, 139 insertions(+), 9 deletions(-) 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) { ".link_with_GET_variables("Operating system", "hosts_user.php", 'sort', 'os')." "; $config = get_config(); - if (parse_bool($config, "show_results")) echo "Results"; + if (parse_bool($config, "show_results")) echo "Tasks"; echo "".link_with_GET_variables("Last contact", "hosts_user.php", 'sort', 'rpc_time').""; } diff --git a/tools/upgrade b/tools/upgrade index d0e1316d5e..4fb86d5de3 100755 --- a/tools/upgrade +++ b/tools/upgrade @@ -19,14 +19,14 @@ from Boinc.setup_project import * import os, getopt def usage(): - print "Usage: upgrade [--project_root] project_name" + print "Usage: upgrade [--project_root] [--web_only] project_name" raise SystemExit def syntax_error(str): raise SystemExit('%s; See "%s --help" for help\n' % (str, sys.argv[0])) try: - opts, args = getopt.getopt(sys.argv[1:], '', ['help', 'project_root=']) + opts, args = getopt.getopt(sys.argv[1:], '', ['help', 'project_root=', 'web_only']) except getopt.GetoptError, e: syntax_error(e) @@ -37,6 +37,7 @@ options.project_root = os.path.join(home, 'projects') for o,a in opts: if o == '--help': usage() elif o == '--project_root': options.project_root = a + elif o == '--web_only': options.web_only = True else: raise SystemExit('internal error o=%s'%o) @@ -57,7 +58,7 @@ print "Upgrading files... " options.install_method = 'copy' init() -install_boinc_files(INSTALL_DIR) +install_boinc_files(INSTALL_DIR, options.web_only) print "Upgrading files... done" print "You may need to do database upgrades also."