svn path=/trunk/boinc/; revision=15921

This commit is contained in:
David Anderson 2008-08-21 23:24:11 +00:00
parent c7695c1812
commit 1d99bfec2b
7 changed files with 91 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -461,12 +461,12 @@ function empty_row() {
function show_refresh($r) {
echo "<tr>
<td>".time_str($r->create_time)."</td>
<td>$r->name
<a href=bolt_sched.php?course_id=$r->course_id&refresh_id=$r->id&action=start>Start</a>
<a href=bolt_sched.php?course_id=$r->course_id&refresh_id=$r->id&action=resume>Resume</a>
</td>
<td>$r->name</td>
<td>".time_str($r->due_time)."</td>
<td>
<a href=bolt_sched.php?course_id=$r->course_id&refresh_id=$r->id&action=start>Start</a>
| <a href=bolt_sched.php?course_id=$r->course_id&refresh_id=$r->id&action=resume>Resume</a>
</td>
</tr>
";
}
@ -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 "<tr><th colspan=3>Refresh schedule</th></tr>\n";
foreach ($refreshes as $r) {
show_refresh($r);
}

View File

@ -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 "</td></tr>";
}
@ -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?
<p>
<a href=bolt_admin.php?action=clear&course_id=$course_id>Yes</a>
";
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;

View File

@ -51,7 +51,7 @@ foreach ($courses as $course) {
";
}
$status .= "<br><a href=bolt_sched.php?course_id=$course->id&action=start>Restart</a>
<br><a href=bolt_course.php?course_id=$course->id>History</a>
| <a href=bolt_course.php?course_id=$course->id>History</a>
";
} else {
$status = "

View File

@ -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 = "<br>Score: $result->score
$score = number_format($result->score*100);
$x = "<br>Score: $score%
<br><a href=bolt_sched.php?$qs>Answer page</a>";
}
echo "<tr>
@ -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",

View File

@ -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);