Skip to content
Browse files

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

  • Loading branch information...
2 parents bf69dc5 + 2cbdaa7 commit 6998831d31af46da86db48d8e50687bb66251142 @wdjunaidi wdjunaidi committed Jul 11, 2012
Showing with 2,387 additions and 623 deletions.
  1. +15 −8 admin/blocks.php
  2. +4 −0 admin/tool/customlang/db/upgrade.php
  3. +4 −4 admin/tool/health/styles.css
  4. +3 −2 auth/ldap/ntlmsso_attempt.php
  5. +2 −1 auth/ldap/ntlmsso_magic.php
  6. +4 −0 auth/manual/db/upgrade.php
  7. +4 −0 auth/mnet/db/upgrade.php
  8. +4 −4 auth/shibboleth/login.php
  9. +4 −0 blocks/community/db/upgrade.php
  10. +1 −1 blocks/community/styles.css
  11. +1 −1 blocks/completionstatus/block_completionstatus.php
  12. +9 −9 blocks/feedback/block_feedback.php
  13. +4 −0 blocks/html/db/upgrade.php
  14. +4 −0 blocks/navigation/db/upgrade.php
  15. +4 −0 blocks/settings/db/upgrade.php
  16. +1 −1 calendar/delete.php
  17. +1 −1 cohort/edit_form.php
  18. +0 −10 course/completion.php
  19. +4 −1 course/completion_form.php
  20. +18 −5 course/externallib.php
  21. +5 −5 course/lib.php
  22. +570 −0 course/tests/externallib_test.php
  23. +12 −2 course/view.php
  24. +4 −0 enrol/authorize/db/upgrade.php
  25. +4 −0 enrol/database/db/upgrade.php
  26. +2 −1 enrol/database/lib.php
  27. +4 −0 enrol/flatfile/db/upgrade.php
  28. +4 −0 enrol/guest/db/upgrade.php
  29. +4 −0 enrol/imsenterprise/db/upgrade.php
  30. +4 −0 enrol/mnet/db/upgrade.php
  31. +4 −0 enrol/paypal/db/upgrade.php
  32. +1 −1 enrol/self/lib.php
  33. +10 −14 files/renderer.php
  34. +1 −1 filter/glossary/version.php
  35. +1 −1 filter/glossary/yui/autolinker/autolinker.js
  36. +4 −0 filter/mediaplugin/db/upgrade.php
  37. +4 −0 filter/tex/db/upgrade.php
  38. +1 −1 grade/grading/form/guide/js/guide.js
  39. +4 −0 grade/grading/form/rubric/db/upgrade.php
  40. +3 −0 grade/report/grader/lib.php
  41. +4 −4 grade/report/grader/styles.css
  42. +4 −1 group/externallib.php
  43. +4 −4 install.php
  44. +1 −1 install/css.php
  45. +34 −0 install/lang/ca_valencia/error.php
  46. +55 −0 install/lang/ca_valencia/install.php
  47. +36 −0 install/lang/es_mx/moodle.php
  48. +42 −0 install/lang/id/admin.php
  49. +1 −0 install/lang/id/moodle.php
  50. +1 −1 install/lang/ja/langconfig.php
  51. +1 −1 install/lang/pt/install.php
  52. +1 −1 install/lang/ru/install.php
  53. +1 −1 install/lang/sr_cr/install.php
  54. +1 −1 install/lang/sr_lt/install.php
  55. +34 −0 install/lang/sv_fi/moodle.php
  56. +1 −0 install/lang/zh_cn/langconfig.php
  57. +2 −2 lang/en/admin.php
  58. +1 −1 lang/en/auth.php
  59. +3 −1 lang/en/completion.php
  60. +2 −2 lang/en/moodle.php
  61. +3 −0 lib/accesslib.php
  62. +1 −1 lib/adminlib.php
  63. +0 −3 lib/ajax/ajaxlib.php
  64. +14 −11 lib/completion/completion_criteria_grade.php
  65. +3 −3 lib/cronlib.php
  66. +1 −1 lib/csslib.php
  67. +2 −30 lib/db/install.xml
  68. +28 −0 lib/db/upgrade.php
  69. +3 −3 lib/dml/mssql_native_moodle_database.php
  70. +15 −6 lib/dml/pgsql_native_moodle_database.php
  71. +120 −14 lib/dml/tests/dml_test.php
  72. +56 −10 lib/filelib.php
  73. +24 −3 lib/filestorage/file_storage.php
  74. +67 −17 lib/filestorage/tests/file_storage_test.php
  75. +1 −1 lib/form/filemanager.js
  76. +3 −0 lib/formslib.php
  77. +18 −4 lib/modinfolib.php
  78. +1 −1 lib/moodlelib.php
  79. +3 −0 lib/navigationlib.php
  80. +4 −3 lib/outputcomponents.php
  81. +2 −2 lib/outputrenderers.php
  82. +0 −1 lib/outputrequirementslib.php
  83. +1 −1 lib/pluginlib.php
  84. +12 −9 lib/portfolio/exporter.php
  85. +37 −8 lib/setuplib.php
  86. +53 −0 lib/tests/accesslib_test.php
  87. +74 −0 lib/tests/setuplib_test.php
  88. +6 −0 lib/tests/textlib_test.php
  89. +1 −1 lib/textlib.class.php
  90. +4 −0 message/output/email/db/upgrade.php
  91. +4 −0 message/output/jabber/db/upgrade.php
  92. +4 −0 message/output/popup/db/upgrade.php
  93. +4 −0 mod/assign/db/upgrade.php
  94. +4 −0 mod/assign/feedback/comments/db/upgrade.php
  95. +4 −0 mod/assign/feedback/file/db/upgrade.php
  96. +1 −0 mod/assign/lang/en/assign.php
  97. +10 −0 mod/assign/locallib.php
  98. +3 −1 mod/assign/portfolio_callback.php
  99. +2 −0 mod/assign/styles.css
  100. +4 −0 mod/assign/submission/comments/db/upgrade.php
  101. +4 −0 mod/assign/submission/file/db/upgrade.php
  102. +4 −0 mod/assign/submission/onlinetext/db/upgrade.php
  103. +41 −0 mod/assignment/db/upgrade.php
  104. +12 −5 mod/assignment/type/upload/assignment.class.php
  105. +1 −1 mod/assignment/version.php
  106. +4 −0 mod/book/db/upgrade.php
  107. +4 −0 mod/chat/db/upgrade.php
  108. +4 −0 mod/choice/db/upgrade.php
  109. +4 −0 mod/data/db/upgrade.php
  110. +4 −0 mod/feedback/db/upgrade.php
  111. +3 −0 mod/feedback/item/multichoice/lib.php
  112. +4 −0 mod/folder/db/upgrade.php
  113. +20 −5 mod/folder/renderer.php
  114. +4 −0 mod/forum/db/upgrade.php
  115. +13 −6 mod/forum/lib.php
  116. +2 −2 mod/forum/post.php
  117. +37 −14 mod/forum/post_form.php
  118. +5 −5 mod/forum/search.php
  119. +4 −0 mod/glossary/db/upgrade.php
  120. +1 −4 mod/glossary/print.php
  121. +4 −0 mod/imscp/db/upgrade.php
  122. +4 −0 mod/label/db/upgrade.php
  123. +4 −0 mod/lesson/db/upgrade.php
  124. +7 −5 mod/lti/backup/moodle2/backup_lti_stepslib.php
  125. +7 −20 mod/lti/backup/moodle2/restore_lti_stepslib.php
  126. +4 −0 mod/lti/db/upgrade.php
  127. +1 −1 mod/lti/edit_form.php
  128. +3 −6 mod/lti/instructor_edit_tool_type.php
  129. +30 −101 mod/lti/typessettings.php
  130. +4 −0 mod/page/db/upgrade.php
  131. +1 −1 mod/quiz/accessmanager.php
  132. +13 −4 mod/quiz/cronlib.php
  133. +1 −1 mod/quiz/db/install.xml
  134. +4 −0 mod/quiz/db/upgrade.php
  135. +1 −1 mod/quiz/report/attemptsreport_options.php
  136. +4 −0 mod/quiz/report/overview/db/upgrade.php
  137. +3 −2 mod/quiz/report/reportlib.php
  138. +4 −0 mod/quiz/report/statistics/db/upgrade.php
  139. +3 −3 mod/quiz/styles.css
  140. +4 −0 mod/resource/db/upgrade.php
  141. +53 −47 mod/scorm/datamodels/aicclib.php
  142. +16 −0 mod/scorm/db/upgrade.php
  143. +13 −11 mod/scorm/lib.php
  144. +2 −1 mod/scorm/locallib.php
  145. +2 −2 mod/scorm/mod_form.php
  146. +1 −1 mod/scorm/settings.php
  147. +1 −0 mod/scorm/styles.css
  148. +1 −1 mod/scorm/version.php
  149. +4 −0 mod/survey/db/upgrade.php
  150. +2 −2 mod/survey/view.php
  151. +5 −0 mod/upgrade.txt
  152. +4 −0 mod/url/db/upgrade.php
  153. +4 −0 mod/wiki/db/upgrade.php
  154. +1 −0 mod/wiki/lang/en/wiki.php
  155. +1 −1 mod/wiki/parser/markups/wikimarkup.php
  156. +1 −1 mod/wiki/styles.css
  157. +4 −0 mod/workshop/db/upgrade.php
  158. +4 −0 mod/workshop/form/accumulative/db/upgrade.php
  159. +4 −0 mod/workshop/form/comments/db/upgrade.php
  160. +4 −0 mod/workshop/form/numerrors/db/upgrade.php
  161. +4 −0 mod/workshop/form/rubric/db/upgrade.php
  162. +4 −4 mod/workshop/styles.css
  163. +3 −2 portfolio/boxnet/lib.php
  164. +4 −0 portfolio/googledocs/db/upgrade.php
  165. +4 −0 portfolio/picasa/db/upgrade.php
  166. +17 −0 question/engine/questionattempt.php
  167. +33 −17 question/engine/renderer.php
  168. +1 −1 question/engine/states.php
  169. +3 −9 question/engine/tests/unitofwork_test.php
  170. +4 −1 question/format.php
  171. +4 −0 question/type/calculated/db/upgrade.php
  172. +4 −0 question/type/essay/db/upgrade.php
  173. +4 −0 question/type/match/db/upgrade.php
  174. +4 −0 question/type/multianswer/db/upgrade.php
  175. +4 −0 question/type/multichoice/db/upgrade.php
  176. +4 −0 question/type/numerical/db/upgrade.php
  177. +2 −2 question/type/rendererbase.php
  178. +2 −1 report/progress/index.php
  179. +1 −0 repository/alfresco/lib.php
  180. +1 −0 repository/flickr/lib.php
  181. +4 −0 repository/googledocs/db/upgrade.php
  182. +4 −0 repository/picasa/db/upgrade.php
  183. +1 −0 repository/repository_ajax.php
  184. +10 −1 repository/url/lib.php
  185. +0 −2 theme/anomaly/config.php
  186. +25 −27 theme/anomaly/style/dock.css
  187. +2 −2 theme/base/style/admin.css
  188. +3 −0 theme/base/style/core.css
  189. +1 −1 theme/base/style/course.css
  190. +8 −6 theme/base/style/filemanager.css
  191. +1 −1 theme/base/style/message.css
  192. +1 −1 theme/base/style/question.css
  193. +1 −0 theme/base/style/user.css
  194. +4 −0 theme/formal_white/db/upgrade.php
  195. +25 −13 theme/splash/config.php
  196. +63 −0 theme/splash/javascript/colourswitcher.js
  197. +6 −1 theme/splash/layout/general.php
  198. +6 −1 theme/splash/layout/report.php
  199. +4 −2 theme/splash/lib.php
  200. +1 −2 theme/splash/style/pagelayout.css
  201. +1 −1 theme/standard/style/grade.css
  202. +1 −1 theme/standard/style/modules.css
  203. +7 −4 user/edit.php
  204. +16 −11 user/edit_form.php
  205. +2 −1 user/editadvanced.php
  206. +14 −10 user/editadvanced_form.php
  207. +7 −8 user/filters/courserole.php
  208. +1 −1 user/profile.php
  209. +5 −3 user/profile/lib.php
  210. +1 −1 user/view.php
  211. +2 −2 version.php
  212. +82 −0 webservice/tests/helpers.php
View
23 admin/blocks.php
@@ -131,12 +131,25 @@
$table->setup();
$tablerows = array();
+ // Sort blocks using current locale.
+ $blocknames = array();
foreach ($blocks as $blockid=>$block) {
$blockname = $block->name;
+ if (file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
+ $blocknames[$blockid] = get_string('pluginname', 'block_'.$blockname);
+ } else {
+ $blocknames[$blockid] = $blockname;
+ }
+ }
+ collatorlib::asort($blocknames);
+
+ foreach ($blocknames as $blockid=>$strblockname) {
+ $block = $blocks[$blockid];
+ $blockname = $block->name;
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
$blockobject = false;
- $strblockname = '<span class="notifyproblem">'.$blockname.' ('.get_string('missingfromdisk').')</span>';
+ $strblockname = '<span class="notifyproblem">'.$strblockname.' ('.get_string('missingfromdisk').')</span>';
$plugin = new stdClass();
$plugin->version = $block->version;
@@ -151,7 +164,6 @@
$incompatible[] = $block;
continue;
}
- $strblockname = get_string('pluginname', 'block_'.$blockname);
}
$delete = '<a href="blocks.php?delete='.$blockid.'&amp;sesskey='.sesskey().'">'.$strdelete.'</a>';
@@ -222,12 +234,7 @@
$delete,
$settings
);
- $tablerows[] = array(strip_tags($strblockname), $row); // first element will be used for sorting
- }
-
- collatorlib::asort($tablerows);
- foreach ($tablerows as $row) {
- $table->add_data($row[1]);
+ $table->add_data($row);
}
$table->print_html();
View
4 admin/tool/customlang/db/upgrade.php
@@ -30,5 +30,9 @@ function xmldb_tool_customlang_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
8 admin/tool/health/styles.css
@@ -3,7 +3,7 @@
width: 60%;
margin: auto;
padding: 1em;
- border: 1px black solid;
+ border: 1px solid black;
-moz-border-radius: 6px;
}
.path-admin-tool-health dl.healthissues {
@@ -35,15 +35,15 @@
.path-admin-tool-health dl.healthissues dd {
margin: 0px;
padding: 1em;
- border: 1px black solid;
+ border: 1px solid black;
}
.path-admin-tool-health dl.healthissues dt {
font-weight: bold;
- border-bottom: none;
+ border-bottom: 0;
padding-bottom: 0.5em;
}
.path-admin-tool-health dl.healthissues dd {
- border-top: none;
+ border-top: 0;
padding-top: 0.5em;
margin-bottom: 10px;
}
View
5 auth/ldap/ntlmsso_attempt.php
@@ -33,8 +33,9 @@
$PAGE->set_heading($site->fullname);
echo $OUTPUT->header();
+// $PAGE->https_required() up above takes care of what $CFG->httpswwwroot should be.
$msg = '<p>'.get_string('ntlmsso_attempting', 'auth_ldap').'</p>'
. '<img width="1", height="1" '
- . ' src="' . $CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey='
+ . ' src="' . $CFG->httpswwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey='
. $sesskey . '" />';
-redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_finish.php', $msg, 3);
+redirect($CFG->httpswwwroot . '/auth/ldap/ntlmsso_finish.php', $msg, 3);
View
3 auth/ldap/ntlmsso_magic.php
@@ -29,7 +29,8 @@
if ($authplugin->ntlmsso_magic($sesskey) && file_exists($file)) {
if (!empty($authplugin->config->ntlmsso_ie_fastpath)) {
if (check_browser_version('MSIE')) {
- redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_finish.php');
+ // $PAGE->https_required() up above takes care of what $CFG->httpswwwroot should be.
+ redirect($CFG->httpswwwroot.'/auth/ldap/ntlmsso_finish.php');
}
}
View
4 auth/manual/db/upgrade.php
@@ -33,5 +33,9 @@ function xmldb_auth_manual_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 auth/mnet/db/upgrade.php
@@ -34,5 +34,9 @@ function xmldb_auth_mnet_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
8 auth/shibboleth/login.php
@@ -44,17 +44,17 @@
// Redirect to SessionInitiator with entityID as argument
if (isset($IdPs[$selectedIdP][1]) && !empty($IdPs[$selectedIdP][1])) {
// For Shibbolet 1.x Service Providers
- header('Location: '.$IdPs[$selectedIdP][1].'?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
+ header('Location: '.$IdPs[$selectedIdP][1].'?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->httpswwwroot.'/auth/shibboleth/index.php'));
// For Shibbolet 2.x Service Providers
- // header('Location: '.$IdPs[$selectedIdP][1].'?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
+ // header('Location: '.$IdPs[$selectedIdP][1].'?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->httpswwwroot.'/auth/shibboleth/index.php'));
} else {
// For Shibbolet 1.x Service Providers
- header('Location: /Shibboleth.sso?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
+ header('Location: /Shibboleth.sso?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->httpswwwroot.'/auth/shibboleth/index.php'));
// For Shibboleth 2.x Service Providers
- // header('Location: /Shibboleth.sso/DS?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
+ // header('Location: /Shibboleth.sso/DS?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->httpswwwroot.'/auth/shibboleth/index.php'));
}
} elseif (isset($_POST['idp']) && !isset($IdPs[$_POST['idp']])) {
$errormsg = get_string('auth_shibboleth_errormsg', 'auth_shibboleth');
View
4 blocks/community/db/upgrade.php
@@ -46,5 +46,9 @@
function xmldb_block_community_upgrade($oldversion) {
global $CFG, $DB;
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
2 blocks/community/styles.css
@@ -173,7 +173,7 @@
bottom:0;
right:0;
opacity:0.35;
- filter:alpha(opacity:35);
+ filter:alpha(opacity=35);
background:#000;
}
View
2 blocks/completionstatus/block_completionstatus.php
@@ -171,7 +171,7 @@ public function get_content() {
$a = new stdClass();
$a->first = $prerequisites_complete;
$a->second = count($prerequisites);
- $shtml .= get_string('firstofsecond', 'block_completionstatus', $a);
+ $phtml .= get_string('firstofsecond', 'block_completionstatus', $a);
$phtml .= '</td></tr>';
$shtml = $phtml . $shtml;
View
18 blocks/feedback/block_feedback.php
@@ -4,7 +4,7 @@
define('FEEDBACK_BLOCK_LIB_IS_OK', true);
}
-class block_feedback extends block_base {
+class block_feedback extends block_list {
function init() {
$this->title = get_string('feedback', 'block_feedback');
@@ -21,10 +21,13 @@ function get_content() {
return $this->content;
}
+ $this->content = new stdClass;
+ $this->content->items = array();
+ $this->content->icons = array();
+ $this->content->footer = '';
+
if (!defined('FEEDBACK_BLOCK_LIB_IS_OK')) {
- $this->content = new stdClass;
- $this->content->text = get_string('missing_feedback_module', 'block_feedback');
- $this->content->footer = '';
+ $this->content->items = array(get_string('missing_feedback_module', 'block_feedback'));
return $this->content;
}
@@ -33,9 +36,7 @@ function get_content() {
$courseid = SITEID;
}
- $this->content = new stdClass;
- $this->content->text = '';
- $this->content->footer = '';
+ $icon = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />';
if (empty($this->instance->pageid)) {
@@ -47,8 +48,7 @@ function get_content() {
foreach ($feedbacks as $feedback) {
$url = new moodle_url($baseurl);
$url->params(array('id'=>$feedback->cmid, 'courseid'=>$courseid));
- $icon = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />&nbsp;';
- $this->content->text = ' <a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
+ $this->content->items[] = '<a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
}
}
View
4 blocks/html/db/upgrade.php
@@ -32,5 +32,9 @@
function xmldb_block_html_upgrade($oldversion) {
global $CFG, $DB;
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 blocks/navigation/db/upgrade.php
@@ -58,5 +58,9 @@ function xmldb_block_navigation_upgrade($oldversion, $block) {
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 blocks/settings/db/upgrade.php
@@ -58,5 +58,9 @@ function xmldb_block_settings_upgrade($oldversion, $block) {
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
2 calendar/delete.php
@@ -108,7 +108,7 @@
if (!empty($event->eventrepeats) && $event->eventrepeats > 0) {
$url = new moodle_url(CALENDAR_URL.'delete.php', array('id'=>$event->repeatid, 'confirm'=>true, 'repeats'=>true));
$buttons .= $OUTPUT->single_button($url, get_string('deleteall'));
- $repeatspan = '<br /><br /><span>'.get_string('youcandeleteallrepeats', 'calendar').'</span>';
+ $repeatspan = '<br /><br /><span>'.get_string('youcandeleteallrepeats', 'calendar', $event->eventrepeats).'</span>';
}
// And add the cancel button
View
2 cohort/edit_form.php
@@ -49,7 +49,7 @@ public function definition() {
$mform->addElement('select', 'contextid', get_string('context', 'role'), $options);
$mform->addElement('text', 'idnumber', get_string('idnumber', 'cohort'), 'maxlength="254" size="50"');
- $mform->setType('name', PARAM_RAW); // idnumbers are plain text, must not be changed
+ $mform->setType('idnumber', PARAM_RAW); // idnumbers are plain text, must not be changed
$mform->addElement('editor', 'description_editor', get_string('description', 'cohort'), null, $editoroptions);
$mform->setType('description_editor', PARAM_RAW);
View
10 course/completion.php
@@ -141,16 +141,6 @@
$aggregation->setMethod($data->role_aggregation);
$aggregation->save();
- // Update course total passing grade
- if (!empty($data->criteria_grade)) {
- if ($grade_item = grade_category::fetch_course_category($course->id)->grade_item) {
- $grade_item->gradepass = $data->criteria_grade_value;
- if (method_exists($grade_item, 'update')) {
- $grade_item->update('course/completion.php');
- }
- }
- }
-
add_to_log($course->id, 'course', 'completion updated', 'completion.php?id='.$course->id);
$url = new moodle_url('/course/view.php', array('id' => $course->id));
View
5 course/completion_form.php
@@ -179,10 +179,13 @@ function definition() {
$criteria->config_form_display($mform);
// Completion on course grade
- $mform->addElement('header', 'grade', get_string('grade'));
+ $mform->addElement('header', 'grade', get_string('coursegrade', 'completion'));
// Grade enable and passing grade
$course_grade = $DB->get_field('grade_items', 'gradepass', array('courseid' => $course->id, 'itemtype' => 'course'));
+ if (!$course_grade) {
+ $course_grade = '0.00000';
+ }
$criteria = new completion_criteria_grade($params);
$criteria->config_form_display($mform, $course_grade);
View
23 course/externallib.php
@@ -904,9 +904,10 @@ public static function get_categories_parameters() {
'"parent" (int) the parent category id,'.
'"idnumber" (string) category idnumber'.
' - user must have \'moodle/category:manage\' to search on idnumber,'.
- '"visible" (int) whether the category is visible or not'.
+ '"visible" (int) whether the returned categories must be visible or hidden. If the key is not passed,
+ then the function return all categories that the user can see.'.
' - user must have \'moodle/category:manage\' or \'moodle/category:viewhiddencategories\' to search on visible,'.
- '"theme" (string) category theme'.
+ '"theme" (string) only return the categories having this theme'.
' - user must have \'moodle/category:manage\' to search on theme'),
'value' => new external_value(PARAM_RAW, 'the value to match')
)
@@ -1017,10 +1018,22 @@ public static function get_categories($criteria = array(), $addsubcategories = t
if ($categories and !empty($params['addsubcategories'])) {
$newcategories = array();
+ // Check if we required visible/theme checks.
+ $additionalselect = '';
+ $additionalparams = array();
+ if (isset($conditions['visible'])) {
+ $additionalselect .= ' AND visible = :visible';
+ $additionalparams['visible'] = $conditions['visible'];
+ }
+ if (isset($conditions['theme'])) {
+ $additionalselect .= ' AND theme= :theme';
+ $additionalparams['theme'] = $conditions['theme'];
+ }
+
foreach ($categories as $category) {
- $sqllike = $DB->sql_like('path', ':path');
- $sqlparams = array('path' => $category->path.'/%'); // It will NOT include the specified category.
- $subcategories = $DB->get_records_select('course_categories', $sqllike, $sqlparams);
+ $sqlselect = $DB->sql_like('path', ':path') . $additionalselect;
+ $sqlparams = array('path' => $category->path.'/%') + $additionalparams; // It will NOT include the specified category.
+ $subcategories = $DB->get_records_select('course_categories', $sqlselect, $sqlparams);
$newcategories = $newcategories + $subcategories; // Both arrays have integer as keys.
}
$categories = $categories + $newcategories;
View
10 course/lib.php
@@ -1470,9 +1470,8 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
// 2. the activity has dates set which do not include current, or
// 3. the activity has any other conditions set (regardless of whether
// current user meets them)
- $canviewhidden = has_capability(
- 'moodle/course:viewhiddenactivities',
- get_context_instance(CONTEXT_MODULE, $mod->id));
+ $modcontext = context_module::instance($mod->id);
+ $canviewhidden = has_capability('moodle/course:viewhiddenactivities', $modcontext);
$accessiblebutdim = false;
if ($canviewhidden) {
$accessiblebutdim = !$mod->visible;
@@ -1684,9 +1683,10 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
}
if ($completionicon) {
$imgsrc = $OUTPUT->pix_url('i/completion-'.$completionicon);
- $imgalt = s(get_string('completion-alt-'.$completionicon, 'completion', $mod->name));
+ $formattedname = format_string($mod->name, true, array('context' => $modcontext));
+ $imgalt = get_string('completion-alt-' . $completionicon, 'completion', $formattedname);
if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting) {
- $imgtitle = s(get_string('completion-title-'.$completionicon, 'completion', $mod->name));
+ $imgtitle = get_string('completion-title-' . $completionicon, 'completion', $formattedname);
$newstate =
$completiondata->completionstate==COMPLETION_COMPLETE
? COMPLETION_INCOMPLETE
View
570 course/tests/externallib_test.php
@@ -0,0 +1,570 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * External course functions unit tests
+ *
+ * @package core_course
+ * @category external
+ * @copyright 2012 Jerome Mouneyrac
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+
+require_once($CFG->dirroot . '/webservice/tests/helpers.php');
+
+/**
+ * External course functions unit tests
+ *
+ * @package core_course
+ * @category external
+ * @copyright 2012 Jerome Mouneyrac
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_course_external_testcase extends externallib_advanced_testcase {
+
+ /**
+ * Tests set up
+ */
+ protected function setUp() {
+ global $CFG;
+ require_once($CFG->dirroot . '/course/externallib.php');
+ }
+
+ /**
+ * Test create_categories
+ */
+ public function test_create_categories() {
+
+ global $DB;
+
+ $this->resetAfterTest(true);
+
+ // Set the required capabilities by the external function
+ $contextid = context_system::instance()->id;
+ $roleid = $this->assignUserCapability('moodle/category:manage', $contextid);
+
+ // Create base categories.
+ $category1 = new stdClass();
+ $category1->name = 'Root Test Category 1';
+ $category2 = new stdClass();
+ $category2->name = 'Root Test Category 2';
+ $category2->idnumber = 'rootcattest2';
+ $category2->desc = 'Description for root test category 1';
+ $category2->theme = 'base';
+ $categories = array(
+ array('name' => $category1->name, 'parent' => 0),
+ array('name' => $category2->name, 'parent' => 0, 'idnumber' => $category2->idnumber,
+ 'description' => $category2->desc, 'theme' => $category2->theme)
+ );
+
+ $createdcats = core_course_external::create_categories($categories);
+
+ // Initially confirm that base data was inserted correctly.
+ $this->assertEquals($category1->name, $createdcats[0]['name']);
+ $this->assertEquals($category2->name, $createdcats[1]['name']);
+
+ // Save the ids.
+ $category1->id = $createdcats[0]['id'];
+ $category2->id = $createdcats[1]['id'];
+
+ // Create on sub category.
+ $category3 = new stdClass();
+ $category3->name = 'Sub Root Test Category 3';
+ $subcategories = array(
+ array('name' => $category3->name, 'parent' => $category1->id)
+ );
+
+ $createdsubcats = core_course_external::create_categories($subcategories);
+
+ // Confirm that sub categories were inserted correctly.
+ $this->assertEquals($category3->name, $createdsubcats[0]['name']);
+
+ // Save the ids.
+ $category3->id = $createdsubcats[0]['id'];
+
+ // Calling the ws function should provide a new sortorder to give category1,
+ // category2, category3. New course categories are ordered by id not name.
+ $category1 = $DB->get_record('course_categories', array('id' => $category1->id));
+ $category2 = $DB->get_record('course_categories', array('id' => $category2->id));
+ $category3 = $DB->get_record('course_categories', array('id' => $category3->id));
+
+ $this->assertGreaterThanOrEqual($category1->sortorder, $category3->sortorder);
+ $this->assertGreaterThanOrEqual($category2->sortorder, $category3->sortorder);
+
+ // Call without required capability
+ $this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
+ $this->setExpectedException('required_capability_exception');
+ $createdsubcats = core_course_external::create_categories($subcategories);
+
+ }
+
+ /**
+ * Test delete categories
+ */
+ public function test_delete_categories() {
+ global $DB;
+
+ $this->resetAfterTest(true);
+
+ // Set the required capabilities by the external function
+ $contextid = context_system::instance()->id;
+ $roleid = $this->assignUserCapability('moodle/category:manage', $contextid);
+
+ $category1 = self::getDataGenerator()->create_category();
+ $category2 = self::getDataGenerator()->create_category(
+ array('parent' => $category1->id));
+ $category3 = self::getDataGenerator()->create_category();
+ $category4 = self::getDataGenerator()->create_category(
+ array('parent' => $category3->id));
+ $category5 = self::getDataGenerator()->create_category(
+ array('parent' => $category4->id));
+
+ //delete category 1 and 2 + delete category 4, category 5 moved under category 3
+ core_course_external::delete_categories(array(
+ array('id' => $category1->id, 'recursive' => 1),
+ array('id' => $category4->id)
+ ));
+
+ //check $category 1 and 2 are deleted
+ $notdeletedcount = $DB->count_records_select('course_categories',
+ 'id IN ( ' . $category1->id . ',' . $category2->id . ',' . $category4->id . ')');
+ $this->assertEquals(0, $notdeletedcount);
+
+ //check that $category5 as $category3 for parent
+ $dbcategory5 = $DB->get_record('course_categories', array('id' => $category5->id));
+ $this->assertEquals($dbcategory5->path, $category3->path . '/' . $category5->id);
+
+ // Call without required capability
+ $this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
+ $this->setExpectedException('required_capability_exception');
+ $createdsubcats = core_course_external::delete_categories(
+ array(array('id' => $category3->id)));
+ }
+
+ /**
+ * Test get categories
+ */
+ public function test_get_categories() {
+ global $DB;
+
+ $this->resetAfterTest(true);
+ $category1data['idnumber'] = 'idnumbercat1';
+ $category1data['name'] = 'Category 1 for PHPunit test';
+ $category1data['description'] = 'Category 1 description';
+ $category1data['descriptionformat'] = FORMAT_MOODLE;
+ $category1 = self::getDataGenerator()->create_category($category1data);
+ $category2 = self::getDataGenerator()->create_category(
+ array('parent' => $category1->id));
+ $category6 = self::getDataGenerator()->create_category(
+ array('parent' => $category1->id, 'visible' => 0));
+ $category3 = self::getDataGenerator()->create_category();
+ $category4 = self::getDataGenerator()->create_category(
+ array('parent' => $category3->id));
+ $category5 = self::getDataGenerator()->create_category(
+ array('parent' => $category4->id));
+
+ // Set the required capabilities by the external function.
+ $context = context_system::instance();
+ $roleid = $this->assignUserCapability('moodle/category:manage', $context->id);
+
+ // Retrieve category1 + sub-categories except not visible ones
+ $categories = core_course_external::get_categories(array(
+ array('key' => 'id', 'value' => $category1->id),
+ array('key' => 'visible', 'value' => 1)), 1);
+
+ // Check we retrieve the good total number of categories.
+ $this->assertEquals(2, count($categories));
+
+ // Check the return values
+ $this->assertEquals($categories[0]['id'], $category1->id);
+ $this->assertEquals($categories[0]['idnumber'], $category1->idnumber);
+ $this->assertEquals($categories[0]['name'], $category1->name);
+ $this->assertEquals($categories[0]['description'], $category1->description);
+ $this->assertEquals($categories[0]['descriptionformat'], FORMAT_HTML);
+
+ // Check different params.
+ $categories = core_course_external::get_categories(array(
+ array('key' => 'id', 'value' => $category1->id),
+ array('key' => 'idnumber', 'value' => $category1->idnumber),
+ array('key' => 'visible', 'value' => 1)), 0);
+ $this->assertEquals(1, count($categories));
+
+ // Retrieve categories from parent.
+ $categories = core_course_external::get_categories(array(
+ array('key' => 'parent', 'value' => $category3->id)), 1);
+ $this->assertEquals(2, count($categories));
+
+ // Retrieve all categories.
+ $categories = core_course_external::get_categories();
+ $this->assertEquals($DB->count_records('course_categories'), count($categories));
+
+ // Call without required capability (it will fail cause of the search on idnumber).
+ $this->unassignUserCapability('moodle/category:manage', $context->id, $roleid);
+ $this->setExpectedException('moodle_exception');
+ $categories = core_course_external::get_categories(array(
+ array('key' => 'id', 'value' => $category1->id),
+ array('key' => 'idnumber', 'value' => $category1->idnumber),
+ array('key' => 'visible', 'value' => 1)), 0);
+ }
+
+ /**
+ * Test update_categories
+ */
+ public function test_update_categories() {
+ global $DB;
+
+ $this->resetAfterTest(true);
+
+ // Set the required capabilities by the external function
+ $contextid = context_system::instance()->id;
+ $roleid = $this->assignUserCapability('moodle/category:manage', $contextid);
+
+ // Create base categories.
+ $category1data['idnumber'] = 'idnumbercat1';
+ $category1data['name'] = 'Category 1 for PHPunit test';
+ $category1data['description'] = 'Category 1 description';
+ $category1data['descriptionformat'] = FORMAT_MOODLE;
+ $category1 = self::getDataGenerator()->create_category($category1data);
+ $category2 = self::getDataGenerator()->create_category(
+ array('parent' => $category1->id));
+ $category3 = self::getDataGenerator()->create_category();
+ $category4 = self::getDataGenerator()->create_category(
+ array('parent' => $category3->id));
+ $category5 = self::getDataGenerator()->create_category(
+ array('parent' => $category4->id));
+
+ // We update all category1 attribut.
+ // Then we move cat4 and cat5 parent: cat3 => cat1
+ $categories = array(
+ array('id' => $category1->id,
+ 'name' => $category1->name . '_updated',
+ 'idnumber' => $category1->idnumber . '_updated',
+ 'description' => $category1->description . '_updated',
+ 'descriptionformat' => FORMAT_HTML,
+ 'theme' => $category1->theme),
+ array('id' => $category4->id, 'parent' => $category1->id));
+
+ core_course_external::update_categories($categories);
+
+ // Check the values were updated.
+ $dbcategories = $DB->get_records_select('course_categories',
+ 'id IN (' . $category1->id . ',' . $category2->id . ',' . $category2->id
+ . ',' . $category3->id . ',' . $category4->id . ',' . $category5->id .')');
+ $this->assertEquals($category1->name . '_updated',
+ $dbcategories[$category1->id]->name);
+ $this->assertEquals($category1->idnumber . '_updated',
+ $dbcategories[$category1->id]->idnumber);
+ $this->assertEquals($category1->description . '_updated',
+ $dbcategories[$category1->id]->description);
+ $this->assertEquals(FORMAT_HTML, $dbcategories[$category1->id]->descriptionformat);
+
+ // Check that category4 and category5 have been properly moved.
+ $this->assertEquals('/' . $category1->id . '/' . $category4->id,
+ $dbcategories[$category4->id]->path);
+ $this->assertEquals('/' . $category1->id . '/' . $category4->id . '/' . $category5->id,
+ $dbcategories[$category5->id]->path);
+
+ // Call without required capability.
+ $this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
+ $this->setExpectedException('required_capability_exception');
+ core_course_external::update_categories($categories);
+ }
+
+ /**
+ * Test create_courses
+ */
+ public function test_create_courses() {
+ global $DB;
+
+ $this->resetAfterTest(true);
+
+ // Set the required capabilities by the external function
+ $contextid = context_system::instance()->id;
+ $roleid = $this->assignUserCapability('moodle/course:create', $contextid);
+ $this->assignUserCapability('moodle/course:visibility', $contextid, $roleid);
+
+ $category = self::getDataGenerator()->create_category();
+
+ // Create base categories.
+ $course1['fullname'] = 'Test course 1';
+ $course1['shortname'] = 'Testcourse1';
+ $course1['categoryid'] = $category->id;
+ $course2['fullname'] = 'Test course 2';
+ $course2['shortname'] = 'Testcourse2';
+ $course2['categoryid'] = $category->id;
+ $course2['idnumber'] = 'testcourse2idnumber';
+ $course2['summary'] = 'Description for course 2';
+ $course2['summaryformat'] = FORMAT_MOODLE;
+ $course2['format'] = 'weeks';
+ $course2['showgrades'] = 1;
+ $course2['newsitems'] = 3;
+ $course2['startdate'] = 32882306400; // 01/01/3012
+ $course2['numsections'] = 4;
+ $course2['maxbytes'] = 100000;
+ $course2['showreports'] = 1;
+ $course2['visible'] = 0;
+ $course2['hiddensections'] = 0;
+ $course2['groupmode'] = 0;
+ $course2['groupmodeforce'] = 0;
+ $course2['defaultgroupingid'] = 0;
+ $course2['enablecompletion'] = 1;
+ $course2['completionstartonenrol'] = 1;
+ $course2['completionnotify'] = 1;
+ $course2['lang'] = 'en';
+ $course2['forcetheme'] = 'base';
+ $courses = array($course1, $course2);
+
+ $createdcourses = core_course_external::create_courses($courses);
+
+ // Check that right number of courses were created.
+ $this->assertEquals(2, count($createdcourses));
+
+ // Check that the courses were correctly created.
+ foreach ($createdcourses as $createdcourse) {
+ $dbcourse = $DB->get_record('course', array('id' => $createdcourse['id']));
+
+ if ($createdcourse['shortname'] == $course2['shortname']) {
+ $this->assertEquals($dbcourse->fullname, $course2['fullname']);
+ $this->assertEquals($dbcourse->shortname, $course2['shortname']);
+ $this->assertEquals($dbcourse->category, $course2['categoryid']);
+ $this->assertEquals($dbcourse->idnumber, $course2['idnumber']);
+ $this->assertEquals($dbcourse->summary, $course2['summary']);
+ $this->assertEquals($dbcourse->summaryformat, $course2['summaryformat']);
+ $this->assertEquals($dbcourse->format, $course2['format']);
+ $this->assertEquals($dbcourse->showgrades, $course2['showgrades']);
+ $this->assertEquals($dbcourse->newsitems, $course2['newsitems']);
+ $this->assertEquals($dbcourse->startdate, $course2['startdate']);
+ $this->assertEquals($dbcourse->numsections, $course2['numsections']);
+ $this->assertEquals($dbcourse->maxbytes, $course2['maxbytes']);
+ $this->assertEquals($dbcourse->showreports, $course2['showreports']);
+ $this->assertEquals($dbcourse->visible, $course2['visible']);
+ $this->assertEquals($dbcourse->hiddensections, $course2['hiddensections']);
+ $this->assertEquals($dbcourse->groupmode, $course2['groupmode']);
+ $this->assertEquals($dbcourse->groupmodeforce, $course2['groupmodeforce']);
+ $this->assertEquals($dbcourse->defaultgroupingid, $course2['defaultgroupingid']);
+ $this->assertEquals($dbcourse->completionnotify, $course2['completionnotify']);
+ $this->assertEquals($dbcourse->lang, $course2['lang']);
+
+ if (!empty($CFG->allowcoursethemes)) {
+ $this->assertEquals($dbcourse->theme, $course2['forcetheme']);
+ }
+
+ if (completion_info::is_enabled_for_site()) {
+ $this->assertEquals($dbcourse->enablecompletion, $course2['enabledcompletion']);
+ $this->assertEquals($dbcourse->completionstartonenrol, $course2['completionstartonenrol']);
+ } else {
+ $this->assertEquals($dbcourse->enablecompletion, 0);
+ $this->assertEquals($dbcourse->completionstartonenrol, 0);
+ }
+
+ } else if ($createdcourse['shortname'] == $course1['shortname']) {
+ $courseconfig = get_config('moodlecourse');
+ $this->assertEquals($dbcourse->fullname, $course1['fullname']);
+ $this->assertEquals($dbcourse->shortname, $course1['shortname']);
+ $this->assertEquals($dbcourse->category, $course1['categoryid']);
+ $this->assertEquals($dbcourse->summaryformat, FORMAT_HTML);
+ $this->assertEquals($dbcourse->format, $courseconfig->format);
+ $this->assertEquals($dbcourse->showgrades, $courseconfig->showgrades);
+ $this->assertEquals($dbcourse->newsitems, $courseconfig->newsitems);
+ $this->assertEquals($dbcourse->numsections, $courseconfig->numsections);
+ $this->assertEquals($dbcourse->maxbytes, $courseconfig->maxbytes);
+ $this->assertEquals($dbcourse->showreports, $courseconfig->showreports);
+ $this->assertEquals($dbcourse->hiddensections, $courseconfig->hiddensections);
+ $this->assertEquals($dbcourse->groupmode, $courseconfig->groupmode);
+ $this->assertEquals($dbcourse->groupmodeforce, $courseconfig->groupmodeforce);
+ $this->assertEquals($dbcourse->defaultgroupingid, 0);
+ } else {
+ throw moodle_exception('Unexpected shortname');
+ }
+ }
+
+ // Call without required capability
+ $this->unassignUserCapability('moodle/course:create', $contextid, $roleid);
+ $this->setExpectedException('required_capability_exception');
+ $createdsubcats = core_course_external::create_courses($courses);
+ }
+
+ /**
+ * Test delete_courses
+ */
+ public function test_delete_courses() {
+ global $DB, $USER;
+
+ $this->resetAfterTest(true);
+
+ // Admin can delete a course.
+ $this->setAdminUser();
+ // Validate_context() will fail as the email is not set by $this->setAdminUser().
+ $USER->email = 'emailtopass@contextvalidation.me';
+
+ $course1 = self::getDataGenerator()->create_course();
+ $course2 = self::getDataGenerator()->create_course();
+ $course3 = self::getDataGenerator()->create_course();
+
+ // Delete courses.
+ core_course_external::delete_courses(array($course1->id, $course2->id));
+
+ // Check $course 1 and 2 are deleted.
+ $notdeletedcount = $DB->count_records_select('course',
+ 'id IN ( ' . $course1->id . ',' . $course2->id . ')');
+ $this->assertEquals(0, $notdeletedcount);
+
+ // Fail when the user is not allow to access the course (enrolled) or is not admin.
+ $this->setGuestUser();
+ $this->setExpectedException('require_login_exception');
+ $createdsubcats = core_course_external::delete_courses(array($course3->id));
+ }
+
+ /**
+ * Test get_courses
+ */
+ public function test_get_courses () {
+ global $DB;
+
+ $this->resetAfterTest(true);
+
+ $coursedata['idnumber'] = 'idnumbercourse1';
+ $coursedata['fullname'] = 'Course 1 for PHPunit test';
+ $coursedata['summary'] = 'Course 1 description';
+ $coursedata['summaryformat'] = FORMAT_MOODLE;
+ $course1 = self::getDataGenerator()->create_course($coursedata);
+ $course2 = self::getDataGenerator()->create_course();
+ $course3 = self::getDataGenerator()->create_course();
+
+ // Set the required capabilities by the external function.
+ $context = context_system::instance();
+ $roleid = $this->assignUserCapability('moodle/course:view', $context->id);
+ $this->assignUserCapability('moodle/course:update',
+ context_course::instance($course1->id)->id, $roleid);
+ $this->assignUserCapability('moodle/course:update',
+ context_course::instance($course2->id)->id, $roleid);
+ $this->assignUserCapability('moodle/course:update',
+ context_course::instance($course3->id)->id, $roleid);
+
+ $courses = core_course_external::get_courses(array('ids' =>
+ array($course1->id, $course2->id)));
+
+ // Check we retrieve the good total number of categories.
+ $this->assertEquals(2, count($courses));
+
+ // Check the return values for course 1
+ $dbcourse = $DB->get_record('course', array('id' => $course1->id));
+ $this->assertEquals($courses[0]['id'], $dbcourse->id);
+ $this->assertEquals($courses[0]['idnumber'], $coursedata['idnumber']);
+ $this->assertEquals($courses[0]['fullname'], $coursedata['fullname']);
+ $this->assertEquals($courses[0]['summary'], $coursedata['summary']);
+ $this->assertEquals($courses[0]['summaryformat'], FORMAT_HTML);
+ $this->assertEquals($courses[0]['shortname'], $dbcourse->shortname);
+ $this->assertEquals($courses[0]['categoryid'], $dbcourse->category);
+ $this->assertEquals($courses[0]['format'], $dbcourse->format);
+ $this->assertEquals($courses[0]['showgrades'], $dbcourse->showgrades);
+ $this->assertEquals($courses[0]['newsitems'], $dbcourse->newsitems);
+ $this->assertEquals($courses[0]['startdate'], $dbcourse->startdate);
+ $this->assertEquals($courses[0]['numsections'], $dbcourse->numsections);
+ $this->assertEquals($courses[0]['maxbytes'], $dbcourse->maxbytes);
+ $this->assertEquals($courses[0]['showreports'], $dbcourse->showreports);
+ $this->assertEquals($courses[0]['visible'], $dbcourse->visible);
+ $this->assertEquals($courses[0]['hiddensections'], $dbcourse->hiddensections);
+ $this->assertEquals($courses[0]['groupmode'], $dbcourse->groupmode);
+ $this->assertEquals($courses[0]['groupmodeforce'], $dbcourse->groupmodeforce);
+ $this->assertEquals($courses[0]['defaultgroupingid'], $dbcourse->defaultgroupingid);
+ $this->assertEquals($courses[0]['completionnotify'], $dbcourse->completionnotify);
+ $this->assertEquals($courses[0]['lang'], $dbcourse->lang);
+ $this->assertEquals($courses[0]['forcetheme'], $dbcourse->theme);
+ $this->assertEquals($courses[0]['completionstartonenrol'], $dbcourse->completionstartonenrol);
+ $this->assertEquals($courses[0]['enablecompletion'], $dbcourse->enablecompletion);
+ $this->assertEquals($courses[0]['completionstartonenrol'], $dbcourse->completionstartonenrol);
+
+ // Get all courses in the DB
+ $courses = core_course_external::get_courses(array());
+ $this->assertEquals($DB->count_records('course'), count($courses));
+ }
+
+ /**
+ * Test get_course_contents
+ */
+ public function test_get_course_contents() {
+ $this->resetAfterTest(true);
+
+ $course = self::getDataGenerator()->create_course();
+ $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id));
+ $forumcm = get_coursemodule_from_id('forum', $forum->cmid);
+ $forumcontext = context_module::instance($forum->cmid);
+ $data = $this->getDataGenerator()->create_module('data', array('assessed'=>1, 'scale'=>100, 'course'=>$course->id));
+ $datacontext = context_module::instance($data->cmid);
+ $datacm = get_coursemodule_from_instance('page', $data->id);
+ $page = $this->getDataGenerator()->create_module('page', array('course'=>$course->id));
+ $pagecontext = context_module::instance($page->cmid);
+ $pagecm = get_coursemodule_from_instance('page', $page->id);
+
+ // Set the required capabilities by the external function.
+ $context = context_course::instance($course->id);
+ $roleid = $this->assignUserCapability('moodle/course:view', $context->id);
+ $this->assignUserCapability('moodle/course:update', $context->id, $roleid);
+
+ $courses = core_course_external::get_course_contents($course->id, array());
+
+ // Check that the course has the 3 created modules
+ $this->assertEquals(3, count($courses[0]['modules']));
+ }
+
+ /**
+ * Test duplicate_course
+ */
+ public function test_duplicate_course() {
+ $this->resetAfterTest(true);
+
+ // Create one course with three modules.
+ $course = self::getDataGenerator()->create_course();
+ $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id));
+ $forumcm = get_coursemodule_from_id('forum', $forum->cmid);
+ $forumcontext = context_module::instance($forum->cmid);
+ $data = $this->getDataGenerator()->create_module('data', array('assessed'=>1, 'scale'=>100, 'course'=>$course->id));
+ $datacontext = context_module::instance($data->cmid);
+ $datacm = get_coursemodule_from_instance('page', $data->id);
+ $page = $this->getDataGenerator()->create_module('page', array('course'=>$course->id));
+ $pagecontext = context_module::instance($page->cmid);
+ $pagecm = get_coursemodule_from_instance('page', $page->id);
+
+ // Set the required capabilities by the external function.
+ $coursecontext = context_course::instance($course->id);
+ $categorycontext = context_coursecat::instance($course->category);
+ $roleid = $this->assignUserCapability('moodle/course:create', $categorycontext->id);
+ $this->assignUserCapability('moodle/course:view', $categorycontext->id, $roleid);
+ $this->assignUserCapability('moodle/restore:restorecourse', $categorycontext->id, $roleid);
+ $this->assignUserCapability('moodle/backup:backupcourse', $coursecontext->id, $roleid);
+ $this->assignUserCapability('moodle/backup:configure', $coursecontext->id, $roleid);
+ // Optional capabilities to copy user data.
+ $this->assignUserCapability('moodle/backup:userinfo', $coursecontext->id, $roleid);
+ $this->assignUserCapability('moodle/restore:userinfo', $categorycontext->id, $roleid);
+
+ $newcourse['fullname'] = 'Course duplicate';
+ $newcourse['shortname'] = 'courseduplicate';
+ $newcourse['categoryid'] = $course->category;
+ $newcourse['visible'] = true;
+ $newcourse['options'][] = array('name' => 'users', 'value' => true);
+
+ $duplicate = core_course_external::duplicate_course($course->id, $newcourse['fullname'],
+ $newcourse['shortname'], $newcourse['categoryid'], $newcourse['visible'], $newcourse['options']);
+
+ // Check that the course has been duplicated.
+ $this->assertEquals($newcourse['shortname'], $duplicate['shortname']);
+ }
+}
View
14 course/view.php
@@ -99,8 +99,18 @@
$infoid = $course->id;
if(!empty($section)) {
$loglabel = 'view section';
- $sectionparams = array('course' => $course->id, 'section' => $section);
- $coursesections = $DB->get_record('course_sections', $sectionparams, 'id', MUST_EXIST);
+
+ // Get section details and check it exists.
+ $modinfo = get_fast_modinfo($course);
+ $coursesections = $modinfo->get_section_info($section, MUST_EXIST);
+
+ // Check user is allowed to see it.
+ if (!$coursesections->uservisible) {
+ // Note: We actually already know they don't have this capability
+ // or uservisible would have been true; this is just to get the
+ // correct error message shown.
+ require_capability('moodle/course:viewhiddensections', $context);
+ }
$infoid = $coursesections->id;
$logparam .= '&sectionid='. $infoid;
}
View
4 enrol/authorize/db/upgrade.php
@@ -26,5 +26,9 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 enrol/database/db/upgrade.php
@@ -30,5 +30,9 @@ function xmldb_enrol_database_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
3 enrol/database/lib.php
@@ -445,8 +445,9 @@ public function sync_enrolments($verbose = false) {
$sql = $this->db_get_sql($table, array($coursefield=>$course->mapping), $sqlfields);
if ($rs = $extdb->Execute($sql)) {
if (!$rs->EOF) {
+ $usersearch = array('deleted' => 0);
if ($localuserfield === 'username') {
- $usersearch = array('mnethostid'=>$CFG->mnet_localhost_id, 'deleted' =>0);
+ $usersearch['mnethostid'] = $CFG->mnet_localhost_id;
}
while ($fields = $rs->FetchRow()) {
$fields = array_change_key_case($fields, CASE_LOWER);
View
4 enrol/flatfile/db/upgrade.php
@@ -32,5 +32,9 @@ function xmldb_enrol_flatfile_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 enrol/guest/db/upgrade.php
@@ -40,6 +40,10 @@ function xmldb_enrol_guest_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2011112901, 'enrol', 'guest');
}
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 enrol/imsenterprise/db/upgrade.php
@@ -31,6 +31,10 @@ function xmldb_enrol_imsenterprise_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 enrol/mnet/db/upgrade.php
@@ -32,5 +32,9 @@ function xmldb_enrol_mnet_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 enrol/paypal/db/upgrade.php
@@ -47,5 +47,9 @@ function xmldb_enrol_paypal_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
2 enrol/self/lib.php
@@ -291,7 +291,7 @@ protected function email_welcome_message($instance, $user) {
if ($rusers) {
$contact = reset($rusers);
} else {
- $contact = get_admin();
+ $contact = generate_email_supportuser();
}
//directly emailing welcome message rather than using messaging
View
24 files/renderer.php
@@ -219,7 +219,7 @@ private function fm_print_generallayout($fm) {
<div class="filemanager-container" >
<div class="fm-content-wrapper">
<div class="fp-content"></div>
- <div class="fm-empty-container <!--mdl-align-->">
+ <div class="fm-empty-container">
<span class="dndupload-message">'.$strdndenabledinbox.'<br/><span class="dndupload-arrow"></span></span>
</div>
<div class="dndupload-target">'.$strdroptoupload.'<br/><span class="dndupload-arrow"></span></div>
@@ -368,8 +368,7 @@ private function fm_js_template_fileselectlayout() {
$rv = '
<div class="filemanager fp-select">
<div class="fp-select-loading">
- <img src="'.$this->pix_url('i/loading').'" />
- <p>'.get_string('loading', 'repository').'</p>
+ <img src="'.$this->pix_url('i/loading_small').'" />
</div>
<form>
<button class="{!}fp-file-download">'.get_string('download').'</button>
@@ -455,10 +454,10 @@ public function filemanager_js_templates() {
*/
private function fm_print_restrictions($fm) {
$maxbytes = display_size($fm->options->maxbytes);
- if (empty($options->maxfiles) || $options->maxfiles == -1) {
+ if (empty($fm->options->maxfiles) || $fm->options->maxfiles == -1) {
$maxsize = get_string('maxfilesize', 'moodle', $maxbytes);
} else {
- $strparam = (object)array('size' => $maxbytes, 'attachments' => $options->maxfiles);
+ $strparam = (object)array('size' => $maxbytes, 'attachments' => $fm->options->maxfiles);
$maxsize = get_string('maxsizeandattachments', 'moodle', $strparam);
}
// TODO MDL-32020 also should say about 'File types accepted'
@@ -622,8 +621,7 @@ private function fp_js_template_nextpage() {
<div class="{!}fp-nextpage">
<div class="fp-nextpage-link"><a href="#">'.get_string('more').'</a></div>
<div class="fp-nextpage-loading">
- <img src="'.$this->pix_url('i/loading').'" />
- <p>'.get_string('loading', 'repository').'</p>
+ <img src="'.$this->pix_url('i/loading_small').'" />
</div>
</div>';
return preg_replace('/\{\!\}/', '', $rv);
@@ -661,19 +659,18 @@ private function fp_js_template_selectlayout() {
$rv = '
<div class="file-picker fp-select">
<div class="fp-select-loading">
- <img src="'.$this->pix_url('i/loading').'" />
- <p>'.get_string('loading', 'repository').'</p>
+ <img src="'.$this->pix_url('i/loading_small').'" />
</div>
<form>
<table>
<tr class="{!}fp-linktype-2">
- <td></td>
+ <td class="mdl-right"></td>
<td class="mdl-left"><input type="radio"/><label>&nbsp;'.get_string('makefileinternal', 'repository').'</label></td></tr>
<tr class="{!}fp-linktype-1">
- <td></td>
+ <td class="mdl-right"></td>
<td class="mdl-left"><input type="radio"/><label>&nbsp;'.get_string('makefilelink', 'repository').'</label></td></tr>
<tr class="{!}fp-linktype-4">
- <td></td>
+ <td class="mdl-right"></td>
<td class="mdl-left"><input type="radio"/><label>&nbsp;'.get_string('makefilereference', 'repository').'</label></td></tr>
<tr class="{!}fp-saveas">
<td class="mdl-right"><label>'.get_string('saveas', 'repository').'</label>:</td>
@@ -759,8 +756,7 @@ private function fp_js_template_loading() {
return '
<div class="fp-content-loading">
<div class="fp-content-center">
- <img src="'.$this->pix_url('i/loading').'" />
- <p>'.get_string('loading', 'repository').'</p>
+ <img src="'.$this->pix_url('i/loading_small').'" />
</div>
</div>';
}
View
2 filter/glossary/version.php
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2012061700;
+$plugin->version = 2012061701;
$plugin->requires = 2012061700; // Requires this Moodle version
$plugin->component= 'filter_glossary';
View
2 filter/glossary/yui/autolinker/autolinker.js
@@ -130,4 +130,4 @@ YUI.add('moodle-filter_glossary-autolinker', function(Y) {
return new AUTOLINKER(config);
}
-}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']});
+}, '@VERSION@', {requires:['base','node','io-base','json-parse','event-delegate','overlay','moodle-enrol-notification']});
View
4 filter/mediaplugin/db/upgrade.php
@@ -54,5 +54,9 @@ function xmldb_filter_mediaplugin_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2011121200, 'filter', 'mediaplugin');
}
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
4 filter/tex/db/upgrade.php
@@ -33,5 +33,9 @@ function xmldb_filter_tex_upgrade($oldversion) {
$dbman = $DB->get_manager();
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
2 grade/grading/form/guide/js/guide.js
@@ -4,7 +4,7 @@ M.gradingform_guide = {};
* This function is called for each guide on page.
*/
M.gradingform_guide.init = function(Y, options) {
- var currentfocus = null;
+ var currentfocus = Y.one('.markingguideremark');
Y.all('.markingguideremark').on('blur', function(e) {
currentfocus = e.currentTarget;
View
4 grade/grading/form/rubric/db/upgrade.php
@@ -38,5 +38,9 @@ function xmldb_gradingform_rubric_upgrade($oldversion) {
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
return true;
}
View
3 grade/report/grader/lib.php
@@ -411,6 +411,9 @@ public function load_users() {
case 'firstname':
$sort = "u.firstname $this->sortorder, u.lastname $this->sortorder";
break;
+ case 'email':
+ $sort = "u.email $this->sortorder";
+ break;
case 'idnumber':
default:
$sort = "u.idnumber $this->sortorder";
View
8 grade/report/grader/styles.css
@@ -185,7 +185,7 @@ margin-right:10px;
}
table#user-grades .quickfeedback {
-border:#000 1px dashed;
+border:1px dashed #000;
}
.path-grade-report-grader #siteconfiglink {
@@ -262,7 +262,7 @@ border-width:0 1px 1px;
}
.path-grade-report-grader table td.topleft {
-border-bottom:none;
+border-bottom:0;
}
table#user-grades td.topleft {
@@ -325,12 +325,12 @@ margin: 10px 10px 0px 10px;
}
.path-grade-report-grader table#quick_edit td.fullname {
-border-left:none;
+border-left:0;
padding-left:5px;
}
.path-grade-report-grader table#quick_edit td.picture {
-border-right:none;
+border-right:0;
}
.path-grade-report-grader table#quick_edit td.finalgrade input {
View
5 group/externallib.php
@@ -53,7 +53,7 @@ public static function create_groups_parameters() {
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
'description' => new external_value(PARAM_RAW, 'group description text'),
'descriptionformat' => new external_format_value('description', VALUE_DEFAULT),
- 'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
+ 'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase', VALUE_OPTIONAL),
)
), 'List of group object. A group has a courseid, a name, a description and an enrolment key.'
)
@@ -105,6 +105,9 @@ public static function create_groups($groups) {
// finally create the group
$group->id = groups_create_group($group, false);
+ if (!isset($group->enrolmentkey)) {
+ $group->enrolmentkey = '';
+ }
$groups[] = (array)$group;
}
View
8 install.php
@@ -410,21 +410,21 @@
$disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
- echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="30" class="forminput" />';
+ echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" class="forminput" />';
echo '</div>';