Merge branch 'wip-MDL-34285-m24' of git://github.com/samhemelryk/moodle

This commit is contained in:
Aparup Banerjee 2012-07-23 17:22:14 +08:00
commit f36b0ba502
2 changed files with 32 additions and 11 deletions

View File

@ -47,7 +47,10 @@ $string['completion_fail'] = 'must be complete with fail grade';
$string['completion_incomplete'] = 'must not be marked complete';
$string['completion_pass'] = 'must be complete with pass grade';
$string['configenableavailability'] = 'When enabled, this lets you set conditions (based on date, grade, or completion) that control whether an activity or resource can be accessed.';
$string['contains'] = 'contains';
$string['doesnotcontain'] = 'doesn\'t contain';
$string['enableavailability'] = 'Enable conditional access';
$string['endswith'] = 'ends with';
$string['fielddeclaredmultipletimes'] = 'You can not declare the same field more than once per activity.';
$string['grade_atleast'] = 'must be at least';
$string['gradecondition'] = 'Grade condition';
@ -62,6 +65,9 @@ $string['grade_upto'] = 'and less than';
$string['gradeitembutnolimits'] = 'You must enter an upper or lower limit, or both.';
$string['gradelimitsbutnoitem'] = 'You must choose a grade item.';
$string['gradesmustbenumeric'] = 'The minimum and maximum grades must be numeric (or blank).';
$string['isempty'] = 'is empty';
$string['isequalto'] = 'is equal to';
$string['isnotempty'] = 'is not empty';
$string['none'] = '(none)';
$string['notavailableyet'] = 'Not available yet';
$string['requires_completion_0'] = 'Not available unless the activity <strong>{$a}</strong> is incomplete.';
@ -76,13 +82,20 @@ $string['requires_grade_any'] = 'Not available until you have a grade in <strong
$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'] = 'Not available unless your <strong>{$a->field}</strong> {$a->operator} <strong>{$a->value}</strong>.';
$string['requires_user_field_contains'] = 'Not available unless your <strong>{$a->field}</strong> contains <strong>{$a->value}</strong>.';
$string['requires_user_field_doesnotcontain'] = 'Not available if your <strong>{$a->field}</strong> contains <strong>{$a->value}</strong>.';
$string['requires_user_field_endswith'] = 'Not available unless your <strong>{$a->field}</strong> ends with <strong>{$a->value}</strong>.';
$string['requires_user_field_isempty'] = 'Not available unless your <strong>{$a->field}</strong> is empty.';
$string['requires_user_field_isequalto'] = 'Not available unless your <strong>{$a->field}</strong> is equal to <strong>{$a->value}</strong>.';
$string['requires_user_field_isnotempty'] = 'Not available if your <strong>{$a->field}</strong> is empty.';
$string['requires_user_field_startswith'] = 'Not available unless your <strong>{$a->field}</strong> starts withs <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['startswith'] = 'starts with';
$string['userfield'] = 'User field';
$string['userfield_help'] = 'You can restrict access based on any field from the users profile.';
$string['userrestriction_hidden'] = 'Restricted (completely hidden, no message): &lsquo;{$a}&rsquo;';

View File

@ -79,6 +79,10 @@ define('OP_ENDS_WITH', 'endswith');
* OP_IS_EMPTY - comparison operator that determines whether a specified user field is empty
*/
define('OP_IS_EMPTY', 'isempty');
/**
* OP_IS_NOT_EMPTY - comparison operator that determines whether a specified user field is not empty
*/
define('OP_IS_NOT_EMPTY', 'isnotempty');
require_once($CFG->libdir.'/completionlib.php');
@ -584,12 +588,13 @@ abstract class condition_info_base {
*/
public static function get_condition_user_field_operators() {
return array(
OP_CONTAINS => get_string('contains', 'filters'),
OP_DOES_NOT_CONTAIN => get_string('doesnotcontain', 'filters'),
OP_IS_EQUAL_TO => get_string('isequalto', 'filters'),
OP_STARTS_WITH => get_string('startswith', 'filters'),
OP_ENDS_WITH => get_string('endswith', 'filters'),
OP_IS_EMPTY => get_string('isempty', 'filters')
OP_CONTAINS => get_string('contains', 'condition'),
OP_DOES_NOT_CONTAIN => get_string('doesnotcontain', 'condition'),
OP_IS_EQUAL_TO => get_string('isequalto', 'condition'),
OP_STARTS_WITH => get_string('startswith', 'condition'),
OP_ENDS_WITH => get_string('endswith', 'condition'),
OP_IS_EMPTY => get_string('isempty', 'condition'),
OP_IS_NOT_EMPTY => get_string('isnotempty', 'condition'),
);
}
@ -802,9 +807,8 @@ abstract class condition_info_base {
foreach ($this->item->conditionsfield as $field => $details) {
$a = new stdclass;
$a->field = $details->fieldname;
$a->operator = get_string($details->operator, 'filters');
$a->value = $details->value;
$information .= get_string('requires_user_field_restriction', 'condition', $a) . ' ';
$information .= get_string('requires_user_field_'.$details->operator, 'condition', $a) . ' ';
}
}
@ -1009,9 +1013,8 @@ abstract class condition_info_base {
$available = false;
$a = new stdClass();
$a->field = $details->fieldname;
$a->operator = get_string($details->operator, 'filters');
$a->value = $details->value;
$information .= get_string('requires_user_field_restriction', 'condition', $a) . ' ';
$information .= get_string('requires_user_field_'.$details->operator, 'condition', $a) . ' ';
}
}
}
@ -1233,6 +1236,11 @@ abstract class condition_info_base {
$fieldconditionmet = false;
}
break;
case OP_IS_NOT_EMPTY: // is not empty
if (empty($uservalue)) {
$fieldconditionmet = false;
}
break;
}
return $fieldconditionmet;
}