Skip to content

Commit

Permalink
MDL-29538 core_condition: changed the logic in the code so that it wo…
Browse files Browse the repository at this point in the history
…rks with the new database structure as well as tidying up parts of the code
  • Loading branch information
mdjnelson committed Jun 26, 2012
1 parent 92fb7dd commit cb4492c
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 163 deletions.
12 changes: 8 additions & 4 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions course/moodleform_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions lang/en/condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. ';
Loading

0 comments on commit cb4492c

Please sign in to comment.