From af38142142b6f6ccccb0ffd68a7cebd31969963e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 15 Aug 2008 22:07:24 +0000 Subject: [PATCH] - Bolt stuff svn path=/trunk/boinc/; revision=15860 --- bolt_checkin_notes.txt | 19 +++++++++ html/inc/bolt.inc | 43 +++++++++----------- html/inc/bolt_select.inc | 1 - html/inc/bolt_util.inc | 63 +++++++++++++++++++++-------- html/inc/util.inc | 1 + html/{user => ops}/bolt_compare.php | 5 ++- html/ops/bolt_datagen.php | 20 ++++++--- html/ops/bolt_map.php | 28 +++++++++---- html/user/bolt_sched.php | 15 +++++-- 9 files changed, 136 insertions(+), 59 deletions(-) rename html/{user => ops}/bolt_compare.php (98%) diff --git a/bolt_checkin_notes.txt b/bolt_checkin_notes.txt index f80f089d3d..bf7817852c 100644 --- a/bolt_checkin_notes.txt +++ b/bolt_checkin_notes.txt @@ -187,3 +187,22 @@ David August 14 2008 bolt_course.php bolt_sched.php white.css + +David August 15 2008 + - The logical name of an item is now its filename. + Items can also have titles, but they're used only + when showing outline to students + - Fixed bugs and improved appearance of course maps and lesson compare + + html/ + inc/ + bolt.inc + bolt_util.inc + bolt_select.inc + util.inc + ops/ + bolt_map.php + bolt_datagen.php + bolt_compare.php (moved here from user/) + user/ + bolt_sched.php diff --git a/html/inc/bolt.inc b/html/inc/bolt.inc index 66359c0b40..54e1ad0751 100644 --- a/html/inc/bolt.inc +++ b/html/inc/bolt.inc @@ -23,8 +23,12 @@ ini_set('display_errors', true); ini_set('display_startup_errors', true); abstract class BoltUnit { - public $name; // logical name. + public $name; + // Logical name. Changing this makes it a different unit. + // For items, this is the filename with query string; + // for structures, it must be specified with name() public $title; + // Optional; used when showing course history outline. public $is_item; abstract function walk(&$iter, $incr, &$frac_done); @@ -43,7 +47,7 @@ abstract class BoltUnit { class BoltItem extends BoltUnit { public $filename; public $query_string; - function __construct($name, $title, $filename) { + function __construct($filename, $title) { $p = strpos($filename, '?'); if ($p === false) { $this->filename = $filename; @@ -52,7 +56,7 @@ class BoltItem extends BoltUnit { $this->filename = substr($filename, 0, $p); $this->query_string = substr($filename, $p+1); } - $this->name = $name; + $this->name = $filename; $this->title = $title; $this->is_item = true; } @@ -243,56 +247,49 @@ function filename($n) { } function lesson() { - $name = ""; - $file = ""; + $filename = ""; $title = ""; $args = func_get_args(); foreach ($args as $arg) { if (is_array($arg)) { switch ($arg[0]) { - case 'name': $name = $arg[1]; break; case 'title': $title = $arg[1]; break; - case 'filename': $file = $arg[1]; break; - default: echo "Unrecognized array arg: ", $arg[0], "\n"; break; + case 'filename': $filename = $arg[1]; break; + default: echo "Unrecognized lesson parameter: ", $arg[0], "\n"; break; } } else { echo "unprocessed arg of class ".get_class($arg); } } - if (!$name) { - $name = $file; - } if (!$title) { - $title = $name; + $title = $filename; } - if (!$file) { + if (!$filename) { error_page("Missing filename in lesson"); } - return new BoltLesson($name, $title, $file); + return new BoltLesson($filename, $title); } function exercise() { - $name = ""; - $file = ""; + $filename = ""; $title = ""; $args = func_get_args(); foreach ($args as $arg) { if (is_array($arg)) { switch ($arg[0]) { - case 'name': $name = $arg[1]; break; case 'title': $title = $arg[1]; break; - case 'filename': $file = $arg[1]; break; - default: echo "Unrecognized array arg: ", $arg[0], "\n"; break; + case 'filename': $filename = $arg[1]; break; + default: echo "Unrecognized exercise parameter: ", $arg[0], "\n"; break; } } } - if (!$name) { - $name = $file; + if (!$title) { + $title = $filename; } - if (!$file) { + if (!$filename) { error_page("Missing filename in lesson"); } - return new BoltExercise($name, $title, $file); + return new BoltExercise($filename, $title); } require_once('../inc/bolt_seq.inc'); diff --git a/html/inc/bolt_select.inc b/html/inc/bolt_select.inc index b854cb5f5f..5e982ba9fe 100644 --- a/html/inc/bolt_select.inc +++ b/html/inc/bolt_select.inc @@ -46,7 +46,6 @@ class BoltSelect extends BoltSet { $state_rec = $iter->state[$this->name]; $child_name = $state_rec['child_name']; - echo "FINISHED: $child_name"; $now = time(); BoltSelectFinished::insert("(user_id, course_id, end_time, name, selected_unit, view_id) values ($user->id, $course->id, $now, '$this->name', '$child_name', $view->id)"); parent::finished($iter); diff --git a/html/inc/bolt_util.inc b/html/inc/bolt_util.inc index f1bdba43df..58df693d6e 100644 --- a/html/inc/bolt_util.inc +++ b/html/inc/bolt_util.inc @@ -129,7 +129,9 @@ function request_info($user, $course) { ////// stuff related to snapshots function compare_snapshot_filename($course_id, $select_name, $xset_name) { - return "../bolt_snap/compare_snapshot_".$course_id."_".$select_name."_".$xset_name; + @mkdir("../bolt_snap"); + $x = urlencode($course_id."_".$select_name."_".$xset_name); + return "../bolt_snap/compare_snapshot_$x"; } // a "snapshot" is a condensed representation of the results @@ -172,10 +174,10 @@ function write_compare_snapshot($course_id, $select_name, $xset_name, $dur) { $x = $a[$uid]; $xr = $x->xr; if ($sf->end_time > $xr->create_time) { - echo "select finish is too late"; + //echo "select finish is too late"; continue; } - if (!isset($x->sf) || $sf->create_time > $s.create_time) { + if (!isset($x->sf) || $sf->end_time > $x->sf->end_time) { $x->sf = $sf; $a[$uid] = $x; } @@ -264,7 +266,7 @@ function write_map_snapshot($course_id, $dur) { if (!array_key_exists($r->user_id, $users)) { $user = BoincUser::lookup_id($r->user_id); BoltUser::lookup($user); - $users[$v->user_id] = $user; + $users[$r->user_id] = $user; } } @@ -280,7 +282,7 @@ function write_map_snapshot($course_id, $dur) { if (!array_key_exists($xr->user_id, $users)) { $user = BoincUser::lookup_id($xr->user_id); BoltUser::lookup($user); - $users[$v->user_id] = $user; + $users[$xr->user_id] = $user; } } @@ -394,14 +396,25 @@ function outcome_graph($x, $width) { } else { $t0 = ""; } - return " + $s = " - - - -
$t0
+ "; + if ($x0) { + $s .= "$t0 + "; + } + if ($x1) { + $s .= "
+ "; + } + if ($x2) { + $s .= "
+ "; + } + $s .= " "; + return $s; } function time_graph($t, $w) { @@ -410,7 +423,7 @@ function time_graph($t, $w) { $t = number_format($t, 1); return " - +
$t sec$t sec
"; } @@ -420,18 +433,30 @@ function score_graph($t, $w) { $x = $t*$w; $y = (1-$t)*$w; $t = number_format($t*100); - return " + $s = " - - -
$t%
- "; + "; + if ($x) { + $s .= "$t% + "; + } + if ($y) { + $s .= " + "; + } + $s .= " + "; + return $s; } function empty_cell() { return "
"; } +function empty_row() { + return "
"; +} + //////////// show refresh schedule ////////////// function show_refresh($r) { @@ -460,4 +485,10 @@ function show_refreshes() { end_table(); } +function bolt_style() { + echo " + + "; +} + ?> diff --git a/html/inc/util.inc b/html/inc/util.inc index cfac014b09..3ccb03ca3b 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -25,6 +25,7 @@ require_once("../inc/translation.inc"); require_once("../inc/profile.inc"); ini_set("memory_limit", "64M"); + date_default_timezone_set("UTC"); $generating_xml = false; diff --git a/html/user/bolt_compare.php b/html/ops/bolt_compare.php similarity index 98% rename from html/user/bolt_compare.php rename to html/ops/bolt_compare.php index d6278f134c..2d0358b179 100644 --- a/html/user/bolt_compare.php +++ b/html/ops/bolt_compare.php @@ -31,6 +31,7 @@ require_once("../inc/util.inc"); require_once("../inc/bolt_db.inc"); require_once("../inc/bolt_util.inc"); +require_once("../inc/bolt.inc"); require_once("../inc/bolt_cat.inc"); function compare_case( @@ -82,7 +83,7 @@ function compare_aux($select_name, $xset_name, $snap) { global $course_id; $breakdown_name = get_str('breakdown', true); - if ($breakdown_name) { + if ($breakdown_name && $breakdown_name != 'none') { $breakdown = lookup_categorization($breakdown_name); if (!$breakdown) error_page("unknown breakdown $breakdown_name"); } else { @@ -180,7 +181,7 @@ function show_snap_form($top_unit) { Create a new snapshot using data from the last - days. + days. "; diff --git a/html/ops/bolt_datagen.php b/html/ops/bolt_datagen.php index 7af78dcc0b..8405cc98e3 100644 --- a/html/ops/bolt_datagen.php +++ b/html/ops/bolt_datagen.php @@ -16,10 +16,13 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -// generate synthetic usage data for a Bolt course (for debugging analytics) +// Generate synthetic usage data for a Bolt course (for debugging analytics), +// or to clear out existing data. +// See comments below for how to use this. require_once("../inc/bolt_db.inc"); require_once("../inc/bolt_util.inc"); +require_once("../inc/bolt.inc"); require_once("../inc/bolt_cat.inc"); // generate a random student @@ -67,7 +70,7 @@ function compare_gen( $a2, $d2 // avg and dev of score for chosen alternative ) { global $course; - $top_unit = require_once("../user/$course->doc_file"); + $top_unit = require_once($course->doc_file()); $select_unit = lookup_unit($top_unit, $select_name); if (!$select_unit) error_page("no such select unit"); if (!lookup_unit($top_unit, $xset_name)) error_page("no such xset"); @@ -104,7 +107,7 @@ function compare_gen( function map_gen($n, $sb1, $sb2, $sel, $sel_cat) { global $course; - $top_unit = require_once("../user/$course->doc_file"); + $top_unit = require_once($course->doc_file()); for ($i=0; $i<$n; $i++) { $uid = random_student(); $user = BoincUser::lookup_id($uid); @@ -191,7 +194,9 @@ function clear() { $db->do_query("delete from DBNAME.bolt_select_finished where course_id=$course->id"); } -$course = BoltCourse::lookup_id(2); +// put your course ID here: + +$course = BoltCourse::lookup_id(4); if (!$course) error_page("no such course"); $now = time(); @@ -201,7 +206,12 @@ if (1) { if (0) { compare_gen( - 'sample select', 'exercise set 1', 10, .5, .1, 'lesson 1', .8, .1 + 'Conifer/deciduous alternative', // select name + 'Intro exercises', // xset name + 50, // # of records to create + .5, .1, // mean and dev of default score + 'conifer_decid2.php', // name of chosen alternative + .8, .1 // mean and dev of score for that alternative ); } diff --git a/html/ops/bolt_map.php b/html/ops/bolt_map.php index 1d53397ec2..1f157d6f17 100644 --- a/html/ops/bolt_map.php +++ b/html/ops/bolt_map.php @@ -50,9 +50,6 @@ require_once("../inc/bolt_cat.inc"); require_once("../inc/bolt_util.inc"); require_once("../inc/bolt.inc"); -echo " - -"; // the following are to minimize argument passing $snap = null; @@ -87,7 +84,7 @@ function show_snap_form() { Create a new snapshot using data from the last - days. + days. "; @@ -167,6 +164,7 @@ function outcomes($views) { switch ($v->action) { case BOLT_ACTION_NONE: $x[0]++; break; case BOLT_ACTION_NEXT: $x[1]++; break; + case BOLT_ACTION_SUBMIT: $x[1]++; break; default: $x[2]++; break; } } @@ -215,11 +213,15 @@ function class_name($class) { } } +$rownum = 0; + function show_unit_row($unit, $class, $level, $is_answer) { global $breakdown, $breakdown_cat; + global $rownum; $a = $is_answer?" (answer)":""; - echo ""; + $j = ($rownum++)%2; + echo ""; if ($breakdown && $breakdown_cat) { echo "
@@ -276,6 +278,10 @@ function show_unit_row($unit, $class, $level, $is_answer) { echo empty_cell(); break; default: + echo empty_cell(); + echo empty_cell(); + echo empty_cell(); + echo empty_cell(); } echo "\n"; } @@ -327,6 +333,7 @@ function show_unit_recurse($unit, $level) { function show_map() { global $snap, $course_id, $top_unit, $filter, $filter_cat, $breakdown; + global $course; $breakdown_name = get_str('breakdown', true); if ($breakdown_name && $breakdown_name != 'none') { @@ -348,10 +355,11 @@ function show_map() { $filter = null; } - page_head("Course map"); + page_head("Course map for '$course->name'"); + bolt_style(); $snap = read_map_snapshot($course_id); + start_table(); echo " - @@ -361,7 +369,11 @@ function show_map() { } echo " - + diff --git a/html/user/bolt_sched.php b/html/user/bolt_sched.php index 6cf0eb8bca..c812f517a6 100644 --- a/html/user/bolt_sched.php +++ b/html/user/bolt_sched.php @@ -78,8 +78,15 @@ function create_view($iter, $mode, $prev_view_id) { return BoltView::insert("(user_id, course_id, item_name, start_time, mode, state, fraction_done, prev_view_id) values ($user->id, $course->id, '$item->name', $now, $mode, '$state', $iter->frac_done, $prev_view_id)"); } -function page_header($title) { - echo "$title +function page_header($title=null) { + echo " + "; + if ($title) { + echo " + $title + "; + } + echo " "; @@ -160,7 +167,7 @@ function show_item($iter, $view_id, $prev_view_id, $mode, $repeat=null) { global $url_args; $item = $iter->item; - page_header($item->title); + page_header(); $bolt_query_string = $item->query_string; $links = array(); @@ -251,7 +258,7 @@ function show_answer_page($iter, $score) { $bolt_ex_index = 0; $item = $iter->item; - page_header($item->title); + page_header(); $bolt_query_string = $item->query_string; require_once($item->filename); if (function_exists('bolt_divide')) bolt_divide();
Name TypeViewsOutcome
Green=Next,
Yellow=Back,
Red=None
Outcome
+ Next + Back + None +
Score Time