/** * * * @param int|null $userid * * @return array An array of group objects keyed by groupid */ public function get_user_groups($userid = null) { global $USER; // assume current user when none specified if (empty($userid)) { $userid = $USER->id; } if (!empty($this->rtq->getRTQ()->grouping)) { return groups_get_all_groups($this->rtq->getCourse()->id, $userid, $this->rtq->getRTQ()->grouping); } else { return array(); // return empty array when there is no grouping } }
/** * Sets the data to the table * */ public function set_data() { global $CFG, $OUTPUT; $download = $this->is_downloading(); $tabledata = $this->get_data(); foreach ($tabledata as $item) { $row = array(); if (!$download) { if ($this->rtq->group_mode()) { $userlink = $item->groupname . ' (<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $item->userid . '&course=' . $this->rtq->getCourse()->id . '">' . $item->takenby . '</a>)'; } else { $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $item->userid . '&course=' . $this->rtq->getCourse()->id . '">' . $item->username . '</a>'; } $row[] = $userlink; } else { if ($this->rtq->group_mode()) { $row[] = $item->groupname . ' (' . $item->takenby . ')'; } else { $row[] = $item->username; } } $row[] = $item->attemptno; $row[] = $item->preview; $row[] = date('m-d-Y H:i:s', $item->timestart); if (!empty($item->timefinish)) { $row[] = date('m-d-Y H:i:s', $item->timefinish); } else { $row[] = ' - '; } $row[] = date('m-d-Y H:i:s', $item->timemodified); $row[] = $item->status; if (is_null($item->grade)) { $totalmark = ' - '; } else { $totalmark = $item->grade . ' / ' . $item->totalgrade; } $row[] = $totalmark; // Add in controls column // view attempt $viewattempturl = new \moodle_url('/mod/activequiz/viewquizattempt.php'); $viewattempturl->param('quizid', $this->rtq->getRTQ()->id); $viewattempturl->param('sessionid', $item->sessionid); $viewattempturl->param('attemptid', $item->attemptid); $viewattemptpix = new \pix_icon('t/preview', 'preview'); $popup = new \popup_action('click', $viewattempturl, 'viewquizattempt'); $actionlink = new \action_link($viewattempturl, '', $popup, array('target' => '_blank'), $viewattemptpix); $row[] = $OUTPUT->render($actionlink); $this->add_data($row); } }
/** * Process a comment for a particular question on an attempt * * @param int $slot * @param \mod_activequiz\activequiz $rtq * * @return bool */ public function process_comment($slot = null, $rtq) { global $DB; // if there is no slot return false if (empty($slot)) { return false; } // Process any data that was submitted. if (data_submitted() && confirm_sesskey()) { if (optional_param('submit', false, PARAM_BOOL) && \question_engine::is_manual_grade_in_range($this->attempt->questionengid, $slot)) { $transaction = $DB->start_delegated_transaction(); $this->quba->process_all_actions(time()); $this->save(); $transaction->allow_commit(); // Trigger event for question manually graded $params = array('objectid' => $this->quba->get_question($slot)->id, 'courseid' => $rtq->getCourse()->id, 'context' => $rtq->getContext(), 'other' => array('rtqid' => $rtq->getRTQ()->id, 'attemptid' => $this->attempt->id, 'slot' => $slot, 'sessionid' => $this->attempt->sessionid)); $event = \mod_activequiz\event\question_manually_graded::create($params); $event->trigger(); return true; } } return false; }