mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-40122 SCORM: replace SCORM course format with singleactivity
This commit is contained in:
parent
838d78a9ff
commit
3d1808c6e2
@ -1421,6 +1421,12 @@ class restore_course_structure_step extends restore_structure_step {
|
||||
$data->theme = '';
|
||||
}
|
||||
|
||||
// Check if this is an old SCORM course format.
|
||||
if ($data->format == 'scorm') {
|
||||
$data->format = 'singleactivity';
|
||||
$data->activitytype = 'scorm';
|
||||
}
|
||||
|
||||
// Course record ready, update it
|
||||
$DB->update_record('course', $data);
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
// format.php - course format featuring single activity
|
||||
// included from view.php
|
||||
|
||||
$module = $course->format;
|
||||
require_once($CFG->dirroot.'/mod/'.$module.'/locallib.php');
|
||||
|
||||
$strgroups = get_string('groups');
|
||||
$strgroupmy = get_string('groupmy');
|
||||
$editing = $PAGE->user_is_editing();
|
||||
|
||||
$moduleformat = $module.'_course_format_display';
|
||||
if (function_exists($moduleformat)) {
|
||||
$moduleformat($USER,$course);
|
||||
} else {
|
||||
echo $OUTPUT->notification('The module '. $module. ' does not support single activity course format');
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'format_scorm', language 'en', branch 'MOODLE_20_STABLE'
|
||||
*
|
||||
* @package format_scorm
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['sectionname'] = 'SCORM';
|
||||
$string['pluginname'] = 'SCORM format';
|
@ -1,101 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains main class for the course format SCORM
|
||||
*
|
||||
* @since 2.0
|
||||
* @package format_scorm
|
||||
* @copyright 2009 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
require_once($CFG->dirroot. '/course/format/lib.php');
|
||||
|
||||
/**
|
||||
* Main class for the Scorm course format
|
||||
*
|
||||
* @package format_scorm
|
||||
* @copyright 2012 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_scorm extends format_base {
|
||||
|
||||
/**
|
||||
* The URL to use for the specified course
|
||||
*
|
||||
* @param int|stdClass $section Section object from database or just field course_sections.section
|
||||
* if null the course view page is returned
|
||||
* @param array $options options for view URL. At the moment core uses:
|
||||
* 'navigation' (bool) if true and section has no separate page, the function returns null
|
||||
* 'sr' (int) used by multipage formats to specify to which section to return
|
||||
* @return null|moodle_url
|
||||
*/
|
||||
public function get_view_url($section, $options = array()) {
|
||||
if (!empty($options['navigation']) && $section !== null) {
|
||||
return null;
|
||||
}
|
||||
return new moodle_url('/course/view.php', array('id' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all of the course sections into the navigation
|
||||
*
|
||||
* @param global_navigation $navigation
|
||||
* @param navigation_node $node The course node within the navigation
|
||||
*/
|
||||
public function extend_course_navigation($navigation, navigation_node $node) {
|
||||
// Scorm course format does not extend course navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of blocks to be automatically added for the newly created course
|
||||
*
|
||||
* @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT
|
||||
* each of values is an array of block names (for left and right side columns)
|
||||
*/
|
||||
public function get_default_blocks() {
|
||||
return array(
|
||||
BLOCK_POS_LEFT => array(),
|
||||
BLOCK_POS_RIGHT => array('news_items', 'recent_activity', 'calendar_upcoming')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows course format to execute code on moodle_page::set_course()
|
||||
*
|
||||
* If user is on course view page and there is no scorm module added to the course
|
||||
* and the user has 'moodle/course:update' capability, redirect to create module
|
||||
* form. This function is executed before the output starts
|
||||
*
|
||||
* @param moodle_page $page instance of page calling set_course
|
||||
*/
|
||||
public function page_set_course(moodle_page $page) {
|
||||
global $PAGE;
|
||||
if ($PAGE == $page && $page->has_set_url() &&
|
||||
$page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
|
||||
$modinfo = get_fast_modinfo($this->courseid);
|
||||
if (empty($modinfo->instances['scorm'])
|
||||
&& has_capability('moodle/course:update', context_course::instance($this->courseid))) {
|
||||
// Redirect to create a new activity
|
||||
$url = new moodle_url('/course/modedit.php',
|
||||
array('course' => $this->courseid, 'section' => 0, 'add' => 'scorm'));
|
||||
redirect($url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Version details
|
||||
*
|
||||
* @package format
|
||||
* @subpackage scorm
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2013050100; // Requires this Moodle version
|
||||
$plugin->component = 'format_scorm'; // Full name of the plugin (used for diagnostics)
|
@ -2327,5 +2327,29 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2013081200.00);
|
||||
}
|
||||
|
||||
// Convert SCORM course format courses to singleactivity.
|
||||
if ($oldversion < 2013081500.01) {
|
||||
// First set relevant singleactivity settings.
|
||||
$formatoptions = new stdClass();
|
||||
$formatoptions->format = 'singleactivity';
|
||||
$formatoptions->sectionid = 0;
|
||||
$formatoptions->name = 'activitytype';
|
||||
$formatoptions->value = 'scorm';
|
||||
|
||||
$courses = $DB->get_recordset('course', array('format' => 'scorm'), 'id');
|
||||
foreach ($courses as $course) {
|
||||
$formatoptions->courseid = $course->id;
|
||||
$DB->insert_record('course_format_options', $formatoptions);
|
||||
}
|
||||
$courses->close();
|
||||
|
||||
// Now update course format for these courses.
|
||||
$sql = "UPDATE {course}
|
||||
SET format = 'singleactivity', modinfo = '', sectioncache = ''
|
||||
WHERE format = 'scorm'";
|
||||
$DB->execute($sql);
|
||||
upgrade_main_savepoint(true, 2013081500.01);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ class plugin_manager {
|
||||
),
|
||||
|
||||
'format' => array(
|
||||
'scorm', 'singleactivity', 'social', 'topics', 'weeks'
|
||||
'singleactivity', 'social', 'topics', 'weeks'
|
||||
),
|
||||
|
||||
'gradeexport' => array(
|
||||
|
@ -770,60 +770,6 @@ function scorm_get_last_completed_attempt($scormid, $userid) {
|
||||
}
|
||||
}
|
||||
|
||||
function scorm_course_format_display($user, $course) {
|
||||
global $CFG, $DB, $PAGE, $OUTPUT;
|
||||
|
||||
$strupdate = get_string('update');
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
echo '<div class="mod-scorm">';
|
||||
if ($scorms = get_all_instances_in_course('scorm', $course)) {
|
||||
// The module SCORM activity with the least id is the course
|
||||
$scorm = current($scorms);
|
||||
if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
$contextmodule = context_module::instance($cm->id);
|
||||
if ((has_capability('mod/scorm:skipview', $contextmodule))) {
|
||||
scorm_simple_play($scorm, $user, $contextmodule, $cm->id);
|
||||
}
|
||||
$colspan = '';
|
||||
$headertext = '<table width="100%"><tr><td class="title">'.get_string('name').': <b>'.format_string($scorm->name).'</b>';
|
||||
if (has_capability('moodle/course:manageactivities', $context)) {
|
||||
if ($PAGE->user_is_editing()) {
|
||||
// Display update icon
|
||||
$path = $CFG->wwwroot.'/course';
|
||||
$headertext .= '<span class="commands">'.
|
||||
'<a title="'.$strupdate.'" href="'.$path.'/mod.php?update='.$cm->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="'.$strupdate.'" /></a></span>';
|
||||
}
|
||||
$headertext .= '</td>';
|
||||
// Display report link
|
||||
$trackedusers = $DB->get_record('scorm_scoes_track', array('scormid'=>$scorm->id), 'count(distinct(userid)) as c');
|
||||
if ($trackedusers->c > 0) {
|
||||
$headertext .= '<td class="reportlink">'.
|
||||
'<a href="'.$CFG->wwwroot.'/mod/scorm/report.php?id='.$cm->id.'">'.
|
||||
get_string('viewallreports', 'scorm', $trackedusers->c).'</a>';
|
||||
} else {
|
||||
$headertext .= '<td class="reportlink">'.get_string('noreports', 'scorm');
|
||||
}
|
||||
$colspan = ' colspan="2"';
|
||||
}
|
||||
$headertext .= '</td></tr><tr><td'.$colspan.'>'.get_string('summary').':<br />'.format_module_intro('scorm', $scorm, $scorm->coursemodule).'</td></tr></table>';
|
||||
echo $OUTPUT->box($headertext, 'generalbox boxwidthwide');
|
||||
scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm);
|
||||
} else {
|
||||
if (has_capability('moodle/course:update', $context)) {
|
||||
// Create a new activity
|
||||
$url = new moodle_url('/course/mod.php', array('id'=>$course->id, 'section'=>'0', 'sesskey'=>sesskey(),'add'=>'scorm'));
|
||||
redirect($url);
|
||||
} else {
|
||||
echo $OUTPUT->notification('Could not find a scorm course here');
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||
global $CFG, $DB, $PAGE, $OUTPUT, $COURSE;
|
||||
|
||||
@ -904,7 +850,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||
<label for="a"><?php print_string('newattempt', 'scorm') ?></label>
|
||||
<?php
|
||||
}
|
||||
if ($COURSE->format != 'scorm' && !empty($scorm->popup)) {
|
||||
if (!empty($scorm->popup)) {
|
||||
echo '<input type="hidden" name="display" value="popup" />'."\n";
|
||||
}
|
||||
?>
|
||||
|
@ -132,7 +132,7 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
|
||||
// Skip view page.
|
||||
$skipviewoptions = scorm_get_skip_view_array();
|
||||
if ($COURSE->format == 'scorm') { // Remove option that would cause a constant redirect.
|
||||
if ($COURSE->format == 'singleactivity') { // Remove option that would cause a constant redirect.
|
||||
unset($skipviewoptions[SCORM_SKIPVIEW_ALWAYS]);
|
||||
if ($cfg_scorm->skipview == SCORM_SKIPVIEW_ALWAYS) {
|
||||
$cfg_scorm->skipview = SCORM_SKIPVIEW_FIRST;
|
||||
@ -283,7 +283,7 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_scorm', 'package', 0);
|
||||
$default_values['packagefile'] = $draftitemid;
|
||||
|
||||
if (($COURSE->format == 'scorm') && ((count($scorms) == 0) || ($default_values['instance'] == $coursescorm->id))) {
|
||||
if (($COURSE->format == 'singleactivity') && ((count($scorms) == 0) || ($default_values['instance'] == $coursescorm->id))) {
|
||||
$default_values['redirect'] = 'yes';
|
||||
$default_values['redirecturl'] = '../course/view.php?id='.$default_values['course'];
|
||||
} else {
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2013081500.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2013081500.01; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user