Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-29538 core_condition: made changes to the DB structure - nb. had …

…to rename the table due to length limit
  • Loading branch information...
commit 92fb7dd3a5e1276221cba7438eab6b4fe4eb4c5a 1 parent 76af15b
@markn86 markn86 authored
View
2  backup/moodle2/backup_stepslib.php
@@ -346,7 +346,7 @@ protected function define_structure() {
WHERE cm.id = ?', array(backup::VAR_MODID));
$availability->set_source_table('course_modules_availability', array('coursemoduleid' => backup::VAR_MODID));
- $availability_field->set_source_table('course_modules_availability_field', array('coursemoduleid' => backup::VAR_MODID));
+ $availability_field->set_source_table('course_modules_avail_fields', array('coursemoduleid' => backup::VAR_MODID));
// Define annotations
$module->annotate_ids('grouping', 'groupingid');
View
2  backup/moodle2/restore_stepslib.php
@@ -552,7 +552,7 @@ protected function define_execution() {
$rs = $DB->get_recordset('backup_ids_temp', $params, '', 'itemid');
foreach($rs as $availrec) {
$availability = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'module_availability_field', $availrec->itemid)->info;
- $DB->insert_record('course_modules_availability_field', $availability);
+ $DB->insert_record('course_modules_avail_fields', $availability);
}
$rs->close();
}
View
6 lib/conditionlib.php
@@ -478,7 +478,7 @@ protected static function fill_availability_conditions_inner($item, $tableprefix
SELECT
cma.*
FROM
- {course_modules_availability_field} cma
+ {course_modules_avail_fields} cma
WHERE
coursemoduleid=?",array($cm->id));
foreach ($conditions as $condition) {
@@ -620,7 +620,7 @@ public function add_completion_condition($cmid, $requiredcompletion) {
public function add_user_field_condition($field, $operator, $value) {
// Add to DB
global $DB;
- $DB->insert_record('course_modules_availability_field',
+ $DB->insert_record('course_modules_avail_fields',
(object)array('coursemoduleid'=>$this->cm->id,
'field'=>$field,'operator'=>$operator,
'value'=>$value),
@@ -676,7 +676,7 @@ public function wipe_conditions() {
global $DB;
$DB->delete_records($this->availtable, array($this->idfieldname => $this->item->id));
- $DB->delete_records('course_modules_availability_field',
+ $DB->delete_records('course_modules_avail_fields',
array('coursemoduleid'=>$this->cm->id));
// And from memory
View
15 lib/db/install.xml
@@ -330,7 +330,7 @@
<INDEX NAME="idnumber-course" UNIQUE="false" FIELDS="idnumber, course" COMMENT="non unique index (although programatically we are guarantying some sort of uniqueness both under this table and the grade_items one). TODO: We need a central store of module idnumbers in the future." PREVIOUS="instance"/>
</INDEXES>
</TABLE>
- <TABLE NAME="course_modules_availability" COMMENT="Table stores conditions that affect whether a module/activity is currently available to students or not." PREVIOUS="course_modules" NEXT="course_modules_availability_field">
+ <TABLE NAME="course_modules_availability" COMMENT="Table stores conditions that affect whether a module/activity is currently available to students or not." PREVIOUS="course_modules" NEXT="course_modules_avail_fields">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="coursemoduleid"/>
<FIELD NAME="coursemoduleid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="ID of the module whose availability is being restricted by this condition." PREVIOUS="id" NEXT="sourcecmid"/>
@@ -347,20 +347,21 @@
<KEY NAME="gradeitemid" TYPE="foreign" FIELDS="gradeitemid" REFTABLE="grade_items" REFFIELDS="id" PREVIOUS="sourcecmid"/>
</KEYS>
</TABLE>
- <TABLE NAME="course_modules_availability_field" COMMENT="Table stores user field conditions that affect whether a module/activity is currently available to students or not." PREVIOUS="course_modules_availability" NEXT="course_modules_completion">
+ <TABLE NAME="course_modules_avail_fields" COMMENT="Table stores user field conditions that affect whether a module/activity is currently available to students or not." PREVIOUS="course_modules_availability" NEXT="course_modules_completion">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="coursemoduleid"/>
- <FIELD NAME="coursemoduleid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="ID of the module whose availability is being restricted by this condition." PREVIOUS="id" NEXT="field"/>
- <FIELD NAME="field" TYPE="char" LENGTH="50" NOTNULL="false" SEQUENCE="false" COMMENT="If this is numeric it is a user custom profile field, else it is a user field" PREVIOUS="coursemoduleid" NEXT="operator"/>
- <FIELD NAME="operator" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The integer that represents the operator, such as less than or equal to, between the field and the value" PREVIOUS="field" NEXT="value"/>
- <FIELD NAME="value" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The required value of the field" PREVIOUS="operator"/>
+ <FIELD NAME="coursemoduleid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="ID of the module whose availability is being restricted by this condition." PREVIOUS="id" NEXT="userfield"/>
+ <FIELD NAME="userfield" TYPE="char" LENGTH="50" NOTNULL="false" SEQUENCE="false" COMMENT="The required value of the field" PREVIOUS="coursemoduleid" NEXT="customfieldid"/>
+ <FIELD NAME="customfieldid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The required value of the user profile field" PREVIOUS="userfield" NEXT="operator"/>
+ <FIELD NAME="operator" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="The operator, such as less than or equal to, between the field and the value" PREVIOUS="customfieldid" NEXT="value"/>
+ <FIELD NAME="value" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The required value of the field" PREVIOUS="operator"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="coursemoduleid"/>
<KEY NAME="coursemoduleid" TYPE="foreign" FIELDS="coursemoduleid" REFTABLE="course_modules" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
</TABLE>
- <TABLE NAME="course_modules_completion" COMMENT="Stores the completion state (completed or not completed, etc) of each user on each activity." PREVIOUS="course_modules_availability_field" NEXT="course_sections">
+ <TABLE NAME="course_modules_completion" COMMENT="Stores the completion state (completed or not completed, etc) of each user on each activity." PREVIOUS="course_modules_avail_fields" NEXT="course_sections">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="coursemoduleid"/>
<FIELD NAME="coursemoduleid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Activity that has been completed (or not)." PREVIOUS="id" NEXT="userid"/>
View
3  lib/moodlelib.php
@@ -4584,7 +4584,7 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
$DB->delete_records_select('course_modules_availability',
'coursemoduleid IN (SELECT id from {course_modules} WHERE course=?)',
array($courseid));
- $DB->delete_records_select('course_modules_availability_field',
+ $DB->delete_records_select('course_modules_avail_fields',
'coursemoduleid IN (SELECT id from {course_modules} WHERE course=?)',
array($courseid));
@@ -4601,7 +4601,6 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
context_helper::delete_instance(CONTEXT_MODULE, $cm->id);
$DB->delete_records('course_modules', array('id'=>$cm->id));
}
-
if ($showfeedback) {
echo $OUTPUT->notification($strdeleted.get_string('type_mod_plural', 'plugin'), 'notifysuccess');
}
View
2  user/profile/definelib.php
@@ -290,7 +290,7 @@ function profile_delete_field($id) {
}
// Delete any module dependencies for this field
- $DB->delete_records('course_modules_availability_field', array('field'=>$id));
+ $DB->delete_records('course_modules_avail_fields', array('field'=>$id));
// Need to rebuild course cache to update the info
rebuild_course_cache();
/// Try to remove the record from the database
Please sign in to comment.
Something went wrong with that request. Please try again.