Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   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  require_once('../../../config.php');
  18  require_once($CFG->dirroot.'/mod/scorm/locallib.php');
  19  
  20  $id = optional_param('id', '', PARAM_INT);  // Course Module ID, or
  21  $a = optional_param('a', '', PARAM_INT);  // scorm ID.
  22  $scoid = required_param('scoid', PARAM_INT);  // Sco ID.
  23  $attempt = required_param('attempt', PARAM_INT);  // Attempt number.
  24  $function  = required_param('function', PARAM_RAW);  // Function to call.
  25  $request = optional_param('request', '', PARAM_RAW);  // Scorm ID.
  26  
  27  if (!empty($id)) {
  28      $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
  29      $course = $DB->get_record("course", array("id" => $cm->course), '*', MUST_EXIST);
  30      $scorm = $DB->get_record("scorm", array("id" => $cm->instance), '*', MUST_EXIST);
  31  } else if (!empty($a)) {
  32      $scorm = $DB->get_record("scorm", array("id" => $a), '*', MUST_EXIST);
  33      $course = $DB->get_record("course", array("id" => $scorm->course), '*', MUST_EXIST);
  34      $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id, false, MUST_EXIST);
  35  } else {
  36      print_error('missingparameter');
  37  }
  38  
  39  $PAGE->set_url('/mod/scorm/datamodels/sequencinghandler.php',
  40      array('scoid' => $scoid, 'attempt' => $attempt, 'id' => $cm->id, 'function' => $function, 'request' => $request));
  41  
  42  require_login($course, false, $cm);
  43  
  44  if (!empty($scoid) && !empty($function)) {
  45      require_once($CFG->dirroot.'/mod/scorm/datamodels/scorm_13lib.php');
  46  
  47      if (has_capability('mod/scorm:savetrack', context_module::instance($cm->id))) {
  48          $result = null;
  49          switch ($function) {
  50              case 'scorm_seq_flow' :
  51                  if ($request == 'forward' || $request == 'backward') {
  52                      $seq = scorm_seq_navigation ($scoid, $USER->id, $request.'_', $attempt);
  53                      $sco = scorm_get_sco($scoid);
  54                      $seq = scorm_seq_flow($sco, $request, $seq, true, $USER->id);
  55                      if (!empty($seq->nextactivity)) {
  56                          scorm_seq_end_attempt($sco, $USER->id, $seq);
  57                      }
  58                  }
  59                  echo json_encode($seq);
  60                  break;
  61          }
  62      }
  63  }