mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
MDL-44070 Conditional availability enhancements (6): core changes
Changes core code to use new API instead of the old one when checking user access to activities and sections. Includes changes to other libraries that are necessary after adding the availability system and removing old conditional tables etc.
This commit is contained in:
parent
6a601097a0
commit
8d1f33e122
14 changed files with 393 additions and 402 deletions
|
@ -360,16 +360,16 @@ class grade_report_user extends grade_report {
|
|||
($this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_grade->is_hiddenuntil()))) {
|
||||
$hide = true;
|
||||
} else if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
|
||||
// The grade object can be marked visible but still be hidden if...
|
||||
// 1) "enablegroupmembersonly" is on and the activity is assigned to a grouping the user is not in.
|
||||
// 2) the student cannot see the activity due to conditional access and its set to be hidden entirely.
|
||||
// The grade object can be marked visible but still be hidden if
|
||||
// the student cannot see the activity due to conditional access
|
||||
// and it's set to be hidden entirely.
|
||||
$instances = $this->gtree->modinfo->get_instances_of($grade_object->itemmodule);
|
||||
if (!empty($instances[$grade_object->iteminstance])) {
|
||||
$cm = $instances[$grade_object->iteminstance];
|
||||
if (!$cm->uservisible) {
|
||||
// Further checks are required to determine whether the activity is entirely hidden or just greyed out.
|
||||
if ($cm->is_user_access_restricted_by_group() || $cm->is_user_access_restricted_by_conditional_access() ||
|
||||
$cm->is_user_access_restricted_by_capability()) {
|
||||
// If there is 'availableinfo' text then it is only greyed
|
||||
// out and not entirely hidden.
|
||||
if (!$cm->availableinfo) {
|
||||
$hide = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,16 +147,17 @@ class core_grade_reportuserlib_testcase extends advanced_testcase {
|
|||
}
|
||||
|
||||
// Conditional activity tests.
|
||||
$DB->insert_record('course_modules_availability', (object)array(
|
||||
'coursemoduleid'=>$forum1cm->id,
|
||||
'gradeitemid' => 37,
|
||||
'grademin' => 5.5
|
||||
));
|
||||
|
||||
$cm = (object)array('id' => $forum1cm->id);
|
||||
$test = new condition_info($cm, CONDITION_MISSING_EVERYTHING);
|
||||
$fullcm = $test->get_full_course_module();
|
||||
|
||||
// Note: I have ported this test to the new conditional availability
|
||||
// system, but it does not appear to actually test anything - in fact,
|
||||
// if you remove the code that sets the condition, it still passes
|
||||
// because it apparently is intended to have the same number of rows
|
||||
// even when some are hidden. The same is true of the
|
||||
// set_coursemodule_visible test above. I don't feel this is a very
|
||||
// good test; somebody with more knowledge of this report might want to
|
||||
// fix it to check that the row actually is being hidden.
|
||||
$DB->set_field('course_modules', 'availability', '{"op":"|","show":false,"c":[' .
|
||||
'{"type":"grade","min":5.5,"id":37}]}', array('id' => $forum1cm->id));
|
||||
get_fast_modinfo($course->id, 0, true);
|
||||
foreach ($users as $user) {
|
||||
|
||||
$this->setUser($user);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue