Topic progress indicator with restricted items gives the wrong results.

Issue #16 closed
Peter Gee created an issue

When a topic has restricted items and you are viewing the content in student role, the tile progress indicator is not giving expected results:

For example in a module we have four items: there are restrictions to cause the ‘revision quiz’ and ‘exam’ to not show their activity completion status at this point in time.

The tile heading for this topic is:

It is reporting that 1 of 2 items is complete. However there are four items in the topic- students would find this confusing.

in course_output.php i changed section_progress from:

private function section_progress($sectioncmids, $coursecms, $completioninfo) {
        $completed = 0;
        $outof = 0;
        foreach ($sectioncmids as $cmid) {
            $thismod = $coursecms[$cmid];
            if ($thismod->uservisible && !$this->treat_as_label($thismod)) {
                if ($completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
                    $outof++;
                    $completiondata = $completioninfo->get_data($thismod, true);
                    if ($completiondata->completionstate == COMPLETION_COMPLETE ||
                        $completiondata->completionstate == COMPLETION_COMPLETE_PASS
                    ) {
                        $completed++;
                    }
                }
            }
        }
        return array('completed' => $completed, 'outof' => $outof);
    }

to:

private function section_progress($sectioncmids, $coursecms, $completioninfo) {
        $completed = 0;
        $outof = 0;
        foreach ($sectioncmids as $cmid) {
            $thismod = $coursecms[$cmid];
            if ($thismod->visible && !$this->treat_as_label($thismod)) {
                if ($completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
                    $outof++;
                    $completiondata = $completioninfo->get_data($thismod, true);
                    if ($completiondata->completionstate == COMPLETION_COMPLETE ||
                        $completiondata->completionstate == COMPLETION_COMPLETE_PASS
                    ) {
                        $completed++;
                    }
                }
            }
        }
        return array('completed' => $completed, 'outof' => $outof);
    }

note line 6 changes from $thismod->uservisible to $thismod->visible

then we see:

which is what we expect.

I am not great at moodle, and it appears to work but i don’t know if using this visible flag (which is string ‘1’ in the debugger) is the best fix.

Comments (5)

  1. David Watson repo owner

    Hi Peter I have not had a chance to look at this properly yet, and it will be a while before I can come back to it unfortunately.

    My initial reaction is that this may well be correct already, so no change needed. I say this based only on a superficial examination, but initial signs are that this may be the way core does it, and in that sense it’s “correct”. From the quickest of glances at format_section_renderer_base\section_activity_summary() it does seem that they are using uservisible too. Since the two restricted items don’t have check boxes showing, I can see the logic in excluding them from the count (i.e. 1/2 not 1/4) though I take your point and it’s not clear cut.

    It would be useful to know how it appears if you switch the course into a core format like “Topics” - did you try that already? With these things, there’s always room for debate about which way is clearer for users but, in those cases, I’d usually assume that core had already had that debate, so it was safe for “Tiles” to follow what they do.

  2. Peter Gee reporter

    Hi David

    I don’t have the show topic progress percentage with my versions fo topics format. I can’t see an option to view that progress. it looks like something you have added in the tiles format.

    The weird thing for me is that the results change depending on my role.

    as an admin i see:

    switching my role to a student i see:

    The version with 25% is what i would have expected to see based on the completion. I can well imagine the moodle forums debating this ad-infinitum. I guess it is about the intent of restrictions. if the restriction intent is to never show the student the content, then the latter is correct. If the intent is to later show the content, the former is correct. In our case it is the former, so it looks wrong to me.

  3. David Watson repo owner

    Hi Peter the place that the equivalent information would appear in the “Topics” format would be on the right of the section as below. This isn’t always visible but it should be if, under Course Admin > Edit Settings > Format > Course layout, you have selected “Show one section per page”.

    I’d be happy to come back to this for Tiles if it differs from core

  4. Log in to comment