239 Commits

Author SHA1 Message Date
Stephan Robotta
219d5bfb44 MDL-79758 qbank: add filter in pagination links
Contains some minor tweaks by Tim Hunt <T.J.Hunt@open.ac.uk>.
2024-06-27 09:22:31 +01:00
Anupama Sarjoshi
4e151ddf30 MDL-81407 qbank_columnsortorder: Fix error displaying hiddencols
When the question custom fields were deleted, if there were any
hidden columns in qbank Column sort order referring those fields they
were throwing 'Custom field does not exist' exception. Changes done to
ignore such fields and display valid hiddencols, as these references
were breaking the qbank Column sort order and Question bank pages.
2024-05-19 08:58:45 +01:00
Andrew Nicols
d26c40db26
Merge branch 'MDL-81114' of https://github.com/timhunt/moodle 2024-04-11 23:25:22 +08:00
Sara Arjona
54960f8e15
Merge branch 'MDL-81383' of https://github.com/timhunt/moodle 2024-04-11 12:49:29 +02:00
Tim Hunt
0b8c6bd64d MDL-81383 questions: get_filtered_questions order should be predictable
This method supports $limit and $offset paramters. The query must have
a predictable ORDER BY for that to make sense.
2024-04-11 10:25:50 +01:00
Tim Hunt
f17d5783e1 MDL-81227 question bank: improve the order of the action menu 2024-03-18 14:19:52 +00:00
Tim Hunt
3c724fecad MDL-81114 question: fix selection of random questions with draft status
We need to pick the latest 'ready' version of each question
(not questions where the latest version is ready).

There are test of the behaviour of random_question_loader, and
then a test in the quiz to prove it works in use.
2024-03-13 15:23:02 +00:00
Mathew May
886d86623e MDL-72438 question: Final deprecations 2024-03-11 13:26:18 +08:00
Tim Hunt
ff678d360a MDL-81114 question: clarify the SQL in ensure_filtered_questions_loaded
This should not change the (currently buggy) behaviour at all,
but my brain needs this to understand how to fix the bug.
2024-03-08 18:34:08 +00:00
Eloy Lafuente (stronk7)
ba1f804ffa
MDL-65292 style: Fix all function declarations white space
This has been generated running the following Sniffs, all
them part of the Moodle's CodeSniffer standard:
- PSR12.Functions.ReturnTypeDeclaration
- PSR12.Functions.NullableTypeDeclaration
- moodle.Methods.MethodDeclarationSpacing
- Squiz.Whitespace.ScopeKeywordSpacing

All them are, exclusively, about correct spacing, so the changes
are, all them, only white space changes.

Only exceptions to the above are 3 changes what were setting the
return type in a new line, and, when that happens, the closing
parenthesis (bracket) has to go to the same line than the colon.
2024-02-28 23:33:26 +01:00
Jun Pataleta
c67b184f4c
Merge branch 'MDL-79780' of https://github.com/timhunt/moodle 2024-01-11 10:44:41 +08:00
Tim Hunt
9ee42d0a34 MDL-79780 quiz_statistics: take advantage of get_fieldset method
This updates the MDL-79639 code.
2023-12-22 12:09:42 +00:00
Ilya Tregubov
b642d2710b MDL-79708 question_bank: Fix legacy filter condition.
build_query_from_filter method expects includesubcategories
to be inside filteroptions array
2023-12-11 11:27:21 +08:00
Mark Johnson
58c0f91375 MDL-79639 quiz_statistics: Prevent database deadlocks
This changes the cache purge code to select IDs for deletion
first, rather than using a subquery in a DELETE, since this
risks causing a deadlock in MySQL.
2023-10-19 08:59:07 +01:00
Jun Pataleta
98ac14eecb
Merge branch 'MDL-79531-master-1' of https://github.com/mihailges/moodle 2023-10-05 07:37:02 +08:00
Mihail Geshoski
451614016e MDL-79531 mod_quiz: Fix exception when adding random questions
Moves the data-filtercondition property to an element that always
exists regardless of whether the selected category from the filter
has questions or not. This will effectively solve the exception
that is being thrown due to the non-existing element and also
enable creation of random questions in a category that does not
have any questions yet. Also, the data-filtercondition attribute
is no longer used when creating a random question in a new category
as this value is not relevant in this case. Instead, a default
filter condition is generated in the webservice for the random
question based on the newly created category.
2023-10-04 12:31:12 +02:00
Andrew Nicols
be8093e2c7
Merge branch 'MDL-78580_master' of https://github.com/marxjohnson/moodle 2023-10-03 11:05:42 +08:00
Mark Johnson
0ac2936c11
MDL-74054 questions: Fix question bank header widths
Chrome ignores min-width on table headers with table-layout:fixed,
meaning that question bank headers could be resized so that the controls
were overlapping, and could be too narrow by default.

This removes min-width: min-content in the headers and instead uses
Javascript to calculate a constrain a min width based on the content of
the headers.
2023-09-22 22:52:36 +08:00
Andrew Nicols
a3cfd50482
MDL-74054 qbank: Miscellaneous coding style fixes 2023-09-22 10:53:53 +08:00
Mark Johnson
33e52fe4ed
MDL-74054 qbank_viewquestiontext: Convert from filter to question bank control
This replaces the "Show question text in the question list?" filter, which was
never really a filter, with a new widget displayed alongside other question bank
controls like "Create a new question" and "Reset columns".

It also refactors the logic of displaying the question text field or not, so that
it is all handled within the qbank_viewquestiontext plugin rather than relying on
code in the view.
2023-09-22 10:53:53 +08:00
Mark Johnson
63894ec2fe
MDL-74054 qbank_columnsortorder: Progressively enhance question bank actions
This modifies the question_data fragment used by the filter code to make its
parameters closer to the URL parameters of the question/edit.php page. This
Allows us to progressively enhance the add, remove and reset actions on the
question bank page, using this same fragment to reload the question table after
each change. This re-uses the same actions.js module used for enhancing these
actions on the qbank_columnsortorder admin screen.
2023-09-22 10:53:52 +08:00
Mark Johnson
37d69fff6b
MDL-74054 qbank_columnsortorder: Implement add, remove and resize
This updates the admin interface, and hooks into the question bank view
for users to override admin defaults with their preferences.
2023-09-22 10:53:52 +08:00
Mark Johnson
6001ee3dfd
MDL-74054 core_question: Define unique question bank column IDs
This also resolves MDL-78829.
Some question bank plugins use a separate class for each plugin they
define. However, qbank_customfields (and potentially others in the
future) uses a single class to define multiple fields. Using the class
name as an ID for the column doesn't give us a way of reliable
instantiating an object for the column. Previously, qbank_customfields
appended the field name as though it was a namespaced class, but this
had to be manually constructed and deconstructed by detecting this
particular column class.

This change introduces a standard way of constructing a unique ID for
each question bank column, in the form
pluginname\columnclass-columnname. This ensures that the ID will be
unique for each column, and the ID can be used to instatiate the
column's object.
2023-09-22 10:53:51 +08:00
Nathan Nguyen
2be0e10a80
MDL-74054 core_question: Add additional plugin points
This refactors the question bank view class to support new plugin points
required for the question bank UI customisation features.
2023-09-22 10:53:51 +08:00
Mark Johnson
feef716c91
MDL-74054 core_question: Re-apply filters when performing a qbank action
This changes the root element used by the fragment when
applying filters, so that the whole of display_question_list()
is reloaded.

This ensures that the returnurl will be updated correctly on the
question actions and bulk actions without manipulating then
further in Javascript.
2023-09-22 10:53:46 +08:00
Mark Johnson
a92e5c5770 MDL-78580 report_statistics: Prevent database deadlocks when viewing
If a quiz had a long job to calculate statstics running, this would
cause pages that may also attempt a recalculation (the statistics report
page or question bank) to load very slowly, and possibly result in a
database deadlock.

This change will firstly prevent the question bank page performing
analysis calculations at all, since these are not required for this
page, which will speed up loading and prevent deadlocks on this page.

Secondly, this adds a lock to the recalcuation process so that it cannot
run twice concurrently. This will present the user with a message to
indicate that it is waiting for a running calculation until it is
complete, and eventually it will timeout with a message and debugging.
2023-09-15 15:16:52 +01:00
Tim Hunt
a047d2f8b4 MDL-79332 Question stats: make loading robust to bad data
We were experiencing problems caused by old stats analysis in our
database, computed when there was a bug, causing fatal errors
when they were displayed. Therefore, this code needs to be robust to that.
2023-09-12 16:58:25 +01:00
Andrew Nicols
47cc73fe1a
MDL-72321 question: Ensure that all instance props are defined
Since PHP 8.2, all properties on a class must be defined as the PHP
Dynamic Property feature has been deprecated.

This commit goes one step further and switches this class to using
constructor property promotion. This language feature has been available
since PHP 8.0 and allows for simplified creation of class properties
which are initially defined in the constructor.
2023-09-01 09:52:33 +08:00
Nathan Nguyen
d9a75f5315 MDL-72321 core: backup/restore filter condition 2023-08-31 15:00:39 +01:00
Mark Johnson
823af3a8f1 MDL-72321 core_question: Replace old conditions with new datafilters 2023-08-31 15:00:39 +01:00
Andrew Nicols
de919962ea
Merge branch 'MDL-77328-master-fix' of https://github.com/junpataleta/moodle 2023-07-21 11:58:36 +08:00
Andrew Nicols
094f5dbb5b
Merge branch 'MDL-77745_master' of https://github.com/marxjohnson/moodle 2023-07-21 11:58:34 +08:00
Jun Pataleta
26905eeb93
MDL-77328 question: Declare $qbank as a proper view_component property 2023-07-21 11:57:14 +08:00
Andrew Nicols
3ed796bc10
Merge branch 'MDL-75125_master' of https://github.com/marxjohnson/moodle 2023-07-13 16:51:03 +02:00
Mark Johnson
ab8a4dd8cb MDL-77745 core_question: Show question version in info box 2023-07-13 11:11:43 +01:00
Tim Hunt
931a4cbd56 MDL-76996 question bank: fix errors when qbank_statistics is disabled 2023-07-12 11:46:38 +01:00
Jun Pataleta
d3767cb9f6
Merge branch 'MDL-78488' of https://github.com/t-schroeder/moodle 2023-07-06 11:17:03 +08:00
Ilya Tregubov
39662f1e32
Merge branch 'MDL-78608' of https://github.com/timhunt/moodle 2023-07-06 09:56:37 +08:00
Mark Johnson
f3e3bac918 MDL-78174 core_question: Build tertiary navigation using qbank plugins 2023-07-03 11:29:04 +01:00
Tim Schroeder
b42ca2cbbd
MDL-78488 question bank: don't load statistics when they are disabled 2023-06-30 11:39:04 +02:00
Tim Hunt
3534b31745 MDL-78608 question stats: avoid loading data for missing contexts
It turns out that there are plugins which don't (currently)
clean up their question attempts when a context is deleted.
Therefore, we need to make Moodle core robust to that.
2023-06-28 17:16:48 +01:00
Mark Johnson
0fd25d1edd MDL-75125 core_question: Deprecate old action column classes
Final removal in Moodle 4.7 MDL-78090
2023-06-02 11:42:02 +01:00
Mark Johnson
359bb7e31a MDL-75125 qbank: Convert qbank plugins to new actions API 2023-06-02 11:15:40 +01:00
Safat Shahin
be1bc85028 MDL-75125 core_question: Add action as a feature
This commit will implement question bank actions as a feature.
Previously, it used to implement columns and actions together in one
feature.
With this change it will have actions a different feature which will
allow
developers to implement actions in an easier way.

The existing "action column" API will be deprecated in a separate
commit.

Co-authored-by: Mark Johnson <mark.johnson@catalyst-eu.net>
2023-06-02 11:14:23 +01:00
Tim Hunt
ddd1ce66fd MDL-78327 question stats: store same timestamp for all question stats 2023-05-31 10:41:34 +01:00
Tim Hunt
60dbaa0065 MDL-75576 quiz/question statistics: don't expire by time
Previously, a set of calculated quiz statistics would only 'last' for
15 minutes. Then they would be considered invalid and not used.

Now, computed statistics are kept indefinitely. Instead, when a new
batch of values are computed for a particular set of settings, older numbers
for the same settings are deleted first. Therefore,
question_stats_cleanup_task is no more.
2023-05-15 10:01:27 +01:00
Tim Hunt
056db339d6 MDL-75576 question bank: bulk-load statistics for all questions at once
There is a new method on the column class, for the column to declare any
statistics it requires. The question then efficiently loads all those
statistics in one go, and makes them available as the columns are
rendererd, or do any subsequent processing.
2023-05-15 09:59:34 +01:00
Tim Hunt
25596a50e5 MDL-78025 questions: questions_in_use should check question_references
This avoids the needs for plugins to do separate queries, which is
easier for them, and better performing.
2023-04-26 15:29:38 +01:00
Marina Glancy
8fc1486d36 MDL-77164 various: fix incorrect phpdocs 2023-04-13 11:35:06 +01:00
Mark Johnson
23630ece3d MDL-75301 question: Add "always latest" option to previews 2023-04-05 10:23:47 +01:00