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 "
+ 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 "