Commit Graph

11 Commits

Author SHA1 Message Date
Mihail Geshoski 1ec2077191 Merge branch 'MDL-87287_main' of https://github.com/marxjohnson/moodle 2026-01-20 10:34:41 +08:00
Huong Nguyen 3aa7774f26 Merge branch 'MDL-85431_main' of https://github.com/marxjohnson/moodle 2026-01-16 15:18:06 +08:00
Mark Johnson 2fd133a905 MDL-87287 mod_qbank: De-duplicate tags when migrating questions
In the migration from old-style question banks to mod_qbank, if a
question had the same tag from multiple contexts, when it was moved to
its new question bank context, the migration tried to set multiple tag
instances for the same tag to the same context, which caused a unique
key violation.

This add some checking to the
`question_move_question_tags_to_new_context` function to identify any
tag instances to be moved that will trigger this key violation, and
delte any duplicates before the move so we end up with a single instance
of the tag in the new context. This is done in a transaction that will
only be committed once the remaining tags have been moved.

This required adding the `tiuserid` field to the data returned by
`core_tag_tag::get_items_tag` so we can assemble the unique key without
having to do additional queries.

This also extends the test coverage for the `transfer_questions` task
to ensure tags are moved to the new contexts, and tags on stale questions
are deleted.
2026-01-09 10:40:00 +00:00
Mark Johnson 8209e0581b MDL-85431 questions: Fix access checks on Question banks page
Users who could not manage activities on a course, but did have
permission to access particular question banks, could not access the
Question banks page.

This modifies the permission checks on that page to allow access if the
user can either manage activities, or has access to at least one
activity that publishes questions. Some additional changes to the output
were required to prevent non-editing users adding banks.

It also modifies the navigation hook to add the Question banks
navigation node if the user can access any activitiy that publishes
questions on the course. This is all based on cached modinfo and
permissions data so should remain performant.
2026-01-05 15:19:45 +00:00
Mark Johnson c25d5fd063 MDL-86798 questions: Track next version for question bank entries
This adds a new "nextversion" field to `question_bank_entries` to track
which version number the next version of the question should have. This
ensures that version numbers are not re-used if the latest version is
deleted.

To use this field, you must call
`\core_question\versions::get_next_version()`. This will initialise the
field to the correct value if it is currently null.

If you create a new version using this value, you must then call
`\core_question\versions::increment_next_version()` to increment the
counter.
2025-12-19 09:45:27 +00:00
Daniel Poggenpohl ab1c3d2b59 MDL-87017 blocks: Provide page context to page_type_list functions
- The current context may be necessary when deleting a frontpage block displayed on every page with javascript disabled
- The current context may be necessary when a frontpage block is displayed on every page and the question bank is viewed
- Also handle a NULL currentcontext for question_page_type_list() correctly
2025-11-14 15:30:50 +01:00
hieuvu 53f306ef55 MDL-86621 core_question: Add capability checking for question bank node 2025-10-15 23:16:26 +08:00
hieuvu af360dbf2e MDL-86621 core_question: remove incorrect navigation nodes. 2025-10-13 15:34:21 +07:00
Mark Johnson ad277fbd8b MDL-85551 questions: Increase category name field size
This increases the maximum length of category names in line with the
increased activity names from MDL-83985, avoiding issues when generating
a default category.
2025-08-12 14:03:26 +01:00
Mihail Geshoski 3ec78bc079 Merge branch 'MDL-84466_main' of https://github.com/marxjohnson/moodle 2025-07-16 13:19:23 +08:00
Andrew Nicols f747c15cbf MDL-83424 core: Restructure Moodle codebase 2025-07-12 17:51:38 +08:00