[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 $this->participants = $assignment->list_participants_with_filter_status_and_group($groupid); 71 if (!$this->userid && count($this->participants)) { 72 $this->userid = reset($this->participants)->id; 73 } 74 } 75 76 /** 77 * Export this class data as a flat list for rendering in a template. 78 * 79 * @param renderer_base $output The current page renderer. 80 * @return stdClass - Flat list of exported data. 81 */ 82 public function export_for_template(renderer_base $output) { 83 global $CFG; 84 85 $export = new stdClass(); 86 $export->userid = $this->userid; 87 $export->assignmentid = $this->assignment->get_instance()->id; 88 $export->cmid = $this->assignment->get_course_module()->id; 89 $export->contextid = $this->assignment->get_context()->id; 90 $export->groupid = $this->groupid; 91 $export->name = $this->assignment->get_instance()->name; 92 $export->courseid = $this->assignment->get_course()->id; 93 $export->participants = array(); 94 $num = 1; 95 foreach ($this->participants as $idx => $record) { 96 $user = new stdClass(); 97 $user->id = $record->id; 98 $user->fullname = fullname($record); 99 $user->requiregrading = $record->requiregrading; 100 $user->submitted = $record->submitted; 101 if (!empty($record->groupid)) { 102 $user->groupid = $record->groupid; 103 $user->groupname = $record->groupname; 104 } 105 if ($record->id == $this->userid) { 106 $export->index = $num; 107 $user->current = true; 108 } 109 $export->participants[] = $user; 110 $num++; 111 } 112 113 $feedbackplugins = $this->assignment->get_feedback_plugins(); 114 $showreview = false; 115 foreach ($feedbackplugins as $plugin) { 116 if ($plugin->is_enabled() && $plugin->is_visible()) { 117 if ($plugin->supports_review_panel()) { 118 $showreview = true; 119 } 120 } 121 } 122 123 $export->showreview = $showreview; 124 125 $time = time(); 126 $export->count = count($export->participants); 127 $export->coursename = $this->assignment->get_course_context()->get_context_name(); 128 $export->caneditsettings = has_capability('mod/assign:addinstance', $this->assignment->get_context()); 129 $export->duedate = $this->assignment->get_instance()->duedate; 130 $export->duedatestr = userdate($this->assignment->get_instance()->duedate); 131 132 // Time remaining. 133 $due = ''; 134 if ($export->duedate - $time <= 0) { 135 $due = get_string('assignmentisdue', 'assign'); 136 } else { 137 $due = get_string('timeremainingcolon', 'assign', format_time($export->duedate - $time)); 138 } 139 $export->timeremainingstr = $due; 140 141 if ($export->duedate < $time) { 142 $export->cutoffdate = $this->assignment->get_instance()->cutoffdate; 143 $cutoffdate = $export->cutoffdate; 144 if ($cutoffdate) { 145 if ($cutoffdate > $time) { 146 $late = get_string('latesubmissionsaccepted', 'assign', userdate($export->cutoffdate)); 147 } else { 148 $late = get_string('nomoresubmissionsaccepted', 'assign'); 149 } 150 $export->cutoffdatestr = $late; 151 } 152 } 153 154 $export->defaultsendnotifications = $this->assignment->get_instance()->sendstudentnotifications; 155 $export->rarrow = $output->rarrow(); 156 $export->larrow = $output->larrow(); 157 // List of identity fields to display (the user info will not contain any fields the user cannot view anyway). 158 $export->showuseridentity = $CFG->showuseridentity; 159 160 return $export; 161 } 162 163 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |