diff --git a/bolt_checkin_notes.txt b/bolt_checkin_notes.txt
index cfe412185e..f80f089d3d 100644
--- a/bolt_checkin_notes.txt
+++ b/bolt_checkin_notes.txt
@@ -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
diff --git a/db/bolt_schema.sql b/db/bolt_schema.sql
index 37e5bee249..63c35f5c61 100644
--- a/db/bolt_schema.sql
+++ b/db/bolt_schema.sql
@@ -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)
);
diff --git a/html/inc/bolt_rnd.inc b/html/inc/bolt_rnd.inc
index da0807dc07..35bd7c030d 100644
--- a/html/inc/bolt_rnd.inc
+++ b/html/inc/bolt_rnd.inc
@@ -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);
}
diff --git a/html/inc/bolt_util.inc b/html/inc/bolt_util.inc
index 4542b6f447..f1bdba43df 100644
--- a/html/inc/bolt_util.inc
+++ b/html/inc/bolt_util.inc
@@ -432,4 +432,32 @@ function empty_cell() {
return "
| ";
}
+//////////// show refresh schedule //////////////
+
+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
+ |
+ ".time_str($r->due_time)." |
+
+ ";
+}
+
+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();
+}
+
?>
diff --git a/html/inc/bolt_xset.inc b/html/inc/bolt_xset.inc
index e2b711371c..36ff8e9553 100644
--- a/html/inc/bolt_xset.inc
+++ b/html/inc/bolt_xset.inc
@@ -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];
diff --git a/html/ops/bolt_map.php b/html/ops/bolt_map.php
index 101f8fa11e..1d53397ec2 100644
--- a/html/ops/bolt_map.php
+++ b/html/ops/bolt_map.php
@@ -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 "
Views |
- Outcome |
+ Outcome Green=Next, Yellow=Back, Red=None |
Score |
Time |
diff --git a/html/user/bolt.php b/html/user/bolt.php
index be735012b7..497a84b278 100644
--- a/html/user/bolt.php
+++ b/html/user/bolt.php
@@ -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) {
id&action=start>Start
";
}
- row2("$course->name
+ row2_init("$course->name
$course->description",
$status
);
+ show_refreshes();
+ echo "\n";
}
end_table();
page_tail();
diff --git a/html/user/bolt_course.php b/html/user/bolt_course.php
index 78d0dfc564..66f44a5309 100644
--- a/html/user/bolt_course.php
+++ b/html/user/bolt_course.php
@@ -95,32 +95,8 @@ function show_views() {
end_table();
}
-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
- |
- ".time_str($r->due_time)." |
-
- ";
-}
-
-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);
diff --git a/html/user/bolt_sched.php b/html/user/bolt_sched.php
index e76b4ebab7..6cf0eb8bca 100644
--- a/html/user/bolt_sched.php
+++ b/html/user/bolt_sched.php
@@ -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 "Return to courses";
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)"
+ );
+ }
}
}
}
diff --git a/html/user/white.css b/html/user/white.css
index 5806d4c109..8760299224 100644
--- a/html/user/white.css
+++ b/html/user/white.css
@@ -50,6 +50,7 @@ table.noborder {
th {
background-color: #c0c0c0;
font-weight: bold;
+ vertical-align: top;
}
td {