From: jerome Date: Fri, 21 Nov 2008 07:19:00 +0000 (+0000) Subject: database: MDL-16999 fix "Required Entries" and "Required Entries before viewing"... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c861f079e4ee05d4f09967ffae6bf73c0407bb0a;p=moodle.git database: MDL-16999 fix "Required Entries" and "Required Entries before viewing" settings. Display a warning message during upgrade process if the fields were set previously (partially merged from 1.9) --- diff --git a/admin/environment.xml b/admin/environment.xml index 315dadea67..9c1c2bac42 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -277,6 +277,8 @@ + + diff --git a/install/stringnames.txt b/install/stringnames.txt index 24c3ffac71..2bcdf80585 100644 --- a/install/stringnames.txt +++ b/install/stringnames.txt @@ -196,6 +196,7 @@ releasenoteslink remotedownloaderror remotedownloadnotallowed report +requiredentrieschanged restricted safemode safemodeerror diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 0ed3808556..e37836f489 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -657,6 +657,8 @@ $string['remotelangnotavailable'] = 'Because Moodle can not connect to download. $string['renameerrors'] = 'Rename errors'; $string['requiredtemplate'] = 'Required. You may use template syntax here (%%l = lastname, %%f = firstname, %%u = username). See help for details and examples.'; $string['requires'] = 'Requires'; +$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['reverseproxy'] = 'Reverse proxy'; diff --git a/lang/en_utf8/data.php b/lang/en_utf8/data.php index 4d7476faf5..afa55d9c28 100644 --- a/lang/en_utf8/data.php +++ b/lang/en_utf8/data.php @@ -88,7 +88,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 d7664bf9f4..ae4fb887ce 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -2540,6 +2540,42 @@ function data_pluginfile($course, $cminfo, $context, $filearea, $args) { return false; } +/** + * NOTE: this function is called into environment.xml + * Check if both of database required entries fields have been set for a version anterior to 2008112101 + * This check has been required by the bug MDL-16999 + * @global $CFG + * @param $result + * @return object status + */ +function data_check_required_entries_fields($result) { + global $CFG, $DB; + if (!empty($CFG->version) //we are not installing a new Moodle site + && $CFG->version < 2008112101 //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("data/requiredentriesfixflag",true); + $databases = $DB->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; +} + require_once($CFG->libdir . '/portfoliolib.php'); class data_portfolio_caller extends portfolio_module_caller_base { diff --git a/mod/data/view.php b/mod/data/view.php index c1298b8ae9..41375e12df 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -393,13 +393,20 @@ } } - // 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); + $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; } diff --git a/version.php b/version.php index 3c29ba7d8c..cea1711fcf 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 = 2008111801; // YYYYMMDD = date of the last version bump + $version = 2008112101; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20081121)'; // Human-friendly version name