return set_field("course_modules", "groupmode", $groupmode, "id", $id);
}
+function set_coursemodule_idnumber($id, $idnumber) {
+ return set_field("course_modules", "idnumber", $idnumber, "id", $id);
+}
/**
* $prevstateoverrides = true will set the visibility of the course module
* to what is defined in visibleold. This enables us to remember the current
if (!empty($fromform->update)) {
-
if (isset($fromform->name)) {
if (trim($fromform->name) == '') {
unset($fromform->name);
if (isset($fromform->groupmode)) {
set_coursemodule_groupmode($fromform->coursemodule, $fromform->groupmode);
}
-
+
+ // set cm id number
+ if (isset($fromform->idnumber)) {
+ set_coursemodule_idnumber($fromform->coursemodule, $fromform->idnumber);
+ }
add_to_log($course->id, "course", "update mod",
"../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
}
// make sure visibility is set correctly (in particular in calendar)
set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
-
+
+ // set cm idnumber
+ if (isset($fromform->idnumber)) {
+ set_coursemodule_idnumber($fromform->coursemodule, $fromform->idnumber);
+ }
+
add_to_log($course->id, "course", "add mod",
"../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
"$fromform->modulename $fromform->instance");
$mform->addElement('modgroupmode', 'groupmode', get_string('groupmode'));
}
$mform->addElement('modvisible', 'visible', get_string('visible'));
-
+ $mform->addElement('text', 'idnumber', get_string('idnumber'));
+ $mform->setDefault('idnumber', $this->_cm->idnumber);
$this->standard_hidden_coursemodule_elements();
}
* @return unknown
*/
function standard_coursemodule_elements_settings(){
- return ($this->modgroupmode_settings() + $this->modvisible_settings());
+ return ($this->modgroupmode_settings() + $this->modvisible_settings() + $this->modidnumber_settings());
}
/**
* This is called from modedit.php to load the default for the groupmode element.
global $COURSE;
return array('groupmode'=>groupmode($COURSE, $this->_cm));
}
+ /**
+ * This is called from modedit.php to load the default for the groupmode element.
+ *
+ * @param object $course
+ * @param object $cm
+ */
+ function modidnumber_settings() {
+ global $COURSE;
+ return array('idnumber'=>$this->_cm->idnumber);
+ }
/**
* This is called from modedit.php to set the default for modvisible form element.
*
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20070322" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20070411" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="module"/>
<FIELD NAME="module" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="instance"/>
<FIELD NAME="instance" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="module" NEXT="section"/>
- <FIELD NAME="section" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="instance" NEXT="added"/>
- <FIELD NAME="added" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="section" NEXT="score"/>
+ <FIELD NAME="section" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="instance" NEXT="idnumber"/>
+ <FIELD NAME="idnumber" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="customizable idnumber" PREVIOUS="section" NEXT="added"/>
+ <FIELD NAME="added" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="idnumber" NEXT="score"/>
<FIELD NAME="score" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="added" NEXT="indent"/>
<FIELD NAME="indent" TYPE="int" LENGTH="5" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="score" NEXT="visible"/>
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="indent" NEXT="visibleold"/>
<INDEX NAME="visible" UNIQUE="false" FIELDS="visible" NEXT="course"/>
<INDEX NAME="course" UNIQUE="false" FIELDS="course" PREVIOUS="visible" NEXT="module"/>
<INDEX NAME="module" UNIQUE="false" FIELDS="module" PREVIOUS="course" NEXT="instance"/>
- <INDEX NAME="instance" UNIQUE="false" FIELDS="instance" PREVIOUS="module"/>
+ <INDEX NAME="instance" UNIQUE="false" FIELDS="instance" PREVIOUS="module" NEXT="idnumber"/>
+ <INDEX NAME="idnumber" UNIQUE="true" FIELDS="idnumber" COMMENT="Default comment for the index, please edit me" PREVIOUS="instance"/>
</INDEXES>
</TABLE>
<TABLE NAME="course_sections" COMMENT="to define the sections for each course" PREVIOUS="course_modules" NEXT="course_request">
/// Launch add index text
$result = $result && add_index($table, $index);
}
+
+ if ($result && $oldversion < 2007041100) {
+
+ /// Define field idnumber to be added to course_modules
+ $table = new XMLDBTable('course_modules');
+ $field = new XMLDBField('idnumber');
+ $field->setAttributes(XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null, 'section');
+
+ /// Launch add field idnumber
+ $result = $result && add_field($table, $field);
+
+ /// Define index idnumber (unique) to be added to course_modules
+ $table = new XMLDBTable('course_modules');
+ $index = new XMLDBIndex('idnumber');
+ $index->setAttributes(XMLDB_INDEX_UNIQUE, array('idnumber'));
+
+ /// Launch add index idnumber
+ $result = $result && add_index($table, $index);
+
+ }
+
return $result;
}
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2007040400; // YYYYMMDD = date
+ $version = 2007041100; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 dev'; // Human-friendly version name