mirror of https://github.com/BOINC/boinc.git
- Detect when a refresh has finished
svn path=/trunk/boinc/; revision=16237
This commit is contained in:
parent
2224b8d906
commit
6dd22eec1c
|
@ -219,3 +219,14 @@ David August 15 2008
|
|||
user/
|
||||
bolt.php
|
||||
bolt_sched.php
|
||||
|
||||
David Oct 20 2008
|
||||
- Detect when a refresh has finished
|
||||
|
||||
html/
|
||||
inc/
|
||||
bolt_util.inc
|
||||
bolt.inc
|
||||
bolt_xset.inc
|
||||
user/
|
||||
bolt_sched.php
|
||||
|
|
|
@ -110,7 +110,7 @@ class BoltSet extends BoltUnit {
|
|||
$this->ordered = false;
|
||||
}
|
||||
|
||||
// restart this unit
|
||||
// restart this unit - set its state record to an initial state
|
||||
//
|
||||
function restart(&$iter) {
|
||||
$state_rec = $iter->state[$this->name];
|
||||
|
|
|
@ -464,8 +464,18 @@ function show_refresh($r) {
|
|||
<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>
|
||||
";
|
||||
if ($r->last_view_id) {
|
||||
echo "
|
||||
<a href=bolt_sched.php?course_id=$r->course_id&refresh_id=$r->id&action=start>Restart</a>
|
||||
| <a href=bolt_sched.php?course_id=$r->course_id&refresh_id=$r->id&action=resume>Resume</a>
|
||||
";
|
||||
} else {
|
||||
echo "
|
||||
<a href=bolt_sched.php?course_id=$r->course_id&refresh_id=$r->id&action=start>Start</a>
|
||||
";
|
||||
}
|
||||
echo "
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
|
|
|
@ -122,11 +122,6 @@ class BoltExerciseSet extends BoltRandom {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function start_repeat(&$iter) {
|
||||
$this->restart($iter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class BoltRefresh{
|
||||
|
|
|
@ -302,7 +302,7 @@ function start_course() {
|
|||
show_item($iter, $view_id, 0, $mode);
|
||||
}
|
||||
|
||||
function start_repeat() {
|
||||
function start_refresh() {
|
||||
global $course_doc;
|
||||
global $refresh;
|
||||
|
||||
|
@ -317,7 +317,7 @@ function start_repeat() {
|
|||
if (!$xset || $xset->name != $xset_result->name) {
|
||||
error_page("missing exercise set");
|
||||
}
|
||||
$xset->start_repeat($iter);
|
||||
$xset->restart($iter);
|
||||
$iter->at();
|
||||
$mode = default_mode($iter->item);
|
||||
$view_id = create_view($iter, $mode, 0);
|
||||
|
@ -352,7 +352,7 @@ case 'start':
|
|||
exit();
|
||||
}
|
||||
if ($refresh) {
|
||||
start_repeat();
|
||||
start_refresh();
|
||||
exit();
|
||||
}
|
||||
$e = BoltEnrollment::lookup($user->id, $course_id);
|
||||
|
@ -412,27 +412,34 @@ case 'next': // "next" button in lesson or exercise answer page
|
|||
|
||||
$iter = new BoltIter($course_doc);
|
||||
$iter->decode_state($view->state);
|
||||
|
||||
$iter->next();
|
||||
|
||||
if ($refresh) {
|
||||
$iter->at();
|
||||
if (!$iter->xset) {
|
||||
// if we're doing a refresh and are no longer in an xset,
|
||||
// we must have finished the refresh
|
||||
//
|
||||
show_refresh_finished();
|
||||
$refresh->update('count=count+1');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($iter->item) {
|
||||
$state = $iter->encode_state();
|
||||
$mode = default_mode($iter->item);
|
||||
$view_id = create_view($iter, $mode, $view->id);
|
||||
show_item($iter, $view_id, $view->id, $mode);
|
||||
} 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);
|
||||
$e = new BoltEnrollment();
|
||||
$e->user_id = $user->id;
|
||||
$e->course_id = $course->id;
|
||||
$e->update("last_view_id=$fin_view_id");
|
||||
show_finished_page($fin_view_id, $view->id);
|
||||
}
|
||||
// course finished
|
||||
$iter->frac_done = 1;
|
||||
$fin_view_id = create_view($iter, BOLT_MODE_FINISHED, $view_id);
|
||||
$e = new BoltEnrollment();
|
||||
$e->user_id = $user->id;
|
||||
$e->course_id = $course->id;
|
||||
$e->update("last_view_id=$fin_view_id");
|
||||
show_finished_page($fin_view_id, $view->id);
|
||||
}
|
||||
break;
|
||||
case 'answer': // submit answer in exercise
|
||||
|
@ -535,6 +542,8 @@ case 'course_home':
|
|||
Header("Location: bolt.php");
|
||||
break;
|
||||
case 'review':
|
||||
// user chose to do review then repeat an exercise set
|
||||
//
|
||||
$view = finalize_view($view_id, BOLT_ACTION_REVIEW);
|
||||
debug_show_state(json_decode($view->state, true), "Initial");
|
||||
$iter = new BoltIter($course_doc);
|
||||
|
@ -555,6 +564,8 @@ case 'review':
|
|||
show_item($iter, $view_id, $view->id, $mode);
|
||||
break;
|
||||
case 'repeat':
|
||||
// user chose to repeat an exercise set
|
||||
//
|
||||
$view = finalize_view($view_id, BOLT_ACTION_REPEAT);
|
||||
debug_show_state(json_decode($view->state, true), "Initial");
|
||||
$iter = new BoltIter($course_doc);
|
||||
|
@ -564,23 +575,20 @@ case 'repeat':
|
|||
echo "NO XSET"; exit;
|
||||
}
|
||||
$xset = $iter->xset;
|
||||
$xset->start_repeat($iter);
|
||||
$xset->restart($iter);
|
||||
$iter->at();
|
||||
$mode = default_mode($iter->item);
|
||||
$view_id = create_view($iter, $mode, $view->id);
|
||||
show_item($iter, $view_id, $view->id, $mode);
|
||||
break;
|
||||
case 'refresh':
|
||||
$refresh_id = get_int('refresh_id');
|
||||
$refresh = BoltRefreshRec::lookup_id($refresh_id);
|
||||
if (!$refresh) error_page("refresh not found");
|
||||
// fall through
|
||||
case 'resume':
|
||||
// user chose to resume a course or refresh
|
||||
//
|
||||
if ($refresh) {
|
||||
if ($refresh->last_view_id) {
|
||||
$view = BoltView::lookup_id($refresh->last_view_id);
|
||||
} else {
|
||||
start_repeat();
|
||||
start_refresh();
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue