mirror of https://github.com/BOINC/boinc.git
parent
aa10bcb37a
commit
af38142142
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 "<td>
|
||||
$s = "<td>
|
||||
<table class=bolt_bar><tr>
|
||||
<td class=bolt_bar height=10 width=$x0 bgcolor=#88ff88><span class=note>$t0</span></td>
|
||||
<td class=bolt_bar height=10 width=$x1 bgcolor=#ff8888></td>
|
||||
<td class=bolt_bar height=10 width=$x2 bgcolor=#ffff88></td>
|
||||
</tr></table>
|
||||
";
|
||||
if ($x0) {
|
||||
$s .= "<td class=bolt_bar height=10 width=$x0 bgcolor=#88ff88><span class=note>$t0</span></td>
|
||||
";
|
||||
}
|
||||
if ($x1) {
|
||||
$s .= "<td class=bolt_bar height=10 width=$x1 bgcolor=#ff8888><br></td>
|
||||
";
|
||||
}
|
||||
if ($x2) {
|
||||
$s .= "<td class=bolt_bar height=10 width=$x2 bgcolor=#ffff88><br></td>
|
||||
";
|
||||
}
|
||||
$s .= "</tr></table>
|
||||
</td>
|
||||
";
|
||||
return $s;
|
||||
}
|
||||
|
||||
function time_graph($t, $w) {
|
||||
|
@ -410,7 +423,7 @@ function time_graph($t, $w) {
|
|||
$t = number_format($t, 1);
|
||||
return "<td>
|
||||
<table class=bolt_bar><tr>
|
||||
<td class=bolt_bar height=10 width=$x bgcolor=#cccccc>$t sec</td>
|
||||
<td class=bolt_bar height=10 width=$x bgcolor=#ffffcc><span class=note>$t sec</span></td>
|
||||
</tr></table>
|
||||
</td>";
|
||||
}
|
||||
|
@ -420,18 +433,30 @@ function score_graph($t, $w) {
|
|||
$x = $t*$w;
|
||||
$y = (1-$t)*$w;
|
||||
$t = number_format($t*100);
|
||||
return "<td>
|
||||
$s = "<td>
|
||||
<table class=bolt_bar><tr>
|
||||
<td class=bolt_bar height=10 width=$x bgcolor=#cccccc><span class=note>$t%</span></td>
|
||||
<td class=bolt_bar width=$y bgcolor=white></td>
|
||||
</tr></table>
|
||||
</td>";
|
||||
";
|
||||
if ($x) {
|
||||
$s .= "<td class=bolt_bar height=10 width=$x bgcolor=#ffffcc><span class=note>$t%</span></td>
|
||||
";
|
||||
}
|
||||
if ($y) {
|
||||
$s .= "<td class=bolt_bar width=$y bgcolor=gray></td>
|
||||
";
|
||||
}
|
||||
$s .= "</tr></table></td>
|
||||
";
|
||||
return $s;
|
||||
}
|
||||
|
||||
function empty_cell() {
|
||||
return "<td><br></td>";
|
||||
}
|
||||
|
||||
function empty_row() {
|
||||
return "<tr><td><br></td></tr>";
|
||||
}
|
||||
|
||||
//////////// show refresh schedule //////////////
|
||||
|
||||
function show_refresh($r) {
|
||||
|
@ -460,4 +485,10 @@ function show_refreshes() {
|
|||
end_table();
|
||||
}
|
||||
|
||||
function bolt_style() {
|
||||
echo "
|
||||
<link rel=\"stylesheet\" type=\"text/css\" href=\"".URL_BASE."bolt.css\">
|
||||
";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
|||
<input type=hidden name=select_name value=\"$select_name\">
|
||||
<input type=hidden name=xset_name value=\"$xset_name\">
|
||||
Create a new snapshot using data from the last
|
||||
<input name=dur> days.
|
||||
<input name=dur value=7> days.
|
||||
<input type=submit value=OK>
|
||||
</form>
|
||||
";
|
|
@ -16,10 +16,13 @@
|
|||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// 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
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,9 +50,6 @@ require_once("../inc/bolt_cat.inc");
|
|||
require_once("../inc/bolt_util.inc");
|
||||
require_once("../inc/bolt.inc");
|
||||
|
||||
echo "
|
||||
<link rel=\"stylesheet\" type=\"text/css\" href=\"".URL_BASE."bolt.css\">
|
||||
";
|
||||
// the following are to minimize argument passing
|
||||
|
||||
$snap = null;
|
||||
|
@ -87,7 +84,7 @@ function show_snap_form() {
|
|||
<input type=hidden name=action value=snap_action>
|
||||
<input type=hidden name=course_id value=$course_id>
|
||||
Create a new snapshot using data from the last
|
||||
<input name=dur> days.
|
||||
<input name=dur value=7> days.
|
||||
<input type=submit value=OK>
|
||||
</form>
|
||||
";
|
||||
|
@ -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 "<tr>";
|
||||
$j = ($rownum++)%2;
|
||||
echo "<tr class=row$j>";
|
||||
if ($breakdown && $breakdown_cat) {
|
||||
echo "
|
||||
<td><br></td>
|
||||
|
@ -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 "</tr>\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 "
|
||||
<table class=\"bolt_box\">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
|
@ -361,7 +369,11 @@ function show_map() {
|
|||
}
|
||||
echo "
|
||||
<th>Views</th>
|
||||
<th>Outcome<br><span class=note>Green=Next,<br>Yellow=Back,<br>Red=None</span></th>
|
||||
<th>Outcome<br>
|
||||
<span class=green>Next</span>
|
||||
<span class=yellow>Back</span>
|
||||
<span class=red>None</span>
|
||||
</th>
|
||||
<th>Score</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
|
|
|
@ -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 "<html><head><title>$title</title>
|
||||
function page_header($title=null) {
|
||||
echo "<html><head>
|
||||
";
|
||||
if ($title) {
|
||||
echo "
|
||||
<title>$title</title>
|
||||
";
|
||||
}
|
||||
echo "
|
||||
<link rel=stylesheet type=text/css href=white.css>
|
||||
</head><body>
|
||||
";
|
||||
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue