Merge branch 'MDL-42495-m' of git://github.com/micaherne/moodle
authorDamyon Wiese <damyon@moodle.com>
Mon, 20 Jan 2014 05:21:58 +0000 (13:21 +0800)
committerDamyon Wiese <damyon@moodle.com>
Mon, 20 Jan 2014 05:21:58 +0000 (13:21 +0800)
1  2 
mod/lesson/essay.php

diff --combined mod/lesson/essay.php
@@@ -243,6 -243,8 +243,6 @@@ switch ($mode) 
                  $essayinfo->sent = 1;
                  $attempt->useranswer = serialize($essayinfo);
                  $DB->update_record('lesson_attempts', $attempt);
 -                // Log it
 -                add_to_log($course->id, 'lesson', 'update email essay grade', "essay.php?id=$cm->id", format_string($pages[$attempt->pageid]->title,true).': '.fullname($users[$attempt->userid]), $cm->id);
              }
          }
          $lesson->add_message(get_string('emailsuccess', 'lesson'), 'notifysuccess');
                  $ufields = user_picture::fields('u');
                  list($sort, $sortparams) = users_order_by_sql('u');
                  $params = array_merge($params, $sortparams);
-                 if (!empty($cm->groupingid)) {
-                     $params["groupingid"] = $cm->groupingid;
-                     $sql = "SELECT DISTINCT $ufields
-                             FROM {lesson_attempts} a
-                                 INNER JOIN {user} u ON u.id = a.userid
-                                 INNER JOIN {groups_members} gm ON gm.userid = u.id
-                                 INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid AND gg.groupingid = :groupingid
-                             WHERE a.lessonid = :lessonid
-                             ORDER BY $sort";
-                 } else {
-                     $sql = "SELECT DISTINCT $ufields
-                             FROM {user} u,
-                                  {lesson_attempts} a
-                             WHERE a.lessonid = :lessonid and
-                                   u.id = a.userid
-                             ORDER BY $sort";
-                 }
+                 $sql = "SELECT DISTINCT $ufields
+                         FROM {user} u,
+                              {lesson_attempts} a
+                         WHERE a.lessonid = :lessonid and
+                               u.id = a.userid
+                         ORDER BY $sort";
                  if (!$users = $DB->get_records_sql($sql, $params)) {
                      $mode = 'none'; // not displaying anything
                      $lesson->add_message(get_string('noonehasanswered', 'lesson'));
          }
          break;
  }
 -// Log it
 -add_to_log($course->id, 'lesson', 'view grade', "essay.php?id=$cm->id", get_string('manualgrading', 'lesson'), $cm->id);
  
  $lessonoutput = $PAGE->get_renderer('mod_lesson');
  echo $lessonoutput->header($lesson, $cm, 'essay', false, null, get_string('manualgrading', 'lesson'));
@@@ -380,16 -373,6 +369,16 @@@ switch ($mode) 
          echo html_writer::table($table);
          break;
      case 'grade':
 +        // Trigger the essay grade viewed event.
 +        $event = \mod_lesson\event\essay_attempt_viewed::create(array(
 +            'objectid' => $attempt->id,
 +            'relateduserid' => $attempt->userid,
 +            'context' => $context,
 +            'courseid' => $course->id,
 +        ));
 +        $event->add_record_snapshot('lesson_attempts', $attempt);
 +        $event->trigger();
 +
          // Grading form
          // Expects the following to be set: $attemptid, $answer, $user, $page, $attempt
          $essayinfo = unserialize($attempt->useranswer);