Permalink
Browse files

Merge branch 'master' of https://github.com/moodle/moodle

  • Loading branch information...
pcharsle committed Aug 27, 2012
2 parents 4a52712 + d71c486 commit 4873a890df33c8d529e47bcde170ffb281ae0cf4
Showing with 3,601 additions and 887 deletions.
  1. +4 −6 admin/roles/lib.php
  2. +5 −0 admin/settings/courses.php
  3. +1 −1 admin/settings/location.php
  4. +1 −1 admin/tool/phpunit/cli/util.php
  5. +3 −1 auth/email/auth.php
  6. +3 −1 auth/ldap/auth.php
  7. +3 −1 auth/manual/auth.php
  8. +18 −9 backup/moodle2/backup_stepslib.php
  9. +69 −19 backup/moodle2/restore_stepslib.php
  10. +1 −1 backup/util/dbops/backup_plan_dbops.class.php
  11. +47 −25 backup/util/helper/backup_cron_helper.class.php
  12. +442 −0 backup/util/helper/tests/cronhelper_test.php
  13. +3 −3 backup/util/structure/restore_path_element.class.php
  14. +3 −0 backup/util/ui/base_moodleform.class.php
  15. +80 −0 backup/util/ui/yui/backupselectall/backupselectall.js
  16. +15 −0 blocks/html/block_html.php
  17. +4 −0 blocks/html/edit_form.php
  18. +2 −0 blocks/html/lang/en/block_html.php
  19. +1 −0 blocks/tags/block_tags.php
  20. +5 −1 completion/completion_completion.php
  21. +3 −1 config-dist.php
  22. +1 −1 course/edit_form.php
  23. +8 −5 course/format/renderer.php
  24. +0 −3 course/lib.php
  25. +0 −2 course/recent_form.php
  26. +1 −1 course/reset_form.php
  27. +1 −1 course/rest.php
  28. +1 −1 course/tests/externallib_test.php
  29. +1 −1 course/view.php
  30. +30 −6 enrol/category/cli/sync.php
  31. +2 −2 enrol/category/db/access.php
  32. +3 −3 enrol/category/db/events.php
  33. +1 −3 enrol/category/db/install.php
  34. +2 −4 enrol/category/lang/en/enrol_category.php
  35. +11 −14 enrol/category/lib.php
  36. +83 −40 enrol/category/locallib.php
  37. +2 −5 enrol/category/settings.php
  38. +365 −0 enrol/category/tests/sync_test.php
  39. +4 −5 enrol/category/version.php
  40. +1 −10 enrol/cohort/lib.php
  41. +5 −9 enrol/locallib.php
  42. +1 −1 enrol/manual/lang/en/enrol_manual.php
  43. +3 −5 enrol/manual/locallib.php
  44. +2 −2 enrol/manual/settings.php
  45. +1 −1 enrol/paypal/lang/en/enrol_paypal.php
  46. +2 −2 enrol/paypal/settings.php
  47. +1 −1 enrol/self/lang/en/enrol_self.php
  48. +2 −2 enrol/self/settings.php
  49. +1 −1 install/lang/es_mx/langconfig.php
  50. +1 −1 install/lang/zh_cn/install.php
  51. +10 −8 iplookup/index.php
  52. +16 −17 iplookup/module.js
  53. +3 −3 lang/en/admin.php
  54. +1 −1 lang/en/completion.php
  55. +1 −0 lang/en/moodle.php
  56. +1 −0 lang/en/role.php
  57. +162 −0 lib/adminlib.php
  58. +6 −0 lib/blocklib.php
  59. +25 −0 lib/completionlib.php
  60. +7 −0 lib/cronlib.php
  61. +11 −0 lib/db/access.php
  62. +7 −0 lib/db/upgrade.php
  63. +37 −0 lib/editor/tinymce/adminlib.php
  64. +0 −1 lib/editor/tinymce/extra/tools/.gitignore
  65. +1 −0 lib/editor/tinymce/lang/en/editor_tinymce.php
  66. +74 −0 lib/editor/tinymce/subplugins.php
  67. +3 −2 lib/form/duration.php
  68. +2 −2 lib/form/tests/dateselector_test.php
  69. +2 −2 lib/form/tests/datetimeselector_test.php
  70. +1 −1 lib/form/tests/duration_test.php
  71. +2 −1 lib/grade/grade_item.php
  72. +1 −1 lib/messagelib.php
  73. +28 −12 lib/moodlelib.php
  74. +3 −0 lib/pagelib.php
  75. +6 −6 lib/phpunit/classes/data_generator.php
  76. +41 −0 lib/phpunit/classes/hint_resultprinter.php
  77. +25 −2 lib/phpunit/classes/util.php
  78. +12 −0 lib/phpunit/tests/generator_test.php
  79. +18 −3 lib/pluginlib.php
  80. +3 −0 lib/setup.php
  81. +5 −0 lib/tablelib.php
  82. +0 −184 lib/tests/backup_test.php
  83. +3 −3 lib/tests/moodlelib_test.php
  84. +1 −0 lib/upgrade.txt
  85. +24 −9 lib/weblib.php
  86. +2 −1 mod/assign/backup/moodle2/backup_assign_stepslib.php
  87. +2 −1 mod/assign/db/install.xml
  88. +15 −0 mod/assign/db/upgrade.php
  89. +4 −2 mod/assign/gradingtable.php
  90. +7 −2 mod/assign/index.php
  91. +2 −0 mod/assign/lang/en/assign.php
  92. +27 −0 mod/assign/lib.php
  93. +21 −1 mod/assign/locallib.php
  94. +26 −1 mod/assign/mod_form.php
  95. +12 −0 mod/assign/module.js
  96. +1 −1 mod/assign/renderer.php
  97. +1 −1 mod/assign/version.php
  98. +12 −0 mod/assignment/assignment.js
  99. +1 −0 mod/assignment/lang/en/assignment.php
  100. +16 −1 mod/assignment/mod_form.php
  101. +3 −0 mod/book/backup/moodle2/restore_book_activity_task.class.php
  102. +1 −1 mod/book/version.php
  103. +47 −32 mod/chat/lib.php
  104. +1 −2 mod/forum/lib.php
  105. +1 −1 mod/lesson/lib.php
  106. +1 −1 mod/quiz/attemptlib.php
  107. +1 −1 mod/quiz/backup/moodle1/lib.php
  108. +1 −1 mod/quiz/db/install.xml
  109. +19 −0 mod/quiz/db/upgrade.php
  110. +9 −12 mod/quiz/lib.php
  111. +7 −5 mod/quiz/renderer.php
  112. +1 −1 mod/quiz/report/responses/responses_table.php
  113. +12 −0 mod/quiz/upgrade.txt
  114. +1 −1 mod/quiz/version.php
  115. +7 −0 mod/upgrade.txt
  116. +2 −1 mod/wiki/editors/wikieditor.php
  117. +2 −1 mod/wiki/lib.php
  118. +0 −2 mod/wiki/mod_form.php
  119. +0 −1 phpunit.xml.dist
  120. +33 −27 question/editlib.php
  121. +11 −0 question/engine/bank.php
  122. +9 −1 question/engine/datalib.php
  123. +54 −0 question/format.php
  124. +388 −265 question/format/blackboard/format.php
  125. +4 −2 question/format/blackboard/lang/en/qformat_blackboard.php
  126. +328 −0 question/format/blackboard/tests/blackboardformat_test.php
  127. +142 −0 question/format/blackboard/tests/fixtures/sample_blackboard.dat
  128. +2 −3 question/format/blackboard/version.php
  129. +64 −39 question/format/examview/format.php
  130. +1 −2 question/format/examview/lang/en/qformat_examview.php
  131. +305 −0 question/format/examview/tests/examviewformat_test.php
  132. +161 −0 question/format/examview/tests/fixtures/examview_sample.xml
  133. +2 −3 question/format/examview/version.php
  134. +27 −0 question/previewlib.php
  135. +1 −1 report/stats/locallib.php
  136. +2 −1 tag/edit.php
  137. +4 −2 tag/lib.php
  138. +2 −1 tag/locallib.php
  139. +1 −1 theme/base/style/core.css
  140. +2 −3 user/selector/lib.php
  141. +2 −2 version.php
View
@@ -1039,12 +1039,10 @@ public function find_users($search) {
$countfields = 'SELECT COUNT(u.id)';
$sql = " FROM {user} u
- WHERE u.id IN ($enrolsql) $wherecondition
- AND u.id NOT IN (
- SELECT r.userid
- FROM {role_assignments} r
- WHERE r.contextid = :contextid
- AND r.roleid = :roleid)";
+ LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.roleid = :roleid AND ra.contextid = :contextid)
+ WHERE u.id IN ($enrolsql)
+ $wherecondition
+ AND ra.id IS NULL";
$order = ' ORDER BY lastname ASC, firstname ASC';
$params['contextid'] = $this->context->id;
@@ -47,6 +47,11 @@
$temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'), new lang_string('courselegacyfiles_help'), key($choices), $choices));
}
+ $choices = array();
+ $choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
+ $choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
+ $temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'), new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
+
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
$choices = array();
$choices[NOGROUPS] = new lang_string('groupsnone', 'group');
@@ -14,7 +14,7 @@
$temp->add(new admin_setting_heading('iplookup', new lang_string('iplookup', 'admin'), new lang_string('iplookupinfo', 'admin')));
$temp->add(new admin_setting_configfile('geoipfile', new lang_string('geoipfile', 'admin'), new lang_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLiteCity.dat'));
- $temp->add(new admin_setting_configtext('googlemapkey', new lang_string('googlemapkey', 'admin'), new lang_string('configgooglemapkey', 'admin', $CFG->wwwroot), ''));
+ $temp->add(new admin_setting_configtext('googlemapkey3', new lang_string('googlemapkey3', 'admin'), new lang_string('googlemapkey3_help', 'admin'), '', PARAM_RAW, 60));
$temp->add(new admin_setting_configtext('allcountrycodes', new lang_string('allcountrycodes', 'admin'), new lang_string('configallcountrycodes', 'admin'), '', '/^(?:\w+(?:,\w+)*)?$/'));
@@ -150,7 +150,7 @@
} else if ($drop) {
// make sure tests do not run in parallel
phpunit_util::acquire_test_lock();
- phpunit_util::drop_site();
+ phpunit_util::drop_site(true);
// note: we must stop here because $CFG is messed up and we can not reinstall, sorry
exit(0);
View
@@ -132,7 +132,9 @@ function user_confirm($username, $confirmsecret) {
} else if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
- $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
+ if ($user->firstaccess == 0) {
+ $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
+ }
return AUTH_CONFIRM_OK;
}
} else {
View
@@ -546,7 +546,9 @@ function user_confirm($username, $confirmsecret) {
return AUTH_CONFIRM_FAIL;
}
$DB->set_field('user', 'confirmed', 1, array('id'=>$user->id));
- $DB->set_field('user', 'firstaccess', time(), array('id'=>$user->id));
+ if ($user->firstaccess == 0) {
+ $DB->set_field('user', 'firstaccess', time(), array('id'=>$user->id));
+ }
return AUTH_CONFIRM_OK;
}
} else {
View
@@ -170,7 +170,9 @@ function user_confirm($username, $confirmsecret = null) {
return AUTH_CONFIRM_ALREADY;
} else {
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
- $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
+ if ($user->firstaccess == 0) {
+ $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
+ }
return AUTH_CONFIRM_OK;
}
} else {
@@ -182,8 +182,17 @@ protected function prepare_activity_structure($activitystructure) {
/**
* Attach to $element (usually attempts) the needed backup structures
* for question_usages and all the associated data.
+ *
+ * @param backup_nested_element $element the element that will contain all the question_usages data.
+ * @param string $usageidname the name of the element that holds the usageid.
+ * This must be child of $element, and must be a final element.
+ * @param string $nameprefix this prefix is added to all the element names we create.
+ * Element names in the XML must be unique, so if you are using usages in
+ * two different ways, you must give a prefix to at least one of them. If
+ * you only use one sort of usage, then you can just use the default empty prefix.
+ * This should include a trailing underscore. For example "myprefix_"
*/
- protected function add_question_usages($element, $usageidname) {
+ protected function add_question_usages($element, $usageidname, $nameprefix = '') {
global $CFG;
require_once($CFG->dirroot . '/question/engine/lib.php');
@@ -195,21 +204,21 @@ protected function add_question_usages($element, $usageidname) {
throw new backup_step_exception('question_states_bad_question_attempt_element', $usageidname);
}
- $quba = new backup_nested_element('question_usage', array('id'),
+ $quba = new backup_nested_element($nameprefix . 'question_usage', array('id'),
array('component', 'preferredbehaviour'));
- $qas = new backup_nested_element('question_attempts');
- $qa = new backup_nested_element('question_attempt', array('id'), array(
+ $qas = new backup_nested_element($nameprefix . 'question_attempts');
+ $qa = new backup_nested_element($nameprefix . 'question_attempt', array('id'), array(
'slot', 'behaviour', 'questionid', 'maxmark', 'minfraction',
'flagged', 'questionsummary', 'rightanswer', 'responsesummary',
'timemodified'));
- $steps = new backup_nested_element('steps');
- $step = new backup_nested_element('step', array('id'), array(
+ $steps = new backup_nested_element($nameprefix . 'steps');
+ $step = new backup_nested_element($nameprefix . 'step', array('id'), array(
'sequencenumber', 'state', 'fraction', 'timecreated', 'userid'));
- $response = new backup_nested_element('response');
- $variable = new backup_nested_element('variable', null, array('name', 'value'));
+ $response = new backup_nested_element($nameprefix . 'response');
+ $variable = new backup_nested_element($nameprefix . 'variable', null, array('name', 'value'));
// Build the tree
$element->add_child($quba);
@@ -1835,7 +1844,7 @@ protected function define_execution() {
'backupid' => $this->get_backupid(), 'itemname' => 'userfinal'));
foreach ($rs as $record) {
$userid = $record->itemid;
- $userctx = context_user::instance($userid);
+ $userctx = context_user::instance($userid, IGNORE_MISSING);
if (!$userctx) {
continue; // User has not context, sure it's a deleted user, so cannot have files
}
@@ -3478,31 +3478,74 @@ private function add_result_item($name, $value) {
/**
* Attach below $element (usually attempts) the needed restore_path_elements
* to restore question_usages and all they contain.
+ *
+ * If you use the $nameprefix parameter, then you will need to implement some
+ * extra methods in your class, like
+ *
+ * protected function process_{nameprefix}question_attempt($data) {
+ * $this->restore_question_usage_worker($data, '{nameprefix}');
+ * }
+ * protected function process_{nameprefix}question_attempt($data) {
+ * $this->restore_question_attempt_worker($data, '{nameprefix}');
+ * }
+ * protected function process_{nameprefix}question_attempt_step($data) {
+ * $this->restore_question_attempt_step_worker($data, '{nameprefix}');
+ * }
+ *
+ * @param restore_path_element $element the parent element that the usages are stored inside.
+ * @param array $paths the paths array that is being built.
+ * @param string $nameprefix should match the prefix passed to the corresponding
+ * backup_questions_activity_structure_step::add_question_usages call.
*/
- protected function add_question_usages($element, &$paths) {
+ protected function add_question_usages($element, &$paths, $nameprefix = '') {
// Check $element is restore_path_element
if (! $element instanceof restore_path_element) {
throw new restore_step_exception('element_must_be_restore_path_element', $element);
}
+
// Check $paths is one array
if (!is_array($paths)) {
throw new restore_step_exception('paths_must_be_array', $paths);
}
- $paths[] = new restore_path_element('question_usage',
- $element->get_path() . '/question_usage');
- $paths[] = new restore_path_element('question_attempt',
- $element->get_path() . '/question_usage/question_attempts/question_attempt');
- $paths[] = new restore_path_element('question_attempt_step',
- $element->get_path() . '/question_usage/question_attempts/question_attempt/steps/step',
+ $paths[] = new restore_path_element($nameprefix . 'question_usage',
+ $element->get_path() . "/{$nameprefix}question_usage");
+ $paths[] = new restore_path_element($nameprefix . 'question_attempt',
+ $element->get_path() . "/{$nameprefix}question_usage/{$nameprefix}question_attempts/{$nameprefix}question_attempt");
+ $paths[] = new restore_path_element($nameprefix . 'question_attempt_step',
+ $element->get_path() . "/{$nameprefix}question_usage/{$nameprefix}question_attempts/{$nameprefix}question_attempt/{$nameprefix}steps/{$nameprefix}step",
true);
- $paths[] = new restore_path_element('question_attempt_step_data',
- $element->get_path() . '/question_usage/question_attempts/question_attempt/steps/step/response/variable');
+ $paths[] = new restore_path_element($nameprefix . 'question_attempt_step_data',
+ $element->get_path() . "/{$nameprefix}question_usage/{$nameprefix}question_attempts/{$nameprefix}question_attempt/{$nameprefix}steps/{$nameprefix}step/{$nameprefix}response/{$nameprefix}variable");
}
/**
* Process question_usages
*/
protected function process_question_usage($data) {
+ $this->restore_question_usage_worker($data, '');
+ }
+
+ /**
+ * Process question_attempts
+ */
+ protected function process_question_attempt($data) {
+ $this->restore_question_attempt_worker($data, '');
+ }
+
+ /**
+ * Process question_attempt_steps
+ */
+ protected function process_question_attempt_step($data) {
+ $this->restore_question_attempt_step_worker($data, '');
+ }
+
+ /**
+ * This method does the acutal work for process_question_usage or
+ * process_{nameprefix}_question_usage.
+ * @param array $data the data from the XML file.
+ * @param string $nameprefix the element name prefix.
+ */
+ protected function restore_question_usage_worker($data, $nameprefix) {
global $DB;
// Clear our caches.
@@ -3520,7 +3563,7 @@ protected function process_question_usage($data) {
$this->inform_new_usage_id($newitemid);
- $this->set_mapping('question_usage', $oldid, $newitemid, false);
+ $this->set_mapping($nameprefix . 'question_usage', $oldid, $newitemid, false);
}
/**
@@ -3532,45 +3575,51 @@ protected function process_question_usage($data) {
abstract protected function inform_new_usage_id($newusageid);
/**
- * Process question_attempts
+ * This method does the acutal work for process_question_attempt or
+ * process_{nameprefix}_question_attempt.
+ * @param array $data the data from the XML file.
+ * @param string $nameprefix the element name prefix.
*/
- protected function process_question_attempt($data) {
+ protected function restore_question_attempt_worker($data, $nameprefix) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
$question = $this->get_mapping('question', $data->questionid);
- $data->questionusageid = $this->get_new_parentid('question_usage');
+ $data->questionusageid = $this->get_new_parentid($nameprefix . 'question_usage');
$data->questionid = $question->newitemid;
$data->timemodified = $this->apply_date_offset($data->timemodified);
$newitemid = $DB->insert_record('question_attempts', $data);
- $this->set_mapping('question_attempt', $oldid, $newitemid);
+ $this->set_mapping($nameprefix . 'question_attempt', $oldid, $newitemid);
$this->qtypes[$newitemid] = $question->info->qtype;
$this->newquestionids[$newitemid] = $data->questionid;
}
/**
- * Process question_attempt_steps
+ * This method does the acutal work for process_question_attempt_step or
+ * process_{nameprefix}_question_attempt_step.
+ * @param array $data the data from the XML file.
+ * @param string $nameprefix the element name prefix.
*/
- protected function process_question_attempt_step($data) {
+ protected function restore_question_attempt_step_worker($data, $nameprefix) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
// Pull out the response data.
$response = array();
- if (!empty($data->response['variable'])) {
- foreach ($data->response['variable'] as $variable) {
+ if (!empty($data->{$nameprefix . 'response'}[$nameprefix . 'variable'])) {
+ foreach ($data->{$nameprefix . 'response'}[$nameprefix . 'variable'] as $variable) {
$response[$variable['name']] = $variable['value'];
}
}
unset($data->response);
- $data->questionattemptid = $this->get_new_parentid('question_attempt');
+ $data->questionattemptid = $this->get_new_parentid($nameprefix . 'question_attempt');
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->userid = $this->get_mappingid('user', $data->userid);
@@ -3583,6 +3632,7 @@ protected function process_question_attempt_step($data) {
$this->qtypes[$data->questionattemptid],
$this->newquestionids[$data->questionattemptid],
$data->sequencenumber, $response);
+
foreach ($response as $name => $value) {
$row = new stdClass();
$row->attemptstepid = $newitemid;
@@ -112,7 +112,7 @@ public static function get_sections_from_courseid($courseid) {
// Get all sections belonging to requested course
$sectionsarr = array();
- $sections = $DB->get_records('course_sections', array('course' => $courseid));
+ $sections = $DB->get_records('course_sections', array('course' => $courseid), 'section');
foreach ($sections as $section) {
$sectionsarr[] = $section->id;
}
Oops, something went wrong.

0 comments on commit 4873a89

Please sign in to comment.