From 1d99bfec2b40fa02a7e27ac65afe05fd6caf51f6 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 21 Aug 2008 23:24:11 +0000 Subject: [PATCH] svn path=/trunk/boinc/; revision=15921 --- bolt_checkin_notes.txt | 13 +++++++++++++ html/inc/bolt_db.inc | 30 +++++++++++++++++++++++++++++- html/inc/bolt_util.inc | 12 ++++++------ html/ops/bolt_admin.php | 38 ++++++++++++++++++++++++++++++++++++++ html/user/bolt.php | 2 +- html/user/bolt_course.php | 5 +++-- html/user/bolt_sched.php | 2 +- 7 files changed, 91 insertions(+), 11 deletions(-) diff --git a/bolt_checkin_notes.txt b/bolt_checkin_notes.txt index bf7817852c..04d1915a97 100644 --- a/bolt_checkin_notes.txt +++ b/bolt_checkin_notes.txt @@ -206,3 +206,16 @@ David August 15 2008 bolt_compare.php (moved here from user/) user/ bolt_sched.php + +David August 15 2008 + - Add admin "clear data" function + + html/ + inc/ + bolt_util.inc + bolt_db.inc + ops/ + bolt_admin.php + user/ + bolt.php + bolt_sched.php diff --git a/html/inc/bolt_db.inc b/html/inc/bolt_db.inc index 77aed15256..6a72055d63 100644 --- a/html/inc/bolt_db.inc +++ b/html/inc/bolt_db.inc @@ -168,10 +168,14 @@ class BoltEnrollment { $db = BoltDb::get(); $db->update_aux('bolt_enrollment', "$clause where user_id=$this->user_id and course_id=$this->course_id"); } - function delete($user_id, $course_id) { + static function delete($user_id, $course_id) { $db = BoltDb::get(); $db->delete_aux('bolt_enrollment', "user_id=$user_id and course_id=$course_id"); } + static function delete_aux($clause) { + $db = BoltDb::get(); + $db->delete_aux('bolt_enrollment', $clause); + } } class BoltView { @@ -193,6 +197,10 @@ class BoltView { $db = BoltDb::get(); return $db->enum('bolt_view', 'BoltView', $clause); } + static function delete_aux($clause) { + $db = BoltDb::get(); + $db->delete_aux('bolt_view', $clause); + } } class BoltResult { @@ -210,6 +218,10 @@ class BoltResult { $db = BoltDb::get(); return $db->enum('bolt_result', 'BoltResult', $clause); } + static function delete_aux($clause) { + $db = BoltDb::get(); + $db->delete_aux('bolt_result', $clause); + } } class BoltXsetResult { @@ -227,6 +239,10 @@ class BoltXsetResult { $db = BoltDb::get(); return $db->enum('bolt_xset_result', 'BoltXsetResult', $clause); } + static function delete_aux($clause) { + $db = BoltDb::get(); + $db->delete_aux('bolt_xset_result', $clause); + } } class BoltRefreshRec { @@ -256,6 +272,10 @@ class BoltRefreshRec { $db = BoltDb::get(); $db->update($this, 'bolt_refresh', $clause); } + static function delete_aux($clause) { + $db = BoltDb::get(); + $db->delete_aux('bolt_refresh', $clause); + } } class BoltSelectFinished { @@ -267,6 +287,10 @@ class BoltSelectFinished { $db = BoltDb::get(); return $db->enum('bolt_select_finished', 'BoltSelectFinished', $clause); } + static function delete_aux($clause) { + $db = BoltDb::get(); + $db->delete_aux('bolt_select_finished', $clause); + } } class BoltQuestion { @@ -278,6 +302,10 @@ class BoltQuestion { $db = BoltDb::get(); return $db->enum('bolt_question', 'BoltQuestion', $clause); } + static function delete_aux($clause) { + $db = BoltDb::get(); + $db->delete_aux('bolt_question', $clause); + } } // TODO: move this somewhere else, and think about whether it's correct diff --git a/html/inc/bolt_util.inc b/html/inc/bolt_util.inc index 58df693d6e..54a9993441 100644 --- a/html/inc/bolt_util.inc +++ b/html/inc/bolt_util.inc @@ -461,12 +461,12 @@ function empty_row() { function show_refresh($r) { echo " - ".time_str($r->create_time)." - $r->name - course_id&refresh_id=$r->id&action=start>Start - course_id&refresh_id=$r->id&action=resume>Resume - + $r->name ".time_str($r->due_time)." + + course_id&refresh_id=$r->id&action=start>Start + | course_id&refresh_id=$r->id&action=resume>Resume + "; } @@ -478,7 +478,7 @@ function show_refreshes() { $refreshes = BoltRefreshRec::enum("user_id=$user->id and course_id=$course->id"); if (!count($refreshes)) return; start_table(); - table_header("Created", "Unit", "Due"); + echo "Refresh schedule\n"; foreach ($refreshes as $r) { show_refresh($r); } diff --git a/html/ops/bolt_admin.php b/html/ops/bolt_admin.php index 9e12416abf..55666149e0 100644 --- a/html/ops/bolt_admin.php +++ b/html/ops/bolt_admin.php @@ -34,6 +34,7 @@ function show_course($course) { } else { show_button("bolt_admin.php?action=hide&course_id=$course->id", "Hide", "Hide this course"); } + show_button("bolt_admin.php?action=clear_confirm&course_id=$course->id", "Clear data", "Clear student data for this course"); echo ""; } @@ -90,6 +91,37 @@ function show_all() { admin_page_tail(); } +function clear_confirm() { + global $course_id; + + admin_page_head("Bolt course administration"); + echo "This will clear all student data for this course. + This is irrevocable. + Are you sure you want to do this? +

+ Yes + "; + admin_page_tail(); +} + +function clear() { + global $course_id; + + admin_page_head("Deleting course data"); + BoltEnrollment::delete_aux("course_id = $course_id"); + BoltView::delete_aux("course_id = $course_id"); + BoltResult::delete_aux("course_id = $course_id"); + BoltXsetResult::delete_aux("course_id = $course_id"); + BoltSelectFinished::delete_aux("course_id = $course_id"); + BoltRefreshRec::delete_aux("course_id = $course_id"); + BoltQuestion::delete_aux("course_id = $course_id"); + + echo " + Course data deleted. + "; + admin_page_tail(); +} + $user = get_logged_in_user(); $db = BoltDb::get(); @@ -152,6 +184,12 @@ case 'unhide': $course->update("hidden=0"); Header('Location: bolt_admin.php'); break; +case 'clear_confirm': + clear_confirm(); + break; +case 'clear': + clear(); + break; case '': show_all(); break; diff --git a/html/user/bolt.php b/html/user/bolt.php index 497a84b278..9d5f056d57 100644 --- a/html/user/bolt.php +++ b/html/user/bolt.php @@ -51,7 +51,7 @@ foreach ($courses as $course) { "; } $status .= "
id&action=start>Restart -
id>History + | id>History "; } else { $status = " diff --git a/html/user/bolt_course.php b/html/user/bolt_course.php index 66f44a5309..9ba8a94aad 100644 --- a/html/user/bolt_course.php +++ b/html/user/bolt_course.php @@ -62,7 +62,8 @@ function show_view($view) { if ($view->result_id) { $result = BoltResult::lookup_id($view->result_id); $qs = str_replace("action=answer", "action=answer_page", $result->response); - $x = "
Score: $result->score + $score = number_format($result->score*100); + $x = "
Score: $score%
Answer page"; } echo " @@ -83,7 +84,7 @@ function show_views() { global $user; global $course; - $views = BoltView::enum("user_id=$user->id and course_id=$course->id order by id desc"); + $views = BoltView::enum("user_id=$user->id and course_id=$course->id order by id"); start_table(); table_header("ID", "Time", "Duration", "Item", "Mode", diff --git a/html/user/bolt_sched.php b/html/user/bolt_sched.php index c812f517a6..de5a39d2dc 100644 --- a/html/user/bolt_sched.php +++ b/html/user/bolt_sched.php @@ -288,7 +288,7 @@ function start_repeat() { global $refresh; $xset_result = BoltXsetResult::lookup_id($refresh->xset_result_id); - if (!$xset_result) error_page("result not found"); + if (!$xset_result) error_page("Exercise set result not found"); $view = BoltView::lookup_id($xset_result->view_id); if (!$view) error_page("view not found"); $iter = new BoltIter($course_doc);