studentquiz / moodle-mod_studentquiz

Moodle-Plugin
GNU General Public License v3.0
38 stars 37 forks source link

StudentQuiz: Student can view and attempt the questions that belong t… #459

Closed BruceGoodGuy closed 1 year ago

BruceGoodGuy commented 1 year ago

Hi @timhunt ,

I have resolved this ticket by updating the function require_access_to_a_relevant_group. After spending time investigating this issue, I realized that the function require_access_to_a_relevant_group only covers cases where the user doesn't have the current group and tries to access the student quiz with the group mode set to separate groups.

However, in situations where the user has another group that does not belong to the valid group, this function does not handle it properly. Therefore, I believe it's necessary to update this function to address this scenario.

Regarding the use of exit() in this function, it makes it challenging to write unit tests for it when it always stop the code flow, so that I can't write Unite test for it. Commit ID: 4cbcd6d8b267e83f7ff29616fa2df3a08aeb0d94 I'd appreciate your feedback on my changes. Please let me know your thoughts. Thank you.

timhunt commented 1 year ago

Sorry, but groups_get_user_groups is not the right function to use. We don't want course groups here, just the ones relevant to this activity, so it should be groups_get_activity_allowed_groups.

Except that, should not be implementing this logic yourself if you don't need to, and I think groups_group_visible does exactly what you need.

timhunt commented 1 year ago

Thanks. That makes sense now. Merging.