mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-63959 mod_feedback: Fixed nested dependency handling
For example the dependecy chain is the following: A->B->C. When a question (A) depends on another dependent item (B) and B hasn't displayed (because of C's response), the $value for the B's response will be null. In this case the can_see_item() method returned null. Because the can_see_item() returned null (not false), the get_pages() method displayed the question A, because it checks for explicit false: $this->can_see_item($item) !== false. Now, false is also returned, if the dependent question is not visible.
This commit is contained in:
parent
14cdf51189
commit
5b8d533067
1 changed files with 8 additions and 1 deletions
|
@ -147,7 +147,10 @@ class mod_feedback_completion extends mod_feedback_structure {
|
|||
*
|
||||
* @param stdClass $item
|
||||
* @return bool whether user can see item or not,
|
||||
* null if dependency is broken or dependent question is not answered.
|
||||
* true if there is no dependency or dependency is met,
|
||||
* false if dependent question is visible or broken
|
||||
* and further it is either not answered or the dependency is not met,
|
||||
* null if dependency is broken.
|
||||
*/
|
||||
protected function can_see_item($item) {
|
||||
if (empty($item->dependitem)) {
|
||||
|
@ -165,6 +168,10 @@ class mod_feedback_completion extends mod_feedback_structure {
|
|||
$value = $this->get_values_tmp($ditem);
|
||||
}
|
||||
if ($value === null) {
|
||||
// Cyclic dependencies are no problem here, since they will throw an dependency error above.
|
||||
if ($this->can_see_item($ditem) === false) {
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return $itemobj->compare_value($ditem, $value, $item->dependvalue) ? true : false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue