Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[BugFix] Bug #4174 - Lesson Essay Question Can't be Graded when attem…

…pt not finished
  • Loading branch information...
commit f0ebc0976fc349f136d39df9456154cfd5760378 1 parent c200adc
michaelpenne authored
Showing with 18 additions and 1 deletion.
  1. +18 −1 mod/lesson/view.php
View
19 mod/lesson/view.php
@@ -1153,10 +1153,17 @@
$a = new stdClass;
$a->notgradedcount = 0;
$a->notsentcount = 0;
- foreach ($studentessays as $pages) { // students
+ foreach ($studentessays as $studentid => $pages) { // students
+ $attempts = count_records('lesson_grades', 'userid', $studentid, 'lessonid', $lesson->id);
+ $count = 0;
foreach ($pages as $tries) { // pages
// go through each essay per page
foreach($tries as $try) { // actual attempts
+ if ($attempts == $count) {
+ break; // dont count unfinnished attempts
+ }
+ $count++;
+
// make sure they didn't answer it more than the max number of attmepts
if (count($try) > $lesson->maxattempts) {
$essay = $try[$lesson->maxattempts-1];
@@ -1616,10 +1623,20 @@
foreach ($studentids as $id) {
$studentname = $users[$id]->lastname.", ".$users[$id]->firstname;
$essaylinks = array();
+
+ // number of attempts on the lesson
+ $attempts = count_records('lesson_grades', 'userid', $id, 'lessonid', $lesson->id);
+ $count = 0;
+
// go through each essay
foreach ($studentessays[$id] as $page => $tries) {
// go through each essay per page
foreach($tries as $try) {
+ if ($count == $attempts) {
+ break; // stop displaying essays (attempt not completed)
+ }
+ $count++;
+
// make sure they didn't answer it more than the max number of attmepts
if (count($try) > $lesson->maxattempts) {
$essay = $try[$lesson->maxattempts-1];
Please sign in to comment.
Something went wrong with that request. Please try again.