/**
  * Format a column of data for display.
  *
  * @param stdClass $row
  * @return string
  */
 public function col_userid(stdClass $row)
 {
     global $USER;
     $edit = '';
     $actions = array();
     $urlparams = array('id' => $this->seplment->get_course_module()->id, 'rownum' => $this->rownum, 'action' => 'grade');
     $url = new moodle_url('/mod/sepl/view.php', $urlparams);
     $noimage = null;
     if (!$row->grade) {
         $description = get_string('grade');
     } else {
         $description = get_string('updategrade', 'sepl');
     }
     $actions['grade'] = new action_menu_link_secondary($url, $noimage, $description);
     // Everything we need is in the row.
     $submission = $row;
     $flags = $row;
     if ($this->seplment->get_instance()->teamsubmission) {
         // Use the cache for this.
         $submission = false;
         $group = false;
         $this->get_group_and_submission($row->id, $group, $submission, -1);
     }
     $submissionsopen = $this->seplment->submissions_open($row->id, true, $submission, $flags, $this->gradinginfo);
     $caneditsubmission = $this->seplment->can_edit_submission($row->id, $USER->id);
     // Hide for offline seplments.
     if ($this->seplment->is_any_submission_plugin_enabled()) {
         if (!$row->status || $row->status == ASSIGN_SUBMISSION_STATUS_DRAFT || !$this->seplment->get_instance()->submissiondrafts) {
             if (!$row->locked) {
                 $urlparams = array('id' => $this->seplment->get_course_module()->id, 'userid' => $row->id, 'action' => 'lock', 'sesskey' => sesskey(), 'page' => $this->currpage);
                 $url = new moodle_url('/mod/sepl/view.php', $urlparams);
                 $description = get_string('preventsubmissionsshort', 'sepl');
                 $actions['lock'] = new action_menu_link_secondary($url, $noimage, $description);
             } else {
                 $urlparams = array('id' => $this->seplment->get_course_module()->id, 'userid' => $row->id, 'action' => 'unlock', 'sesskey' => sesskey(), 'page' => $this->currpage);
                 $url = new moodle_url('/mod/sepl/view.php', $urlparams);
                 $description = get_string('allowsubmissionsshort', 'sepl');
                 $actions['unlock'] = new action_menu_link_secondary($url, $noimage, $description);
             }
         }
         if ($submissionsopen && $USER->id != $row->id && $caneditsubmission) {
             $urlparams = array('id' => $this->seplment->get_course_module()->id, 'userid' => $row->id, 'action' => 'editsubmission', 'sesskey' => sesskey(), 'page' => $this->currpage);
             $url = new moodle_url('/mod/sepl/view.php', $urlparams);
             $description = get_string('editsubmission', 'sepl');
             $actions['editsubmission'] = new action_menu_link_secondary($url, $noimage, $description);
         }
     }
     if (($this->seplment->get_instance()->duedate || $this->seplment->get_instance()->cutoffdate) && $this->hasgrantextension) {
         $urlparams = array('id' => $this->seplment->get_course_module()->id, 'userid' => $row->id, 'action' => 'grantextension', 'sesskey' => sesskey(), 'page' => $this->currpage);
         $url = new moodle_url('/mod/sepl/view.php', $urlparams);
         $description = get_string('grantextension', 'sepl');
         $actions['grantextension'] = new action_menu_link_secondary($url, $noimage, $description);
     }
     if ($row->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED && $this->seplment->get_instance()->submissiondrafts) {
         $urlparams = array('id' => $this->seplment->get_course_module()->id, 'userid' => $row->id, 'action' => 'reverttodraft', 'sesskey' => sesskey(), 'page' => $this->currpage);
         $url = new moodle_url('/mod/sepl/view.php', $urlparams);
         $description = get_string('reverttodraftshort', 'sepl');
         $actions['reverttodraft'] = new action_menu_link_secondary($url, $noimage, $description);
     }
     if ($row->status == ASSIGN_SUBMISSION_STATUS_DRAFT && $this->seplment->get_instance()->submissiondrafts && $caneditsubmission && $submissionsopen && $row->id != $USER->id) {
         $urlparams = array('id' => $this->seplment->get_course_module()->id, 'userid' => $row->id, 'action' => 'submitotherforgrading', 'sesskey' => sesskey(), 'page' => $this->currpage);
         $url = new moodle_url('/mod/sepl/view.php', $urlparams);
         $description = get_string('submitforgrading', 'sepl');
         $actions['submitforgrading'] = new action_menu_link_secondary($url, $noimage, $description);
     }
     $ismanual = $this->seplment->get_instance()->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL;
     $hassubmission = !empty($row->status);
     $notreopened = $hassubmission && $row->status != ASSIGN_SUBMISSION_STATUS_REOPENED;
     $isunlimited = $this->seplment->get_instance()->maxattempts == ASSIGN_UNLIMITED_ATTEMPTS;
     $hasattempts = $isunlimited || $row->attemptnumber < $this->seplment->get_instance()->maxattempts - 1;
     if ($ismanual && $hassubmission && $notreopened && $hasattempts) {
         $urlparams = array('id' => $this->seplment->get_course_module()->id, 'userid' => $row->id, 'action' => 'addattempt', 'sesskey' => sesskey(), 'page' => $this->currpage);
         $url = new moodle_url('/mod/sepl/view.php', $urlparams);
         $description = get_string('addattempt', 'sepl');
         $actions['addattempt'] = new action_menu_link_secondary($url, $noimage, $description);
     }
     $menu = new action_menu();
     $menu->set_owner_selector('.gradingtable-actionmenu');
     $menu->set_alignment(action_menu::TL, action_menu::BL);
     $menu->set_constraint('.gradingtable > .no-overflow');
     $menu->set_menu_trigger(get_string('edit'));
     foreach ($actions as $action) {
         $menu->add($action);
     }
     // Prioritise the menu ahead of all other actions.
     $menu->prioritise = true;
     $edit .= $this->output->render($menu);
     return $edit;
 }
Пример #2
0
 public function testable_submissions_open($userid = 0)
 {
     return parent::submissions_open($userid);
 }