Skip to content
Browse files

use while loop instead of foreach loop during regrade, to allow for t…

…he possibility of splitting a regrade and so avoid "maximum execution time exceeded" errors
  • Loading branch information...
1 parent b8584ba commit 76a72c55b8387181370b80d497358533579106af gbateson committed Sep 27, 2005
Showing with 16 additions and 3 deletions.
  1. +16 −3 mod/hotpot/index.php
View
19 mod/hotpot/index.php
@@ -150,17 +150,30 @@
if ($attempts = get_records_select('hotpot_attempts', $select)) {
// start counter and timer
- $count = 0;
$start = microtime();
- foreach ($attempts as $attempt) {
- $attempt->details = get_field('hotpot_details', 'details', 'attempt', "$attempt->id");
+ $count = 0;
+
+ // use while loop instead of foreach loop
+ // to allow the possibility of splitting a regrade
+ // and so avoid "maximum script time exceeded" errors
+ $attemptids = array_keys($attempts);
+ $i_max = count($attemptids);
+ $i = 0;
+ while ($i<$i_max) {
+
+ $attemptid = $attemptids[$i];
+ $attempt =&$attempts[$attemptid];
+
+ $attempt->details = get_field('hotpot_details', 'details', 'attempt', $attemptid);
if ($attempt->details) {
+
hotpot_add_attempt_details($attempt);
if (! update_record('hotpot_attempts', $attempt)) {
error("Could not update attempt record: ".$db->ErrorMsg(), $next_url);
}
}
$count++;
+ $i++;
}
if ($count) {
notify(get_string('added', 'moodle', "$count x ".get_string('attempts', 'quiz')));

0 comments on commit 76a72c5

Please sign in to comment.
Something went wrong with that request. Please try again.