mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
course publication MDL-19315 retrieve previously published information when republished
This commit is contained in:
parent
9e86f2e7a9
commit
178097a0c0
@ -110,7 +110,7 @@ if (!empty($fromform)) {
|
|||||||
|
|
||||||
|
|
||||||
$function = 'hub_get_courses';
|
$function = 'hub_get_courses';
|
||||||
$params = array($search, $downloadable, $options);
|
$params = array($search, $downloadable, !$downloadable, $options);
|
||||||
$serverurl = $huburl."/local/hub/webservice/webservices.php";
|
$serverurl = $huburl."/local/hub/webservice/webservices.php";
|
||||||
require_once($CFG->dirroot."/webservice/xmlrpc/lib.php");
|
require_once($CFG->dirroot."/webservice/xmlrpc/lib.php");
|
||||||
$xmlrpcclient = new webservice_xmlrpc_client();
|
$xmlrpcclient = new webservice_xmlrpc_client();
|
||||||
|
@ -94,18 +94,82 @@ class course_publication_form extends moodleform {
|
|||||||
$mform->addElement('hidden', 'huburl', $huburl);
|
$mform->addElement('hidden', 'huburl', $huburl);
|
||||||
$mform->addElement('hidden', 'hubname', $hubname);
|
$mform->addElement('hidden', 'hubname', $hubname);
|
||||||
|
|
||||||
|
//check on the hub if the course has already been published
|
||||||
|
$hub = new hub();
|
||||||
|
$registeredhub = $hub->get_registeredhub($huburl);
|
||||||
|
$publications = $hub->get_publications($registeredhub->id, $course->id, $advertise);
|
||||||
|
|
||||||
|
if (!empty($publications)) {
|
||||||
|
//get the last publication of this course
|
||||||
|
$publication = array_pop($publications);
|
||||||
|
|
||||||
|
$function = 'hub_get_courses';
|
||||||
|
$options = new stdClass();
|
||||||
|
$options->ids = array($publication->hubcourseid);
|
||||||
|
$options->allsitecourses = 1;
|
||||||
|
$params = array('', $share, !$share, $options);
|
||||||
|
$serverurl = $huburl."/local/hub/webservice/webservices.php";
|
||||||
|
require_once($CFG->dirroot."/webservice/xmlrpc/lib.php");
|
||||||
|
$xmlrpcclient = new webservice_xmlrpc_client();
|
||||||
|
$publishedcourses = $xmlrpcclient->call($serverurl, $registeredhub->token, $function, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!empty($publishedcourses)) {
|
||||||
|
$publishedcourse = $publishedcourses[0];
|
||||||
|
$defaultfullname = $publishedcourse['fullname'];
|
||||||
|
$defaultshortname = $publishedcourse['shortname'];
|
||||||
|
$defaultsummary = $publishedcourse['description'];
|
||||||
|
$defaultlanguage = $publishedcourse['language'];
|
||||||
|
$defaultpublishername = $publishedcourse['publishername'];
|
||||||
|
$defaultcontributornames = $publishedcourse['contributornames'];
|
||||||
|
$defaultcoverage = $publishedcourse['coverage'];
|
||||||
|
$defaultcreatorname = $publishedcourse['creatorname'];
|
||||||
|
$defaultlicenceshortname = $publishedcourse['licenceshortname'];
|
||||||
|
$defaultsubject = $publishedcourse['subject'];
|
||||||
|
$defaultaudience = $publishedcourse['audience'];
|
||||||
|
$defaulteducationallevel = $publishedcourse['educationallevel'];
|
||||||
|
$defaultcreatornotes = $publishedcourse['creatornotes'];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$defaultfullname = $course->fullname;
|
||||||
|
$defaultshortname = $course->shortname;
|
||||||
|
$defaultsummary = $course->summary;
|
||||||
|
if (empty($course->lang)) {
|
||||||
|
$language = get_site()->lang;
|
||||||
|
if (empty($language)) {
|
||||||
|
$defaultlanguage = current_language();
|
||||||
|
} else {
|
||||||
|
$defaultlanguage = $language;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$defaultlanguage = $course->lang;
|
||||||
|
}
|
||||||
|
$defaultpublishername = $USER->firstname.' '.$USER->lastname;
|
||||||
|
$defaultcontributornames = '';
|
||||||
|
$defaultcoverage = '';
|
||||||
|
$defaultcreatorname = $USER->firstname.' '.$USER->lastname;
|
||||||
|
$defaultlicenceshortname = 'cc';
|
||||||
|
$defaultsubject = '';
|
||||||
|
$defaultaudience = AUDIENCE_EDUCATORS;
|
||||||
|
$defaulteducationallevel = EDULEVEL_TERTIARY;
|
||||||
|
$defaultcreatornotes = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//the input parameters
|
//the input parameters
|
||||||
$mform->addElement('header', 'moodle', get_string('publicationinfo', 'hub'));
|
$mform->addElement('header', 'moodle', get_string('publicationinfo', 'hub'));
|
||||||
|
|
||||||
$mform->addElement('text','name' , get_string('coursename', 'hub'));
|
$mform->addElement('text','name' , get_string('coursename', 'hub'));
|
||||||
$mform->addRule('name', $strrequired, 'required', null, 'client');
|
$mform->addRule('name', $strrequired, 'required', null, 'client');
|
||||||
$mform->setType('name', PARAM_TEXT);
|
$mform->setType('name', PARAM_TEXT);
|
||||||
$mform->setDefault('name', $course->fullname);
|
$mform->setDefault('name', $defaultfullname);
|
||||||
|
|
||||||
$mform->addElement('hidden', 'id', $this->_customdata['id']);
|
$mform->addElement('hidden', 'id', $this->_customdata['id']);
|
||||||
|
|
||||||
if ($share) {
|
if ($share) {
|
||||||
$buttonlabel = get_string('shareon', 'hub', !empty($hubname)?$hubname:$huburl);
|
$buttonlabel = get_string('shareon', 'hub', !empty($hubname)?$hubname:$huburl);
|
||||||
|
|
||||||
$mform->addElement('hidden', 'share', $share);
|
$mform->addElement('hidden', 'share', $share);
|
||||||
|
|
||||||
$mform->addElement('text', 'demourl', get_string('demourl', 'hub'));
|
$mform->addElement('text', 'demourl', get_string('demourl', 'hub'));
|
||||||
@ -115,7 +179,11 @@ class course_publication_form extends moodleform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($advertise) {
|
if ($advertise) {
|
||||||
$buttonlabel = get_string('advertiseon', 'hub', !empty($hubname)?$hubname:$huburl);
|
if (empty($publications)) {
|
||||||
|
$buttonlabel = get_string('advertiseon', 'hub', !empty($hubname)?$hubname:$huburl);
|
||||||
|
} else {
|
||||||
|
$buttonlabel = get_string('readvertiseon', 'hub', !empty($hubname)?$hubname:$huburl);
|
||||||
|
}
|
||||||
$mform->addElement('hidden', 'advertise', $advertise);
|
$mform->addElement('hidden', 'advertise', $advertise);
|
||||||
|
|
||||||
$mform->addElement('static', 'courseurl', get_string('courseurl', 'hub'));
|
$mform->addElement('static', 'courseurl', get_string('courseurl', 'hub'));
|
||||||
@ -124,47 +192,38 @@ class course_publication_form extends moodleform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$mform->addElement('text', 'courseshortname',get_string('courseshortname', 'hub'));
|
$mform->addElement('text', 'courseshortname',get_string('courseshortname', 'hub'));
|
||||||
$mform->setDefault('courseshortname', $course->shortname);
|
$mform->setDefault('courseshortname', $defaultshortname);
|
||||||
$mform->addHelpButton('courseshortname', 'courseshortname', 'hub');
|
$mform->addHelpButton('courseshortname', 'courseshortname', 'hub');
|
||||||
|
|
||||||
$mform->addElement('textarea', 'description', get_string('description'), array('rows'=>10));
|
$mform->addElement('textarea', 'description', get_string('description'), array('rows'=>10));
|
||||||
$mform->addRule('description', $strrequired, 'required', null, 'client');
|
$mform->addRule('description', $strrequired, 'required', null, 'client');
|
||||||
$mform->setDefault('description', $course->summary);
|
$mform->setDefault('description', $defaultsummary);
|
||||||
$mform->setType('description', PARAM_TEXT);
|
$mform->setType('description', PARAM_TEXT);
|
||||||
|
|
||||||
$languages = get_string_manager()->get_list_of_languages();
|
$languages = get_string_manager()->get_list_of_languages();
|
||||||
|
|
||||||
$mform->addElement('select', 'language',get_string('language'), $languages);
|
$mform->addElement('select', 'language',get_string('language'), $languages);
|
||||||
if (empty($course->lang)) {
|
$mform->setDefault('language', $defaultlanguage);
|
||||||
$language = get_site()->lang;
|
|
||||||
if (empty($language)) {
|
|
||||||
$mform->setDefault('language', current_language());
|
|
||||||
} else {
|
|
||||||
$mform->setDefault('language', $language);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$mform->setDefault('language', $course->lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$mform->addElement('text', 'publishername',get_string('publishername', 'hub'));
|
$mform->addElement('text', 'publishername',get_string('publishername', 'hub'));
|
||||||
$mform->setDefault('publishername', $USER->firstname.' '.$USER->lastname);
|
$mform->setDefault('publishername', $defaultpublishername);
|
||||||
$mform->addRule('publishername', $strrequired, 'required', null, 'client');
|
$mform->addRule('publishername', $strrequired, 'required', null, 'client');
|
||||||
$mform->addHelpButton('publishername', 'publishername', 'hub');
|
$mform->addHelpButton('publishername', 'publishername', 'hub');
|
||||||
|
|
||||||
$mform->addElement('text', 'contributornames', get_string('contributornames', 'hub'));
|
$mform->addElement('text', 'contributornames', get_string('contributornames', 'hub'));
|
||||||
$mform->setDefault('contributornames', '');
|
$mform->setDefault('contributornames', $defaultcontributornames);
|
||||||
$mform->addHelpButton('contributornames', 'contributornames', 'hub');
|
$mform->addHelpButton('contributornames', 'contributornames', 'hub');
|
||||||
|
|
||||||
$mform->addElement('text','coverage' , get_string('tags', 'hub'));
|
$mform->addElement('text','coverage' , get_string('tags', 'hub'));
|
||||||
$mform->setType('coverage', PARAM_TEXT);
|
$mform->setType('coverage', PARAM_TEXT);
|
||||||
|
$mform->setDefault('coverage', $defaultcoverage);
|
||||||
$mform->addHelpButton('coverage', 'tags', 'hub');
|
$mform->addHelpButton('coverage', 'tags', 'hub');
|
||||||
|
|
||||||
$mform->addElement('text', 'creatorname', get_string('creatorname', 'hub'));
|
$mform->addElement('text', 'creatorname', get_string('creatorname', 'hub'));
|
||||||
$mform->addRule('creatorname', $strrequired, 'required', null, 'client');
|
$mform->addRule('creatorname', $strrequired, 'required', null, 'client');
|
||||||
$mform->setType('creatorname', PARAM_TEXT);
|
$mform->setType('creatorname', PARAM_TEXT);
|
||||||
$mform->setDefault('creatorname', $USER->firstname.' '.$USER->lastname);
|
$mform->setDefault('creatorname', $defaultcreatorname);
|
||||||
$mform->addHelpButton('creatorname', 'creatorname', 'hub');
|
$mform->addHelpButton('creatorname', 'creatorname', 'hub');
|
||||||
|
|
||||||
require_once($CFG->dirroot."/lib/licenselib.php");
|
require_once($CFG->dirroot."/lib/licenselib.php");
|
||||||
@ -175,7 +234,7 @@ class course_publication_form extends moodleform {
|
|||||||
$options[$license->shortname] = get_string($license->shortname, 'license');
|
$options[$license->shortname] = get_string($license->shortname, 'license');
|
||||||
}
|
}
|
||||||
$mform->addElement('select', 'licence', get_string('license'), $options);
|
$mform->addElement('select', 'licence', get_string('license'), $options);
|
||||||
$mform->setDefault('licence', 'cc');
|
$mform->setDefault('licence', $defaultlicenceshortname);
|
||||||
unset($options);
|
unset($options);
|
||||||
$mform->addHelpButton('licence', 'licence', 'hub');
|
$mform->addHelpButton('licence', 'licence', 'hub');
|
||||||
|
|
||||||
@ -183,13 +242,14 @@ class course_publication_form extends moodleform {
|
|||||||
$mform->addElement('select', 'subject', get_string('subject', 'hub'), $options);
|
$mform->addElement('select', 'subject', get_string('subject', 'hub'), $options);
|
||||||
unset($options);
|
unset($options);
|
||||||
$mform->addHelpButton('subject', 'subject', 'hub');
|
$mform->addHelpButton('subject', 'subject', 'hub');
|
||||||
|
$mform->setDefault('subject', $defaultsubject);
|
||||||
|
|
||||||
$options = array();
|
$options = array();
|
||||||
$options[AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub');
|
$options[AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub');
|
||||||
$options[AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub');
|
$options[AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub');
|
||||||
$options[AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub');
|
$options[AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub');
|
||||||
$mform->addElement('select', 'audience', get_string('audience', 'hub'), $options);
|
$mform->addElement('select', 'audience', get_string('audience', 'hub'), $options);
|
||||||
$mform->setDefault('audience', AUDIENCE_EDUCATORS);
|
$mform->setDefault('audience', $defaultaudience);
|
||||||
unset($options);
|
unset($options);
|
||||||
$mform->addHelpButton('audience', 'audience', 'hub');
|
$mform->addHelpButton('audience', 'audience', 'hub');
|
||||||
|
|
||||||
@ -202,14 +262,14 @@ class course_publication_form extends moodleform {
|
|||||||
$options[EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub');
|
$options[EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub');
|
||||||
$options[EDULEVEL_OTHER] = get_string('edulevelother', 'hub');
|
$options[EDULEVEL_OTHER] = get_string('edulevelother', 'hub');
|
||||||
$mform->addElement('select', 'educationallevel', get_string('educationallevel', 'hub'), $options);
|
$mform->addElement('select', 'educationallevel', get_string('educationallevel', 'hub'), $options);
|
||||||
$mform->setDefault('educationallevel', EDULEVEL_TERTIARY);
|
$mform->setDefault('educationallevel', $defaulteducationallevel);
|
||||||
unset($options);
|
unset($options);
|
||||||
$mform->addHelpButton('educationallevel', 'educationallevel', 'hub');
|
$mform->addHelpButton('educationallevel', 'educationallevel', 'hub');
|
||||||
|
|
||||||
$editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false, 'forcehttps'=>false);
|
$editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false, 'forcehttps'=>false);
|
||||||
$mform->addElement('editor', 'creatornotes', get_string('creatornotes', 'hub'), '', $editoroptions);
|
$mform->addElement('editor', 'creatornotes', get_string('creatornotes', 'hub'), '', $editoroptions);
|
||||||
$mform->addRule('creatornotes', $strrequired, 'required', null, 'client');
|
$mform->addRule('creatornotes', $strrequired, 'required', null, 'client');
|
||||||
$mform->setDefault('creatornotes', '');
|
$mform->setDefault('creatornotes', $defaultcreatornotes);
|
||||||
$mform->setType('creatornotes', PARAM_CLEANHTML);
|
$mform->setType('creatornotes', PARAM_CLEANHTML);
|
||||||
$mform->addHelpButton('creatornotes', 'creatornotes', 'hub');
|
$mform->addHelpButton('creatornotes', 'creatornotes', 'hub');
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
|
|||||||
$creatornotes = optional_param('creatornotes', false, PARAM_RAW);
|
$creatornotes = optional_param('creatornotes', false, PARAM_RAW);
|
||||||
$courseinfo->creatornotes = $creatornotes['text'];
|
$courseinfo->creatornotes = $creatornotes['text'];
|
||||||
$courseinfo->creatornotesformat = $creatornotes['format'];
|
$courseinfo->creatornotesformat = $creatornotes['format'];
|
||||||
|
$courseinfo->sitecourseid = $id;
|
||||||
if ($share) {
|
if ($share) {
|
||||||
$courseinfo->demourl = optional_param('demourl', false, PARAM_URL);
|
$courseinfo->demourl = optional_param('demourl', false, PARAM_URL);
|
||||||
$courseinfo->enrollable = false;
|
$courseinfo->enrollable = false;
|
||||||
@ -137,6 +138,17 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
|
|||||||
$courseregisteredmsg = $OUTPUT->notification(get_string('coursepublished', 'hub'), 'notifysuccess');
|
$courseregisteredmsg = $OUTPUT->notification(get_string('coursepublished', 'hub'), 'notifysuccess');
|
||||||
|
|
||||||
|
|
||||||
|
//save the record into the published course table
|
||||||
|
$publication = $hub->get_publication($courseids[0]);
|
||||||
|
if (empty($publication)) {
|
||||||
|
//if never been published or if we share, we need to save this new publication record
|
||||||
|
$hub->add_course_publication($registeredhub->id, $course->id, !$share, $courseids[0]);
|
||||||
|
} else {
|
||||||
|
//if we update the enrollable course publication we update the publication record
|
||||||
|
$hub->update_enrollable_course_publication($publication->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SEND FILES
|
// SEND FILES
|
||||||
|
|
||||||
// send screenshots
|
// send screenshots
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
$string['addedtoblock'] = 'Course added to block';
|
$string['addedtoblock'] = 'Course added to block';
|
||||||
$string['advertise'] = 'Publish as enrollable';
|
$string['advertise'] = 'Publish as enrollable';
|
||||||
$string['advertiseon'] = 'Publish as enrollable on {$a}';
|
$string['advertiseon'] = 'Publish as enrollable on {$a}';
|
||||||
|
$string['readvertiseon'] = 'Update publication information on {$a}';
|
||||||
$string['advertiseonhub'] = 'Publish as enrollable on hub';
|
$string['advertiseonhub'] = 'Publish as enrollable on hub';
|
||||||
$string['advertiseonmoodleorg'] = 'Publish as enrollable on Moodle.org';
|
$string['advertiseonmoodleorg'] = 'Publish as enrollable on Moodle.org';
|
||||||
$string['advertiseonspecifichub'] = 'Publish as enrollable on a specific hub';
|
$string['advertiseonspecifichub'] = 'Publish as enrollable on a specific hub';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<XMLDB PATH="lib/db" VERSION="20100504" COMMENT="XMLDB file for core Moodle tables"
|
<XMLDB PATH="lib/db" VERSION="20100513" COMMENT="XMLDB file for core Moodle tables"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||||
>
|
>
|
||||||
@ -2594,7 +2594,7 @@
|
|||||||
<INDEX NAME="backupid_parentitemid_ix" UNIQUE="false" FIELDS="backupid, itemname, parentitemid"/>
|
<INDEX NAME="backupid_parentitemid_ix" UNIQUE="false" FIELDS="backupid, itemname, parentitemid"/>
|
||||||
</INDEXES>
|
</INDEXES>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
<TABLE NAME="backup_logs" COMMENT="To store all the logs from backup and restore operations (by db logger)" PREVIOUS="backup_ids_template">
|
<TABLE NAME="backup_logs" COMMENT="To store all the logs from backup and restore operations (by db logger)" PREVIOUS="backup_ids_template" NEXT="published_courses">
|
||||||
<FIELDS>
|
<FIELDS>
|
||||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="backupid"/>
|
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="backupid"/>
|
||||||
<FIELD NAME="backupid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="backupid the log record belongs to" PREVIOUS="id" NEXT="loglevel"/>
|
<FIELD NAME="backupid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="backupid the log record belongs to" PREVIOUS="id" NEXT="loglevel"/>
|
||||||
@ -2610,5 +2610,18 @@
|
|||||||
<INDEX NAME="backupid-id" UNIQUE="true" FIELDS="backupid, id" COMMENT="for quick ordered retrieval by backupid"/>
|
<INDEX NAME="backupid-id" UNIQUE="true" FIELDS="backupid, id" COMMENT="for quick ordered retrieval by backupid"/>
|
||||||
</INDEXES>
|
</INDEXES>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
|
<TABLE NAME="published_courses" COMMENT="All course that has been published on a hub and the type of publishing (enrol/download)" PREVIOUS="backup_logs">
|
||||||
|
<FIELDS>
|
||||||
|
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="hubid"/>
|
||||||
|
<FIELD NAME="hubid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the id of the "registered on" hub" PREVIOUS="id" NEXT="courseid"/>
|
||||||
|
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the id of the published course" PREVIOUS="hubid" NEXT="time"/>
|
||||||
|
<FIELD NAME="time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the time when the publication occured" PREVIOUS="courseid" NEXT="enrollable"/>
|
||||||
|
<FIELD NAME="enrollable" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="1 = enrollable, 0 = downloadable" PREVIOUS="time" NEXT="hubcourseid"/>
|
||||||
|
<FIELD NAME="hubcourseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="the course id on the hub server" PREVIOUS="enrollable"/>
|
||||||
|
</FIELDS>
|
||||||
|
<KEYS>
|
||||||
|
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||||
|
</KEYS>
|
||||||
|
</TABLE>
|
||||||
</TABLES>
|
</TABLES>
|
||||||
</XMLDB>
|
</XMLDB>
|
@ -4017,6 +4017,46 @@ AND EXISTS (SELECT 'x'
|
|||||||
upgrade_main_savepoint($result, 2010050411);
|
upgrade_main_savepoint($result, 2010050411);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($result && $oldversion < 2010050413) {
|
||||||
|
|
||||||
|
/// Define table published_courses to be created
|
||||||
|
$table = new xmldb_table('published_courses');
|
||||||
|
|
||||||
|
/// Adding fields to table published_courses
|
||||||
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||||
|
$table->add_field('hubid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||||
|
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||||
|
$table->add_field('time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||||
|
$table->add_field('enrollable', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
|
||||||
|
|
||||||
|
/// Adding keys to table published_courses
|
||||||
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||||
|
|
||||||
|
/// Conditionally launch create table for published_courses
|
||||||
|
if (!$dbman->table_exists($table)) {
|
||||||
|
$dbman->create_table($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Main savepoint reached
|
||||||
|
upgrade_main_savepoint($result, 2010050413);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result && $oldversion < 2010050414) {
|
||||||
|
|
||||||
|
/// Define field hubcourseid to be added to published_courses
|
||||||
|
$table = new xmldb_table('published_courses');
|
||||||
|
$field = new xmldb_field('hubcourseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'enrollable');
|
||||||
|
|
||||||
|
/// Conditionally launch add field hubcourseid
|
||||||
|
if (!$dbman->field_exists($table, $field)) {
|
||||||
|
$dbman->add_field($table, $field);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Main savepoint reached
|
||||||
|
upgrade_main_savepoint($result, 2010050414);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +190,40 @@ class hub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function add_course_publication($hubid, $courseid, $enrollable, $hubcourseid) {
|
||||||
|
global $DB;
|
||||||
|
$publication = new stdClass();
|
||||||
|
$publication->hubid = $hubid;
|
||||||
|
$publication->courseid = $courseid;
|
||||||
|
$publication->hubcourseid = $hubcourseid;
|
||||||
|
$publication->enrollable = $enrollable;
|
||||||
|
$publication->time = time();
|
||||||
|
$DB->insert_record('published_courses', $publication);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_enrollable_course_publication($publicationid) {
|
||||||
|
global $DB;
|
||||||
|
$publication = new stdClass();
|
||||||
|
$publication->id = $publicationid;
|
||||||
|
$publication->time = time();
|
||||||
|
$DB->update_record('published_courses', $publication);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_publications($hubid, $courseid, $enrollable) {
|
||||||
|
global $DB;
|
||||||
|
return $DB->get_records('published_courses',
|
||||||
|
array('hubid' => $hubid, 'courseid' => $courseid, 'enrollable' => $enrollable));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_publication($hubcourseid) {
|
||||||
|
global $DB;
|
||||||
|
return $DB->get_record('published_courses',
|
||||||
|
array('hubcourseid' => $hubcourseid));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
/// Library functions ///
|
/// Library functions ///
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
// This is compared against the values stored in the database to determine
|
// This is compared against the values stored in the database to determine
|
||||||
// whether upgrades should be performed (see lib/db/*.php)
|
// whether upgrades should be performed (see lib/db/*.php)
|
||||||
|
|
||||||
$version = 2010050412; // YYYYMMDD = date of the last version bump
|
$version = 2010050414; // YYYYMMDD = date of the last version bump
|
||||||
// XX = daily increments
|
// XX = daily increments
|
||||||
|
|
||||||
$release = '2.0 Preview 1 (Build: 20100513)'; // Human-friendly version name
|
$release = '2.0 Preview 1 (Build: 20100513)'; // Human-friendly version name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user