Search moodle.org's
Developer Documentation


  • Bug fixes for general core bugs in 2.8.x ended 9 November 2015 (12 months).
  • Bug fixes for security issues in 2.8.x ended 9 May 2016 (18 months).
  • minimum PHP 5.4.4 (always use latest PHP 5.4.x or 5.5.x on Windows - http://windows.php.net/download/), PHP 7 is NOT supported
  • Differences Between: [Versions 28 and 30] [Versions 28 and 31] [Versions 28 and 32] [Versions 28 and 33] [Versions 28 and 34] [Versions 28 and 35] [Versions 28 and 36] [Versions 28 and 37]

       1  <?php
       2  
       3  // This file is part of Moodle - http://moodle.org/
       4  //
       5  // Moodle is free software: you can redistribute it and/or modify
       6  // it under the terms of the GNU General Public License as published by
       7  // the Free Software Foundation, either version 3 of the License, or
       8  // (at your option) any later version.
       9  //
      10  // Moodle is distributed in the hope that it will be useful,
      11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
      12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13  // GNU General Public License for more details.
      14  //
      15  // You should have received a copy of the GNU General Public License
      16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
      17  
      18  /**
      19   * Prints a particular instance of workshop
      20   *
      21   * You can have a rather longer description of the file as well,
      22   * if you like, and it can span multiple lines.
      23   *
      24   * @package    mod_workshop
      25   * @copyright  2009 David Mudrak <david.mudrak@gmail.com>
      26   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
      27   */
      28  
      29  require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
      30  require_once(dirname(__FILE__).'/locallib.php');
      31  require_once($CFG->libdir.'/completionlib.php');
      32  
      33  $id         = optional_param('id', 0, PARAM_INT); // course_module ID, or
      34  $w          = optional_param('w', 0, PARAM_INT);  // workshop instance ID
      35  $editmode   = optional_param('editmode', null, PARAM_BOOL);
      36  $page       = optional_param('page', 0, PARAM_INT);
      37  $perpage    = optional_param('perpage', null, PARAM_INT);
      38  $sortby     = optional_param('sortby', 'lastname', PARAM_ALPHA);
      39  $sorthow    = optional_param('sorthow', 'ASC', PARAM_ALPHA);
      40  $eval       = optional_param('eval', null, PARAM_PLUGIN);
      41  
      42  if ($id) {
      43      $cm             = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST);
      44      $course         = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
      45      $workshoprecord = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
      46  } else {
      47      $workshoprecord = $DB->get_record('workshop', array('id' => $w), '*', MUST_EXIST);
      48      $course         = $DB->get_record('course', array('id' => $workshoprecord->course), '*', MUST_EXIST);
      49      $cm             = get_coursemodule_from_instance('workshop', $workshoprecord->id, $course->id, false, MUST_EXIST);
      50  }
      51  
      52  require_login($course, true, $cm);
      53  require_capability('mod/workshop:view', $PAGE->context);
      54  
      55  $workshop = new workshop($workshoprecord, $cm, $course);
      56  
      57  // Mark viewed
      58  $completion = new completion_info($course);
      59  $completion->set_module_viewed($cm);
      60  
      61  $eventdata = array();
      62  $eventdata['objectid']         = $workshop->id;
      63  $eventdata['context']          = $workshop->context;
      64  
      65  $PAGE->set_url($workshop->view_url());
      66  $event = \mod_workshop\event\course_module_viewed::create($eventdata);
      67  $event->add_record_snapshot('course', $course);
      68  $event->add_record_snapshot('workshop', $workshoprecord);
      69  $event->add_record_snapshot('course_modules', $cm);
      70  $event->trigger();
      71  
      72  // If the phase is to be switched, do it asap. This just has to happen after triggering
      73  // the event so that the scheduled allocator had a chance to allocate submissions.
      74  if ($workshop->phase == workshop::PHASE_SUBMISSION and $workshop->phaseswitchassessment
      75          and $workshop->submissionend > 0 and $workshop->submissionend < time()) {
      76      $workshop->switch_phase(workshop::PHASE_ASSESSMENT);
      77      // Disable the automatic switching now so that it is not executed again by accident
      78      // if the teacher changes the phase back to the submission one.
      79      $DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id));
      80      $workshop->phaseswitchassessment = 0;
      81  }
      82  
      83  if (!is_null($editmode) && $PAGE->user_allowed_editing()) {
      84      $USER->editing = $editmode;
      85  }
      86  
      87  $PAGE->set_title($workshop->name);
      88  $PAGE->set_heading($course->fullname);
      89  
      90  if ($perpage and $perpage > 0 and $perpage <= 1000) {
      91      require_sesskey();
      92      set_user_preference('workshop_perpage', $perpage);
      93      redirect($PAGE->url);
      94  }
      95  
      96  if ($eval) {
      97      require_sesskey();
      98      require_capability('mod/workshop:overridegrades', $workshop->context);
      99      $workshop->set_grading_evaluation_method($eval);
     100      redirect($PAGE->url);
     101  }
     102  
     103  $output = $PAGE->get_renderer('mod_workshop');
     104  $userplan = new workshop_user_plan($workshop, $USER->id);
     105  
     106  /// Output starts here
     107  
     108  echo $output->header();
     109  echo $output->heading_with_help(format_string($workshop->name), 'userplan', 'workshop');
     110  echo $output->render($userplan);
     111  
     112  switch ($workshop->phase) {
     113  case workshop::PHASE_SETUP:
     114      if (trim($workshop->intro)) {
     115          print_collapsible_region_start('', 'workshop-viewlet-intro', get_string('introduction', 'workshop'));
     116          echo $output->box(format_module_intro('workshop', $workshop, $workshop->cm->id), 'generalbox');
     117          print_collapsible_region_end();
     118      }
     119      if ($workshop->useexamples and has_capability('mod/workshop:manageexamples', $PAGE->context)) {
     120          print_collapsible_region_start('', 'workshop-viewlet-allexamples', get_string('examplesubmissions', 'workshop'));
     121          echo $output->box_start('generalbox examples');
     122          if ($workshop->grading_strategy_instance()->form_ready()) {
     123              if (! $examples = $workshop->get_examples_for_manager()) {
     124                  echo $output->container(get_string('noexamples', 'workshop'), 'noexamples');
     125              }
     126              foreach ($examples as $example) {
     127                  $summary = $workshop->prepare_example_summary($example);
     128                  $summary->editable = true;
     129                  echo $output->render($summary);
     130              }
     131              $aurl = new moodle_url($workshop->exsubmission_url(0), array('edit' => 'on'));
     132              echo $output->single_button($aurl, get_string('exampleadd', 'workshop'), 'get');
     133          } else {
     134              echo $output->container(get_string('noexamplesformready', 'workshop'));
     135          }
     136          echo $output->box_end();
     137          print_collapsible_region_end();
     138      }
     139      break;
     140  case workshop::PHASE_SUBMISSION:
     141      if (trim($workshop->instructauthors)) {
     142          $instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id,
     143              'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($PAGE->context));
     144          print_collapsible_region_start('', 'workshop-viewlet-instructauthors', get_string('instructauthors', 'workshop'));
     145          echo $output->box(format_text($instructions, $workshop->instructauthorsformat, array('overflowdiv'=>true)), array('generalbox', 'instructions'));
     146          print_collapsible_region_end();
     147      }
     148  
     149      // does the user have to assess examples before submitting their own work?
     150      $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION);
     151  
     152      // is the assessment of example submissions considered finished?
     153      $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context);
     154      if ($workshop->assessing_examples_allowed()
     155              and has_capability('mod/workshop:submit', $workshop->context)
     156                      and ! has_capability('mod/workshop:manageexamples', $workshop->context)) {
     157          $examples = $userplan->get_examples();
     158          $total = count($examples);
     159          $left = 0;
     160          // make sure the current user has all examples allocated
     161          foreach ($examples as $exampleid => $example) {
     162              if (is_null($example->assessmentid)) {
     163                  $examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0);
     164              }
     165              if (is_null($example->grade)) {
     166                  $left++;
     167              }
     168          }
     169          if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) {
     170              $examplesdone = false;
     171          } else {
     172              $examplesdone = true;
     173          }
     174          print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'), false, $examplesdone);
     175          echo $output->box_start('generalbox exampleassessments');
     176          if ($total == 0) {
     177              echo $output->heading(get_string('noexamples', 'workshop'), 3);
     178          } else {
     179              foreach ($examples as $example) {
     180                  $summary = $workshop->prepare_example_summary($example);
     181                  echo $output->render($summary);
     182              }
     183          }
     184          echo $output->box_end();
     185          print_collapsible_region_end();
     186      }
     187  
     188      if (has_capability('mod/workshop:submit', $PAGE->context) and (!$examplesmust or $examplesdone)) {
     189          print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'));
     190          echo $output->box_start('generalbox ownsubmission');
     191          if ($submission = $workshop->get_submission_by_author($USER->id)) {
     192              echo $output->render($workshop->prepare_submission_summary($submission, true));
     193              if ($workshop->modifying_submission_allowed($USER->id)) {
     194                  $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
     195                  $btntxt = get_string('editsubmission', 'workshop');
     196              }
     197          } else {
     198              echo $output->container(get_string('noyoursubmission', 'workshop'));
     199              if ($workshop->creating_submission_allowed($USER->id)) {
     200                  $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
     201                  $btntxt = get_string('createsubmission', 'workshop');
     202              }
     203          }
     204          if (!empty($btnurl)) {
     205              echo $output->single_button($btnurl, $btntxt, 'get');
     206          }
     207          echo $output->box_end();
     208          print_collapsible_region_end();
     209      }
     210  
     211      if (has_capability('mod/workshop:viewallsubmissions', $PAGE->context)) {
     212          $groupmode = groups_get_activity_groupmode($workshop->cm);
     213          $groupid = groups_get_activity_group($workshop->cm, true);
     214  
     215          if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $workshop->context)) {
     216              $allowedgroups = groups_get_activity_allowed_groups($workshop->cm);
     217              if (empty($allowedgroups)) {
     218                  echo $output->container(get_string('groupnoallowed', 'mod_workshop'), 'groupwidget error');
     219                  break;
     220              }
     221              if (! in_array($groupid, array_keys($allowedgroups))) {
     222                  echo $output->container(get_string('groupnotamember', 'core_group'), 'groupwidget error');
     223                  break;
     224              }
     225          }
     226  
     227          $countsubmissions = $workshop->count_submissions('all', $groupid);
     228          $perpage = get_user_preferences('workshop_perpage', 10);
     229          $pagingbar = new paging_bar($countsubmissions, $page, $perpage, $PAGE->url, 'page');
     230  
     231          print_collapsible_region_start('', 'workshop-viewlet-allsubmissions', get_string('allsubmissions', 'workshop', $countsubmissions));
     232          echo $output->box_start('generalbox allsubmissions');
     233          echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget');
     234  
     235          if ($countsubmissions == 0) {
     236              echo $output->container(get_string('nosubmissions', 'workshop'), 'nosubmissions');
     237  
     238          } else {
     239              $submissions = $workshop->get_submissions('all', $groupid, $page * $perpage, $perpage);
     240              $shownames = has_capability('mod/workshop:viewauthornames', $workshop->context);
     241              echo $output->render($pagingbar);
     242              foreach ($submissions as $submission) {
     243                  echo $output->render($workshop->prepare_submission_summary($submission, $shownames));
     244              }
     245              echo $output->render($pagingbar);
     246              echo $output->perpage_selector($perpage);
     247          }
     248  
     249          echo $output->box_end();
     250          print_collapsible_region_end();
     251      }
     252  
     253      break;
     254  
     255  case workshop::PHASE_ASSESSMENT:
     256  
     257      $ownsubmissionexists = null;
     258      if (has_capability('mod/workshop:submit', $PAGE->context)) {
     259          if ($ownsubmission = $workshop->get_submission_by_author($USER->id)) {
     260              print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'), false, true);
     261              echo $output->box_start('generalbox ownsubmission');
     262              echo $output->render($workshop->prepare_submission_summary($ownsubmission, true));
     263              $ownsubmissionexists = true;
     264          } else {
     265              print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'));
     266              echo $output->box_start('generalbox ownsubmission');
     267              echo $output->container(get_string('noyoursubmission', 'workshop'));
     268              $ownsubmissionexists = false;
     269              if ($workshop->creating_submission_allowed($USER->id)) {
     270                  $btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
     271                  $btntxt = get_string('createsubmission', 'workshop');
     272              }
     273          }
     274          if (!empty($btnurl)) {
     275              echo $output->single_button($btnurl, $btntxt, 'get');
     276          }
     277          echo $output->box_end();
     278          print_collapsible_region_end();
     279      }
     280  
     281      if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
     282          $perpage = get_user_preferences('workshop_perpage', 10);
     283          $groupid = groups_get_activity_group($workshop->cm, true);
     284          $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow);
     285          if ($data) {
     286              $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
     287              $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);
     288  
     289              // prepare paging bar
     290              $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow));
     291              $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page');
     292  
     293              // grading report display options
     294              $reportopts                         = new stdclass();
     295              $reportopts->showauthornames        = $showauthornames;
     296              $reportopts->showreviewernames      = $showreviewernames;
     297              $reportopts->sortby                 = $sortby;
     298              $reportopts->sorthow                = $sorthow;
     299              $reportopts->showsubmissiongrade    = false;
     300              $reportopts->showgradinggrade       = false;
     301  
     302              print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'));
     303              echo $output->box_start('generalbox gradesreport');
     304              echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget');
     305              echo $output->render($pagingbar);
     306              echo $output->render(new workshop_grading_report($data, $reportopts));
     307              echo $output->render($pagingbar);
     308              echo $output->perpage_selector($perpage);
     309              echo $output->box_end();
     310              print_collapsible_region_end();
     311          }
     312      }
     313      if (trim($workshop->instructreviewers)) {
     314          $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id,
     315              'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($PAGE->context));
     316          print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop'));
     317          echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv'=>true)), array('generalbox', 'instructions'));
     318          print_collapsible_region_end();
     319      }
     320  
     321      // does the user have to assess examples before assessing other's work?
     322      $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_ASSESSMENT);
     323  
     324      // is the assessment of example submissions considered finished?
     325      $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context);
     326  
     327      // can the examples be assessed?
     328      $examplesavailable = true;
     329  
     330      if (!$examplesdone and $examplesmust and ($ownsubmissionexists === false)) {
     331          print_collapsible_region_start('', 'workshop-viewlet-examplesfail', get_string('exampleassessments', 'workshop'));
     332          echo $output->box(get_string('exampleneedsubmission', 'workshop'));
     333          print_collapsible_region_end();
     334          $examplesavailable = false;
     335      }
     336  
     337      if ($workshop->assessing_examples_allowed()
     338              and has_capability('mod/workshop:submit', $workshop->context)
     339                  and ! has_capability('mod/workshop:manageexamples', $workshop->context)
     340                      and $examplesavailable) {
     341          $examples = $userplan->get_examples();
     342          $total = count($examples);
     343          $left = 0;
     344          // make sure the current user has all examples allocated
     345          foreach ($examples as $exampleid => $example) {
     346              if (is_null($example->assessmentid)) {
     347                  $examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0);
     348              }
     349              if (is_null($example->grade)) {
     350                  $left++;
     351              }
     352          }
     353          if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) {
     354              $examplesdone = false;
     355          } else {
     356              $examplesdone = true;
     357          }
     358          print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'), false, $examplesdone);
     359          echo $output->box_start('generalbox exampleassessments');
     360          if ($total == 0) {
     361              echo $output->heading(get_string('noexamples', 'workshop'), 3);
     362          } else {
     363              foreach ($examples as $example) {
     364                  $summary = $workshop->prepare_example_summary($example);
     365                  echo $output->render($summary);
     366              }
     367          }
     368          echo $output->box_end();
     369          print_collapsible_region_end();
     370      }
     371      if (!$examplesmust or $examplesdone) {
     372          print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop'));
     373          if (! $assessments = $workshop->get_assessments_by_reviewer($USER->id)) {
     374              echo $output->box_start('generalbox assessment-none');
     375              echo $output->notification(get_string('assignedassessmentsnone', 'workshop'));
     376              echo $output->box_end();
     377          } else {
     378              $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
     379              foreach ($assessments as $assessment) {
     380                  $submission                     = new stdClass();
     381                  $submission->id                 = $assessment->submissionid;
     382                  $submission->title              = $assessment->submissiontitle;
     383                  $submission->timecreated        = $assessment->submissioncreated;
     384                  $submission->timemodified       = $assessment->submissionmodified;
     385                  $userpicturefields = explode(',', user_picture::fields());
     386                  foreach ($userpicturefields as $userpicturefield) {
     387                      $prefixedusernamefield = 'author' . $userpicturefield;
     388                      $submission->$prefixedusernamefield = $assessment->$prefixedusernamefield;
     389                  }
     390  
     391                  // transform the submission object into renderable component
     392                  $submission = $workshop->prepare_submission_summary($submission, $shownames);
     393  
     394                  if (is_null($assessment->grade)) {
     395                      $submission->status = 'notgraded';
     396                      $class = ' notgraded';
     397                      $buttontext = get_string('assess', 'workshop');
     398                  } else {
     399                      $submission->status = 'graded';
     400                      $class = ' graded';
     401                      $buttontext = get_string('reassess', 'workshop');
     402                  }
     403  
     404                  echo $output->box_start('generalbox assessment-summary' . $class);
     405                  echo $output->render($submission);
     406                  $aurl = $workshop->assess_url($assessment->id);
     407                  echo $output->single_button($aurl, $buttontext, 'get');
     408                  echo $output->box_end();
     409              }
     410          }
     411          print_collapsible_region_end();
     412      }
     413      break;
     414  case workshop::PHASE_EVALUATION:
     415      if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
     416          $perpage = get_user_preferences('workshop_perpage', 10);
     417          $groupid = groups_get_activity_group($workshop->cm, true);
     418          $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow);
     419          if ($data) {
     420              $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
     421              $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);
     422  
     423              if (has_capability('mod/workshop:overridegrades', $PAGE->context)) {
     424                  // Print a drop-down selector to change the current evaluation method.
     425                  $selector = new single_select($PAGE->url, 'eval', workshop::available_evaluators_list(),
     426                      $workshop->evaluation, false, 'evaluationmethodchooser');
     427                  $selector->set_label(get_string('evaluationmethod', 'mod_workshop'));
     428                  $selector->set_help_icon('evaluationmethod', 'mod_workshop');
     429                  $selector->method = 'post';
     430                  echo $output->render($selector);
     431                  // load the grading evaluator
     432                  $evaluator = $workshop->grading_evaluation_instance();
     433                  $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(),
     434                          compact('sortby', 'sorthow', 'page')));
     435                  $form->display();
     436              }
     437  
     438              // prepare paging bar
     439              $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow));
     440              $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page');
     441  
     442              // grading report display options
     443              $reportopts                         = new stdclass();
     444              $reportopts->showauthornames        = $showauthornames;
     445              $reportopts->showreviewernames      = $showreviewernames;
     446              $reportopts->sortby                 = $sortby;
     447              $reportopts->sorthow                = $sorthow;
     448              $reportopts->showsubmissiongrade    = true;
     449              $reportopts->showgradinggrade       = true;
     450  
     451              print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'));
     452              echo $output->box_start('generalbox gradesreport');
     453              echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget');
     454              echo $output->render($pagingbar);
     455              echo $output->render(new workshop_grading_report($data, $reportopts));
     456              echo $output->render($pagingbar);
     457              echo $output->perpage_selector($perpage);
     458              echo $output->box_end();
     459              print_collapsible_region_end();
     460          }
     461      }
     462      if (has_capability('mod/workshop:overridegrades', $workshop->context)) {
     463          print_collapsible_region_start('', 'workshop-viewlet-cleargrades', get_string('toolbox', 'workshop'), false, true);
     464          echo $output->box_start('generalbox toolbox');
     465  
     466          // Clear aggregated grades
     467          $url = new moodle_url($workshop->toolbox_url('clearaggregatedgrades'));
     468          $btn = new single_button($url, get_string('clearaggregatedgrades', 'workshop'), 'post');
     469          $btn->add_confirm_action(get_string('clearaggregatedgradesconfirm', 'workshop'));
     470          echo $output->container_start('toolboxaction');
     471          echo $output->render($btn);
     472          echo $output->help_icon('clearaggregatedgrades', 'workshop');
     473          echo $output->container_end();
     474          // Clear assessments
     475          $url = new moodle_url($workshop->toolbox_url('clearassessments'));
     476          $btn = new single_button($url, get_string('clearassessments', 'workshop'), 'post');
     477          $btn->add_confirm_action(get_string('clearassessmentsconfirm', 'workshop'));
     478          echo $output->container_start('toolboxaction');
     479          echo $output->render($btn);
     480          echo $output->help_icon('clearassessments', 'workshop');
     481          echo html_writer::empty_tag('img', array('src' => $output->pix_url('i/risk_dataloss'),
     482                                                   'title' => get_string('riskdatalossshort', 'admin'),
     483                                                   'alt' => get_string('riskdatalossshort', 'admin'),
     484                                                   'class' => 'workshop-risk-dataloss'));
     485          echo $output->container_end();
     486  
     487          echo $output->box_end();
     488          print_collapsible_region_end();
     489      }
     490      if (has_capability('mod/workshop:submit', $PAGE->context)) {
     491          print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'));
     492          echo $output->box_start('generalbox ownsubmission');
     493          if ($submission = $workshop->get_submission_by_author($USER->id)) {
     494              echo $output->render($workshop->prepare_submission_summary($submission, true));
     495          } else {
     496              echo $output->container(get_string('noyoursubmission', 'workshop'));
     497          }
     498          echo $output->box_end();
     499          print_collapsible_region_end();
     500      }
     501      if ($assessments = $workshop->get_assessments_by_reviewer($USER->id)) {
     502          print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop'));
     503          $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
     504          foreach ($assessments as $assessment) {
     505              $submission                     = new stdclass();
     506              $submission->id                 = $assessment->submissionid;
     507              $submission->title              = $assessment->submissiontitle;
     508              $submission->timecreated        = $assessment->submissioncreated;
     509              $submission->timemodified       = $assessment->submissionmodified;
     510              $userpicturefields = explode(',', user_picture::fields());
     511              foreach ($userpicturefields as $userpicturefield) {
     512                  $prefixedusernamefield = 'author' . $userpicturefield;
     513                  $submission->$prefixedusernamefield = $assessment->$prefixedusernamefield;
     514              }
     515  
     516              if (is_null($assessment->grade)) {
     517                  $class = ' notgraded';
     518                  $submission->status = 'notgraded';
     519                  $buttontext = get_string('assess', 'workshop');
     520              } else {
     521                  $class = ' graded';
     522                  $submission->status = 'graded';
     523                  $buttontext = get_string('reassess', 'workshop');
     524              }
     525              echo $output->box_start('generalbox assessment-summary' . $class);
     526              echo $output->render($workshop->prepare_submission_summary($submission, $shownames));
     527              echo $output->box_end();
     528          }
     529          print_collapsible_region_end();
     530      }
     531      break;
     532  case workshop::PHASE_CLOSED:
     533      if (trim($workshop->conclusion)) {
     534          $conclusion = file_rewrite_pluginfile_urls($workshop->conclusion, 'pluginfile.php', $workshop->context->id,
     535              'mod_workshop', 'conclusion', 0, workshop::instruction_editors_options($workshop->context));
     536          print_collapsible_region_start('', 'workshop-viewlet-conclusion', get_string('conclusion', 'workshop'));
     537          echo $output->box(format_text($conclusion, $workshop->conclusionformat, array('overflowdiv'=>true)), array('generalbox', 'conclusion'));
     538          print_collapsible_region_end();
     539      }
     540      $finalgrades = $workshop->get_gradebook_grades($USER->id);
     541      if (!empty($finalgrades)) {
     542          print_collapsible_region_start('', 'workshop-viewlet-yourgrades', get_string('yourgrades', 'workshop'));
     543          echo $output->box_start('generalbox grades-yourgrades');
     544          echo $output->render($finalgrades);
     545          echo $output->box_end();
     546          print_collapsible_region_end();
     547      }
     548      if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
     549          $perpage = get_user_preferences('workshop_perpage', 10);
     550          $groupid = groups_get_activity_group($workshop->cm, true);
     551          $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow);
     552          if ($data) {
     553              $showauthornames    = has_capability('mod/workshop:viewauthornames', $workshop->context);
     554              $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);
     555  
     556              // prepare paging bar
     557              $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow));
     558              $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page');
     559  
     560              // grading report display options
     561              $reportopts                         = new stdclass();
     562              $reportopts->showauthornames        = $showauthornames;
     563              $reportopts->showreviewernames      = $showreviewernames;
     564              $reportopts->sortby                 = $sortby;
     565              $reportopts->sorthow                = $sorthow;
     566              $reportopts->showsubmissiongrade    = true;
     567              $reportopts->showgradinggrade       = true;
     568  
     569              print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'));
     570              echo $output->box_start('generalbox gradesreport');
     571              echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget');
     572              echo $output->render($pagingbar);
     573              echo $output->render(new workshop_grading_report($data, $reportopts));
     574              echo $output->render($pagingbar);
     575              echo $output->perpage_selector($perpage);
     576              echo $output->box_end();
     577              print_collapsible_region_end();
     578          }
     579      }
     580      if (has_capability('mod/workshop:submit', $PAGE->context)) {
     581          print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'));
     582          echo $output->box_start('generalbox ownsubmission');
     583          if ($submission = $workshop->get_submission_by_author($USER->id)) {
     584              echo $output->render($workshop->prepare_submission_summary($submission, true));
     585          } else {
     586              echo $output->container(get_string('noyoursubmission', 'workshop'));
     587          }
     588          echo $output->box_end();
     589  
     590          if (!empty($submission->gradeoverby) and strlen(trim($submission->feedbackauthor)) > 0) {
     591              echo $output->render(new workshop_feedback_author($submission));
     592          }
     593  
     594          print_collapsible_region_end();
     595      }
     596      if (has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context)) {
     597          $shownames = has_capability('mod/workshop:viewauthorpublished', $workshop->context);
     598          if ($submissions = $workshop->get_published_submissions()) {
     599              print_collapsible_region_start('', 'workshop-viewlet-publicsubmissions', get_string('publishedsubmissions', 'workshop'));
     600              foreach ($submissions as $submission) {
     601                  echo $output->box_start('generalbox submission-summary');
     602                  echo $output->render($workshop->prepare_submission_summary($submission, $shownames));
     603                  echo $output->box_end();
     604              }
     605              print_collapsible_region_end();
     606          }
     607      }
     608      if ($assessments = $workshop->get_assessments_by_reviewer($USER->id)) {
     609          print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop'));
     610          $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
     611          foreach ($assessments as $assessment) {
     612              $submission                     = new stdclass();
     613              $submission->id                 = $assessment->submissionid;
     614              $submission->title              = $assessment->submissiontitle;
     615              $submission->timecreated        = $assessment->submissioncreated;
     616              $submission->timemodified       = $assessment->submissionmodified;
     617              $userpicturefields = explode(',', user_picture::fields());
     618              foreach ($userpicturefields as $userpicturefield) {
     619                  $prefixedusernamefield = 'author' . $userpicturefield;
     620                  $submission->$prefixedusernamefield = $assessment->$prefixedusernamefield;
     621              }
     622  
     623              if (is_null($assessment->grade)) {
     624                  $class = ' notgraded';
     625                  $submission->status = 'notgraded';
     626                  $buttontext = get_string('assess', 'workshop');
     627              } else {
     628                  $class = ' graded';
     629                  $submission->status = 'graded';
     630                  $buttontext = get_string('reassess', 'workshop');
     631              }
     632              echo $output->box_start('generalbox assessment-summary' . $class);
     633              echo $output->render($workshop->prepare_submission_summary($submission, $shownames));
     634              echo $output->box_end();
     635  
     636              if (strlen(trim($assessment->feedbackreviewer)) > 0) {
     637                  echo $output->render(new workshop_feedback_reviewer($assessment));
     638              }
     639          }
     640          print_collapsible_region_end();
     641      }
     642      break;
     643  default:
     644  }
     645  
     646  echo $output->footer();
    

    Search This Site: