Compare commits
144 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f2867a8672 | |||
| 62e9e694b7 | |||
| b24e6ed930 | |||
| 50b1caaf86 | |||
| 2ddf3ffcd2 | |||
| b73a7519c4 | |||
| 2425229c88 | |||
| 353580b0e3 | |||
| 4539b33788 | |||
| 9b47ec7bb3 | |||
| b9c20952a3 | |||
| e819ff4263 | |||
| b20b1c32bf | |||
| 1e9130ae6e | |||
| c57fa60f3d | |||
| 617d260dd7 | |||
| b86a48c5b9 | |||
| a2c2ab3e1a | |||
| bbe378a63e | |||
| 9d5ced06c1 | |||
| 6019d2b2f3 | |||
| ccef7fe8d0 | |||
| f2b7928df7 | |||
| 9f6f18d2c2 | |||
| 848fc30a2d | |||
| 8530aac4a8 | |||
| 3bcca35591 | |||
| e3f4094ac8 | |||
| 7df86db31d | |||
| b41f914927 | |||
| a5f68fb2c2 | |||
| 28f23328c5 | |||
| 3e1648723f | |||
| 60a72a03b2 | |||
| 741543e9a7 | |||
| a1a00aeee7 | |||
| 9152878ed3 | |||
| 81b2147092 | |||
| e570ee4b63 | |||
| 0afd953daf | |||
| f224fd9498 | |||
| 69b2bab32e | |||
| f95e28e0ff | |||
| f5cd2c6ef1 | |||
| 10ff22d6f6 | |||
| d0d407f0bb | |||
| 8ad459ed58 | |||
| cf5b51af0e | |||
| 18c264790a | |||
| 7523da44fc | |||
| bd9ecafba9 | |||
| 5200c254a1 | |||
| 3d43075cfd | |||
| 5df543a60e | |||
| bed1c4a943 | |||
| 66ff4c0a06 | |||
| 9ea8065f1c | |||
| eadad29dc9 | |||
| e068b3dbe3 | |||
| 5809f6912b | |||
| 815aecf6c7 | |||
| 15d8babd1a | |||
| a78e4e9147 | |||
| d9edd25111 | |||
| 1a76bbe2e4 | |||
| af63cc85df | |||
| dff8438e50 | |||
| ec3fe6e123 | |||
| 770cee9696 | |||
| 1db89f5e6a | |||
| 5c1b768aec | |||
| f2b4305c8e | |||
| 502ecc4c9f | |||
| 34c10b84fb | |||
| f09dcd4b6d | |||
| 2b1b2017a6 | |||
| 592443f4e1 | |||
| dabab94b6e | |||
| 039089f3aa | |||
| 9cb942820c | |||
| 0ba1ee1dd2 | |||
| 7debccbdee | |||
| 9a211c853d | |||
| ed8cab855e | |||
| 6253f69246 | |||
| 49ac5deff6 | |||
| 6737eda426 | |||
| c7132d7c93 | |||
| d9b9bfd288 | |||
| ec70cf6ef1 | |||
| a6b0b36cdc | |||
| 3e839bd513 | |||
| 8633142f53 | |||
| 564b878840 | |||
| c3f59e043c | |||
| 4b0e6f38fa | |||
| fb978df0f0 | |||
| 45353da409 | |||
| 08641906e1 | |||
| 6b5ce20c16 | |||
| 800fb7533e | |||
| 789c8b8194 | |||
| e9aa190a37 | |||
| 786ad3511c | |||
| abfc9e2512 | |||
| e5c2bbd0f7 | |||
| 1494f20da3 | |||
| 4fa4a727b4 | |||
| 4be710795a | |||
| 9ea40f27a0 | |||
| 19ba134d3b | |||
| d0812ba0e6 | |||
| a2b8856558 | |||
| a61e8c8ebe | |||
| 1cf431a329 | |||
| 9ee97228bd | |||
| 43fb824bd2 | |||
| 9d774c9445 | |||
| 8b3d60557c | |||
| 134affd943 | |||
| 5df5bcba99 | |||
| 93fd7cb10c | |||
| 3705a88629 | |||
| 5cb477c4a1 | |||
| 4aabce216c | |||
| b273b20a7c | |||
| f8e05deb35 | |||
| 263e8c144c | |||
| b574c078a6 | |||
| a44c303d63 | |||
| e5ff0d3278 | |||
| faca708484 | |||
| fc14c79fc9 | |||
| 2670a3a684 | |||
| d81d6ea2c3 | |||
| b0cf55f145 | |||
| 5af6c9676e | |||
| 225e058685 | |||
| 3d348a3cc7 | |||
| 896f9ae83b | |||
| 11824b0461 | |||
| 9b57d5bc38 | |||
| e0d90c54c0 | |||
| 8ac8aae4f4 |
+15
-8
@@ -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.'&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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ $PAGE->set_title("$site->fullname: $loginsite");
|
||||
$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);
|
||||
|
||||
@@ -29,7 +29,8 @@ $file = $CFG->dirroot.'/pix/spacer.gif';
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -44,17 +44,17 @@ $PAGE->https_required();
|
||||
// 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');
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
bottom:0;
|
||||
right:0;
|
||||
opacity:0.35;
|
||||
filter:alpha(opacity:35);
|
||||
filter:alpha(opacity=35);
|
||||
background:#000;
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ class block_completionstatus extends block_base {
|
||||
$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;
|
||||
|
||||
@@ -4,7 +4,7 @@ if (is_file($CFG->dirroot.'/mod/feedback/lib.php')) {
|
||||
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 @@ class block_feedback extends block_base {
|
||||
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 @@ class block_feedback extends block_base {
|
||||
$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 @@ class block_feedback extends block_base {
|
||||
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="" /> ';
|
||||
$this->content->text = ' <a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
|
||||
$this->content->items[] = '<a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
+1
-1
@@ -108,7 +108,7 @@ $repeatspan = '';
|
||||
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
|
||||
|
||||
@@ -49,7 +49,7 @@ class cohort_edit_form extends moodleform {
|
||||
$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);
|
||||
|
||||
@@ -141,16 +141,6 @@ if ($form->is_cancelled()){
|
||||
$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));
|
||||
|
||||
@@ -179,10 +179,13 @@ class course_completion_form extends moodleform {
|
||||
$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);
|
||||
|
||||
|
||||
+18
-5
@@ -904,9 +904,10 @@ class core_course_external extends external_api {
|
||||
'"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 @@ class core_course_external extends external_api {
|
||||
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;
|
||||
|
||||
+5
-5
@@ -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
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
+12
-2
@@ -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 .= '§ionid='. $infoid;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -445,8 +445,9 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
$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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -291,7 +291,7 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
if ($rusers) {
|
||||
$contact = reset($rusers);
|
||||
} else {
|
||||
$contact = get_admin();
|
||||
$contact = generate_email_supportuser();
|
||||
}
|
||||
|
||||
//directly emailing welcome message rather than using messaging
|
||||
|
||||
+10
-14
@@ -219,7 +219,7 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
<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 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
$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 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
*/
|
||||
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 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
<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 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
$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> '.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> '.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> '.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 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
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>';
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
+1
-1
@@ -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']});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -411,6 +411,9 @@ class grade_report_grader extends grade_report {
|
||||
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";
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -53,7 +53,7 @@ class core_group_external extends external_api {
|
||||
'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 @@ class core_group_external extends external_api {
|
||||
|
||||
// finally create the group
|
||||
$group->id = groups_create_group($group, false);
|
||||
if (!isset($group->enrolmentkey)) {
|
||||
$group->enrolmentkey = '';
|
||||
}
|
||||
$groups[] = (array)$group;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -410,21 +410,21 @@ if ($config->stage == INSTALL_DATABASE) {
|
||||
|
||||
$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>';
|
||||
|
||||
echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
|
||||
echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="30" class="forminput" />';
|
||||
echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="50" class="forminput" />';
|
||||
echo '</div>';
|
||||
|
||||
$disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
|
||||
echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
|
||||
echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="30" class="forminput" />';
|
||||
echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="50" class="forminput" />';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
|
||||
// no password field here, the password may be visible in config.php if we can not write it to disk
|
||||
echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="30" class="forminput" />';
|
||||
echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="50" class="forminput" />';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ h2 {
|
||||
.formrow label.formlabel {
|
||||
display:block;
|
||||
float:left;
|
||||
width: 260px;
|
||||
width: 160px;
|
||||
margin-right:5px;
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['cannotsavemd5file'] = 'No s\'ha pogut alçar el fitxer md5';
|
||||
$string['cannotsavezipfile'] = 'No s\'ha pogut alçar el fitxer zip';
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['langdownloaderror'] = 'Dissortadament l\'idioma "{$a}" no està instal·lat. La instal·lació prosseguirà en anglés.';
|
||||
$string['memorylimithelp'] = '<p>El límit de memòria del PHP del vostre servidor actualment està definit en {$a}.</p>
|
||||
|
||||
<p>Això pot causar que Moodle tinga problemes de memòria més avant, especialment si teniu molts mòduls habilitats i/o molts usuaris.</p>
|
||||
|
||||
<p>És recomanable que configureu el PHP amb un límit superior, com ara 40 MB, sempre que siga possible. Hi ha diverses maneres de fer això:</p>
|
||||
<ol>
|
||||
<li>Si podeu, recompileu el PHP amb <i>--enable-memory-limit</i>. Això permetrà que Moodle definisca el límit de memòria per si mateix.</li>
|
||||
<li>Si teniu accés al fitxer php.ini, podeu canviar el paràmetre <b>memory_limit</b> a 40 MB. Si no hi teniu accés podeu demanar al vostre administrador que ho faça ell.</li>
|
||||
<li>En alguns servidors PHP podeu crear un fitxer .htaccess dins del directori de Moodle amb esta línia:
|
||||
<p><blockquote>php_value memory_limit 40M</blockquote></p>
|
||||
<p>Tanmateix, en alguns servidors això farà que no funcioni <b>cap</b> pàgina PHP (es visualitzaran errors) en el qual cas hauríeu de suprimir el fitxer .htaccess.</p></li>
|
||||
</ol>';
|
||||
$string['pathssubdataroot'] = 'Necessiteu un espai on Moodle puga alçar els fitxers penjats. Este directori hauria de tindre permisos de lectura I ESCRIPTURA per a l\'usuari del servidor web (normalment \'nobody\' o \'apache\'), però no cal que siga accessible directament via web. L\'instal·lador provarà de crear-lo si no existeix.';
|
||||
$string['phpversionhelp'] = '<p>Moodle necessita la versió de PHP 4.1.0 o posterior.</p>
|
||||
<p>A hores d\'ara esteu utilitzant la versió {$a}.</p>
|
||||
<p>Vos caldrà actualitzar el PHP o traslladar Moodle a un ordinador amb una versió de PHP més recent.</p>';
|
||||
$string['welcomep20'] = 'Esteu veient esta pàgina perquè heu instal·lat amb èxit i heu executat el paquet <strong>{$a->packname} {$a->packversion}</strong>. Felicitacions!';
|
||||
$string['welcomep30'] = 'Esta versió de <strong>{$a->installername}</strong> inclou les aplicacions necessàries per crear un entorn en el qual funcioni <strong>Moodle</strong>:';
|
||||
$string['welcomep50'] = 'L\'ús de totes les aplicacions d\'este paquet és governat per les seues llicències respectives. El paquet <strong>{$a->installername}</strong> complet és
|
||||
<a href="http://www.opensource.org/docs/definition_plain.html">codi font obert</a> i es distribueix
|
||||
sota llicència <a href="http://www.gnu.org/copyleft/gpl.html">GPL</a>.';
|
||||
$string['welcomep60'] = 'Les pàgines següents vos guiaran per una sèrie de passos fàcils de seguir per configurar <strong>Moodle</strong> en el vostre ordinador. Podeu acceptar els paràmetres per defecte o, opcionalment, modificar-los perquè s\'ajusten a les vostres necessitats.';
|
||||
@@ -35,7 +35,7 @@ $string['availablelangs'] = 'Lista de línguas disponíveis';
|
||||
$string['chooselanguagehead'] = 'Escolha uma língua';
|
||||
$string['chooselanguagesub'] = 'Escolha por favor a língua a usar na instalação. Esta língua será usada por omissão no site, mas pode ser alterada posteriormente.';
|
||||
$string['clialreadyconfigured'] = 'O ficheiro config.php já existe; por favor execute admin/cli/install_database.php se quiser instalar este sítio.';
|
||||
$string['clialreadyinstalled'] = 'O ficheiro config.php já existe. Por favor, use o script admin/cli/upgrade.php se quiser atualizar o seu site.';
|
||||
$string['clialreadyinstalled'] = 'O ficheiro config.php já existe. Por favor, use o script admin/cli/upgrade.php se quiser atualizar o seu sítio.';
|
||||
$string['cliinstallheader'] = 'Programa de instalação do Moodle {$a} por linha de comandos';
|
||||
$string['databasehost'] = 'Servidor da base de dados';
|
||||
$string['databasename'] = 'Nome da base de dados';
|
||||
|
||||
@@ -34,7 +34,7 @@ $string['admindirname'] = 'Каталог администратора';
|
||||
$string['availablelangs'] = 'Доступные языковые пакеты';
|
||||
$string['chooselanguagehead'] = 'Выберите язык';
|
||||
$string['chooselanguagesub'] = 'Сейчас необходимо выбрать язык ТОЛЬКО для сообщений во время установки. Язык сайта и пользовательских интерфейсов можно будет указать далее в процессе установки.';
|
||||
$string['clialreadyinstalled'] = 'Файл config.php уже существует. Если вы хотите обновить сайт, пожалуйста, используйте скрипт admin/cli/upgrade.php.';
|
||||
$string['clialreadyinstalled'] = 'Файл config.php уже существует. Если Вы хотите обновить сайт, то используйте скрипт admin/cli/upgrade.php.';
|
||||
$string['cliinstallheader'] = 'Программа установки Moodle {$a} в режиме командной строки';
|
||||
$string['databasehost'] = 'Сервер баз данных';
|
||||
$string['databasename'] = 'Название базы данных';
|
||||
|
||||
@@ -37,7 +37,7 @@ $string['chooselanguagesub'] = 'Молимо изаберите језик ко
|
||||
$string['clialreadyconfigured'] = 'Датотека config.php већ постоји. Молимо, користите admin/cli/install_database.php ако желите да инсталирате овај сајт.';
|
||||
$string['clialreadyinstalled'] = 'Датотека config.php већ постоји. Употребите команду admin/cli/upgrade.php ако желите да надоградите свај сајт.';
|
||||
$string['cliinstallheader'] = 'Moodle {$a} програм за инсталацију из командне линије';
|
||||
$string['databasehost'] = 'Сервер базе података :';
|
||||
$string['databasehost'] = 'Сервер базе података';
|
||||
$string['databasename'] = 'Име базе података';
|
||||
$string['databasetypehead'] = 'Изаберите драјвер базе података';
|
||||
$string['dataroot'] = 'Директоријум података';
|
||||
|
||||
@@ -37,7 +37,7 @@ $string['chooselanguagesub'] = 'Molimo izaberite jezik koji će se koristiti tok
|
||||
$string['clialreadyconfigured'] = 'Datoteka config.php već postoji. Molimo, koristite admin/cli/install_database.php ako želite da instalirate ovaj sajt.';
|
||||
$string['clialreadyinstalled'] = 'Datoteka config.php već postoji. Upotrebite komandu admin/cli/upgrade.php ako želite da nadogradite svaj sajt.';
|
||||
$string['cliinstallheader'] = 'Moodle {$a} program za instalaciju iz komandne linije';
|
||||
$string['databasehost'] = 'Server baze podataka :';
|
||||
$string['databasehost'] = 'Server baze podataka';
|
||||
$string['databasename'] = 'Ime baze podataka';
|
||||
$string['databasetypehead'] = 'Izaberite drajver baze podataka';
|
||||
$string['dataroot'] = 'Direktorijum podataka';
|
||||
|
||||
@@ -30,5 +30,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['parentlanguage'] = '';
|
||||
$string['thisdirection'] = 'ltr';
|
||||
$string['thislanguage'] = '简体中文';
|
||||
|
||||
+2
-2
@@ -189,7 +189,7 @@ $string['configdoctonewwindow'] = 'If you enable this, then links to Moodle Docs
|
||||
$string['configeditordictionary'] = 'This value will be used if aspell doesn\'t have dictionary for users own language.';
|
||||
$string['configeditorfontlist'] = 'Select the fonts that should appear in the editor\'s drop-down list.';
|
||||
$string['configemailchangeconfirmation'] = 'Require an email confirmation step when users change their email address in their profile.';
|
||||
$string['configenableajax'] = 'This setting allows you to control the use of AJAX (advanced client/server interfaces using Javascript) across the whole site. With this setting enabled users can still make a choice in their profile, otherwise AJAX is disabled for everybody.';
|
||||
$string['configenableajax'] = 'This setting controls the use of AJAX across the site. AJAX is required for certain functionality such as drag and drop.';
|
||||
$string['configenablecalendarexport'] = 'Enable exporting or subscribing to calendars.';
|
||||
$string['configenablecomments'] = 'Enable comments';
|
||||
$string['configenablecourserequests'] = 'This will allow any user to request a course be created.';
|
||||
@@ -468,7 +468,7 @@ $string['enablecalendarexport'] = 'Enable calendar export';
|
||||
$string['enablecomments'] = 'Enable comments';
|
||||
$string['enablecourserequests'] = 'Enable course requests';
|
||||
$string['enablecssoptimiser'] = 'Enable CSS optimiser';
|
||||
$string['enablecssoptimiser_desc'] = 'When enabled CSS will be run through an optimisation process before being cached. The optimiser processes the CSS removing duplicate rules and styles, as well as white space removeable and reformatting. Please note turning this on at the same time as theme designer mode is aweful for performance but will help theme designers create optimised CSS.';
|
||||
$string['enablecssoptimiser_desc'] = 'When enabled CSS will be run through an optimisation process before being cached. The optimiser processes the CSS removing duplicate rules and styles, as well as white space removable and reformatting. Please note turning this on at the same time as theme designer mode is awful for performance but will help theme designers create optimised CSS.';
|
||||
$string['enabledevicedetection'] = 'Enable device detection';
|
||||
$string['enablegravatar'] = 'Enable Gravatar';
|
||||
$string['enablegravatar_help'] = 'When enabled Moodle will attempt to fetch a user profile picture from Gravatar if the user has not uploaded an image.';
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ $string['auth_changepasswordhelp_expl'] = 'Display lost password help to users w
|
||||
$string['auth_changepasswordurl'] = 'Change password URL';
|
||||
$string['auth_changepasswordurl_expl'] = 'Specify the url to send users who have lost their {$a} password. Set <strong>Use standard Change Password page</strong> to <strong>No</strong>.';
|
||||
$string['auth_changingemailaddress'] = 'You have requested a change of email address, from {$a->oldemail} to {$a->newemail}. For security reasons, we are sending you an email message at the new address to confirm that it belongs to you. Your email address will be updated as soon as you open the URL sent to you in that message.';
|
||||
$string['authinstructions'] = 'Here you can provide instructions for your users, so they know which username and password they should be using. The text you enter here will appear on the login page. If you leave this blank then no instructions will be printed.';
|
||||
$string['authinstructions'] = 'Leave this blank for the default login instructions to be displayed on the login page. If you want to provide custom login instructions, enter them here.';
|
||||
$string['auth_invalidnewemailkey'] = 'Error: if you are trying to confirm a change of email address, you may have made a mistake in copying the URL we sent you by email. Please copy the address and try again.';
|
||||
$string['auth_multiplehosts'] = 'Multiple hosts OR addresses can be specified (eg host1.com;host2.com;host3.com) or (eg xxx.xxx.xxx.xxx;xxx.xxx.xxx.xxx)';
|
||||
$string['auth_outofnewemailupdateattempts'] = 'You have run out of allowed attempts to update your email address. Your update request has been cancelled.';
|
||||
|
||||
@@ -110,6 +110,7 @@ $string['courseprerequisites']='Course prerequisites';
|
||||
$string['coursesavailable']='Courses available';
|
||||
$string['coursesavailableexplaination']='<i>Course completion criteria must be set for a course to appear in this list</i>';
|
||||
$string['criteria']='Criteria';
|
||||
$string['criteriagradenote'] = 'Please note that updating the required grade here will not update the current course pass grade.';
|
||||
$string['criteriagroup']='Criteria group';
|
||||
$string['criteriarequiredall']='All criteria below are required';
|
||||
$string['criteriarequiredany']='Any criteria below are required';
|
||||
@@ -124,6 +125,8 @@ $string['datepassed']='Date passed';
|
||||
$string['daysafterenrolment']='Days after enrolment';
|
||||
$string['durationafterenrolment']='Duration after enrolment';
|
||||
$string['fraction']='Fraction';
|
||||
$string['gradexrequired']='{$a} required';
|
||||
$string['graderequired']='Grade required';
|
||||
$string['inprogress']='In progress';
|
||||
$string['manualcompletionby']='Manual completion by';
|
||||
$string['manualselfcompletion']='Manual self completion';
|
||||
@@ -136,7 +139,6 @@ $string['nocriteriaset']='No completion criteria set for this course';
|
||||
$string['notenroled']='You are not enrolled in this course';
|
||||
$string['notyetstarted']='Not yet started';
|
||||
$string['overallcriteriaaggregation']='Overall criteria type aggregation';
|
||||
$string['passinggrade']='Passing grade';
|
||||
$string['pending']='Pending';
|
||||
$string['periodpostenrolment']='Period post enrolment';
|
||||
$string['prerequisites']='Prerequisites';
|
||||
|
||||
+2
-2
@@ -838,7 +838,7 @@ $string['home'] = 'Home';
|
||||
$string['hour'] = 'hour';
|
||||
$string['hours'] = 'hours';
|
||||
$string['howtomakethemes'] = 'How to make new themes';
|
||||
$string['htmleditor'] = 'Use HTML editor (some browsers only)';
|
||||
$string['htmleditor'] = 'Use HTML editor';
|
||||
$string['htmleditoravailable'] = 'The HTML editor is available';
|
||||
$string['htmleditordisabled'] = 'You have disabled the HTML editor in your user profile';
|
||||
$string['htmleditordisabledadmin'] = 'The administrator has disabled the HTML editor on this site';
|
||||
@@ -1710,7 +1710,7 @@ $string['uploadcantwrite'] = 'Failed to write file to disk';
|
||||
$string['uploadedfile'] = 'File uploaded successfully';
|
||||
$string['uploadedfileto'] = 'Uploaded {$a->file} to {$a->directory}';
|
||||
$string['uploadedfiletoobig'] = 'Sorry, but that file is too big (limit is {$a} bytes)';
|
||||
$string['uploadextension'] = 'File upload stopped by extension';
|
||||
$string['uploadextension'] = 'File upload stopped by a PHP extension';
|
||||
$string['uploadfailednotrecovering'] = 'Your file upload has failed because there was a problem with one of the files, {$a->name}.<br /> Here is a log of the problems:<br />{$a->problem}<br />Not recovering.';
|
||||
$string['uploadfilelog'] = 'Upload log for file {$a}';
|
||||
$string['uploadformlimit'] = 'Uploaded file {$a} exceeded the maximum size limit set by the form';
|
||||
|
||||
@@ -1961,6 +1961,9 @@ function is_enrolled(context $context, $user = null, $withcapability = '', $only
|
||||
$coursecontext->reload_if_dirty();
|
||||
if (isset($USER->enrol['enrolled'][$coursecontext->instanceid])) {
|
||||
if ($USER->enrol['enrolled'][$coursecontext->instanceid] > time()) {
|
||||
if ($withcapability and !has_capability($withcapability, $context, $userid)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -452,7 +452,7 @@ function get_used_table_names() {
|
||||
|
||||
if ($loaded and $tables = $structure->getTables()) {
|
||||
foreach($tables as $table) {
|
||||
$table_names[] = strtolower($table->name);
|
||||
$table_names[] = strtolower($table->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,6 @@
|
||||
function user_preference_allow_ajax_update($name, $paramtype) {
|
||||
global $USER, $PAGE;
|
||||
|
||||
// Make sure that the required JavaScript libraries are loaded.
|
||||
$PAGE->requires->yui2_lib('connection');
|
||||
|
||||
// Record in the session that this user_preference is allowed to updated remotely.
|
||||
$USER->ajax_updatable_user_prefs[$name] = $paramtype;
|
||||
}
|
||||
|
||||
@@ -62,8 +62,9 @@ class completion_criteria_grade extends completion_criteria {
|
||||
*/
|
||||
public function config_form_display(&$mform, $data = null) {
|
||||
$mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
|
||||
$mform->addElement('text', 'criteria_grade_value', get_string('passinggrade', 'completion'));
|
||||
$mform->addElement('text', 'criteria_grade_value', get_string('graderequired', 'completion'));
|
||||
$mform->setDefault('criteria_grade_value', $data);
|
||||
$mform->addElement('static', 'criteria_grade_value_note', '', get_string('criteriagradenote', 'completion'));
|
||||
|
||||
if ($this->id) {
|
||||
$mform->setDefault('criteria_grade', 1);
|
||||
@@ -128,7 +129,7 @@ class completion_criteria_grade extends completion_criteria {
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
return get_string('grade');
|
||||
return get_string('coursegrade', 'completion');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +138,8 @@ class completion_criteria_grade extends completion_criteria {
|
||||
* @return string
|
||||
*/
|
||||
public function get_title_detailed() {
|
||||
return (float) $this->gradepass . '% required';
|
||||
$graderequired = round($this->gradepass, 2).'%';
|
||||
return get_string('gradexrequired', 'completion', $graderequired);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,15 +158,16 @@ class completion_criteria_grade extends completion_criteria {
|
||||
* @return string
|
||||
*/
|
||||
public function get_status($completion) {
|
||||
// Cast as floats to get rid of excess decimal places
|
||||
$grade = (float) $this->get_grade($completion);
|
||||
$gradepass = (float) $this->gradepass;
|
||||
$grade = $this->get_grade($completion);
|
||||
$graderequired = $this->get_title_detailed();
|
||||
|
||||
if ($grade) {
|
||||
return $grade.'% ('.$gradepass.'% to pass)';
|
||||
$grade = round($grade, 2).'%';
|
||||
} else {
|
||||
return $gradepass.'% to pass';
|
||||
$grade = get_string('nograde');
|
||||
}
|
||||
|
||||
return $grade.' ('.$graderequired.')';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,11 +234,11 @@ class completion_criteria_grade extends completion_criteria {
|
||||
public function get_details($completion) {
|
||||
$details = array();
|
||||
$details['type'] = get_string('coursegrade', 'completion');
|
||||
$details['criteria'] = get_string('passinggrade', 'completion');
|
||||
$details['requirement'] = ((float)$this->gradepass).'%';
|
||||
$details['criteria'] = get_string('graderequired', 'completion');
|
||||
$details['requirement'] = round($this->gradepass, 2).'%';
|
||||
$details['status'] = '';
|
||||
|
||||
$grade = (float)$this->get_grade($completion);
|
||||
$grade = round($this->get_grade($completion), 2);
|
||||
if ($grade) {
|
||||
$details['status'] = $grade.'%';
|
||||
}
|
||||
|
||||
+3
-3
@@ -208,11 +208,11 @@ function cron_run() {
|
||||
if ($DB->count_records('user_preferences', array('name'=>'create_password', 'value'=>'1'))) {
|
||||
mtrace('Creating passwords for new users...');
|
||||
$newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.firstname,
|
||||
u.lastname, u.username,
|
||||
u.lastname, u.username, u.lang,
|
||||
p.id as prefid
|
||||
FROM {user} u
|
||||
JOIN {user_preferences} p ON u.id=p.userid
|
||||
WHERE p.name='create_password' AND p.value='1' AND u.email !='' AND u.suspended = 0 AND u.auth != 'nologin'");
|
||||
WHERE p.name='create_password' AND p.value='1' AND u.email !='' AND u.suspended = 0 AND u.auth != 'nologin' AND u.deleted = 0");
|
||||
|
||||
// note: we can not send emails to suspended accounts
|
||||
foreach ($newusers as $newuser) {
|
||||
@@ -709,7 +709,7 @@ function notify_login_failures() {
|
||||
mtrace('Emailing admins about '. $count .' failed login attempts');
|
||||
foreach ($recip as $admin) {
|
||||
//emailing the admins directly rather than putting these through the messaging system
|
||||
email_to_user($admin,get_admin(), $subject, $body);
|
||||
email_to_user($admin, generate_email_supportuser(), $subject, $body);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ function css_send_cached_css($csspath, $etag) {
|
||||
*
|
||||
* This function takes a raw CSS string, optimises it if required, and then
|
||||
* serves it.
|
||||
* Turning both themedesignermode and CSS optimiser on at the same time is aweful
|
||||
* Turning both themedesignermode and CSS optimiser on at the same time is awful
|
||||
* for performance because of the optimiser running here. However it was done so
|
||||
* that theme designers could utilise the optimised output during development to
|
||||
* help them optimise their CSS... not that they should write lazy CSS.
|
||||
|
||||
+2
-30
@@ -2410,7 +2410,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="repository_instance_config" COMMENT="The config for intances" PREVIOUS="repository_instances" NEXT="backup_files">
|
||||
<TABLE NAME="repository_instance_config" COMMENT="The config for intances" PREVIOUS="repository_instances" NEXT="backup_courses">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="instanceid"/>
|
||||
<FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="name"/>
|
||||
@@ -2421,35 +2421,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="backup_files" COMMENT="To store and recode ids to user and course files" PREVIOUS="repository_instance_config" NEXT="backup_ids">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="backup_code"/>
|
||||
<FIELD NAME="backup_code" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="file_type"/>
|
||||
<FIELD NAME="file_type" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="backup_code" NEXT="path"/>
|
||||
<FIELD NAME="path" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="file_type" NEXT="old_id"/>
|
||||
<FIELD NAME="old_id" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="path" NEXT="new_id"/>
|
||||
<FIELD NAME="new_id" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="old_id"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="backup_code-file_type-path"/>
|
||||
<KEY NAME="backup_code-file_type-path" TYPE="unique" FIELDS="backup_code, file_type, path" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="backup_ids" COMMENT="To store and convert ids in backup/restore" PREVIOUS="backup_files" NEXT="backup_courses">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="backup_code"/>
|
||||
<FIELD NAME="backup_code" TYPE="int" LENGTH="12" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="table_name"/>
|
||||
<FIELD NAME="table_name" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" PREVIOUS="backup_code" NEXT="old_id"/>
|
||||
<FIELD NAME="old_id" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="table_name" NEXT="new_id"/>
|
||||
<FIELD NAME="new_id" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="old_id" NEXT="info"/>
|
||||
<FIELD NAME="info" TYPE="text" NOTNULL="true" SEQUENCE="false" PREVIOUS="new_id"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="backup_code-table_name-old_id"/>
|
||||
<KEY NAME="backup_code-table_name-old_id" TYPE="unique" FIELDS="backup_code, table_name, old_id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="backup_courses" COMMENT="To store every course backup status" PREVIOUS="backup_ids" NEXT="block">
|
||||
<TABLE NAME="backup_courses" COMMENT="To store every course backup status" PREVIOUS="repository_instance_config" NEXT="block">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="courseid"/>
|
||||
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="laststarttime"/>
|
||||
|
||||
@@ -872,5 +872,33 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
if ($oldversion < 2012062500.02) {
|
||||
// Drop some old backup tables, not used anymore
|
||||
|
||||
// Define table backup_files to be dropped
|
||||
$table = new xmldb_table('backup_files');
|
||||
|
||||
// Conditionally launch drop table for backup_files
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
// Define table backup_ids to be dropped
|
||||
$table = new xmldb_table('backup_ids');
|
||||
|
||||
// Conditionally launch drop table for backup_ids
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2012062500.02);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
}
|
||||
$this->tables = array();
|
||||
$sql = "SELECT table_name
|
||||
FROM information_schema.tables
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name LIKE '$this->prefix%'
|
||||
AND table_type = 'BASE TABLE'";
|
||||
$this->query_start($sql, null, SQL_QUERY_AUX);
|
||||
@@ -426,7 +426,7 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
columnproperty(object_id(quotename(table_schema) + '.' +
|
||||
quotename(table_name)), column_name, 'IsIdentity') AS auto_increment,
|
||||
column_default AS default_value
|
||||
FROM information_schema.columns
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = '{" . $table . "}'
|
||||
ORDER BY ordinal_position";
|
||||
} else { // temp table, get metadata from tempdb schema
|
||||
@@ -439,7 +439,7 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
columnproperty(object_id(quotename(table_schema) + '.' +
|
||||
quotename(table_name)), column_name, 'IsIdentity') AS auto_increment,
|
||||
column_default AS default_value
|
||||
FROM tempdb.information_schema.columns
|
||||
FROM tempdb.INFORMATION_SCHEMA.COLUMNS
|
||||
JOIN tempdb..sysobjects ON name = table_name
|
||||
WHERE id = object_id('tempdb..{" . $table . "}')
|
||||
ORDER BY ordinal_position";
|
||||
|
||||
@@ -292,12 +292,21 @@ class pgsql_native_moodle_database extends moodle_database {
|
||||
}
|
||||
$this->tables = array();
|
||||
$prefix = str_replace('_', '|_', $this->prefix);
|
||||
// Get them from information_schema instead of catalog as far as
|
||||
// we want to get only own session temp objects (catalog returns all)
|
||||
$sql = "SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_name LIKE '$prefix%' ESCAPE '|'
|
||||
AND table_type IN ('BASE TABLE', 'LOCAL TEMPORARY')";
|
||||
if ($this->is_min_version('9.1')) {
|
||||
// Use ANSI standard information_schema in recent versions where it is fast enough.
|
||||
$sql = "SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_name LIKE '$prefix%' ESCAPE '|'
|
||||
AND table_type IN ('BASE TABLE', 'LOCAL TEMPORARY')";
|
||||
} else {
|
||||
// information_schema is horribly slow in <= 9.0, so use pg internals.
|
||||
// Note the pg_is_other_temp_schema. We only want temp objects from our own session.
|
||||
$sql = "SELECT c.relname
|
||||
FROM pg_class c
|
||||
WHERE c.relname LIKE '$prefix%' ESCAPE '|'
|
||||
AND c.relkind = 'r'
|
||||
AND NOT pg_is_other_temp_schema(c.relnamespace)";
|
||||
}
|
||||
$this->query_start($sql, null, SQL_QUERY_AUX);
|
||||
$result = pg_query($this->pgsql, $sql);
|
||||
$this->query_end($result);
|
||||
|
||||
+120
-14
@@ -308,6 +308,7 @@ class dml_testcase extends database_driver_testcase {
|
||||
|
||||
function test_fix_sql_params() {
|
||||
$DB = $this->tdb;
|
||||
$prefix = $DB->get_prefix();
|
||||
|
||||
$table = $this->get_test_table();
|
||||
$tablename = $table->getName();
|
||||
@@ -315,13 +316,13 @@ class dml_testcase extends database_driver_testcase {
|
||||
// Correct table placeholder substitution
|
||||
$sql = "SELECT * FROM {{$tablename}}";
|
||||
$sqlarray = $DB->fix_sql_params($sql);
|
||||
$this->assertEquals("SELECT * FROM {$DB->get_prefix()}".$tablename, $sqlarray[0]);
|
||||
$this->assertEquals("SELECT * FROM {$prefix}".$tablename, $sqlarray[0]);
|
||||
|
||||
// Conversions of all param types
|
||||
$sql = array();
|
||||
$sql[SQL_PARAMS_NAMED] = "SELECT * FROM {$DB->get_prefix()}testtable WHERE name = :param1, course = :param2";
|
||||
$sql[SQL_PARAMS_QM] = "SELECT * FROM {$DB->get_prefix()}testtable WHERE name = ?, course = ?";
|
||||
$sql[SQL_PARAMS_DOLLAR] = "SELECT * FROM {$DB->get_prefix()}testtable WHERE name = \$1, course = \$2";
|
||||
$sql[SQL_PARAMS_NAMED] = "SELECT * FROM {$prefix}testtable WHERE name = :param1, course = :param2";
|
||||
$sql[SQL_PARAMS_QM] = "SELECT * FROM {$prefix}testtable WHERE name = ?, course = ?";
|
||||
$sql[SQL_PARAMS_DOLLAR] = "SELECT * FROM {$prefix}testtable WHERE name = \$1, course = \$2";
|
||||
|
||||
$params = array();
|
||||
$params[SQL_PARAMS_NAMED] = array('param1'=>'first record', 'param2'=>1);
|
||||
@@ -921,12 +922,12 @@ class dml_testcase extends database_driver_testcase {
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table);
|
||||
|
||||
$data = array(array('id' => 1, 'course' => 3, 'name' => 'record1', 'onetext'=>'abc'),
|
||||
array('id' => 2, 'course' => 3, 'name' => 'record2', 'onetext'=>'abcd'),
|
||||
array('id' => 3, 'course' => 5, 'name' => 'record3', 'onetext'=>'abcde'));
|
||||
$data = array(array('course' => 3, 'name' => 'record1', 'onetext'=>'abc'),
|
||||
array('course' => 3, 'name' => 'record2', 'onetext'=>'abcd'),
|
||||
array('course' => 5, 'name' => 'record3', 'onetext'=>'abcde'));
|
||||
|
||||
foreach ($data as $record) {
|
||||
$DB->insert_record($tablename, $record);
|
||||
foreach ($data as $key=>$record) {
|
||||
$data[$key]['id'] = $DB->insert_record($tablename, $record);
|
||||
}
|
||||
|
||||
// standard recordset iteration
|
||||
@@ -990,11 +991,79 @@ class dml_testcase extends database_driver_testcase {
|
||||
$this->assertEquals($e->errorcode, 'textconditionsnotallowed');
|
||||
}
|
||||
|
||||
// Test nested iteration.
|
||||
$rs1 = $DB->get_recordset($tablename);
|
||||
$i = 0;
|
||||
foreach($rs1 as $record1) {
|
||||
$rs2 = $DB->get_recordset($tablename);
|
||||
$i++;
|
||||
$j = 0;
|
||||
foreach($rs2 as $record2) {
|
||||
$j++;
|
||||
}
|
||||
$rs2->close();
|
||||
$this->assertEquals($j, count($data));
|
||||
}
|
||||
$rs1->close();
|
||||
$this->assertEquals($i, count($data));
|
||||
|
||||
// notes:
|
||||
// * limits are tested in test_get_recordset_sql()
|
||||
// * where_clause() is used internally and is tested in test_get_records()
|
||||
}
|
||||
|
||||
public function test_get_recordset_static() {
|
||||
$DB = $this->tdb;
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
$table = $this->get_test_table();
|
||||
$tablename = $table->getName();
|
||||
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table);
|
||||
|
||||
$DB->insert_record($tablename, array('course' => 1));
|
||||
$DB->insert_record($tablename, array('course' => 2));
|
||||
$DB->insert_record($tablename, array('course' => 3));
|
||||
$DB->insert_record($tablename, array('course' => 4));
|
||||
|
||||
$rs = $DB->get_recordset($tablename, array(), 'id');
|
||||
|
||||
$DB->set_field($tablename, 'course', 666, array('course'=>1));
|
||||
$DB->delete_records($tablename, array('course'=>2));
|
||||
|
||||
$i = 0;
|
||||
foreach($rs as $record) {
|
||||
$i++;
|
||||
$this->assertEquals($i, $record->course);
|
||||
}
|
||||
$rs->close();
|
||||
$this->assertEquals(4, $i);
|
||||
|
||||
// Now repeat with limits because it may use different code.
|
||||
$DB->delete_records($tablename, array());
|
||||
|
||||
$DB->insert_record($tablename, array('course' => 1));
|
||||
$DB->insert_record($tablename, array('course' => 2));
|
||||
$DB->insert_record($tablename, array('course' => 3));
|
||||
$DB->insert_record($tablename, array('course' => 4));
|
||||
|
||||
$rs = $DB->get_recordset($tablename, array(), 'id', '*', 0, 3);
|
||||
|
||||
$DB->set_field($tablename, 'course', 666, array('course'=>1));
|
||||
$DB->delete_records($tablename, array('course'=>2));
|
||||
|
||||
$i = 0;
|
||||
foreach($rs as $record) {
|
||||
$i++;
|
||||
$this->assertEquals($i, $record->course);
|
||||
}
|
||||
$rs->close();
|
||||
$this->assertEquals(3, $i);
|
||||
}
|
||||
|
||||
public function test_get_recordset_iterator_keys() {
|
||||
$DB = $this->tdb;
|
||||
$dbman = $DB->get_manager();
|
||||
@@ -1009,11 +1078,11 @@ class dml_testcase extends database_driver_testcase {
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table);
|
||||
|
||||
$data = array(array('id'=> 1, 'course' => 3, 'name' => 'record1'),
|
||||
array('id'=> 2, 'course' => 3, 'name' => 'record2'),
|
||||
array('id'=> 3, 'course' => 5, 'name' => 'record3'));
|
||||
foreach ($data as $record) {
|
||||
$DB->insert_record($tablename, $record);
|
||||
$data = array(array('course' => 3, 'name' => 'record1'),
|
||||
array('course' => 3, 'name' => 'record2'),
|
||||
array('course' => 5, 'name' => 'record3'));
|
||||
foreach ($data as $key=>$record) {
|
||||
$data[$key]['id'] = $DB->insert_record($tablename, $record);
|
||||
}
|
||||
|
||||
// Test repeated numeric keys are returned ok
|
||||
@@ -4128,6 +4197,43 @@ class dml_testcase extends database_driver_testcase {
|
||||
$this->assertEquals(0, $DB->count_records($tablename)); // finally rolled back
|
||||
|
||||
$DB->delete_records($tablename);
|
||||
|
||||
// Test interactions of recordset and transactions - this causes problems in SQL Server.
|
||||
$table2 = $this->get_test_table('2');
|
||||
$tablename2 = $table2->getName();
|
||||
|
||||
$table2->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table2->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
$table2->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table2);
|
||||
|
||||
$DB->insert_record($tablename, array('course'=>1));
|
||||
$DB->insert_record($tablename, array('course'=>2));
|
||||
$DB->insert_record($tablename, array('course'=>3));
|
||||
|
||||
$DB->insert_record($tablename2, array('course'=>5));
|
||||
$DB->insert_record($tablename2, array('course'=>6));
|
||||
$DB->insert_record($tablename2, array('course'=>7));
|
||||
$DB->insert_record($tablename2, array('course'=>8));
|
||||
|
||||
$rs1 = $DB->get_recordset($tablename);
|
||||
$i = 0;
|
||||
foreach ($rs1 as $record1) {
|
||||
$i++;
|
||||
$rs2 = $DB->get_recordset($tablename2);
|
||||
$j = 0;
|
||||
foreach ($rs2 as $record2) {
|
||||
$t = $DB->start_delegated_transaction();
|
||||
$DB->set_field($tablename, 'course', $record1->course+1, array('id'=>$record1->id));
|
||||
$DB->set_field($tablename2, 'course', $record2->course+1, array('id'=>$record2->id));
|
||||
$t->allow_commit();
|
||||
$j++;
|
||||
}
|
||||
$rs2->close();
|
||||
$this->assertEquals(4, $j);
|
||||
}
|
||||
$rs1->close();
|
||||
$this->assertEquals(3, $i);
|
||||
}
|
||||
|
||||
function test_transactions_forbidden() {
|
||||
|
||||
+56
-10
@@ -721,9 +721,16 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
|
||||
if (!isset($options['maxfiles'])) {
|
||||
$options['maxfiles'] = -1; // unlimited
|
||||
}
|
||||
if (!isset($options['maxbytes'])) {
|
||||
if (!isset($options['maxbytes']) || $options['maxbytes'] == USER_CAN_IGNORE_FILE_SIZE_LIMITS) {
|
||||
$options['maxbytes'] = 0; // unlimited
|
||||
}
|
||||
$allowreferences = true;
|
||||
if (isset($options['return_types']) && !($options['return_types'] & FILE_REFERENCE)) {
|
||||
// we assume that if $options['return_types'] is NOT specified, we DO allow references.
|
||||
// this is not exactly right. BUT there are many places in code where filemanager options
|
||||
// are not passed to file_save_draft_area_files()
|
||||
$allowreferences = false;
|
||||
}
|
||||
|
||||
$draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id');
|
||||
$oldfiles = $fs->get_area_files($contextid, $component, $filearea, $itemid, 'id');
|
||||
@@ -755,6 +762,9 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
|
||||
}
|
||||
|
||||
if ($file->is_external_file()) {
|
||||
if (!$allowreferences) {
|
||||
continue;
|
||||
}
|
||||
$repoid = $file->get_repository_id();
|
||||
if (!empty($repoid)) {
|
||||
$file_record['repositoryid'] = $repoid;
|
||||
@@ -856,6 +866,9 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
|
||||
}
|
||||
|
||||
if ($file->is_external_file()) {
|
||||
if (!$allowreferences) {
|
||||
continue;
|
||||
}
|
||||
$repoid = $file->get_repository_id();
|
||||
if (!empty($repoid)) {
|
||||
$file_record['repositoryid'] = $repoid;
|
||||
@@ -1405,7 +1418,7 @@ function &get_mimetypes_array() {
|
||||
'hqx' => array ('type'=>'application/mac-binhex40', 'icon'=>'archive', 'groups'=>array('archive'), 'string'=>'archive'),
|
||||
'htc' => array ('type'=>'text/x-component', 'icon'=>'markup'),
|
||||
'html' => array ('type'=>'text/html', 'icon'=>'html', 'groups'=>array('web_file')),
|
||||
'xhtml'=> array ('type'=>'application/xhtml+xml', 'icon'=>'markup', 'groups'=>array('web_file')),
|
||||
'xhtml'=> array ('type'=>'application/xhtml+xml', 'icon'=>'html', 'groups'=>array('web_file')),
|
||||
'htm' => array ('type'=>'text/html', 'icon'=>'html', 'groups'=>array('web_file')),
|
||||
'ico' => array ('type'=>'image/vnd.microsoft.icon', 'icon'=>'image', 'groups'=>array('image'), 'string'=>'image'),
|
||||
'ics' => array ('type'=>'text/calendar', 'icon'=>'text'),
|
||||
@@ -2993,14 +3006,36 @@ class curl {
|
||||
* Calls {@link multi()} with specific download headers
|
||||
*
|
||||
* <code>
|
||||
* $c = new curl;
|
||||
* $c = new curl();
|
||||
* $file1 = fopen('a', 'wb');
|
||||
* $file2 = fopen('b', 'wb');
|
||||
* $c->download(array(
|
||||
* array('url'=>'http://localhost/', 'file'=>fopen('a', 'wb')),
|
||||
* array('url'=>'http://localhost/20/', 'file'=>fopen('b', 'wb'))
|
||||
* array('url'=>'http://localhost/', 'file'=>$file1),
|
||||
* array('url'=>'http://localhost/20/', 'file'=>$file2)
|
||||
* ));
|
||||
* fclose($file1);
|
||||
* fclose($file2);
|
||||
* </code>
|
||||
*
|
||||
* or
|
||||
*
|
||||
* <code>
|
||||
* $c = new curl();
|
||||
* $c->download(array(
|
||||
* array('url'=>'http://localhost/', 'filepath'=>'/tmp/file1.tmp'),
|
||||
* array('url'=>'http://localhost/20/', 'filepath'=>'/tmp/file2.tmp')
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* @param array $requests An array of files to request
|
||||
* @param array $requests An array of files to request {
|
||||
* url => url to download the file [required]
|
||||
* file => file handler, or
|
||||
* filepath => file path
|
||||
* }
|
||||
* If 'file' and 'filepath' parameters are both specified in one request, the
|
||||
* open file handle in the 'file' parameter will take precedence and 'filepath'
|
||||
* will be ignored.
|
||||
*
|
||||
* @param array $options An array of options to set
|
||||
* @return array An array of results
|
||||
*/
|
||||
@@ -3024,11 +3059,15 @@ class curl {
|
||||
$results = array();
|
||||
$main = curl_multi_init();
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$url = $requests[$i];
|
||||
foreach($url as $n=>$v){
|
||||
$options[$n] = $url[$n];
|
||||
if (!empty($requests[$i]['filepath']) and empty($requests[$i]['file'])) {
|
||||
// open file
|
||||
$requests[$i]['file'] = fopen($requests[$i]['filepath'], 'w');
|
||||
$requests[$i]['auto-handle'] = true;
|
||||
}
|
||||
$handles[$i] = curl_init($url['url']);
|
||||
foreach($requests[$i] as $n=>$v){
|
||||
$options[$n] = $v;
|
||||
}
|
||||
$handles[$i] = curl_init($requests[$i]['url']);
|
||||
$this->apply_opt($handles[$i], $options);
|
||||
curl_multi_add_handle($main, $handles[$i]);
|
||||
}
|
||||
@@ -3045,6 +3084,13 @@ class curl {
|
||||
curl_multi_remove_handle($main, $handles[$i]);
|
||||
}
|
||||
curl_multi_close($main);
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (!empty($requests[$i]['filepath']) and !empty($requests[$i]['auto-handle'])) {
|
||||
// close file handler if file is opened in this function
|
||||
fclose($requests[$i]['file']);
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
@@ -1656,6 +1656,7 @@ class file_storage {
|
||||
*
|
||||
* @param string $str
|
||||
* @param bool $cleanparams if set to true, array elements will be passed through {@link clean_param()}
|
||||
* @throws file_reference_exception if the $str does not have the expected format
|
||||
* @return array
|
||||
*/
|
||||
public static function unpack_reference($str, $cleanparams = false) {
|
||||
@@ -1681,7 +1682,13 @@ class file_storage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all aliases that link to an external file identified by the given reference
|
||||
* Returns all aliases that refer to some stored_file via the given reference
|
||||
*
|
||||
* All repositories that provide access to a stored_file are expected to use
|
||||
* {@link self::pack_reference()}. This method can't be used if the given reference
|
||||
* does not use this format or if you are looking for references to an external file
|
||||
* (for example it can't be used to search for all aliases that refer to a given
|
||||
* Dropbox or Box.net file).
|
||||
*
|
||||
* Aliases in user draft areas are excluded from the returned list.
|
||||
*
|
||||
@@ -1695,6 +1702,10 @@ class file_storage {
|
||||
throw new coding_exception('NULL is not a valid reference to an external file');
|
||||
}
|
||||
|
||||
// Give {@link self::unpack_reference()} a chance to throw exception if the
|
||||
// reference is not in a valid format.
|
||||
self::unpack_reference($reference);
|
||||
|
||||
$referencehash = sha1($reference);
|
||||
|
||||
$sql = "SELECT ".self::instance_sql_fields('f', 'r')."
|
||||
@@ -1714,7 +1725,13 @@ class file_storage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of aliases that link to an external file identified by the given reference
|
||||
* Returns the number of aliases that refer to some stored_file via the given reference
|
||||
*
|
||||
* All repositories that provide access to a stored_file are expected to use
|
||||
* {@link self::pack_reference()}. This method can't be used if the given reference
|
||||
* does not use this format or if you are looking for references to an external file
|
||||
* (for example it can't be used to count aliases that refer to a given Dropbox or
|
||||
* Box.net file).
|
||||
*
|
||||
* Aliases in user draft areas are not counted.
|
||||
*
|
||||
@@ -1728,6 +1745,10 @@ class file_storage {
|
||||
throw new coding_exception('NULL is not a valid reference to an external file');
|
||||
}
|
||||
|
||||
// Give {@link self::unpack_reference()} a chance to throw exception if the
|
||||
// reference is not in a valid format.
|
||||
self::unpack_reference($reference);
|
||||
|
||||
$referencehash = sha1($reference);
|
||||
|
||||
$sql = "SELECT COUNT(f.id)
|
||||
@@ -1737,7 +1758,7 @@ class file_storage {
|
||||
WHERE r.referencehash = ?
|
||||
AND (f.component <> ? OR f.filearea <> ?)";
|
||||
|
||||
return $DB->count_records_sql($sql, array($referencehash, 'user', 'draft'));
|
||||
return (int)$DB->count_records_sql($sql, array($referencehash, 'user', 'draft'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -400,16 +400,6 @@ class filestoragelib_testcase extends advanced_testcase {
|
||||
$this->assertFalse($doesntexist);
|
||||
}
|
||||
|
||||
public function test_get_references_by_storedfile() {
|
||||
$user = $this->setup_three_private_files();
|
||||
$fs = get_file_storage();
|
||||
|
||||
$areafiles = $fs->get_area_files($user->ctxid, 'user', 'private');
|
||||
$testfile = reset($areafiles);
|
||||
$references = $fs->get_references_by_storedfile($testfile);
|
||||
// TODO MDL-33368 Verify result!!
|
||||
}
|
||||
|
||||
public function test_get_external_files() {
|
||||
$user = $this->setup_three_private_files();
|
||||
$fs = get_file_storage();
|
||||
@@ -583,15 +573,75 @@ class filestoragelib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_search_references() {
|
||||
$user = $this->setup_three_private_files();
|
||||
$fs = get_file_storage();
|
||||
$references = $fs->search_references('testsearch');
|
||||
// TODO MDL-33368 Verify result!!
|
||||
}
|
||||
$repos = repository::get_instances(array('type'=>'user'));
|
||||
$repo = reset($repos);
|
||||
|
||||
public function test_search_references_count() {
|
||||
$fs = get_file_storage();
|
||||
$references = $fs->search_references_count('testsearch');
|
||||
// TODO MDL-33368 Verify result!!
|
||||
$alias1 = array(
|
||||
'contextid' => $user->ctxid,
|
||||
'component' => 'user',
|
||||
'filearea' => 'private',
|
||||
'itemid' => 0,
|
||||
'filepath' => '/aliases/',
|
||||
'filename' => 'alias-to-1.txt'
|
||||
);
|
||||
|
||||
$alias2 = array(
|
||||
'contextid' => $user->ctxid,
|
||||
'component' => 'user',
|
||||
'filearea' => 'private',
|
||||
'itemid' => 0,
|
||||
'filepath' => '/aliases/',
|
||||
'filename' => 'another-alias-to-1.txt'
|
||||
);
|
||||
|
||||
$reference = file_storage::pack_reference(array(
|
||||
'contextid' => $user->ctxid,
|
||||
'component' => 'user',
|
||||
'filearea' => 'private',
|
||||
'itemid' => 0,
|
||||
'filepath' => '/',
|
||||
'filename' => '1.txt'
|
||||
));
|
||||
|
||||
// There are no aliases now.
|
||||
$result = $fs->search_references($reference);
|
||||
$this->assertEquals(array(), $result);
|
||||
|
||||
$result = $fs->search_references_count($reference);
|
||||
$this->assertSame($result, 0);
|
||||
|
||||
// Create two aliases and make sure they are returned.
|
||||
$fs->create_file_from_reference($alias1, $repo->id, $reference);
|
||||
$fs->create_file_from_reference($alias2, $repo->id, $reference);
|
||||
|
||||
$result = $fs->search_references($reference);
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEquals(count($result), 2);
|
||||
foreach ($result as $alias) {
|
||||
$this->assertTrue($alias instanceof stored_file);
|
||||
}
|
||||
|
||||
$result = $fs->search_references_count($reference);
|
||||
$this->assertSame($result, 2);
|
||||
|
||||
// The method can't be used for references to files outside the filepool
|
||||
$exceptionthrown = false;
|
||||
try {
|
||||
$fs->search_references('http://dl.dropbox.com/download/1234567/naked-dougiamas.jpg');
|
||||
} catch (file_reference_exception $e) {
|
||||
$exceptionthrown = true;
|
||||
}
|
||||
$this->assertTrue($exceptionthrown);
|
||||
|
||||
$exceptionthrown = false;
|
||||
try {
|
||||
$fs->search_references_count('http://dl.dropbox.com/download/1234567/naked-dougiamas.jpg');
|
||||
} catch (file_reference_exception $e) {
|
||||
$exceptionthrown = true;
|
||||
}
|
||||
$this->assertTrue($exceptionthrown);
|
||||
}
|
||||
|
||||
public function test_delete_area_files() {
|
||||
|
||||
@@ -975,7 +975,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
var manager = new FileManagerHelper(options);
|
||||
var dndoptions = {
|
||||
filemanager: manager,
|
||||
acceptedtypes: options.accepted_types,
|
||||
acceptedtypes: options.filepicker.accepted_types,
|
||||
clientid: options.client_id,
|
||||
author: options.author,
|
||||
maxfiles: options.maxfiles,
|
||||
|
||||
@@ -944,6 +944,9 @@ abstract class moodleform {
|
||||
$value = $elementclone->_text;
|
||||
$elementclone->setValue(str_replace('{no}', ($i+1), $value));
|
||||
|
||||
} else if (is_a($elementclone, 'HTML_QuickForm_submit') || is_a($elementclone, 'HTML_QuickForm_button')) {
|
||||
$elementclone->setValue(str_replace('{no}', ($i+1), $elementclone->getValue()));
|
||||
|
||||
} else {
|
||||
$value=$elementclone->getLabel();
|
||||
$elementclone->setLabel(str_replace('{no}', ($i+1), $value));
|
||||
|
||||
+18
-4
@@ -202,9 +202,17 @@ class course_modinfo extends stdClass {
|
||||
/**
|
||||
* Gets data about specific numbered section.
|
||||
* @param int $sectionnumber Number (not id) of section
|
||||
* @return section_info Information for numbered section
|
||||
* @param int $strictness Use MUST_EXIST to throw exception if it doesn't
|
||||
* @return section_info Information for numbered section or null if not found
|
||||
*/
|
||||
public function get_section_info($sectionnumber) {
|
||||
public function get_section_info($sectionnumber, $strictness = IGNORE_MISSING) {
|
||||
if (!array_key_exists($sectionnumber, $this->sectioninfo)) {
|
||||
if ($strictness === MUST_EXIST) {
|
||||
throw new moodle_exception('sectionnotexist');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return $this->sectioninfo[$sectionnumber];
|
||||
}
|
||||
|
||||
@@ -1078,18 +1086,24 @@ class cm_info extends stdClass {
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $this->id);
|
||||
$userid = $this->modinfo->get_user_id();
|
||||
$this->uservisible = true;
|
||||
// Check visibility/availability conditions.
|
||||
if ((!$this->visible or !$this->available) and
|
||||
!has_capability('moodle/course:viewhiddenactivities', $modcontext, $userid)) {
|
||||
// If the activity is hidden or unavailable, and you don't have viewhiddenactivities,
|
||||
// set it so that user can't see or access it
|
||||
// set it so that user can't see or access it.
|
||||
$this->uservisible = false;
|
||||
} else if (!empty($CFG->enablegroupmembersonly) and !empty($this->groupmembersonly)
|
||||
}
|
||||
// Check group membership. The grouping option makes the activity
|
||||
// completely invisible as it does not apply to the user at all.
|
||||
if (!empty($CFG->enablegroupmembersonly) and !empty($this->groupmembersonly)
|
||||
and !has_capability('moodle/site:accessallgroups', $modcontext, $userid)) {
|
||||
// If the activity has 'group members only' and you don't have accessallgroups...
|
||||
$groups = $this->modinfo->get_groups($this->groupingid);
|
||||
if (empty($groups)) {
|
||||
// ...and you don't belong to a group, then set it so you can't see/access it
|
||||
$this->uservisible = false;
|
||||
// Ensure activity is completely hidden from user.
|
||||
$this->showavailability = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7179,7 +7179,7 @@ function get_string($identifier, $component = '', $a = NULL, $lazyload = false)
|
||||
|
||||
$identifier = clean_param($identifier, PARAM_STRINGID);
|
||||
if (empty($identifier)) {
|
||||
throw new coding_exception('Invalid string identifier. Most probably some illegal character is part of the string identifier. Please fix your get_string() call and string definition');
|
||||
throw new coding_exception('Invalid string identifier. The identifier cannot be empty. Please fix your get_string() call.');
|
||||
}
|
||||
|
||||
// There is now a forth argument again, this time it is a boolean however so
|
||||
|
||||
@@ -1924,6 +1924,9 @@ class global_navigation extends navigation_node {
|
||||
$activities = array();
|
||||
|
||||
foreach ($sections as $key => $section) {
|
||||
// Clone and unset summary to prevent $SESSION bloat (MDL-31802).
|
||||
$sections[$key] = clone($section);
|
||||
unset($sections[$key]->summary);
|
||||
$sections[$key]->hasactivites = false;
|
||||
if (!array_key_exists($section->section, $modinfo->sections)) {
|
||||
continue;
|
||||
|
||||
@@ -1577,9 +1577,10 @@ class html_writer {
|
||||
if (!($row instanceof html_table_row)) {
|
||||
$newrow = new html_table_row();
|
||||
|
||||
foreach ($row as $item) {
|
||||
$cell = new html_table_cell();
|
||||
$cell->text = $item;
|
||||
foreach ($row as $cell) {
|
||||
if (!($cell instanceof html_table_cell)) {
|
||||
$cell = new html_table_cell($cell);
|
||||
}
|
||||
$newrow->cells[] = $cell;
|
||||
}
|
||||
$row = $newrow;
|
||||
|
||||
@@ -228,12 +228,12 @@ class plugin_renderer_base extends renderer_base {
|
||||
*/
|
||||
public function __call($method, $arguments) {
|
||||
if (method_exists('renderer_base', $method)) {
|
||||
throw new coding_exception('Protected method called against '.__CLASS__.' :: '.$method);
|
||||
throw new coding_exception('Protected method called against '.get_class($this).' :: '.$method);
|
||||
}
|
||||
if (method_exists($this->output, $method)) {
|
||||
return call_user_func_array(array($this->output, $method), $arguments);
|
||||
} else {
|
||||
throw new coding_exception('Unknown method called against '.__CLASS__.' :: '.$method);
|
||||
throw new coding_exception('Unknown method called against '.get_class($this).' :: '.$method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +326,6 @@ class page_requirements_manager {
|
||||
);
|
||||
if (debugging('', DEBUG_DEVELOPER)) {
|
||||
$this->M_cfg['developerdebug'] = true;
|
||||
$this->yui2_lib('logger');
|
||||
}
|
||||
|
||||
// accessibility stuff
|
||||
|
||||
+1
-1
@@ -811,7 +811,7 @@ class available_update_checker {
|
||||
}
|
||||
|
||||
if (empty($response['forbranch']) or $response['forbranch'] !== moodle_major_version(true)) {
|
||||
throw new available_update_checker_exception('err_response_target_version', $response['target']);
|
||||
throw new available_update_checker_exception('err_response_target_version', $response['forbranch']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -722,15 +722,18 @@ class portfolio_exporter {
|
||||
if ($this->get('user')->id != $USER->id) { // make sure it belongs to the right user
|
||||
throw new portfolio_exception('notyours', 'portfolio');
|
||||
}
|
||||
if (!$readonly && $this->get('instance') && !$this->get('instance')->allows_multiple_exports()
|
||||
&& ($already = portfolio_existing_exports($this->get('user')->id, $this->get('instance')->get('plugin')))
|
||||
&& array_shift(array_keys($already)) != $this->get('id')
|
||||
) {
|
||||
$a = (object)array(
|
||||
'plugin' => $this->get('instance')->get('plugin'),
|
||||
'link' => $CFG->wwwroot . '/user/portfoliologs.php',
|
||||
);
|
||||
throw new portfolio_exception('nomultipleexports', 'portfolio', '', $a);
|
||||
if (!$readonly && $this->get('instance') && !$this->get('instance')->allows_multiple_exports()) {
|
||||
$already = portfolio_existing_exports($this->get('user')->id, $this->get('instance')->get('plugin'));
|
||||
$already = array_keys($already);
|
||||
|
||||
if (array_shift($already) != $this->get('id')) {
|
||||
|
||||
$a = (object)array(
|
||||
'plugin' => $this->get('instance')->get('plugin'),
|
||||
'link' => $CFG->wwwroot . '/user/portfoliologs.php',
|
||||
);
|
||||
throw new portfolio_exception('nomultipleexports', 'portfolio', '', $a);
|
||||
}
|
||||
}
|
||||
if (!$this->caller->check_permissions()) { // recall the caller permission check
|
||||
throw new portfolio_caller_exception('nopermissions', 'portfolio', $this->caller->get_return_url());
|
||||
|
||||
+37
-8
@@ -565,20 +565,49 @@ function get_exception_info($ex) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Moodle Docs URL in the users language
|
||||
* Returns the Moodle Docs URL in the users language for a given 'More help' link.
|
||||
*
|
||||
* @global object
|
||||
* @param string $path the end of the URL.
|
||||
* @return string The MoodleDocs URL in the user's language. for example {@link http://docs.moodle.org/en/ http://docs.moodle.org/en/$path}
|
||||
* There are three cases:
|
||||
*
|
||||
* 1. In the normal case, $path will be a short relative path 'component/thing',
|
||||
* like 'mod/folder/view' 'group/import'. This gets turned into an link to
|
||||
* MoodleDocs in the user's language, and for the appropriate Moodle version.
|
||||
* E.g. 'group/import' may become 'http://docs.moodle.org/2x/en/group/import'.
|
||||
* The 'http://docs.moodle.org' bit comes from $CFG->docroot.
|
||||
*
|
||||
* This is the only option that should be used in standard Moodle code. The other
|
||||
* two options have been implemented because they are useful for third-party plugins.
|
||||
*
|
||||
* 2. $path may be an absolute URL, starting http:// or https://. In this case,
|
||||
* the link is used as is.
|
||||
*
|
||||
* 3. $path may start %%WWWROOT%%, in which case that is replaced by
|
||||
* $CFG->wwwroot to make the link.
|
||||
*
|
||||
* @param string $path the place to link to. See above for details.
|
||||
* @return string The MoodleDocs URL in the user's language. for example @link http://docs.moodle.org/2x/en/$path}
|
||||
*/
|
||||
function get_docs_url($path=null) {
|
||||
function get_docs_url($path = null) {
|
||||
global $CFG;
|
||||
|
||||
// Absolute URLs are used unmodified.
|
||||
if (substr($path, 0, 7) === 'http://' || substr($path, 0, 8) === 'https://') {
|
||||
return $path;
|
||||
}
|
||||
|
||||
// Paths starting %%WWWROOT%% have that replaced by $CFG->wwwroot.
|
||||
if (substr($path, 0, 11) === '%%WWWROOT%%') {
|
||||
return $CFG->wwwroot . substr($path, 11);
|
||||
}
|
||||
|
||||
// Otherwise we do the normal case, and construct a MoodleDocs URL relative to $CFG->docroot.
|
||||
|
||||
// Check that $CFG->branch has been set up, during installation it won't be.
|
||||
if (empty($CFG->branch)) {
|
||||
// It's not there yet so look at version.php
|
||||
// It's not there yet so look at version.php.
|
||||
include($CFG->dirroot.'/version.php');
|
||||
} else {
|
||||
// We can use $CFG->branch and avoid having to include version.php
|
||||
// We can use $CFG->branch and avoid having to include version.php.
|
||||
$branch = $CFG->branch;
|
||||
}
|
||||
// ensure branch is valid.
|
||||
@@ -592,7 +621,7 @@ function get_docs_url($path=null) {
|
||||
if (!empty($CFG->docroot)) {
|
||||
return $CFG->docroot . '/' . $branch . '/' . current_language() . '/' . $path;
|
||||
} else {
|
||||
return 'http://docs.moodle.org/'. $branch . '/en/' . $path;
|
||||
return 'http://docs.moodle.org/'. $branch . '/' . current_language() . '/' . $path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,59 @@ class accesslib_testcase extends advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if user is enrolled in a course
|
||||
* @return void
|
||||
*/
|
||||
public function test_is_enrolled() {
|
||||
global $DB;
|
||||
|
||||
// Generate data
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$role = $DB->get_record('role', array('shortname'=>'student'));
|
||||
|
||||
// There should be a manual enrolment as part of the default install
|
||||
$plugin = enrol_get_plugin('manual');
|
||||
$instance = $DB->get_record('enrol', array(
|
||||
'courseid' => $course->id,
|
||||
'enrol' => 'manual',
|
||||
));
|
||||
$this->assertNotEquals($instance, false);
|
||||
|
||||
// Enrol the user in the course
|
||||
$plugin->enrol_user($instance, $user->id, $role->id);
|
||||
|
||||
// We'll test with the mod/assign:submit capability
|
||||
$capability= 'mod/assign:submit';
|
||||
$this->assertTrue($DB->record_exists('capabilities', array('name' => $capability)));
|
||||
|
||||
// Switch to our user
|
||||
$this->setUser($user);
|
||||
|
||||
// Ensure that the user has the capability first
|
||||
$this->assertTrue(has_capability($capability, $coursecontext, $user->id));
|
||||
|
||||
// We first test whether the user is enrolled on the course as this
|
||||
// seeds the cache, then we test for the capability
|
||||
$this->assertTrue(is_enrolled($coursecontext, $user, '', true));
|
||||
$this->assertTrue(is_enrolled($coursecontext, $user, $capability));
|
||||
|
||||
// Prevent the capability for this user role
|
||||
assign_capability($capability, CAP_PROHIBIT, $role->id, $coursecontext);
|
||||
$coursecontext->mark_dirty();
|
||||
$this->assertFalse(has_capability($capability, $coursecontext, $user->id));
|
||||
|
||||
// Again, we seed the cache first by checking initial enrolment,
|
||||
// and then we test the actual capability
|
||||
$this->assertTrue(is_enrolled($coursecontext, $user, '', true));
|
||||
$this->assertFalse(is_enrolled($coursecontext, $user, $capability));
|
||||
|
||||
// We need variable states to be reset for the next test
|
||||
$this->resetAfterTest(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test logged in test.
|
||||
* @return void
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Unit tests for setuplib.php
|
||||
*
|
||||
* @package core_phpunit
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Unit tests for setuplib.php
|
||||
*
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_setuplib_testcase extends basic_testcase {
|
||||
|
||||
/**
|
||||
* Test get_docs_url_standard in the normal case when we should link to Moodle docs.
|
||||
*/
|
||||
public function test_get_docs_url_standard() {
|
||||
global $CFG;
|
||||
if (empty($CFG->docroot)) {
|
||||
$docroot = 'http://docs.moodle.org/';
|
||||
} else {
|
||||
$docroot = $CFG->docroot;
|
||||
}
|
||||
$this->assertRegExp('~^' . preg_quote($docroot, '') . '/2\d/' . current_language() . '/course/editing$~',
|
||||
get_docs_url('course/editing'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_docs_url_standard in the special case of an absolute HTTP URL.
|
||||
*/
|
||||
public function test_get_docs_url_http() {
|
||||
$url = 'http://moodle.org/';
|
||||
$this->assertEquals($url, get_docs_url($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_docs_url_standard in the special case of an absolute HTTPS URL.
|
||||
*/
|
||||
public function test_get_docs_url_https() {
|
||||
$url = 'https://moodle.org/';
|
||||
$this->assertEquals($url, get_docs_url($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_docs_url_standard in the special case of a link relative to wwwroot.
|
||||
*/
|
||||
public function test_get_docs_url_wwwroot() {
|
||||
global $CFG;
|
||||
$this->assertEquals($CFG->wwwroot . '/lib/tests/setuplib_test.php',
|
||||
get_docs_url('%%WWWROOT%%/lib/tests/setuplib_test.php'));
|
||||
}
|
||||
}
|
||||
@@ -471,6 +471,12 @@ class collatorlib_testcase extends basic_testcase {
|
||||
$this->assertSame(array_keys($arr), array(0, 'b', 1));
|
||||
$this->assertTrue($result);
|
||||
|
||||
// test sorting of array of arrays - first element should be used for actual comparison
|
||||
$arr = array(0=>array('bb', 'z'), 1=>array('ab', 'a'), 2=>array('zz', 'x'));
|
||||
$result = collatorlib::asort($arr, collatorlib::SORT_REGULAR);
|
||||
$this->assertSame(array_keys($arr), array(1, 0, 2));
|
||||
$this->assertTrue($result);
|
||||
|
||||
$arr = array('a' => 'áb', 'b' => 'ab', 1 => 'aa', 0=>'cc', 'x' => 'Áb',);
|
||||
$result = collatorlib::asort($arr);
|
||||
$this->assertSame(array_values($arr), array('aa', 'ab', 'áb', 'Áb', 'cc'), $this->error);
|
||||
|
||||
@@ -616,7 +616,7 @@ class textlib {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class collatorlib {
|
||||
/** @const compare items as strings, equivalent to Collator::SORT_REGULAR */
|
||||
/** @const compare items using general PHP comparison, equivalent to Collator::SORT_REGULAR, this may bot be locale aware! */
|
||||
const SORT_REGULAR = 0;
|
||||
|
||||
/** @const compare items as strings, equivalent to Collator::SORT_STRING */
|
||||
|
||||
@@ -36,6 +36,10 @@ function xmldb_message_email_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;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ function xmldb_message_jabber_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;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ function xmldb_message_popup_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;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ function xmldb_assign_upgrade($oldversion) {
|
||||
upgrade_mod_savepoint(true, 2012051700, 'assign');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
*/
|
||||
function xmldb_assignfeedback_comments_upgrade($oldversion) {
|
||||
// do the upgrades
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
*/
|
||||
function xmldb_assignfeedback_file_upgrade($oldversion) {
|
||||
// do the upgrades
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ $string['couldnotconvertsubmission'] = 'Could not convert assignment submission
|
||||
$string['couldnotcreatecoursemodule'] = 'Could not create course module.';
|
||||
$string['couldnotcreatenewassignmentinstance'] = 'Could not create new assignment instance.';
|
||||
$string['couldnotfindassignmenttoupgrade'] = 'Could not find old assignment instance to upgrade.';
|
||||
$string['currentgrade'] = 'Current grade in gradebook';
|
||||
$string['defaultplugins'] = 'Default assignment settings';
|
||||
$string['defaultplugins_help'] = 'These settings define the defaults for all new assignments.';
|
||||
$string['deletepluginareyousure'] = 'Delete assignment plugin {$a}: are you sure?';
|
||||
|
||||
@@ -2898,6 +2898,16 @@ class assign {
|
||||
}
|
||||
}
|
||||
|
||||
if (has_all_capabilities(array('gradereport/grader:view', 'moodle/grade:viewall'), $this->get_course_context())) {
|
||||
$grade = $this->output->action_link(new moodle_url('/grade/report/grader/index.php',
|
||||
array('id'=>$this->get_course()->id)),
|
||||
$gradinginfo->items[0]->grades[$userid]->str_grade);
|
||||
} else {
|
||||
$grade = $gradinginfo->items[0]->grades[$userid]->str_grade;
|
||||
}
|
||||
$mform->addElement('static', 'finalgrade', get_string('currentgrade', 'assign').':' ,$grade);
|
||||
|
||||
|
||||
$mform->addElement('static', 'progress', '', get_string('gradingstudentprogress', 'assign', array('index'=>$rownum+1, 'count'=>count($useridlist))));
|
||||
|
||||
// plugins
|
||||
|
||||
@@ -45,6 +45,9 @@ class assign_portfolio_caller extends portfolio_module_caller_base {
|
||||
/** @var int callback arg - the id of submission we export */
|
||||
protected $sid;
|
||||
|
||||
/** @var string component of the submission files we export*/
|
||||
protected $component;
|
||||
|
||||
/** @var string callback arg - the area of submission files we export */
|
||||
protected $area;
|
||||
|
||||
@@ -60,7 +63,6 @@ class assign_portfolio_caller extends portfolio_module_caller_base {
|
||||
/** @var string callback arg - the name of the editor field we export */
|
||||
protected $editor;
|
||||
|
||||
|
||||
/**
|
||||
* callback arg for a single file export
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,8 @@ div.gradingsummary .generaltable {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#page-mod-assign-view table.generaltable table td { border: 0px none; }
|
||||
|
||||
.gradingsummarytable,
|
||||
.feedbacktable,
|
||||
.lockedsubmission,
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assignsubmission_comments_upgrade($oldversion) {
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assignsubmission_file_upgrade($oldversion) {
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assignsubmission_onlinetext_upgrade($oldversion) {
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,46 @@ function xmldb_assignment_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
|
||||
|
||||
if ($oldversion < 2012061701) {
|
||||
// Fixed/updated numfiles field in assignment_submissions table to count the actual
|
||||
// number of files has been uploaded when sendformarking is disabled
|
||||
upgrade_set_timeout(600); // increase excution time for in large sites
|
||||
$fs = get_file_storage();
|
||||
|
||||
// Fetch the moduleid for use in the course_modules table
|
||||
$moduleid = $DB->get_field('modules', 'id', array('name' => 'assignment'), MUST_EXIST);
|
||||
|
||||
$selectcount = 'SELECT COUNT(s.id) ';
|
||||
$select = 'SELECT s.id, cm.id AS cmid ';
|
||||
$query = 'FROM {assignment_submissions} s
|
||||
JOIN {assignment} a ON a.id = s.assignment
|
||||
JOIN {course_modules} cm ON a.id = cm.instance AND cm.module = :moduleid
|
||||
WHERE assignmenttype = :assignmenttype';
|
||||
|
||||
$params = array('moduleid' => $moduleid, 'assignmenttype' => 'upload');
|
||||
|
||||
$countsubmissions = $DB->count_records_sql($selectcount.$query, $params);
|
||||
$submissions = $DB->get_recordset_sql($select.$query, $params);
|
||||
|
||||
$pbar = new progress_bar('assignmentupgradenumfiles', 500, true);
|
||||
$i = 0;
|
||||
foreach ($submissions as $sub) {
|
||||
$i++;
|
||||
if ($context = context_module::instance($sub->cmid)) {
|
||||
$sub->numfiles = count($fs->get_area_files($context->id, 'mod_assignment', 'submission', $sub->id, 'sortorder', false));
|
||||
$DB->update_record('assignment_submissions', $sub);
|
||||
}
|
||||
$pbar->update($i, $countsubmissions, "Counting files of submissions ($i/$countsubmissions)");
|
||||
}
|
||||
$submissions->close();
|
||||
|
||||
// assignment savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012061701, 'assignment');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -395,8 +395,8 @@ class assignment_upload extends assignment_base {
|
||||
|
||||
/**
|
||||
* Counts all complete (real) assignment submissions by enrolled students. This overrides assignment_base::count_real_submissions().
|
||||
* This is necessary for advanced file uploads where we need to check that the data2 field is equal to "submitted" to determine
|
||||
* if a submission is complete.
|
||||
* This is necessary for tracked advanced file uploads where we need to check that the data2 field is equal to ASSIGNMENT_STATUS_SUBMITTED
|
||||
* to determine if a submission is complete.
|
||||
*
|
||||
* @param int $groupid (optional) If nonzero then count is restricted to this group
|
||||
* @return int The number of submissions
|
||||
@@ -411,13 +411,19 @@ class assignment_upload extends assignment_base {
|
||||
list($enroledsql, $params) = get_enrolled_sql($context, 'mod/assignment:view', $groupid);
|
||||
$params['assignmentid'] = $this->cm->instance;
|
||||
|
||||
// Get ids of users enrolled in the given course.
|
||||
$query = '';
|
||||
if ($this->drafts_tracked() and $this->isopen()) {
|
||||
$query = ' AND ' . $DB->sql_compare_text('s.data2') . " = '" . ASSIGNMENT_STATUS_SUBMITTED . "'";
|
||||
} else {
|
||||
// Count on submissions with files actually uploaded
|
||||
$query = " AND s.numfiles > 0";
|
||||
}
|
||||
return $DB->count_records_sql("SELECT COUNT('x')
|
||||
FROM {assignment_submissions} s
|
||||
LEFT JOIN {assignment} a ON a.id = s.assignment
|
||||
INNER JOIN ($enroledsql) u ON u.id = s.userid
|
||||
WHERE s.assignment = :assignmentid AND
|
||||
s.data2 = 'submitted'", $params);
|
||||
WHERE s.assignment = :assignmentid" .
|
||||
$query, $params);
|
||||
}
|
||||
|
||||
function print_responsefiles($userid, $return=false) {
|
||||
@@ -581,6 +587,7 @@ class assignment_upload extends assignment_base {
|
||||
$formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $this->context, 'mod_assignment', 'submission', $submission->id);
|
||||
$updates = new stdClass();
|
||||
$updates->id = $submission->id;
|
||||
$updates->numfiles = count($fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, 'sortorder', false));
|
||||
$updates->timemodified = time();
|
||||
$DB->update_record('assignment_submissions', $updates);
|
||||
add_to_log($this->course->id, 'assignment', 'upload',
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$module->version = 2012061700; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->version = 2012061701; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->requires = 2012061700; // Requires this Moodle version
|
||||
$module->component = 'mod_assignment'; // Full name of the plugin (used for diagnostics)
|
||||
$module->cron = 60;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user