time); echo " A data snapshot exists for the $s->dur days prior to $end. "; show_button( "bolt_map.php?action=map&course_id=$course_id", "Use this snapshot", "Use this snapshot" ); } else { echo "There is currently no snapshot."; } echo "
Create a new snapshot using data from the last days.
"; page_tail(); } function snap_action() { global $course_id; global $top_unit; $dur = get_int('dur'); $s = write_map_snapshot($course_id, $dur); show_map(); } function spaces($level) { for ($i=0; $iusers[$y->user_id]; if ($filter->category($u) == $filter_cat) { $x[] = $y; } } return $x; } function avg_score($array) { $sum = 0; foreach ($array as $a) { $sum += $a->score; } return $sum/count($array); } function show_unit($snap, $unit, $level, $filter, $filter_cat, $breakdown) { $class = get_class($unit); echo " ".spaces($level)."$unit->name $class "; if ($unit->is_item) { if (array_key_exists($unit->name, $snap->views)) { $a = filter_array( $snap->views[$unit->name], $snap, $filter, $filter_cat ); $n = count($a); } else { $n = 0; } echo "$n"; } else { echo "
"; } if ($class == "BoltExercise") { if (array_key_exists($unit->name, $snap->results)) { $a = filter_array( $snap->results[$unit->name], $snap, $filter, $filter_cat ); $avg = avg_score($a); $n = count($a); bolt_bar($avg); } } else if ($class == "BoltExerciseSet") { if (array_key_exists($unit->name, $snap->xset_results)) { $a = filter_array( $snap->xset_results[$unit->name], $snap, $filter, $filter_cat ); $avg = avg_score($a); bolt_bar($avg); } } else { echo "
"; } echo "\n"; } function show_unit_recurse( $snap, $unit, $level, $filter, $filter_cat, $breakdown ) { show_unit($snap, $unit, $level, $filter, $filter_cat, $breakdown); if ($unit->is_item) return; foreach ($unit->units as $u) { show_unit_recurse($snap, $u, $level+1, $filter, $filter_cat, $breakdown); } } function show_map() { global $course_id; global $top_unit; $breakdown_name = get_str('breakdown', true); if ($breakdown_name) { $breakdown = lookup_categorization($breakdown_name); if (!$breakdown) error_page("unknown breakdown $breakdown_name"); } else { $breakdown = null; } $filter_info = get_str('filter', true); if ($filter_info && $filter_info != "none") { $arr = explode(":", $filter_info); $filter_name = $arr[0]; $filter_cat = $arr[1]; $filter = lookup_categorization($filter_name); if (!$filter) error_page("unknown filter $filter_name"); } else { $filter_name = ""; $filter_cat = ""; $filter = null; } page_head("Course map"); $snap = read_map_snapshot($course_id); echo " "; show_unit_recurse($snap, $top_unit, $filter, $filter_cat, $breakdown); echo "
Name Type Views Outcome Time Score
"; filter_form($filter_name, $filter_cat); echo ""; breakdown_form($breakdown_name); echo "

"; page_tail(); } $course_id = get_int('course_id'); $course = BoltCourse::lookup_id($course_id); if (!$course) error_page("no course"); $top_unit = require_once("../user/$course->doc_file"); $action = get_str('action', true); switch ($action) { case "": show_snap_form(); break; case "snap_action": snap_action(); break; case "map": show_map(); break; default: error_page("Unknown action $action"); } ?>