Merge branch 'MDL-32119' of git://github.com/srynot4sale/moodle

Conflicts:
	lib/db/upgrade.php
	version.php
This commit is contained in:
Sam Hemelryk
2012-07-09 16:02:49 +12:00
7 changed files with 67 additions and 84 deletions
+2 -9
View File
@@ -2025,15 +2025,11 @@ class backup_course_completion_structure_step extends backup_structure_step {
$criteriacompletions = new backup_nested_element('course_completion_crit_completions');
$criteriacomplete = new backup_nested_element('course_completion_crit_compl', array('id'), array(
'criteriaid', 'userid','gradefinal','unenrolled','deleted','timecompleted'
'criteriaid', 'userid', 'gradefinal', 'unenrolled', 'timecompleted'
));
$coursecompletions = new backup_nested_element('course_completions', array('id'), array(
'userid', 'course', 'deleted', 'timenotified', 'timeenrolled','timestarted','timecompleted','reaggregate'
));
$notify = new backup_nested_element('course_completion_notify', array('id'), array(
'course','role','message','timesent'
'userid', 'course', 'timeenrolled', 'timestarted', 'timecompleted', 'reaggregate'
));
$aggregatemethod = new backup_nested_element('course_completion_aggr_methd', array('id'), array(
@@ -2044,7 +2040,6 @@ class backup_course_completion_structure_step extends backup_structure_step {
$criteria->add_child($criteriacompletions);
$criteriacompletions->add_child($criteriacomplete);
$cc->add_child($coursecompletions);
$cc->add_child($notify);
$cc->add_child($aggregatemethod);
// We need to get the courseinstances shortname rather than an ID for restore
@@ -2054,7 +2049,6 @@ class backup_course_completion_structure_step extends backup_structure_step {
WHERE ccc.course = ?", array(backup::VAR_COURSEID));
$notify->set_source_table('course_completion_notify', array('course' => backup::VAR_COURSEID));
$aggregatemethod->set_source_table('course_completion_aggr_methd', array('course' => backup::VAR_COURSEID));
if ($userinfo) {
@@ -2065,7 +2059,6 @@ class backup_course_completion_structure_step extends backup_structure_step {
$criteria->annotate_ids('role', 'role');
$criteriacomplete->annotate_ids('user', 'userid');
$coursecompletions->annotate_ids('user', 'userid');
$notify->annotate_ids('role', 'role');
return $cc;
-34
View File
@@ -1859,7 +1859,6 @@ class restore_course_completion_structure_step extends restore_structure_step {
$paths = array();
$paths[] = new restore_path_element('course_completion_criteria', '/course_completion/course_completion_criteria');
$paths[] = new restore_path_element('course_completion_notify', '/course_completion/course_completion_notify');
$paths[] = new restore_path_element('course_completion_aggr_methd', '/course_completion/course_completion_aggr_methd');
if ($userinfo) {
@@ -1963,9 +1962,6 @@ class restore_course_completion_structure_step extends restore_structure_step {
if (isset($data->unenroled)) {
$params['unenroled'] = $data->unenroled;
}
if (isset($data->deleted)) {
$params['deleted'] = $data->deleted;
}
$DB->insert_record('course_completion_crit_compl', $params);
}
}
@@ -1988,8 +1984,6 @@ class restore_course_completion_structure_step extends restore_structure_step {
$params = array(
'userid' => $data->userid,
'course' => $data->course,
'deleted' => $data->deleted,
'timenotified' => $this->apply_date_offset($data->timenotified),
'timeenrolled' => $this->apply_date_offset($data->timeenrolled),
'timestarted' => $this->apply_date_offset($data->timestarted),
'timecompleted' => $this->apply_date_offset($data->timecompleted),
@@ -1999,34 +1993,6 @@ class restore_course_completion_structure_step extends restore_structure_step {
}
}
/**
* Process course completion notification records.
*
* Note: As of Moodle 2.0 this table is not being used however it has been
* left in in the hopes that one day the functionality there will be completed
*
* @global moodle_database $DB
* @param stdClass $data
*/
public function process_course_completion_notify($data) {
global $DB;
$data = (object)$data;
$data->course = $this->get_courseid();
if (!empty($data->role)) {
$data->role = $this->get_mappingid('role', $data->role);
}
$params = array(
'course' => $data->course,
'role' => $data->role,
'message' => $data->message,
'timesent' => $this->apply_date_offset($data->timesent),
);
$DB->insert_record('course_completion_notify', $params);
}
/**
* Process course completion aggregate methods
*
+1 -8
View File
@@ -42,7 +42,7 @@ class completion_completion extends data_object {
public $table = 'course_completions';
/* @var array $required_fields Array of required table fields, must start with 'id'. */
public $required_fields = array('id', 'userid', 'course', 'deleted', 'timenotified',
public $required_fields = array('id', 'userid', 'course',
'timeenrolled', 'timestarted', 'timecompleted', 'reaggregate');
/* @var int $userid User ID */
@@ -51,12 +51,6 @@ class completion_completion extends data_object {
/* @var int $course Course ID */
public $course;
/* @var int $deleted set to 1 if this record has been deleted */
public $deleted;
/* @var int Timestamp the interested parties were notified of this user's completion. */
public $timenotified;
/* @var int Time of course enrolment {@link completion_completion::mark_enrolled()} */
public $timeenrolled;
@@ -80,7 +74,6 @@ class completion_completion extends data_object {
* @return data_object instance of data_object or false if none found.
*/
public static function fetch($params) {
$params['deleted'] = null;
return self::fetch_helper('course_completions', __CLASS__, $params);
}
@@ -42,7 +42,7 @@ class completion_criteria_completion extends data_object {
public $table = 'course_completion_crit_compl';
/* @var array Array of required table fields, must start with 'id'. */
public $required_fields = array('id', 'userid', 'course', 'criteriaid', 'gradefinal', 'rpl', 'deleted', 'unenroled', 'timecompleted');
public $required_fields = array('id', 'userid', 'course', 'criteriaid', 'gradefinal', 'rpl', 'unenroled', 'timecompleted');
/* @var array Array of unique fields, used in where clauses */
public $unique_fields = array('userid', 'course', 'criteriaid');
@@ -62,9 +62,6 @@ class completion_criteria_completion extends data_object {
/* @var string Record of prior learning, leave blank if none */
public $rpl;
/* @var bool Course deleted flag */
public $deleted;
/* @var int Timestamp of user unenrolment (if completing a unenrol criteria) */
public $unenroled;
@@ -81,7 +78,6 @@ class completion_criteria_completion extends data_object {
* @return data_object instance of data_object or false if none found.
*/
public static function fetch($params) {
$params['deleted'] = null;
return self::fetch_helper('course_completion_crit_compl', __CLASS__, $params);
}
+7 -25
View File
@@ -173,16 +173,15 @@
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
</INDEXES>
</TABLE>
<TABLE NAME="course_completion_crit_compl" COMMENT="Course completion user records" PREVIOUS="course_completion_criteria" NEXT="course_completion_notify">
<TABLE NAME="course_completion_crit_compl" COMMENT="Course completion user records" PREVIOUS="course_completion_criteria" NEXT="course_completions">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="criteriaid"/>
<FIELD NAME="criteriaid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Completion criteria this references" PREVIOUS="course" NEXT="gradefinal"/>
<FIELD NAME="gradefinal" TYPE="number" LENGTH="10" NOTNULL="false" SEQUENCE="false" DECIMALS="5" COMMENT="The final grade for the course (included regardless of whether a passing grade was required)" PREVIOUS="criteriaid" NEXT="unenroled"/>
<FIELD NAME="unenroled" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Timestamp when the user was unenroled" PREVIOUS="gradefinal" NEXT="deleted"/>
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false" PREVIOUS="unenroled" NEXT="timecompleted"/>
<FIELD NAME="timecompleted" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="deleted"/>
<FIELD NAME="unenroled" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Timestamp when the user was unenroled" PREVIOUS="gradefinal" NEXT="timecompleted"/>
<FIELD NAME="timecompleted" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="unenroled"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
@@ -195,29 +194,12 @@
<INDEX NAME="useridcoursecriteriaid" UNIQUE="true" FIELDS="userid, course, criteriaid" PREVIOUS="timecompleted"/>
</INDEXES>
</TABLE>
<TABLE NAME="course_completion_notify" COMMENT="Course completion notification emails" PREVIOUS="course_completion_crit_compl" NEXT="course_completions">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="role"/>
<FIELD NAME="role" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="ID of the role to receive this notification message when a course has been completed" PREVIOUS="course" NEXT="message"/>
<FIELD NAME="message" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="HTML formatted message to be sent" PREVIOUS="role" NEXT="timesent"/>
<FIELD NAME="timesent" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="message"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
</INDEXES>
</TABLE>
<TABLE NAME="course_completions" COMMENT="Course completion records" PREVIOUS="course_completion_notify" NEXT="enrol">
<TABLE NAME="course_completions" COMMENT="Course completion records" PREVIOUS="course_completion_crit_compl" NEXT="enrol">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="deleted"/>
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false" PREVIOUS="course" NEXT="timenotified"/>
<FIELD NAME="timenotified" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="deleted" NEXT="timeenrolled"/>
<FIELD NAME="timeenrolled" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timenotified" NEXT="timestarted"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="timeenrolled"/>
<FIELD NAME="timeenrolled" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="course" NEXT="timestarted"/>
<FIELD NAME="timestarted" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timeenrolled" NEXT="timecompleted"/>
<FIELD NAME="timecompleted" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="timestarted" NEXT="reaggregate"/>
<FIELD NAME="reaggregate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecompleted"/>
@@ -2875,4 +2857,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
+55 -2
View File
@@ -891,10 +891,15 @@ function xmldb_main_upgrade($oldversion) {
$table = new xmldb_table('backup_ids');
// Conditionally launch drop table for backup_ids
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
// Conditionally launch drop field deleted from course_completion_crit_compl
if ($dbman->field_exists($table2, $field)) {
$dbman->drop_field($table2, $field);
}
// Drop unused table "course_completion_notify"
$table = new xmldb_table('course_completion_notify');
// Conditionally launch drop table course_completion_notify
// Main savepoint reached
upgrade_main_savepoint(true, 2012062500.02);
}
@@ -949,5 +954,53 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012062500.05);
}
if ($oldversion < 2012062500.06) {
// Drop "deleted" fields
$table = new xmldb_table('course_completions');
$field = new xmldb_field('timenotified');
$field = new xmldb_field('deleted');
// Conditionally launch drop field deleted from course_completions
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
$field = new xmldb_field('timenotified');
// Conditionally launch drop field timenotified from course_completions
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Main savepoint reached
upgrade_main_savepoint(true, 2012062500.06);
}
if ($oldversion < 2012062500.07) {
$table = new xmldb_table('course_completion_crit_compl');
$field = new xmldb_field('deleted');
// Conditionally launch drop field deleted from course_completion_crit_compl
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Main savepoint reached
upgrade_main_savepoint(true, 2012062500.07);
}
if ($oldversion < 2012062500.08) {
// Drop unused table "course_completion_notify"
$table = new xmldb_table('course_completion_notify');
// Conditionally launch drop table course_completion_notify
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
// Main savepoint reached
upgrade_main_savepoint(true, 2012062500.08);
}
return true;
}
+1 -1
View File
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2012062500.05; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012062500.08; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes