2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * This file contains the definition for the renderable classes for the assignment
21 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
28 * This class wraps the submit for grading confirmation page
30 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 class assign_submit_for_grading_page
implements renderable
{
34 /** @var array $notifications is a list of notification messages returned from the plugins */
35 public $notifications = array();
36 /** @var int $coursemoduleid */
37 public $coursemoduleid = 0;
38 /** @var moodleform $confirmform */
39 public $confirmform = null;
43 * @param string $notifications - Any mesages to display
44 * @param int $coursemoduleid
45 * @param moodleform $confirmform
47 public function __construct($notifications, $coursemoduleid, $confirmform) {
48 $this->notifications
= $notifications;
49 $this->coursemoduleid
= $coursemoduleid;
50 $this->confirmform
= $confirmform;
56 * Implements a renderable message notification
58 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
59 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
61 class assign_gradingmessage
implements renderable
{
62 /** @var string $heading is the heading to display to the user */
64 /** @var string $message is the message to display to the user */
66 /** @var int $coursemoduleid */
67 public $coursemoduleid = 0;
68 /** @var int $gradingerror should be set true if there was a problem grading */
69 public $gradingerror = null;
73 * @param string $heading This is the heading to display
74 * @param string $message This is the message to display
75 * @param bool $gradingerror Set to true to display the message as an error.
76 * @param int $coursemoduleid
77 * @param int $page This is the current quick grading page
79 public function __construct($heading, $message, $coursemoduleid, $gradingerror = false, $page = null) {
80 $this->heading
= $heading;
81 $this->message
= $message;
82 $this->coursemoduleid
= $coursemoduleid;
83 $this->gradingerror
= $gradingerror;
90 * Implements a renderable grading options form
92 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
93 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
95 class assign_form
implements renderable
{
96 /** @var moodleform $form is the edit submission form */
98 /** @var string $classname is the name of the class to assign to the container */
99 public $classname = '';
100 /** @var string $jsinitfunction is an optional js function to add to the page requires */
101 public $jsinitfunction = '';
105 * @param string $classname This is the class name for the container div
106 * @param moodleform $form This is the moodleform
107 * @param string $jsinitfunction This is an optional js function to add to the page requires
109 public function __construct($classname, moodleform
$form, $jsinitfunction = '') {
110 $this->classname
= $classname;
112 $this->jsinitfunction
= $jsinitfunction;
118 * Implements a renderable user summary
119 * @package mod_assign
120 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
121 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
123 class assign_user_summary
implements renderable
{
124 /** @var stdClass $user suitable for rendering with user_picture and fullname(). */
126 /** @var int $courseid */
128 /** @var bool $viewfullnames */
129 public $viewfullnames = false;
130 /** @var bool $blindmarking */
131 public $blindmarking = false;
132 /** @var int $uniqueidforuser */
133 public $uniqueidforuser;
134 /** @var array $extrauserfields */
135 public $extrauserfields;
136 /** @var bool $suspendeduser */
137 public $suspendeduser;
141 * @param stdClass $user
142 * @param int $courseid
143 * @param bool $viewfullnames
144 * @param bool $blindmarking
145 * @param int $uniqueidforuser
146 * @param array $extrauserfields
147 * @param bool $suspendeduser
149 public function __construct(stdClass
$user,
155 $suspendeduser = false) {
157 $this->courseid
= $courseid;
158 $this->viewfullnames
= $viewfullnames;
159 $this->blindmarking
= $blindmarking;
160 $this->uniqueidforuser
= $uniqueidforuser;
161 $this->extrauserfields
= $extrauserfields;
162 $this->suspendeduser
= $suspendeduser;
167 * Implements a renderable feedback plugin feedback
168 * @package mod_assign
169 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
170 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
172 class assign_feedback_plugin_feedback
implements renderable
{
173 /** @var int SUMMARY */
178 /** @var assign_submission_plugin $plugin */
179 public $plugin = null;
180 /** @var stdClass $grade */
181 public $grade = null;
182 /** @var string $view */
183 public $view = self
::SUMMARY
;
184 /** @var int $coursemoduleid */
185 public $coursemoduleid = 0;
186 /** @var string returnaction The action to take you back to the current page */
187 public $returnaction = '';
188 /** @var array returnparams The params to take you back to the current page */
189 public $returnparams = array();
192 * Feedback for a single plugin
194 * @param assign_feedback_plugin $plugin
195 * @param stdClass $grade
196 * @param string $view one of feedback_plugin::SUMMARY or feedback_plugin::FULL
197 * @param int $coursemoduleid
198 * @param string $returnaction The action required to return to this page
199 * @param array $returnparams The params required to return to this page
201 public function __construct(assign_feedback_plugin
$plugin,
207 $this->plugin
= $plugin;
208 $this->grade
= $grade;
210 $this->coursemoduleid
= $coursemoduleid;
211 $this->returnaction
= $returnaction;
212 $this->returnparams
= $returnparams;
218 * Implements a renderable submission plugin submission
219 * @package mod_assign
220 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
221 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
223 class assign_submission_plugin_submission
implements renderable
{
224 /** @var int SUMMARY */
229 /** @var assign_submission_plugin $plugin */
230 public $plugin = null;
231 /** @var stdClass $submission */
232 public $submission = null;
233 /** @var string $view */
234 public $view = self
::SUMMARY
;
235 /** @var int $coursemoduleid */
236 public $coursemoduleid = 0;
237 /** @var string returnaction The action to take you back to the current page */
238 public $returnaction = '';
239 /** @var array returnparams The params to take you back to the current page */
240 public $returnparams = array();
244 * @param assign_submission_plugin $plugin
245 * @param stdClass $submission
246 * @param string $view one of submission_plugin::SUMMARY, submission_plugin::FULL
247 * @param int $coursemoduleid - the course module id
248 * @param string $returnaction The action to return to the current page
249 * @param array $returnparams The params to return to the current page
251 public function __construct(assign_submission_plugin
$plugin,
252 stdClass
$submission,
257 $this->plugin
= $plugin;
258 $this->submission
= $submission;
260 $this->coursemoduleid
= $coursemoduleid;
261 $this->returnaction
= $returnaction;
262 $this->returnparams
= $returnparams;
267 * Renderable feedback status
268 * @package mod_assign
269 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
270 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
272 class assign_feedback_status
implements renderable
{
274 /** @var stding $gradefordisplay the student grade rendered into a format suitable for display */
275 public $gradefordisplay = '';
276 /** @var mixed the graded date (may be null) */
277 public $gradeddate = 0;
278 /** @var mixed the grader (may be null) */
279 public $grader = null;
280 /** @var array feedbackplugins - array of feedback plugins */
281 public $feedbackplugins = array();
282 /** @var stdClass assign_grade record */
283 public $grade = null;
284 /** @var int coursemoduleid */
285 public $coursemoduleid = 0;
286 /** @var string returnaction */
287 public $returnaction = '';
288 /** @var array returnparams */
289 public $returnparams = array();
293 * @param string $gradefordisplay
294 * @param mixed $gradeddate
295 * @param mixed $grader
296 * @param array $feedbackplugins
297 * @param mixed $grade
298 * @param int $coursemoduleid
299 * @param string $returnaction The action required to return to this page
300 * @param array $returnparams The list of params required to return to this page
302 public function __construct($gradefordisplay,
310 $this->gradefordisplay
= $gradefordisplay;
311 $this->gradeddate
= $gradeddate;
312 $this->grader
= $grader;
313 $this->feedbackplugins
= $feedbackplugins;
314 $this->grade
= $grade;
315 $this->coursemoduleid
= $coursemoduleid;
316 $this->returnaction
= $returnaction;
317 $this->returnparams
= $returnparams;
322 * Renderable submission status
323 * @package mod_assign
324 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
325 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
327 class assign_submission_status
implements renderable
{
328 /** @var int STUDENT_VIEW */
329 const STUDENT_VIEW
= 10;
330 /** @var int GRADER_VIEW */
331 const GRADER_VIEW
= 20;
333 /** @var int allowsubmissionsfromdate */
334 public $allowsubmissionsfromdate = 0;
335 /** @var bool alwaysshowdescription */
336 public $alwaysshowdescription = false;
337 /** @var stdClass the submission info (may be null) */
338 public $submission = null;
339 /** @var boolean teamsubmissionenabled - true or false */
340 public $teamsubmissionenabled = false;
341 /** @var stdClass teamsubmission the team submission info (may be null) */
342 public $teamsubmission = null;
343 /** @var stdClass submissiongroup the submission group info (may be null) */
344 public $submissiongroup = null;
345 /** @var array submissiongroupmemberswhoneedtosubmit list of users who still need to submit */
346 public $submissiongroupmemberswhoneedtosubmit = array();
347 /** @var bool submissionsenabled */
348 public $submissionsenabled = false;
349 /** @var bool locked */
350 public $locked = false;
351 /** @var bool graded */
352 public $graded = false;
353 /** @var int duedate */
355 /** @var int cutoffdate */
356 public $cutoffdate = 0;
357 /** @var array submissionplugins - the list of submission plugins */
358 public $submissionplugins = array();
359 /** @var string returnaction */
360 public $returnaction = '';
361 /** @var string returnparams */
362 public $returnparams = array();
363 /** @var int courseid */
364 public $courseid = 0;
365 /** @var int coursemoduleid */
366 public $coursemoduleid = 0;
367 /** @var int the view (STUDENT_VIEW OR GRADER_VIEW) */
368 public $view = self
::STUDENT_VIEW
;
369 /** @var bool canviewfullnames */
370 public $canviewfullnames = false;
371 /** @var bool canedit */
372 public $canedit = false;
373 /** @var bool cansubmit */
374 public $cansubmit = false;
375 /** @var int extensionduedate */
376 public $extensionduedate = 0;
377 /** @var context context */
379 /** @var bool blindmarking - Should we hide student identities from graders? */
380 public $blindmarking = false;
381 /** @var string gradingcontrollerpreview */
382 public $gradingcontrollerpreview = '';
383 /** @var string attemptreopenmethod */
384 public $attemptreopenmethod = 'none';
385 /** @var int maxattempts */
386 public $maxattempts = -1;
387 /** @var string gradingstatus */
388 public $gradingstatus = '';
389 /** @var bool preventsubmissionnotingroup */
390 public $preventsubmissionnotingroup = 0;
391 /** @var array usergroups */
392 public $usergroups = array();
398 * @param int $allowsubmissionsfromdate
399 * @param bool $alwaysshowdescription
400 * @param stdClass $submission
401 * @param bool $teamsubmissionenabled
402 * @param stdClass $teamsubmission
403 * @param int $submissiongroup
404 * @param array $submissiongroupmemberswhoneedtosubmit
405 * @param bool $submissionsenabled
406 * @param bool $locked
407 * @param bool $graded
408 * @param int $duedate
409 * @param int $cutoffdate
410 * @param array $submissionplugins
411 * @param string $returnaction
412 * @param array $returnparams
413 * @param int $coursemoduleid
414 * @param int $courseid
415 * @param string $view
416 * @param bool $canedit
417 * @param bool $cansubmit
418 * @param bool $canviewfullnames
419 * @param int $extensionduedate - Any extension to the due date granted for this user
420 * @param context $context - Any extension to the due date granted for this user
421 * @param bool $blindmarking - Should we hide student identities from graders?
422 * @param string $gradingcontrollerpreview
423 * @param string $attemptreopenmethod - The method of reopening student attempts.
424 * @param int $maxattempts - How many attempts can a student make?
425 * @param string $gradingstatus - The submission status (ie. Graded, Not Released etc).
426 * @param bool $preventsubmissionnotingroup - Prevent submission if user is not in a group
427 * @param array $usergroups - Array containing all groups the user is assigned to
429 public function __construct($allowsubmissionsfromdate,
430 $alwaysshowdescription,
432 $teamsubmissionenabled,
435 $submissiongroupmemberswhoneedtosubmit,
453 $gradingcontrollerpreview,
454 $attemptreopenmethod,
457 $preventsubmissionnotingroup,
459 $this->allowsubmissionsfromdate
= $allowsubmissionsfromdate;
460 $this->alwaysshowdescription
= $alwaysshowdescription;
461 $this->submission
= $submission;
462 $this->teamsubmissionenabled
= $teamsubmissionenabled;
463 $this->teamsubmission
= $teamsubmission;
464 $this->submissiongroup
= $submissiongroup;
465 $this->submissiongroupmemberswhoneedtosubmit
= $submissiongroupmemberswhoneedtosubmit;
466 $this->submissionsenabled
= $submissionsenabled;
467 $this->locked
= $locked;
468 $this->graded
= $graded;
469 $this->duedate
= $duedate;
470 $this->cutoffdate
= $cutoffdate;
471 $this->submissionplugins
= $submissionplugins;
472 $this->returnaction
= $returnaction;
473 $this->returnparams
= $returnparams;
474 $this->coursemoduleid
= $coursemoduleid;
475 $this->courseid
= $courseid;
477 $this->canedit
= $canedit;
478 $this->cansubmit
= $cansubmit;
479 $this->canviewfullnames
= $canviewfullnames;
480 $this->extensionduedate
= $extensionduedate;
481 $this->context
= $context;
482 $this->blindmarking
= $blindmarking;
483 $this->gradingcontrollerpreview
= $gradingcontrollerpreview;
484 $this->attemptreopenmethod
= $attemptreopenmethod;
485 $this->maxattempts
= $maxattempts;
486 $this->gradingstatus
= $gradingstatus;
487 $this->preventsubmissionnotingroup
= $preventsubmissionnotingroup;
488 $this->usergroups
= $usergroups;
492 * Renderable submission status
493 * @package mod_assign
494 * @copyright 2016 Damyon Wiese
495 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
497 class assign_submission_status_compact
extends assign_submission_status
implements renderable
{
498 // Compact view of the submission status. Not in a table etc.
502 * Used to output the attempt history for a particular assignment.
504 * @package mod_assign
505 * @copyright 2012 Davo Smith, Synergy Learning
506 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
508 class assign_attempt_history
implements renderable
{
510 /** @var array submissions - The list of previous attempts */
511 public $submissions = array();
512 /** @var array grades - The grades for the previous attempts */
513 public $grades = array();
514 /** @var array submissionplugins - The list of submission plugins to render the previous attempts */
515 public $submissionplugins = array();
516 /** @var array feedbackplugins - The list of feedback plugins to render the previous attempts */
517 public $feedbackplugins = array();
518 /** @var int coursemoduleid - The cmid for the assignment */
519 public $coursemoduleid = 0;
520 /** @var string returnaction - The action for the next page. */
521 public $returnaction = '';
522 /** @var string returnparams - The params for the next page. */
523 public $returnparams = array();
524 /** @var bool cangrade - Does this user have grade capability? */
525 public $cangrade = false;
526 /** @var string useridlistid - Id of the useridlist stored in cache, this plus rownum determines the userid */
527 public $useridlistid = 0;
528 /** @var int rownum - The rownum of the user in the useridlistid - this plus useridlistid determines the userid */
534 * @param array $submissions
535 * @param array $grades
536 * @param array $submissionplugins
537 * @param array $feedbackplugins
538 * @param int $coursemoduleid
539 * @param string $returnaction
540 * @param array $returnparams
541 * @param bool $cangrade
542 * @param int $useridlistid
545 public function __construct($submissions,
555 $this->submissions
= $submissions;
556 $this->grades
= $grades;
557 $this->submissionplugins
= $submissionplugins;
558 $this->feedbackplugins
= $feedbackplugins;
559 $this->coursemoduleid
= $coursemoduleid;
560 $this->returnaction
= $returnaction;
561 $this->returnparams
= $returnparams;
562 $this->cangrade
= $cangrade;
563 $this->useridlistid
= $useridlistid;
564 $this->rownum
= $rownum;
569 * Used to output the attempt history chooser for a particular assignment.
571 * @package mod_assign
572 * @copyright 2016 Damyon Wiese
573 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
575 class assign_attempt_history_chooser
implements renderable
, templatable
{
577 /** @var array submissions - The list of previous attempts */
578 public $submissions = array();
579 /** @var array grades - The grades for the previous attempts */
580 public $grades = array();
581 /** @var int coursemoduleid - The cmid for the assignment */
582 public $coursemoduleid = 0;
583 /** @var int userid - The current userid */
589 * @param array $submissions
590 * @param array $grades
591 * @param int $coursemoduleid
594 public function __construct($submissions,
598 $this->submissions
= $submissions;
599 $this->grades
= $grades;
600 $this->coursemoduleid
= $coursemoduleid;
601 $this->userid
= $userid;
605 * Function to export the renderer data in a format that is suitable for a
608 * @param renderer_base $output Used to do a final render of any components that need to be rendered for export.
609 * @return stdClass|array
611 public function export_for_template(renderer_base
$output) {
612 // Show newest to oldest.
613 $export = (object) $this;
614 $export->submissions
= array_reverse($export->submissions
);
615 $export->submissioncount
= count($export->submissions
);
617 foreach ($export->submissions
as $i => $submission) {
619 foreach ($export->grades
as $onegrade) {
620 if ($onegrade->attemptnumber
== $submission->attemptnumber
) {
621 $submission->grade
= $onegrade;
626 $submission = new stdClass();
631 if ($submission->timemodified
) {
632 $submissionsummary = userdate($submission->timemodified
);
634 $submissionsummary = get_string('nosubmission', 'assign');
637 $attemptsummaryparams = array('attemptnumber' => $submission->attemptnumber +
1,
638 'submissionsummary' => $submissionsummary);
639 $submission->attemptsummary
= get_string('attemptheading', 'assign', $attemptsummaryparams);
640 $submission->statussummary
= get_string('submissionstatus_' . $submission->status
, 'assign');
650 * @package mod_assign
651 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
652 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
654 class assign_header
implements renderable
{
655 /** @var stdClass the assign record */
656 public $assign = null;
657 /** @var mixed context|null the context record */
658 public $context = null;
659 /** @var bool $showintro - show or hide the intro */
660 public $showintro = false;
661 /** @var int coursemoduleid - The course module id */
662 public $coursemoduleid = 0;
663 /** @var string $subpage optional subpage (extra level in the breadcrumbs) */
664 public $subpage = '';
665 /** @var string $preface optional preface (text to show before the heading) */
666 public $preface = '';
667 /** @var string $postfix optional postfix (text to show after the intro) */
668 public $postfix = '';
673 * @param stdClass $assign - the assign database record
674 * @param mixed $context context|null the course module context
675 * @param bool $showintro - show or hide the intro
676 * @param int $coursemoduleid - the course module id
677 * @param string $subpage - an optional sub page in the navigation
678 * @param string $preface - an optional preface to show before the heading
680 public function __construct(stdClass
$assign,
687 $this->assign
= $assign;
688 $this->context
= $context;
689 $this->showintro
= $showintro;
690 $this->coursemoduleid
= $coursemoduleid;
691 $this->subpage
= $subpage;
692 $this->preface
= $preface;
693 $this->postfix
= $postfix;
698 * Renderable header related to an individual subplugin
699 * @package mod_assign
700 * @copyright 2014 Henning Bostelmann
701 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
703 class assign_plugin_header
implements renderable
{
704 /** @var assign_plugin $plugin */
705 public $plugin = null;
708 * Header for a single plugin
710 * @param assign_plugin $plugin
712 public function __construct(assign_plugin
$plugin) {
713 $this->plugin
= $plugin;
718 * Renderable grading summary
719 * @package mod_assign
720 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
721 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
723 class assign_grading_summary
implements renderable
{
724 /** @var int participantcount - The number of users who can submit to this assignment */
725 public $participantcount = 0;
726 /** @var bool submissiondraftsenabled - Allow submission drafts */
727 public $submissiondraftsenabled = false;
728 /** @var int submissiondraftscount - The number of submissions in draft status */
729 public $submissiondraftscount = 0;
730 /** @var bool submissionsenabled - Allow submissions */
731 public $submissionsenabled = false;
732 /** @var int submissionssubmittedcount - The number of submissions in submitted status */
733 public $submissionssubmittedcount = 0;
734 /** @var int submissionsneedgradingcount - The number of submissions that need grading */
735 public $submissionsneedgradingcount = 0;
736 /** @var int duedate - The assignment due date (if one is set) */
738 /** @var int cutoffdate - The assignment cut off date (if one is set) */
739 public $cutoffdate = 0;
740 /** @var int coursemoduleid - The assignment course module id */
741 public $coursemoduleid = 0;
742 /** @var boolean teamsubmission - Are team submissions enabled for this assignment */
743 public $teamsubmission = false;
744 /** @var boolean warnofungroupedusers - Do we need to warn people that there are users without groups */
745 public $warnofungroupedusers = false;
750 * @param int $participantcount
751 * @param bool $submissiondraftsenabled
752 * @param int $submissiondraftscount
753 * @param bool $submissionsenabled
754 * @param int $submissionssubmittedcount
755 * @param int $cutoffdate
756 * @param int $duedate
757 * @param int $coursemoduleid
758 * @param int $submissionsneedgradingcount
759 * @param bool $teamsubmission
761 public function __construct($participantcount,
762 $submissiondraftsenabled,
763 $submissiondraftscount,
765 $submissionssubmittedcount,
769 $submissionsneedgradingcount,
771 $warnofungroupedusers) {
772 $this->participantcount
= $participantcount;
773 $this->submissiondraftsenabled
= $submissiondraftsenabled;
774 $this->submissiondraftscount
= $submissiondraftscount;
775 $this->submissionsenabled
= $submissionsenabled;
776 $this->submissionssubmittedcount
= $submissionssubmittedcount;
777 $this->duedate
= $duedate;
778 $this->cutoffdate
= $cutoffdate;
779 $this->coursemoduleid
= $coursemoduleid;
780 $this->submissionsneedgradingcount
= $submissionsneedgradingcount;
781 $this->teamsubmission
= $teamsubmission;
782 $this->warnofungroupedusers
= $warnofungroupedusers;
787 * Renderable course index summary
788 * @package mod_assign
789 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
790 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
792 class assign_course_index_summary
implements renderable
{
793 /** @var array assignments - A list of course module info and submission counts or statuses */
794 public $assignments = array();
795 /** @var boolean usesections - Does this course format support sections? */
796 public $usesections = false;
797 /** @var string courseformat - The current course format name */
798 public $courseformatname = '';
803 * @param boolean $usesections - True if this course format uses sections
804 * @param string $courseformatname - The id of this course format
806 public function __construct($usesections, $courseformatname) {
807 $this->usesections
= $usesections;
808 $this->courseformatname
= $courseformatname;
812 * Add a row of data to display on the course index page
814 * @param int $cmid - The course module id for generating a link
815 * @param string $cmname - The course module name for generating a link
816 * @param string $sectionname - The name of the course section (only if $usesections is true)
817 * @param int $timedue - The due date for the assignment - may be 0 if no duedate
818 * @param string $submissioninfo - A string with either the number of submitted assignments, or the
819 * status of the current users submission depending on capabilities.
820 * @param string $gradeinfo - The current users grade if they have been graded and it is not hidden.
822 public function add_assign_info($cmid, $cmname, $sectionname, $timedue, $submissioninfo, $gradeinfo) {
823 $this->assignments
[] = array('cmid'=>$cmid,
825 'sectionname'=>$sectionname,
827 'submissioninfo'=>$submissioninfo,
828 'gradeinfo'=>$gradeinfo);
836 * An assign file class that extends rendererable class and is used by the assign module.
838 * @package mod_assign
839 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
840 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
842 class assign_files
implements renderable
{
843 /** @var context $context */
845 /** @var string $context */
847 /** @var MoodleQuickForm $portfolioform */
848 public $portfolioform;
849 /** @var stdClass $cm course module */
851 /** @var stdClass $course */
857 * @param context $context
859 * @param string $filearea
860 * @param string $component
862 public function __construct(context
$context, $sid, $filearea, $component) {
864 $this->context
= $context;
865 list($context, $course, $cm) = get_context_info_array($context->id
);
867 $this->course
= $course;
868 $fs = get_file_storage();
869 $this->dir
= $fs->get_area_tree($this->context
->id
, $component, $filearea, $sid);
871 $files = $fs->get_area_files($this->context
->id
,
878 if (!empty($CFG->enableportfolios
)) {
879 require_once($CFG->libdir
. '/portfoliolib.php');
880 if (count($files) >= 1 && !empty($sid) &&
881 has_capability('mod/assign:exportownsubmission', $this->context
)) {
882 $button = new portfolio_add_button();
883 $callbackparams = array('cmid' => $this->cm
->id
,
886 'component' => $component);
887 $button->set_callback_options('assign_portfolio_caller',
890 $button->reset_formats();
891 $this->portfolioform
= $button->to_html(PORTFOLIO_ADD_TEXT_LINK
);
896 $this->preprocess($this->dir
, $filearea, $component);
900 * Preprocessing the file list to add the portfolio links if required.
903 * @param string $filearea
904 * @param string $component
907 public function preprocess($dir, $filearea, $component) {
909 foreach ($dir['subdirs'] as $subdir) {
910 $this->preprocess($subdir, $filearea, $component);
912 foreach ($dir['files'] as $file) {
913 $file->portfoliobutton
= '';
914 if (!empty($CFG->enableportfolios
)) {
915 require_once($CFG->libdir
. '/portfoliolib.php');
916 $button = new portfolio_add_button();
917 if (has_capability('mod/assign:exportownsubmission', $this->context
)) {
918 $portfolioparams = array('cmid' => $this->cm
->id
, 'fileid' => $file->get_id());
919 $button->set_callback_options('assign_portfolio_caller',
922 $button->set_format_by_file($file);
923 $file->portfoliobutton
= $button->to_html(PORTFOLIO_ADD_ICON_LINK
);
933 $file->get_itemid() .
934 $file->get_filepath() .
935 $file->get_filename();
936 $url = file_encode_url("$CFG->wwwroot/pluginfile.php", $path, true);
937 $filename = $file->get_filename();
938 $file->fileurl
= html_writer
::link($url, $filename, [
939 'target' => '_blank',