bdecentgmbh / moodle-availability_sectioncompleted

Moodle availability plugin which lets users restrict resources, activities and sections based on sections being completed
https://bdecent.de/product/restriction-by-section-completion/
GNU General Public License v3.0
8 stars 3 forks source link

Mod Assign error #6

Closed pliniopecanha closed 8 months ago

pliniopecanha commented 2 years ago

It seems a error about a condition not expected, it happened when I put a condition in a task type assignment.

Do you have any advice about it ?

Regards,

In Moodle 3.10.2

Erro de codificação detectado e deve ser corrigido por um programador: Not implemented (do not call unless is_applied_to_user_lists is true)

Outras informações sobre este erro Informações de depuração: Error code: codingerror Rastreamento de pilha:

line 192 of /availability/classes/tree_node.php: coding_exception thrown
line 340 of /availability/classes/tree.php: call to core_availability\tree_node->filter_user_list()
line 640 of /availability/classes/info.php: call to core_availability\tree->filter_user_list()
line 109 of /availability/classes/info_module.php: call to core_availability\info->filter_user_list()
line 2171 of /mod/assign/locallib.php: call to core_availability\info_module->filter_user_list()
line 2291 of /mod/assign/locallib.php: call to assign->list_participants()
line 5664 of /mod/assign/locallib.php: call to assign->count_participants()
line 5746 of /mod/assign/locallib.php: call to assign->get_assign_grading_summary_renderable()
line 675 of /mod/assign/locallib.php: call to assign->view_submission_page()
line 55 of /mod/assign/view.php: call to assign->view()
pliniopecanha commented 2 years ago

https://labs.bdecent.de/course/view.php?id=503 https://labs.bdecent.de/mod/assign/view.php?id=3699

Here also the same thing happens in version 4.0

JosephKennedy4 commented 2 years ago

We are also having this problem in Moodle 4.0.3 (build 20220822). If we remove a section restriction (must have completed a prior section), then Assignments in the restricted section work. If we leave that restriction in place, the Assignments cannot be accessed, although they can be editing. When clicking the More - Overrides option of assignments in restricted sections, we again see this same error.

EDIT: I added myself in student role to the course, and manually checked completion for each activity in the section being used as a restriction condition. This made no difference; I still received the error when I attempted to view the Assignment.

stefanscholz commented 2 years ago

Morning @pliniopecanha @JosephKennedy4,

I think we're talking about several unrelated issues here.

1) When we built the plugin, we did not account for activities that don't have activity completion. We had very simple, linear courses in mind in which every activity had activity completion enabled; others would simply be added to another section. If you have development resources, feel free to provide a pull request. We're happy to do it too, but we're currently in the middle of releasing several updates to other plugins and have to focus on that. But we'll do that in the next release if you don't have resources.

2) The test course you @pliniopecanha set up was configured incorrectly - you had added two restrictions, but only configured one of them. I've removed the second one and now it works as expected. Also, it did not really make sense to have the section completion restriction twice, both for the section and the assignment, which is why I removed the second, obsolete one for the activity.

3) I don't understand how to reproduce the issue about the assignments, can you @JosephKennedy4 please create a separate issue for this and describe in detail how to reproduce this issue? Ideally, a test course in labs.bdecent.de would help (I'll update it to 4.03 shortly)

Thanks for supporting us, appreciate it! Best Stefan

pliniopecanha commented 2 years ago

Thanks Stefan! I understand now how it works and it only considers activities with the completion setting enabled.

For the task module, I solved it here by conditioning a Quiz module that is before the task module.

Regards

nazbav commented 1 year ago

Hello, can you tell me why such an error occurs when logging in from the administrator \ teacher?

image

Course:

image

suvires commented 1 year ago

This is a bug. When you are an administrator or a professor, if an assessment task is in a topic that has a section restriction, you cannot access it.

@stefanscholz have you plan to fix it?

ahlaifloresprepa commented 1 year ago

condition.php I commented out the 'function is_applied_to_user_lists()' and apparently the error with users who have editing permissions disappeared. However, further testing needs to be conducted to ensure there are no subsequent complications (Moodle 3.11)

suvires commented 1 year ago

condition.php I commented out the 'function is_applied_to_user_lists()' and apparently the error with users who have editing permissions disappeared. However, further testing needs to be conducted to ensure there are no subsequent complications (Moodle 3.11)

Have you experiment any complications after comment this functions?

Thanks!

LeonardoRafer commented 11 months ago

/moodle/availability/condition/sectioncompleted/classes/condition.php

The function _is_applied_to_userlists() must return false. That's the solution. Apparently the base plugin used to create the "section condition" was the "group condition". For the group condition it makes sense return true because it's a permanent condition (or you belong to the group or not). But, for the section condition we don't need to return true.. it's not a permanent condition =) Because as soon the users complete the requirement they'll have access to the section. The focus is on a user action and not on the user by itself.

Edit:

https://moodledev.io/docs/apis/subsystems/availability#display-a-list-of-users-who-may-be-able-to-access-the-current-activity

Dev note for the function _is_applied_to_the_userlist() (moodle/availability/classes/tree_node.php):

 * Checks whether this condition applies to user lists. The default is
 * false (the condition is used to control access, but does not prevent
 * the student from appearing in lists).
 *
 * For example, group conditions apply to user lists: we do not want to
 * include a student in a list of users if they are prohibited from
 * accessing the activity because they don't belong to a relevant group.
 * However, date conditions do not apply - we still want to show users
 * in a list of people who might have submitted an assignment, even if they
 * are no longer able to access the assignment in question because there is
 * a date restriction.
 *
 * The general idea is that conditions which are likely to be permanent
 * (group membership, user profile) apply to user lists. Conditions which
 * are likely to be temporary (date, grade requirement) do not.
 *
 * Conditions which do apply to user lists must implement the
 * filter_user_list function.
stefanscholz commented 8 months ago

Fixed in version Version 1.03 (currently on dev branch, will be merged to main once testing complete and released to plugin db).