See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Renderable that initialises the grading "app". 19 * 20 * @package mod_assign 21 * @copyright 2016 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace mod_assign\output; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use renderer_base; 30 use renderable; 31 use templatable; 32 use stdClass; 33 34 /** 35 * Grading app renderable. 36 * 37 * @package mod_assign 38 * @since Moodle 3.1 39 * @copyright 2016 Damyon Wiese 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 */ 42 class grading_app implements templatable, renderable { 43 44 /** 45 * @var $userid - The initial user id. 46 */ 47 public $userid = 0; 48 49 /** 50 * @var $groupid - The initial group id. 51 */ 52 public $groupid = 0; 53 54 /** 55 * @var $assignment - The assignment instance. 56 */ 57 public $assignment = null; 58 59 /** 60 * Constructor for this renderable. 61 * 62 * @param int $userid The user we will open the grading app too. 63 * @param int $groupid If groups are enabled this is the current course group. 64 * @param assign $assignment The assignment class 65 */ 66 public function __construct($userid, $groupid, $assignment) { 67 $this->userid = $userid; 68 $this->groupid = $groupid; 69 $this->assignment = $assignment; 70 user_preference_allow_ajax_update('assign_filter', PARAM_ALPHA); 71 user_preference_allow_ajax_update('assign_workflowfilter', PARAM_ALPHA); 72 user_preference_allow_ajax_update('assign_markerfilter', PARAM_ALPHANUMEXT); 73 $this->participants = $assignment->list_participants_with_filter_status_and_group($groupid); 74 if (!$this->userid && count($this->participants)) { 75 $this->userid = reset($this->participants)->id; 76 } 77 } 78 79 /** 80 * Export this class data as a flat list for rendering in a template. 81 * 82 * @param renderer_base $output The current page renderer. 83 * @return stdClass - Flat list of exported data. 84 */ 85 public function export_for_template(renderer_base $output) { 86 global $CFG, $USER; 87 88 $export = new stdClass(); 89 $export->userid = $this->userid; 90 $export->assignmentid = $this->assignment->get_instance()->id; 91 $export->cmid = $this->assignment->get_course_module()->id; 92 $export->contextid = $this->assignment->get_context()->id; 93 $export->groupid = $this->groupid; 94 $export->name = $this->assignment->get_context()->get_context_name(true, false, false); 95 $export->courseid = $this->assignment->get_course()->id; 96 $export->participants = array(); 97 $export->filters = $this->assignment->get_filters(); 98 $export->markingworkflowfilters = $this->assignment->get_marking_workflow_filters(true); 99 $export->hasmarkingworkflow = count($export->markingworkflowfilters) > 0; 100 $export->markingallocationfilters = $this->assignment->get_marking_allocation_filters(true); 101 $export->hasmarkingallocation = count($export->markingallocationfilters) > 0; 102 103 $num = 1; 104 foreach ($this->participants as $idx => $record) { 105 $user = new stdClass(); 106 $user->id = $record->id; 107 $user->fullname = fullname($record); 108 $user->requiregrading = $record->requiregrading; 109 $user->grantedextension = $record->grantedextension; 110 $user->submitted = $record->submitted; 111 if (!empty($record->groupid)) { 112 $user->groupid = $record->groupid; 113 $user->groupname = $record->groupname; 114 } 115 if ($record->id == $this->userid) { 116 $export->index = $num; 117 $user->current = true; 118 } 119 $export->participants[] = $user; 120 $num++; 121 } 122 123 $feedbackplugins = $this->assignment->get_feedback_plugins(); 124 $showreview = false; 125 foreach ($feedbackplugins as $plugin) { 126 if ($plugin->is_enabled() && $plugin->is_visible()) { 127 if ($plugin->supports_review_panel()) { 128 $showreview = true; 129 } 130 } 131 } 132 133 $export->actiongrading = 'grading'; 134 $export->viewgrading = get_string('viewgrading', 'mod_assign'); 135 136 $export->showreview = $showreview; 137 138 $time = time(); 139 $export->count = count($export->participants); 140 $export->coursename = $this->assignment->get_course_context()->get_context_name(true, false, false); 141 $export->caneditsettings = has_capability('mod/assign:addinstance', $this->assignment->get_context()); 142 $export->duedate = $this->assignment->get_instance()->duedate; 143 $export->duedatestr = userdate($this->assignment->get_instance()->duedate); 144 145 // Time remaining. 146 $due = ''; 147 if ($export->duedate - $time <= 0) { 148 $due = get_string('assignmentisdue', 'assign'); 149 } else { 150 $due = get_string('timeremainingcolon', 'assign', format_time($export->duedate - $time)); 151 } 152 $export->timeremainingstr = $due; 153 154 if ($export->duedate < $time) { 155 $export->cutoffdate = $this->assignment->get_instance()->cutoffdate; 156 $cutoffdate = $export->cutoffdate; 157 if ($cutoffdate) { 158 if ($cutoffdate > $time) { 159 $late = get_string('latesubmissionsaccepted', 'assign', userdate($export->cutoffdate)); 160 } else { 161 $late = get_string('nomoresubmissionsaccepted', 'assign'); 162 } 163 $export->cutoffdatestr = $late; 164 } 165 } 166 167 $export->defaultsendnotifications = $this->assignment->get_instance()->sendstudentnotifications; 168 $export->rarrow = $output->rarrow(); 169 $export->larrow = $output->larrow(); 170 // List of identity fields to display (the user info will not contain any fields the user cannot view anyway). 171 // TODO Does not support custom user profile fields (MDL-70456). 172 $export->showuseridentity = implode(',', \core_user\fields::get_identity_fields(null, false)); 173 $export->currentuserid = $USER->id; 174 $helpicon = new \help_icon('sendstudentnotifications', 'assign'); 175 $export->helpicon = $helpicon->export_for_template($output); 176 return $export; 177 } 178 179 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body