Skip to content

Commit

Permalink
Separate course Cloud ID from Moodle ID
Browse files Browse the repository at this point in the history
Closes #13.
  • Loading branch information
Stuart Childs committed Oct 7, 2011
1 parent b65181b commit 4d1fce7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
5 changes: 3 additions & 2 deletions mod/scormcloud/db/install.xml
Expand Up @@ -6,8 +6,9 @@
<TABLES>
<TABLE NAME="scormcloud" COMMENT="this table tracks the courses for scormcloud" NEXT="scormcloud_registrations">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Course scormcloud activity belongs to" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="cloudid"/>
<FIELD NAME="cloudid" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Unique identifier for course on the SCORM Cloud" PREVIOUS="id" NEXT="course" />
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Course scormcloud activity belongs to" PREVIOUS="cloudid" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="name field for moodle instances" PREVIOUS="course" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="scoreformat"/>
Expand Down
34 changes: 32 additions & 2 deletions mod/scormcloud/db/upgrade.php
Expand Up @@ -39,17 +39,47 @@

defined('MOODLE_INTERNAL') || die();

require_once('../config.php');
require_once($CFG->dirroot . '/mod/scormcloud/constants.php');

/**
* xmldb_scormcloud_upgrade
*
* @param int $oldversion
* @return bool
*/
function xmldb_scormcloud_upgrade($oldversion) {

global $DB;
global $CFG;

$dbman = $DB->get_manager();

$module = new stdClass();
require($CFG->dirroot . '/mod/scormcloud/version.php');

$result = true;

if ($result && $oldversion < 2011100700) {
$table = new xmldb_table(SCORMCLOUD_TABLE);
$field = new xmldb_field('cloudid', XMLDB_TYPE_CHAR, '255', null, 'XMLDB_NULL', null, null, 'id');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

$rs = $DB->get_recordset(SCORMCLOUD_TABLE);
foreach ($rs as $record) {
if (!isset($record->cloudid) || empty($record->cloudid)) {
$record->cloudid = $record->id;
$DB->update_record(SCORMCLOUD_TABLE, $record, true);
}
}
$rs->close();

$field->setNotNull();
$dbman->change_field_notnull($table, $field);
}

upgrade_mod_savepoint($result, $module->version, 'scormcloud');

return true;
return $result;
}
2 changes: 1 addition & 1 deletion mod/scormcloud/locallib.php
Expand Up @@ -105,7 +105,7 @@ function scormcloud_course_format_display($user, $course)

$reportageui = new ReportageUI($rptService, $rptAuth, $scormcloud, $user);

if ($courseExists = scormcloud_course_exists_on_cloud($scormcloud->id)) {
if ($courseExists = scormcloud_course_exists_on_cloud($scormcloud->cloudid)) {
$containerContext = (object)array('scormcloud' => $scormcloud,
'course' => $course,
'user' => $user,
Expand Down
10 changes: 5 additions & 5 deletions mod/scormcloud/ui/ReportageUI.php
Expand Up @@ -43,23 +43,23 @@ public function __construct($reportingService, $reportingServiceAuth, $scormclou
$this->_userSummarySettings->setEmbedded(true);
$this->_userSummarySettings->setVertical(false);
$this->_userSummarySettings->setDivname('UserSummary');
$this->_userSummarySettings->setCourseId($scormcloud->id);
$this->_userSummarySettings->setCourseId($scormcloud->cloudid);
$this->_userSummarySettings->setLearnerId($user->username);

$this->_userActivitiesSettings = new WidgetSettings();
$this->_userActivitiesSettings->setShowTitle(true);
$this->_userActivitiesSettings->setScriptBased(true);
$this->_userActivitiesSettings->setEmbedded(true);
$this->_userActivitiesSettings->setDivname('UserActivities');
$this->_userActivitiesSettings->setCourseId($scormcloud->id);
$this->_userActivitiesSettings->setCourseId($scormcloud->cloudid);
$this->_userActivitiesSettings->setLearnerId($user->username);

$this->_courseSummarySettings = new WidgetSettings();
$this->_courseSummarySettings->setShowTitle(true);
$this->_courseSummarySettings->setScriptBased(true);
$this->_courseSummarySettings->setEmbedded(true);
$this->_courseSummarySettings->setVertical(true);
$this->_courseSummarySettings->setCourseId($scormcloud->id);
$this->_courseSummarySettings->setCourseId($scormcloud->cloudid);
$this->_courseSummarySettings->setDivname('CourseSummary');

$this->_courseListSettings = new WidgetSettings();
Expand All @@ -68,15 +68,15 @@ public function __construct($reportingService, $reportingServiceAuth, $scormclou
$this->_courseListSettings->setEmbedded(true);
$this->_courseListSettings->setExpand(true);
$this->_courseListSettings->setDivname('CourseListData');
$this->_courseListSettings->setCourseId($scormcloud->id);
$this->_courseListSettings->setCourseId($scormcloud->cloudid);

$this->_learnerListSettings = new WidgetSettings();
$this->_learnerListSettings->setShowTitle(true);
$this->_learnerListSettings->setScriptBased(true);
$this->_learnerListSettings->setEmbedded(true);
$this->_learnerListSettings->setExpand(false);
$this->_learnerListSettings->setDivname('LearnersListData');
$this->_learnerListSettings->setCourseId($scormcloud->id);
$this->_learnerListSettings->setCourseId($scormcloud->cloudid);
}

public function getUserSummaryUrl()
Expand Down
2 changes: 1 addition & 1 deletion mod/scormcloud/version.php
Expand Up @@ -34,6 +34,6 @@

defined('MOODLE_INTERNAL') || die();

$module->version = 2011091600; // The current module version (Date: YYYYMMDDXX)
$module->version = 2011100700; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2010031900; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)

0 comments on commit 4d1fce7

Please sign in to comment.