[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/assign/ -> renderable.php (source)

   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   * This file contains the definition for the renderable classes for the assignment
  19   *
  20   * @package   mod_assign
  21   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * This class wraps the submit for grading confirmation page
  29   * @package   mod_assign
  30   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  31   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  32   */
  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;
  40  
  41      /**
  42       * Constructor
  43       * @param string $notifications - Any mesages to display
  44       * @param int $coursemoduleid
  45       * @param moodleform $confirmform
  46       */
  47      public function __construct($notifications, $coursemoduleid, $confirmform) {
  48          $this->notifications = $notifications;
  49          $this->coursemoduleid = $coursemoduleid;
  50          $this->confirmform = $confirmform;
  51      }
  52  
  53  }
  54  
  55  /**
  56   * Implements a renderable message notification
  57   * @package   mod_assign
  58   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  59   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  60   */
  61  class assign_gradingmessage implements renderable {
  62      /** @var string $heading is the heading to display to the user */
  63      public $heading = '';
  64      /** @var string $message is the message to display to the user */
  65      public $message = '';
  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;
  70  
  71      /**
  72       * Constructor
  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
  78       */
  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;
  84          $this->page = $page;
  85      }
  86  
  87  }
  88  
  89  /**
  90   * Implements a renderable grading options form
  91   * @package   mod_assign
  92   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  93   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  94   */
  95  class assign_form implements renderable {
  96      /** @var moodleform $form is the edit submission form */
  97      public $form = null;
  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 = '';
 102  
 103      /**
 104       * Constructor
 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
 108       */
 109      public function __construct($classname, moodleform $form, $jsinitfunction = '') {
 110          $this->classname = $classname;
 111          $this->form = $form;
 112          $this->jsinitfunction = $jsinitfunction;
 113      }
 114  
 115  }
 116  
 117  /**
 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
 122   */
 123  class assign_user_summary implements renderable {
 124      /** @var stdClass $user suitable for rendering with user_picture and fullname(). */
 125      public $user = null;
 126      /** @var int $courseid */
 127      public $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;
 138  
 139      /**
 140       * Constructor
 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
 148       */
 149      public function __construct(stdClass $user,
 150                                  $courseid,
 151                                  $viewfullnames,
 152                                  $blindmarking,
 153                                  $uniqueidforuser,
 154                                  $extrauserfields,
 155                                  $suspendeduser = false) {
 156          $this->user = $user;
 157          $this->courseid = $courseid;
 158          $this->viewfullnames = $viewfullnames;
 159          $this->blindmarking = $blindmarking;
 160          $this->uniqueidforuser = $uniqueidforuser;
 161          $this->extrauserfields = $extrauserfields;
 162          $this->suspendeduser = $suspendeduser;
 163      }
 164  }
 165  
 166  /**
 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
 171   */
 172  class assign_feedback_plugin_feedback implements renderable {
 173      /** @var int SUMMARY */
 174      const SUMMARY                = 10;
 175      /** @var int FULL */
 176      const FULL                   = 20;
 177  
 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();
 190  
 191      /**
 192       * Feedback for a single plugin
 193       *
 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
 200       */
 201      public function __construct(assign_feedback_plugin $plugin,
 202                                  stdClass $grade,
 203                                  $view,
 204                                  $coursemoduleid,
 205                                  $returnaction,
 206                                  $returnparams) {
 207          $this->plugin = $plugin;
 208          $this->grade = $grade;
 209          $this->view = $view;
 210          $this->coursemoduleid = $coursemoduleid;
 211          $this->returnaction = $returnaction;
 212          $this->returnparams = $returnparams;
 213      }
 214  
 215  }
 216  
 217  /**
 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
 222   */
 223  class assign_submission_plugin_submission implements renderable {
 224      /** @var int SUMMARY */
 225      const SUMMARY                = 10;
 226      /** @var int FULL */
 227      const FULL                   = 20;
 228  
 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();
 241  
 242      /**
 243       * Constructor
 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
 250       */
 251      public function __construct(assign_submission_plugin $plugin,
 252                                  stdClass $submission,
 253                                  $view,
 254                                  $coursemoduleid,
 255                                  $returnaction,
 256                                  $returnparams) {
 257          $this->plugin = $plugin;
 258          $this->submission = $submission;
 259          $this->view = $view;
 260          $this->coursemoduleid = $coursemoduleid;
 261          $this->returnaction = $returnaction;
 262          $this->returnparams = $returnparams;
 263      }
 264  }
 265  
 266  /**
 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
 271   */
 272  class assign_feedback_status implements renderable {
 273  
 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();
 290  
 291      /**
 292       * Constructor
 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
 301       */
 302      public function __construct($gradefordisplay,
 303                                  $gradeddate,
 304                                  $grader,
 305                                  $feedbackplugins,
 306                                  $grade,
 307                                  $coursemoduleid,
 308                                  $returnaction,
 309                                  $returnparams) {
 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;
 318      }
 319  }
 320  
 321  /**
 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
 326   */
 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;
 332  
 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 */
 354      public $duedate = 0;
 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 */
 378      public $context = 0;
 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();
 393  
 394  
 395      /**
 396       * Constructor
 397       *
 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
 428       */
 429      public function __construct($allowsubmissionsfromdate,
 430                                  $alwaysshowdescription,
 431                                  $submission,
 432                                  $teamsubmissionenabled,
 433                                  $teamsubmission,
 434                                  $submissiongroup,
 435                                  $submissiongroupmemberswhoneedtosubmit,
 436                                  $submissionsenabled,
 437                                  $locked,
 438                                  $graded,
 439                                  $duedate,
 440                                  $cutoffdate,
 441                                  $submissionplugins,
 442                                  $returnaction,
 443                                  $returnparams,
 444                                  $coursemoduleid,
 445                                  $courseid,
 446                                  $view,
 447                                  $canedit,
 448                                  $cansubmit,
 449                                  $canviewfullnames,
 450                                  $extensionduedate,
 451                                  $context,
 452                                  $blindmarking,
 453                                  $gradingcontrollerpreview,
 454                                  $attemptreopenmethod,
 455                                  $maxattempts,
 456                                  $gradingstatus,
 457                                  $preventsubmissionnotingroup,
 458                                  $usergroups) {
 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;
 476          $this->view = $view;
 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;
 489      }
 490  }
 491  /**
 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
 496   */
 497  class assign_submission_status_compact extends assign_submission_status implements renderable {
 498      // Compact view of the submission status. Not in a table etc.
 499  }
 500  
 501  /**
 502   * Used to output the attempt history for a particular assignment.
 503   *
 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
 507   */
 508  class assign_attempt_history implements renderable {
 509  
 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 */
 529      public $rownum = 0;
 530  
 531      /**
 532       * Constructor
 533       *
 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
 543       * @param int $rownum
 544       */
 545      public function __construct($submissions,
 546                                  $grades,
 547                                  $submissionplugins,
 548                                  $feedbackplugins,
 549                                  $coursemoduleid,
 550                                  $returnaction,
 551                                  $returnparams,
 552                                  $cangrade,
 553                                  $useridlistid,
 554                                  $rownum) {
 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;
 565      }
 566  }
 567  
 568  /**
 569   * Used to output the attempt history chooser for a particular assignment.
 570   *
 571   * @package mod_assign
 572   * @copyright 2016 Damyon Wiese
 573   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 574   */
 575  class assign_attempt_history_chooser implements renderable, templatable {
 576  
 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 */
 584      public $userid = 0;
 585  
 586      /**
 587       * Constructor
 588       *
 589       * @param array $submissions
 590       * @param array $grades
 591       * @param int $coursemoduleid
 592       * @param int $userid
 593       */
 594      public function __construct($submissions,
 595                                  $grades,
 596                                  $coursemoduleid,
 597                                  $userid) {
 598          $this->submissions = $submissions;
 599          $this->grades = $grades;
 600          $this->coursemoduleid = $coursemoduleid;
 601          $this->userid = $userid;
 602      }
 603  
 604      /**
 605       * Function to export the renderer data in a format that is suitable for a
 606       * mustache template.
 607       *
 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
 610       */
 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);
 616  
 617          foreach ($export->submissions as $i => $submission) {
 618              $grade = null;
 619              foreach ($export->grades as $onegrade) {
 620                  if ($onegrade->attemptnumber == $submission->attemptnumber) {
 621                      $submission->grade = $onegrade;
 622                      break;
 623                  }
 624              }
 625              if (!$submission) {
 626                  $submission = new stdClass();
 627              }
 628  
 629              $editbtn = '';
 630  
 631              if ($submission->timemodified) {
 632                  $submissionsummary = userdate($submission->timemodified);
 633              } else {
 634                  $submissionsummary = get_string('nosubmission', 'assign');
 635              }
 636  
 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');
 641  
 642          }
 643  
 644          return $export;
 645      }
 646  }
 647  
 648  /**
 649   * Renderable header
 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
 653   */
 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 = '';
 669  
 670      /**
 671       * Constructor
 672       *
 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
 679       */
 680      public function __construct(stdClass $assign,
 681                                  $context,
 682                                  $showintro,
 683                                  $coursemoduleid,
 684                                  $subpage='',
 685                                  $preface='',
 686                                  $postfix='') {
 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;
 694      }
 695  }
 696  
 697  /**
 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
 702   */
 703  class assign_plugin_header implements renderable {
 704      /** @var assign_plugin $plugin */
 705      public $plugin = null;
 706  
 707      /**
 708       * Header for a single plugin
 709       *
 710       * @param assign_plugin $plugin
 711       */
 712      public function __construct(assign_plugin $plugin) {
 713          $this->plugin = $plugin;
 714      }
 715  }
 716  
 717  /**
 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
 722   */
 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) */
 737      public $duedate = 0;
 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;
 746  
 747      /**
 748       * constructor
 749       *
 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
 760       */
 761      public function __construct($participantcount,
 762                                  $submissiondraftsenabled,
 763                                  $submissiondraftscount,
 764                                  $submissionsenabled,
 765                                  $submissionssubmittedcount,
 766                                  $cutoffdate,
 767                                  $duedate,
 768                                  $coursemoduleid,
 769                                  $submissionsneedgradingcount,
 770                                  $teamsubmission,
 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;
 783      }
 784  }
 785  
 786  /**
 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
 791   */
 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 = '';
 799  
 800      /**
 801       * constructor
 802       *
 803       * @param boolean $usesections - True if this course format uses sections
 804       * @param string $courseformatname - The id of this course format
 805       */
 806      public function __construct($usesections, $courseformatname) {
 807          $this->usesections = $usesections;
 808          $this->courseformatname = $courseformatname;
 809      }
 810  
 811      /**
 812       * Add a row of data to display on the course index page
 813       *
 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.
 821       */
 822      public function add_assign_info($cmid, $cmname, $sectionname, $timedue, $submissioninfo, $gradeinfo) {
 823          $this->assignments[] = array('cmid'=>$cmid,
 824                                 'cmname'=>$cmname,
 825                                 'sectionname'=>$sectionname,
 826                                 'timedue'=>$timedue,
 827                                 'submissioninfo'=>$submissioninfo,
 828                                 'gradeinfo'=>$gradeinfo);
 829      }
 830  
 831  
 832  }
 833  
 834  
 835  /**
 836   * An assign file class that extends rendererable class and is used by the assign module.
 837   *
 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
 841   */
 842  class assign_files implements renderable {
 843      /** @var context $context */
 844      public $context;
 845      /** @var string $context */
 846      public $dir;
 847      /** @var MoodleQuickForm $portfolioform */
 848      public $portfolioform;
 849      /** @var stdClass $cm course module */
 850      public $cm;
 851      /** @var stdClass $course */
 852      public $course;
 853  
 854      /**
 855       * The constructor
 856       *
 857       * @param context $context
 858       * @param int $sid
 859       * @param string $filearea
 860       * @param string $component
 861       */
 862      public function __construct(context $context, $sid, $filearea, $component) {
 863          global $CFG;
 864          $this->context = $context;
 865          list($context, $course, $cm) = get_context_info_array($context->id);
 866          $this->cm = $cm;
 867          $this->course = $course;
 868          $fs = get_file_storage();
 869          $this->dir = $fs->get_area_tree($this->context->id, $component, $filearea, $sid);
 870  
 871          $files = $fs->get_area_files($this->context->id,
 872                                       $component,
 873                                       $filearea,
 874                                       $sid,
 875                                       'timemodified',
 876                                       false);
 877  
 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,
 884                                          'sid' => $sid,
 885                                          'area' => $filearea,
 886                                          'component' => $component);
 887                  $button->set_callback_options('assign_portfolio_caller',
 888                                                $callbackparams,
 889                                                'mod_assign');
 890                  $button->reset_formats();
 891                  $this->portfolioform = $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
 892              }
 893  
 894          }
 895  
 896          $this->preprocess($this->dir, $filearea, $component);
 897      }
 898  
 899      /**
 900       * Preprocessing the file list to add the portfolio links if required.
 901       *
 902       * @param array $dir
 903       * @param string $filearea
 904       * @param string $component
 905       * @return void
 906       */
 907      public function preprocess($dir, $filearea, $component) {
 908          global $CFG;
 909          foreach ($dir['subdirs'] as $subdir) {
 910              $this->preprocess($subdir, $filearea, $component);
 911          }
 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',
 920                                                    $portfolioparams,
 921                                                    'mod_assign');
 922                      $button->set_format_by_file($file);
 923                      $file->portfoliobutton = $button->to_html(PORTFOLIO_ADD_ICON_LINK);
 924                  }
 925              }
 926              $path = '/' .
 927                      $this->context->id .
 928                      '/' .
 929                      $component .
 930                      '/' .
 931                      $filearea .
 932                      '/' .
 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          }
 940      }
 941  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1