diff --git a/admin/environment.xml b/admin/environment.xml index 315dadea677..4b93f78e0fa 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -128,6 +128,10 @@ + + + + diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 37705db105e..95b3be37e82 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -494,6 +494,8 @@ $string['rcachettl'] = 'Record cache TTL'; $string['releasenoteslink'] = 'For information about this version of Moodle, please see the online Release Notes'; $string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from the list below, copy them to your $a directory and unzip them manually.'; $string['renameerrors'] = 'Errors in renames'; +$string['requiredentrieschanged'] = 'IMPORTANT - PLEASE READ
Due to a bug fix, the behaviour of database activities using the \'Required entries\' and \'Required entries before viewing settings\' settings will change. A more detailed explaination of the changes can be read on the database module forum and Moodle Docs. +

This change affects the following databases in your system: (Please save this list now, and after the upgrade, check that these activities still work the way that the teacher intends.)
$a->text
'; $string['restrictbydefault'] = 'Restrict modules by default'; $string['restrictmodulesfor'] = 'Restrict modules for'; $string['riskconfig'] = 'Users could change site configuration and behaviour'; diff --git a/lang/en_utf8/data.php b/lang/en_utf8/data.php index ff87f304b18..b71c98617a6 100644 --- a/lang/en_utf8/data.php +++ b/lang/en_utf8/data.php @@ -71,7 +71,8 @@ $string['editordisable'] = 'Disable editor'; $string['emptyadd'] = 'The Add template is empty, generating a default form...'; $string['emptyaddform'] = 'You did not fill out any fields!'; $string['entries'] = 'Entries'; -$string['entrieslefttoadd'] = 'You must add $a->entriesleft more entry/entries before you can view other participants\' entries.'; +$string['entrieslefttoaddtoview'] = 'You must add $a->entrieslefttoview more entry/entries before you can view other participants\' entries.'; +$string['entrieslefttoadd'] = 'You must add $a->entriesleft more entry/entries in order to complete this activity'; $string['entry'] = 'Entry'; $string['entrysaved'] = 'Your entry has been saved'; $string['errormustbeteacher'] = 'You need to be a teacher to use this page!'; diff --git a/mod/data/lib.php b/mod/data/lib.php index 8fe8ac9df9c..d5cf8ffed80 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1878,4 +1878,41 @@ function data_preset_path($course, $userid, $shortname) { return 'Does it disturb you that this code will never run?'; } + +/** + * This function is called into environment.xml + * Check if both of database required entries fields have been set for a version anterior to 2007021572 + * This check has been required by the bug MDL-16999 + * @global $CFG + * @param $result + * @return object status + */ +function check_required_entries_fields($result) { + global $CFG; + if (!empty($CFG->version) //we are not installing a new Moodle site + && $CFG->version < 2007021572 //the version is anterior to the one when the fix has been applied + && !get_config("data","requiredentriesfixflag")) { //do not show message when upgrading an anterior version when the patch has already been applied + set_config("requiredentriesfixflag",true, "data"); //set a flag into database in order to let know a Moodle 1.9 upgrade that the message has already been displayed + $databases = get_records_sql("SELECT d.*, c.fullname + FROM {$CFG->prefix}data d, + {$CFG->prefix}course c + WHERE d.course = c.id + ORDER BY c.fullname, d.name"); + if (!empty($databases)) { + $a = new object(); + foreach($databases as $database) { + if ($database->requiredentries != 0 || $database->requiredentriestoview != 0) { + $a->text .= "".$database->fullname." - " .$database->name. " (course id: ".$database->course." - database id: ".$database->id.")
"; + //set the feedback string here and not in xml file since we need something + //more complex than just a string picked from admin.php lang file + $result->setFeedbackStr(array('requiredentrieschanged', 'admin', $a)); + $result->setStatus(false);//fail test + } + } + return $result; + } + } + return null; +} + ?> diff --git a/mod/data/view.php b/mod/data/view.php index b290aa217ea..b6ccd8fa6a3 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -266,15 +266,22 @@ } } - // Check the number of entries required against the number of entries already made (doesn't apply to teachers) - $requiredentries_allowed = true; - $numentries = data_numentries($data); - if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', $context)) { - $data->entriesleft = $data->requiredentries - $numentries; - $strentrieslefttoadd = get_string('entrieslefttoadd', 'data', $data); - notify($strentrieslefttoadd); - $requiredentries_allowed = false; - } + $numentries = data_numentries($data); + /// Check the number of entries required against the number of entries already made (doesn't apply to teachers) + if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', $context)) { + $data->entriesleft = $data->requiredentries - $numentries; + $strentrieslefttoadd = get_string('entrieslefttoadd', 'data', $data); + notify($strentrieslefttoadd); + } + + /// Check the number of entries required before to view other participant's entries against the number of entries already made (doesn't apply to teachers) + $requiredentries_allowed = true; + if ($data->requiredentriestoview > 0 && $numentries < $data->requiredentriestoview && !has_capability('mod/data:manageentries', $context)) { + $data->entrieslefttoview = $data->requiredentriestoview - $numentries; + $strentrieslefttoaddtoview = get_string('entrieslefttoaddtoview', 'data', $data); + notify($strentrieslefttoaddtoview); + $requiredentries_allowed = false; + } /// We need to examine the whole dataset to produce the correct paging diff --git a/version.php b/version.php index 4bad6754440..9611aa3abd4 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2007021571; // YYYYMMDD = date of the 1.8 branch (don't change) + $version = 2007021572; // YYYYMMDD = date of the 1.8 branch (don't change) // X = release number 1.8.[0,1,2,3...] // Y = micro-increments between releases