Permalink
Browse files

MDL-29538 core_condition: changed the logic in the code so that it wo…

…rks with the new database structure as well as tidying up parts of the code
  • Loading branch information...
markn86 committed May 8, 2012
1 parent 92fb7dd commit cb4492c2001e5ac2f914d7612b46d5ce63ff30ec
Showing with 203 additions and 163 deletions.
  1. +8 −4 backup/moodle2/restore_stepslib.php
  2. +4 −4 course/moodleform_mod.php
  3. +2 −2 lang/en/condition.php
  4. +183 −153 lib/conditionlib.php
  5. +6 −0 lib/moodlelib.php
@@ -523,10 +523,12 @@ protected function define_execution() {
foreach($rs as $availrec) {
$allmatchesok = true;
// Get the complete availabilityobject
- $availability = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'module_availability', $availrec->itemid)->info;
+ $availability = restore_dbops::get_backup_ids_record($this->get_restoreid(),
+ 'module_availability', $availrec->itemid)->info;
// Map the sourcecmid if needed and possible
if (!empty($availability->sourcecmid)) {
- $newcm = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'course_module', $availability->sourcecmid);
+ $newcm = restore_dbops::get_backup_ids_record($this->get_restoreid(),
+ 'course_module', $availability->sourcecmid);
if ($newcm) {
$availability->sourcecmid = $newcm->newitemid;
} else {
@@ -535,7 +537,8 @@ protected function define_execution() {
}
// Map the gradeitemid if needed and possible
if (!empty($availability->gradeitemid)) {
- $newgi = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'grade_item', $availability->gradeitemid);
+ $newgi = restore_dbops::get_backup_ids_record($this->get_restoreid(),
+ 'grade_item', $availability->gradeitemid);
if ($newgi) {
$availability->gradeitemid = $newgi->newitemid;
} else {
@@ -551,7 +554,8 @@ protected function define_execution() {
$params = array('backupid' => $this->get_restoreid(), 'itemname' => 'module_availability_field');
$rs = $DB->get_recordset('backup_ids_temp', $params, '', 'itemid');
foreach($rs as $availrec) {
- $availability = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'module_availability_field', $availrec->itemid)->info;
+ $availability = restore_dbops::get_backup_ids_record($this->get_restoreid(),
+ 'module_availability_field', $availrec->itemid)->info;
$DB->insert_record('course_modules_avail_fields', $availability);
}
$rs->close();
@@ -263,8 +263,8 @@ function definition_after_data() {
foreach($fullcm->conditionsfield as $field=>$details) {
$groupelements=$mform->getElement('conditionfieldgroup['.$num.']')->getElements();
$groupelements[0]->setValue($field);
- $groupelements[1]->setValue(is_null($details->operator)?'':$details->operator);
- $groupelements[2]->setValue(is_null($details->value)?'':($details->value));
+ $groupelements[1]->setValue(is_null($details->operator) ? '' : $details->operator);
+ $groupelements[2]->setValue(is_null($details->value) ? '' : $details->value);
$num++;
}
@@ -533,7 +533,7 @@ function standard_coursemodule_elements(){
$ci = new condition_info($this->_cm, CONDITION_MISSING_EXTRATABLE);
$this->_cm = $ci->get_full_course_module();
$count = count($this->_cm->conditionsgrade)+1;
- $fieldcount = count($this->_cm->conditionsfield)+1;
+ $fieldcount = count($this->_cm->conditionsfield) + 1;
} else {
$count = 1;
$fieldcount = 1;
@@ -575,7 +575,7 @@ function standard_coursemodule_elements(){
}
}
asort($completionoptions);
- $completionoptions = array(0=>$strnone)+$completionoptions;
+ $completionoptions = array(0=>$strnone) + $completionoptions;
$completionvalues=array(
COMPLETION_COMPLETE=>get_string('completion_complete','condition'),
View
@@ -75,15 +75,15 @@
$string['requires_grade_max'] = 'Not available unless you get an appropriate score in <strong>{$a}</strong>.';
$string['requires_grade_min'] = 'Not available until you achieve a required score in <strong>{$a}</strong>.';
$string['requires_grade_range'] = 'Not available unless you get a particular score in <strong>{$a}</strong>.';
-$string['requires_user_field_restriction'] = 'Only available to users who\'s user field \'{$a->field}\' {$a->operator} \'{$a->value}\'.';
+$string['requires_user_field_restriction'] = 'Not available unless your <strong>{$a->field}</strong> {$a->operator} <strong>{$a->value}</strong>.';
$string['showavailability'] = 'Before activity can be accessed';
$string['showavailabilitysection'] = 'Before section can be accessed';
$string['showavailability_hide'] = 'Hide activity entirely';
$string['showavailability_show'] = 'Show activity greyed-out, with restriction information';
$string['showavailabilitysection_hide'] = 'Hide section entirely';
$string['showavailabilitysection_show'] = 'Show section greyed-out, with restriction information';
$string['userfield'] = 'User field';
-$string['userfield_help'] = 'This is an attribute associated with each individual user';
+$string['userfield_help'] = 'You can restrict access based on any field from the user&rsquo;s profile.';
$string['userrestriction_hidden'] = 'Restricted (completely hidden, no message): &lsquo;{$a}&rsquo;';
$string['userrestriction_visible'] = 'Restricted: &lsquo;{$a}&rsquo;';
$string['groupingnoaccess'] = 'You do not currently belong to a group which has access to this section. ';
Oops, something went wrong.

0 comments on commit cb4492c

Please sign in to comment.