[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/quiz/ -> comment.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 page allows the teacher to enter a manual grade for a particular question.
  19   * This page is expected to only be used in a popup window.
  20   *
  21   * @package   mod_quiz
  22   * @copyright gustav delius 2006
  23   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  require_once('../../config.php');
  27  require_once ('locallib.php');
  28  
  29  $attemptid = required_param('attempt', PARAM_INT);
  30  $slot = required_param('slot', PARAM_INT); // The question number in the attempt.
  31  
  32  $PAGE->set_url('/mod/quiz/comment.php', array('attempt' => $attemptid, 'slot' => $slot));
  33  
  34  $attemptobj = quiz_attempt::create($attemptid);
  35  
  36  // Can only grade finished attempts.
  37  if (!$attemptobj->is_finished()) {
  38      print_error('attemptclosed', 'quiz');
  39  }
  40  
  41  // Check login and permissions.
  42  require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
  43  $attemptobj->require_capability('mod/quiz:grade');
  44  
  45  // Print the page header.
  46  $PAGE->set_pagelayout('popup');
  47  $PAGE->set_heading($attemptobj->get_course()->fullname);
  48  $output = $PAGE->get_renderer('mod_quiz');
  49  echo $output->header();
  50  
  51  // Prepare summary information about this question attempt.
  52  $summarydata = array();
  53  
  54  // Quiz name.
  55  $summarydata['quizname'] = array(
  56      'title'   => get_string('modulename', 'quiz'),
  57      'content' => format_string($attemptobj->get_quiz_name()),
  58  );
  59  
  60  // Question name.
  61  $summarydata['questionname'] = array(
  62      'title'   => get_string('question', 'quiz'),
  63      'content' => $attemptobj->get_question_name($slot),
  64  );
  65  
  66  // Process any data that was submitted.
  67  if (data_submitted() && confirm_sesskey()) {
  68      if (optional_param('submit', false, PARAM_BOOL) && question_engine::is_manual_grade_in_range($attemptobj->get_uniqueid(), $slot)) {
  69          $transaction = $DB->start_delegated_transaction();
  70          $attemptobj->process_submitted_actions(time());
  71          $transaction->allow_commit();
  72  
  73          // Log this action.
  74          $params = array(
  75              'objectid' => $attemptobj->get_question_attempt($slot)->get_question()->id,
  76              'courseid' => $attemptobj->get_courseid(),
  77              'context' => context_module::instance($attemptobj->get_cmid()),
  78              'other' => array(
  79                  'quizid' => $attemptobj->get_quizid(),
  80                  'attemptid' => $attemptobj->get_attemptid(),
  81                  'slot' => $slot
  82              )
  83          );
  84          $event = \mod_quiz\event\question_manually_graded::create($params);
  85          $event->trigger();
  86  
  87          echo $output->notification(get_string('changessaved'), 'notifysuccess');
  88          close_window(2, true);
  89          die;
  90      }
  91  }
  92  
  93  // Print quiz information.
  94  echo $output->review_summary_table($summarydata, 0);
  95  
  96  // Print the comment form.
  97  echo '<form method="post" class="mform" id="manualgradingform" action="' .
  98          $CFG->wwwroot . '/mod/quiz/comment.php">';
  99  echo $attemptobj->render_question_for_commenting($slot);
 100  ?>
 101  <div>
 102      <input type="hidden" name="attempt" value="<?php echo $attemptobj->get_attemptid(); ?>" />
 103      <input type="hidden" name="slot" value="<?php echo $slot; ?>" />
 104      <input type="hidden" name="slots" value="<?php echo $slot; ?>" />
 105      <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
 106  </div>
 107  <fieldset class="hidden">
 108      <div>
 109          <div class="fitem fitem_actionbuttons fitem_fsubmit">
 110              <fieldset class="felement fsubmit">
 111                  <input id="id_submitbutton" type="submit" name="submit" value="<?php
 112                          print_string('save', 'quiz'); ?>"/>
 113              </fieldset>
 114          </div>
 115      </div>
 116  </fieldset>
 117  <?php
 118  echo '</form>';
 119  $PAGE->requires->js_init_call('M.mod_quiz.init_comment_popup', null, false, quiz_get_js_module());
 120  
 121  // End of the page.
 122  echo $output->footer();


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1