mirror of https://github.com/BOINC/boinc.git
- Finished implemenation of refresh intervals;
added "count" field to DB table to keep track of how many times we've refreshed. - show refresh schedule on main courses page - default for random structure is all units, not 1 svn path=/trunk/boinc/; revision=15846
This commit is contained in:
parent
6b9ede5a56
commit
0e14fa8f9e
|
@ -165,3 +165,25 @@ David August 14 2008
|
|||
user/
|
||||
bolt_sched.php
|
||||
bolt_compare.php
|
||||
|
||||
David August 14 2008
|
||||
- Finished implemenation of refresh intervals;
|
||||
added "count" field to DB table to keep track of how many times
|
||||
we've refreshed.
|
||||
- show refresh schedule on main courses page
|
||||
- default for random structure is all units, not 1
|
||||
|
||||
db/
|
||||
bolt_schema.sql
|
||||
html/
|
||||
inc/
|
||||
bolt_rnd.inc
|
||||
bolt_xset.inc
|
||||
bolt_util.inc
|
||||
ops/
|
||||
bolt_map.php
|
||||
user/
|
||||
bolt.php
|
||||
bolt_course.php
|
||||
bolt_sched.php
|
||||
white.css
|
||||
|
|
|
@ -133,6 +133,8 @@ create table bolt_refresh (
|
|||
-- most recent result for this exercise set
|
||||
due_time integer not null,
|
||||
-- when refresh will be due
|
||||
count integer not null,
|
||||
-- index into intervals array
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ function random() {
|
|||
$args = func_get_args();
|
||||
$units = array();
|
||||
$name = "";
|
||||
$number = 1;
|
||||
$number = 0;
|
||||
foreach ($args as $arg) {
|
||||
if (is_array($arg)) {
|
||||
switch ($arg[0]) {
|
||||
|
@ -66,6 +66,7 @@ function random() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($number == 0) $number = count($units);
|
||||
return new BoltRandom($name, $units, $number);
|
||||
}
|
||||
|
||||
|
|
|
@ -432,4 +432,32 @@ function empty_cell() {
|
|||
return "<td><br></td>";
|
||||
}
|
||||
|
||||
//////////// show refresh schedule //////////////
|
||||
|
||||
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>".time_str($r->due_time)."</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
function show_refreshes() {
|
||||
global $user;
|
||||
global $course;
|
||||
|
||||
$refreshes = BoltRefreshRec::enum("user_id=$user->id and course_id=$course->id");
|
||||
if (!count($refreshes)) return;
|
||||
start_table();
|
||||
table_header("Created", "Unit", "Due");
|
||||
foreach ($refreshes as $r) {
|
||||
show_refresh($r);
|
||||
}
|
||||
end_table();
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -18,14 +18,17 @@
|
|||
|
||||
class BoltExerciseSet extends BoltRandom {
|
||||
public $repeats;
|
||||
function __construct($name, $units, $number, $repeats) {
|
||||
public $refresh;
|
||||
function __construct($name, $units, $number, $repeats, $refresh) {
|
||||
parent::__construct($name, $units, $number);
|
||||
$this->repeats = $repeats;
|
||||
$this->refresh = $refresh;
|
||||
}
|
||||
|
||||
// called when an exercise in this set has just been graded.
|
||||
// - record the score in our state structure
|
||||
// - return a structure saying what navigation info to show:
|
||||
// - return true if this was last exercise in the set
|
||||
// - if so, also return a structure saying what navigation info to show:
|
||||
// - review
|
||||
// - repeat now
|
||||
// - next
|
||||
|
@ -33,7 +36,6 @@ class BoltExerciseSet extends BoltRandom {
|
|||
function xset_callback(&$iter, $score, $view_id, &$avg_score, &$repeat) {
|
||||
global $course;
|
||||
global $user;
|
||||
global $refresh;
|
||||
|
||||
$nav_info = null;
|
||||
$state_rec = $iter->state[$this->name];
|
||||
|
|
|
@ -189,7 +189,6 @@ function get_views($unit, $mode) {
|
|||
function get_results($unit) {
|
||||
global $snap;
|
||||
|
||||
print_r($snap->results);
|
||||
if (array_key_exists($unit->name, $snap->results)) {
|
||||
return filter_array($snap->results[$unit->name]);
|
||||
}
|
||||
|
@ -362,7 +361,7 @@ function show_map() {
|
|||
}
|
||||
echo "
|
||||
<th>Views</th>
|
||||
<th>Outcome</th>
|
||||
<th>Outcome<br><span class=note>Green=Next,<br>Yellow=Back,<br>Red=None</span></th>
|
||||
<th>Score</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
require_once("../inc/bolt_db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/bolt_util.inc");
|
||||
|
||||
page_head("Courses");
|
||||
|
||||
|
@ -57,10 +58,12 @@ foreach ($courses as $course) {
|
|||
<a href=bolt_sched.php?course_id=$course->id&action=start>Start</a>
|
||||
";
|
||||
}
|
||||
row2("<b>$course->name</b>
|
||||
row2_init("<b>$course->name</b>
|
||||
<br><span class=note>$course->description</span>",
|
||||
$status
|
||||
);
|
||||
show_refreshes();
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
end_table();
|
||||
page_tail();
|
||||
|
|
|
@ -95,32 +95,8 @@ function show_views() {
|
|||
end_table();
|
||||
}
|
||||
|
||||
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>".time_str($r->due_time)."</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
function show_refreshes() {
|
||||
global $user;
|
||||
global $course;
|
||||
|
||||
$refreshes = BoltRefreshRec::enum("user_id=$user->id and course_id=$course->id");
|
||||
start_table();
|
||||
table_header("Created", "Unit", "Due");
|
||||
foreach ($refreshes as $r) {
|
||||
show_refresh($r);
|
||||
}
|
||||
end_table();
|
||||
}
|
||||
|
||||
require_once("../inc/bolt_db.inc");
|
||||
require_once("../inc/bolt_util.inc");
|
||||
|
||||
$course_id = get_int('course_id');
|
||||
$course = BoltCourse::lookup_id($course_id);
|
||||
|
|
|
@ -118,7 +118,7 @@ function show_finished_page($view_id, $prev_view_id) {
|
|||
|
||||
function show_refresh_finished() {
|
||||
page_header("Refresh completed");
|
||||
echo "Refresh finished";
|
||||
echo "<a href=bolt.php>Return to courses</a>";
|
||||
page_footer();
|
||||
}
|
||||
|
||||
|
@ -401,6 +401,7 @@ case 'next': // "next" button in lesson or exercise answer page
|
|||
} else {
|
||||
if ($refresh) {
|
||||
show_refresh_finished();
|
||||
$refresh->update('count=count+1');
|
||||
} else {
|
||||
$iter->frac_done = 1;
|
||||
$fin_view_id = create_view($iter, BOLT_MODE_FINISHED, $view_id);
|
||||
|
@ -460,25 +461,34 @@ case 'answer': // submit answer in exercise
|
|||
// If this is part of an exercise set, call its callback function
|
||||
//
|
||||
$repeat = null;
|
||||
if ($iter->xset) {
|
||||
$is_last = $iter->xset->xset_callback($iter, $bolt_ex_score, $view->id, $avg_score, $repeat);
|
||||
$xset = $iter->xset;
|
||||
if ($xset) {
|
||||
$is_last = $xset->xset_callback($iter, $bolt_ex_score, $view->id, $avg_score, $repeat);
|
||||
if ($repeat) $repeat->avg_score = $avg_score;
|
||||
if ($is_last) {
|
||||
// if the exercise set if finished, make or update DB records
|
||||
//
|
||||
$now = time();
|
||||
$xset = $iter->xset;
|
||||
$id = BoltXsetResult::insert("(create_time, user_id, course_id, name, score, view_id) values ($now, $user->id, $course->id, '$xset->name', $avg_score, $view_id)");
|
||||
$due_time = $now + 100000;
|
||||
$refresh = BoltRefreshRec::lookup(
|
||||
"user_id=$user->id and course_id=$course->id and name='$xset->name'"
|
||||
);
|
||||
$refresh = $xset->refresh;
|
||||
if ($refresh) {
|
||||
$refresh->update("create_time=$now, xset_result_id=$id, due_time=$due_time");
|
||||
} else {
|
||||
BoltRefreshRec::insert(
|
||||
"(user_id, course_id, name, create_time, xset_result_id, due_time) values ($user->id, $course->id, '$xset->name', $now, $id, $due_time)"
|
||||
$refresh_rec = BoltRefreshRec::lookup(
|
||||
"user_id=$user->id and course_id=$course->id and name='$xset->name'"
|
||||
);
|
||||
if ($refresh_rec) {
|
||||
$count = $refresh_rec->count;
|
||||
$n = count($refresh->intervals);
|
||||
if ($count >= $n) {
|
||||
$count = $n - 1;
|
||||
}
|
||||
$due_time = time() + $refresh->intervals[$count]*86400;
|
||||
$refresh_rec->update("create_time=$now, xset_result_id=$id, due_time=$due_time");
|
||||
} else {
|
||||
$due_time = time() + $refresh->intervals[0]*86400;
|
||||
BoltRefreshRec::insert(
|
||||
"(user_id, course_id, name, create_time, xset_result_id, due_time, count) values ($user->id, $course->id, '$xset->name', $now, $id, $due_time, 0)"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ table.noborder {
|
|||
th {
|
||||
background-color: #c0c0c0;
|
||||
font-weight: bold;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
td {
|
||||
|
|
Loading…
Reference in New Issue