411 Commits

Author SHA1 Message Date
Mathew May
886d86623e MDL-72438 question: Final deprecations 2024-03-11 13:26:18 +08: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
Tim Hunt
049bff63bc MDL-79527 questions: category tree loading handling bad data
It should always be the case that a question category and its parent
category belong to the same context. However, over the years, we have
observed that this becomes violated by some data in some Moodle sites.
(The suspicion is that this is a backup/restor bug of some sort which
has never been tracked down.)

Since this happens, we should make the code robust to it, which is what
this change does. It ensure that when loading child categories, we only
consider ones in the same context.
2024-02-02 11:26:57 +00:00
Paul Holden
3b525fa234
MDL-79073 question: detect missing context when deleting question. 2023-08-22 09:41:15 +01:00
Mark Johnson
1055a2c1c2 MDL-78815 qbank_comment: Delete comments in event observer 2023-08-02 08:34:59 +01:00
Mark Johnson
a2c8eed5c8 MDL-78815 qbank_customfields: Delete custom field data in event observer 2023-08-02 08:34:59 +01:00
Mark Johnson
36ab582177 MDL-78815 qbank_tagquestion: Delete tags in event observer 2023-08-02 08:34:59 +01:00
Tim Hunt
6a4341549d MDL-78025 questions: fix PHPdoc on question_require_capability_on 2023-04-26 15:29:39 +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
Tim Hunt
37e8115d68 MDL-78025 question: move hiding logic into question_delete_question
This logic belongs in the API, so it is applied consistently.

Also this avoids calling the expensive function questions_in_use
twice per question.
2023-04-26 10:49:32 +01:00
Marina Glancy
8fc1486d36 MDL-77164 various: fix incorrect phpdocs 2023-04-13 11:35:06 +01:00
Tim Hunt
de086efd41 MDL-77462 core_question: avoid passing null to preg_match 2023-03-03 08:46:00 +00:00
Tim Hunt
4484757021 MDL-76843 quiz: fix statistics questions for missing questions 2023-02-22 14:30:23 +00:00
Tim Hunt
a9f8547599 MDL-76614 quiz: rename quiz => mod_quiz\quiz_settings 2023-01-06 14:35:54 +00:00
Safat Shahin
0fcea11234 MDL-74768 core_question: Fix for question category movement 2022-07-14 11:11:54 +10:00
Tim Hunt
5fff990e25 MDL-74255 quiz: clean up lots of stuff mainly in the tests
This fixes lots of stuff like outdated or incomplete PHPdoc comments
or test heler functions where the arguments don't have their types
declared.

A few more significant fixes, like places were a silly method
was used to get a context which was readily available.
2022-04-08 12:19:52 +01:00
Eric Merrill
29f83023a6 MDL-74299 question: Don't use a strict comparison for DB objects 2022-03-23 19:20:22 -04:00
Cameron Ball
53d3843955 MDL-54724 qtype_multianswer: Better handle corrupted questions
When questions are deleted, we now check if the parent is in use before deletion.

Prior to this, it would be possible for multianswer questions to reference
questions that have been deleted. This results in fatal errors when the quiz
is viewed.

This patch uses a dummy 'subquestion_replacement' to handle this case and
display some information to the end user about what has happened so that
they may take action to repair the corrupted question.

As a result of the bug described above, the sequence column of
mdl_question_multianswer can contiain references to questions that no
longer exist, and these IDs can make their way in to backups.

When this happens, the backups cannot be restored. To avoid this,
this patch skips trying to restore those questions that reference
question IDs that no longer exist (as there is no way to recover them).
2022-03-02 17:12:19 +08:00
Safat Shahin
bf55e5a481 MDL-71696 core_question: class autoload changes
This commit implements some class autoloading
fixes to align with core question structure.
2022-02-03 22:22:50 +11:00
Safat Shahin
3008edd366 MDL-71696 core_question: Implement question status change
This commit implements the status change pop up for a question
in the base view. This feature update will allow the change of
status of a question without creating a new version.
This commit also implements the status as a char rather than
an int value.
2022-02-03 22:22:50 +11:00
Marc-Alexandre Ghaly
b1ad75aef5 MDL-71696 qbank_preview: previewquestion plugin update
This commit implements versioning and associated features
in the previewquestion plugin. There have been some major
changes in the random question and version selection for
questions. This commit made those changes as well as added
some more features in the preview for version selection
and adds more behat coverage.
2022-02-03 22:22:50 +11:00
Safat Shahin
111951d861 MDL-71696 mod_quiz: quiz updates and behat coverage
The versioning changes will require some major changes
in the backup and restore of question bank and its
elements. This change introduces those changes to make
it compatible with the new world of versioning in question
bank. This commit also removes quiz_slots fields and
quiz_slot_tags table.
This commit will also introduce the versioning db
structure and some major changes to the quiz
and quiz attempts for the question, random
question and the view.
This commit implements the behat changes for versioning
in core question and associated locations.
2022-02-03 22:22:44 +11:00
Guillermo Gomez
c6cfca2a08 MDL-71696 core_question: Changes for versioning
This commit adds the changes in questiontype base
to work with new question tables and the new structure in the
databse. Also needed for versioning.
This implementation will also introduct the question status
which allows a question to be in draft and ready status.
I also introduces changes to the base view where it shows
the latest version of the questions. The view of versions
for a question is not implemented in this commit.
This implementation will also introduce changes in the core
qtype plugins to support versioning and the changed
db schema.
2022-02-03 22:22:44 +11:00
Matt Porritt
556e2f1aec MDL-72553 qbank_customfields: Add custom fields for question types
Custom fields can now be added to question types.
Site administrators can configure the custom fields and
filed types available. Teachers and question creators can
then use these fields for extra question metadata when
creating questions. Question creators can control if
the fields are displayed to students when they are
taking a quiz or not.
This features uses the core Moodle custom field API.

Co-Authored-By: Matt Porritt <mattp@catalyst-au.net>
Co-Authored-By: Safat Shahin <safatshahin@catalyst-au.net>
Co-Authored-By: Marc-Alexandre Ghaly <marc-alexandreghaly@catalyst-ca.net>
2021-12-07 18:32:41 +11:00
Guillermo Gomez
3be2b123e5 MDL-71642 qbank_comment: Add question comment plugin to core
This implementation will introduce a qbank plugin
"comment" which will allow users with the capability
to comment in a question. It also implements a
callback for the question preview page to view
and add comments from the preview page. Comment
plugin is implemented using the existing comments
API from the core.

Co-Authored-By: Guillermo Gomez Arias <guillermogomez@catalyst-au.net>
Co-Authored-By: Safat Shahin <safatshahin@catalyst-au.net>
Co-Authored-By: Matt Porritt <mattp@catalyst-au.net>
2021-10-08 14:48:13 +11:00
Safat Shahin
f9fc355ec7 MDL-71679 mod_quiz: Updates for new qbank api
This implementation will introduct changes to
the mod_quiz to implement the new qbank api
for view. Major changes are introduced in
the custom view and also all the legacy points
to the old qbank are changed to qbank plugins
where needed. It also deprecated and deletes
classes and scripts which were kept not to
break mod_quiz for the new api implementation.
2021-10-04 15:44:25 +11:00
Sara Arjona
5c78efaaea Merge branch 'master_MDL-71614-previewquestion' of https://github.com/catalyst/moodle-MDL-70329 2021-09-08 09:29:22 +02:00
Safat Shahin
0d55b26da8 MDL-71614 qbank_previewquestion: Add Preview question plugin to core
This implementation will introduce a qbank plugin "previewquestion"
which will view the preview question action in the question bank
actions by replacing the core classes, scripts and yui modules.
This plugin will also replace the preview option in the edit
question form. Having this plugin will give users the
flexibility of enabling or disabling this feature from
the question bank view.
This change will also allow other qbank plugins to add
elements or information in the preview question page
by implementing a callback. It also changes the pop
up to page redirect from base view page to make sure
any changes in preview reflects in the base view, for
example, comments added and the number of comments in
the comments colum changes while back from the preview
page. Other locations like edit and qtype plugins where
the preview is implemented, stays the same.

Co-Authored-By: Guillermo Gomez Arias <guillermogomez@catalyst-au.net>
Co-Authored-By: Safat Shahin <safatshahin@catalyst-au.net>
2021-09-08 16:21:06 +10:00
Sara Arjona
3b903ae45d Merge branch 'master_MDL-71585-managecategories' of https://github.com/catalyst/moodle-MDL-70329 2021-09-06 10:39:06 +02:00
Guillermo Gomez
fb10b36c04 MDL-71585 qbank_managecategories: Add managecategories to core
This implementation will introduce a qbank plugin "managecategories"
which will add the question categories feature in the question bank view
by replacing the core classes. Having this plugin will give users
the flexibility of enabling or disabling the category tab.
2021-09-03 09:41:18 +10:00
Safat Shahin
c1797c6c9e MDL-71639 qbank_exporttoxml: Add Export to xml plugin to core
This implementation will introduce a qbank plugin "exporttoxml"
which will implement the export to xml action in the question
bank view by replacing the core class. Having this plugin will
give users the flexibility of enabling or disabling this action.
2021-09-02 21:21:57 +10:00
Guillermo Gomez
06f192aec9 MDL-71573 qbank_exportquestion: Add plugin to core
This implementation will introduce a qbank plugin "exporquestions"
which will add the export feature in the question bank view
by replacing the core classes. Having this plugin will give users
the flexibility of enabling or disabling the export questions tab.

Co-Authored-By: Guillermo Gomez Arias <guillermogomez@catalyst-au.net>
2021-08-23 12:06:20 +10:00
safatshahin
dfed4fd040 MDL-71516 core_question: Qbank api implementation
This commit implements the qbank api so that any plugin
can implement its own question bank. This api currently
works parallely with the moodle core classes and the
added qbank in the core, means the moment a plugin
is installed, that object is replaced with the object
from the plugin instead of core, which means the api
has flexibility till the plugins are integrated and the
plugins can be integrated in any order.

All the old classes are still there and not deprecated
as there is a different tracker for the changes to the
quiz and another tracker for class deprecation and
class renaming. Core question units tests are pointing
to the new api structure but the classes are pointing
to the location related to the plugin availability.

Co-Authored-By: Luca Bösch <luca.boesch@bfh.ch>
Co-Authored-By: Guillermo Gomez Arias <guillermogomez@catalyst-au.net>

one more array fix
2021-08-17 18:57:31 +10:00
Luca Bösch
7dd58aac64 MDL-60331 questions: prevent double escaping question categories. 2021-04-28 17:30:46 +02:00
Tim Hunt
5fbb14524d MDL-69077 questions: question tag capabilties are relevant 2020-06-17 13:06:57 +01:00
Martin Hanusch
08fe534986 MDL-63284 question: Moving questions with tags disabled bug fix 2020-05-29 16:42:04 +02:00
Adrian Greeve
b2978c1787 Merge branch 'MDL-68757' of https://github.com/timhunt/moodle 2020-05-26 10:33:03 +08:00
Victor Deniz Falcon
a735d4d1d4 Merge branch 'MDL-68252' of https://github.com/timhunt/moodle 2020-05-26 00:55:02 +01:00
Tim Hunt
4a45b7112c MDL-68757 questions: don't do output in low-level functions 2020-05-18 20:54:27 +01:00
Tim Hunt
1d47cb2168 MDL-68615 questions: fix fiendish default idnumber edge case 2020-05-05 16:19:54 +01:00
Tim Hunt
fa7431ce50 MDL-68252 question tags: fix tag editing for missingtype questions 2020-04-24 11:26:12 +01:00
Tim Hunt
7459856d26 MDL-68300 questions: un-break duplicating questions without idnumbers
This was a regression caused by MDL-67934
2020-03-31 11:00:39 +01:00
Jake Dallimore
9b8fc9be6d Merge branch 'MDL-67934' of https://github.com/timhunt/moodle 2020-03-25 08:28:27 +08:00
Tim Hunt
f2393804bf MDL-67934 questions: give a sensible default idnumber when duplicating 2020-03-12 18:07:11 +00:00
Tim Hunt
1b6b554118 MDL-67981 questions: avoid errors deleting contextless questions 2020-03-06 17:57:11 +00:00
Eloy Lafuente (stronk7)
2b97ab8adb Merge branch 'MDL-67947' of https://github.com/timhunt/moodle 2020-02-19 17:48:14 +01:00
Tim Hunt
887daf932c MDL-67947 questions: questions_in_use should ask all components
Previously it was only checking mods.
2020-02-19 11:55:04 +00:00
Sara Arjona
855d4db87a Merge branch 'bugfix-MDL-67142' of https://github.com/AngadSethi/moodle 2020-02-11 10:18:49 +01:00
Angad Sethi
86127e774f MDL-67142 quiz: fixed error when deleting saved questions long-name-quiz
An error was showing up while deleting questions
(in the question_save_from_deletion method) which had been saved
and which belonged to a quiz with a super long name, not exceeding 255
characters, as the 'name' field in 'question_categories' table had a
max size of 255 characters. The shorten_text function was used to
shorten the string to 255 characters and a unit test was added with
the name test_question_save_from_deletion_quiz_with_long_name to test
the patch.
2020-02-08 19:40:44 +05:30
Tim Hunt
1aacbb72d3 MDL-67832 quiz: fix lots of PHPdoc in attemptlib.php 2020-01-31 19:09:03 +00:00