58 Commits

Author SHA1 Message Date
Mark Johnson
ab8a4dd8cb MDL-77745 core_question: Show question version in info box 2023-07-13 11:11:43 +01:00
Tim Hunt
1a3897d1ba MDL-77464 questions: regrading was losing question_attempt metadata
This is very similar to MDL-77090, but at the time, I missed that this
also needed to be handled. (Question metadata is, I think, only used
by the quiz 'Try another question like this one' feature.)
2023-03-07 13:40:10 +00:00
Andrew Nicols
6b05cf75a8 Merge branch 'MDL-76582-master' of https://github.com/NashTechOpenUniversity/moodle 2023-02-16 11:25:11 +08:00
Tim Hunt
484828957a MDL-77090 questions: regrade of interactive attempts lose tries count
The behaviour-specific data was getting corrupted when the regrade
recreated the first step, because $oldstep->get_behaviour_data() was
stripping off the leading '-' characters from the names, and they were
not being added back.
2023-02-02 14:34:19 +00:00
hieuvu
2b6bf085af MDL-76582 question: Allow response filearea to have different pattern 2023-01-09 09:26:52 +07:00
Marina Glancy
41b93bd7e5 MDL-73424 general: Internal methods must have same type as parent
Otherwise the error is thrown in PHP8.1
2022-10-10 16:46:13 +02:00
Tim Hunt
39abc01197 MDL-74752 question regrading: implement the required hooks
This commit implements the necessary core hooks to ensure we only
allow a regrade of a quetion attempt to take place if the new and old
versions of the question are sufficiently similar.

It will be followed by commits to each question type where the
new method needs to be implemented.

Automated tests will be included in the first of those (mulitple choice)
becuse we need a question type that implements the hooks to test
the core changes.
2022-05-31 09:22:22 +01:00
Tim Hunt
de3d216c5a MDL-69246 questions: allow for float issues when validating manual marks
As well as fixing the bug, I also rewrote the test to use
data providers, which should lead to more useful failure messages.

And, I moved the magic number we used as the float tolerence to
be a named constant.
2020-08-27 17:37:31 +01:00
Tim Hunt
9cbbb779eb MDL-67183 question engine: allow lazy-init of question_attempts
That is, we don't call apply_attempt_state as soon as a
the data is loaded from the database. Instead, we wait
and only call it if really needed.

This should (especially after the next commit) be a performance win
during quizzes, particularly for people using advanced question
types liks STACK, or people making extensive use of the
'Try another question like this one' feature.
2020-05-19 20:49:33 +01:00
Martin Gauk
09fd8aec27 MDL-58026 question: fix regrading in progress attempt
Do not convert autosave steps to true steps when regrading.

Thanks Eric Merrill for providing the unit test code.
2019-07-08 09:35:34 +00:00
Andrew Nicols
dd457c4fa6 Merge branch 'MDL-65245' of https://github.com/timhunt/moodle 2019-05-03 10:50:32 +08:00
Tim Hunt
be492e2a8f MDL-65245 question engine: response vars should always be PHP strings 2019-04-02 16:32:40 +01:00
Tim Hunt
6c91e515b0 MDL-65245 question_attempt: fix PHPdoc and other PHPstorm warnings 2019-04-02 16:32:36 +01:00
Tim Hunt
f1ffd134d3 MDL-65029 questions: change question div id to acutally be unique
This is largely based on Simey Lameze's work.
2019-03-29 13:37:44 +00:00
Tim Hunt
802ff4c933 MDL-63371 question: USE_RAW_DATA case in check_qt_var_name_restrictions 2018-09-14 16:43:41 +01:00
Andrew Hancox
f3d9872aa3 MDL-41090 questions: Allow embedding files in response comments 2018-01-15 11:19:06 +00:00
Andrew Hancox
18e1450b4b MDL-41090 questions: Support for files in behaviour response 2018-01-09 21:12:58 +00:00
Tim Hunt
808b68835b MDL-60139 question manual grading: redisplay mark as typed if editing
When the teacher is upgrading a previously entered grade, we re-display
exactly what they typed before if possible, rather than displaying with
a set number of decimal places.
2017-10-30 12:52:02 +00:00
Tim Hunt
2d708a7365 MDL-57588 questions: regrading should not lose flags 2017-01-30 14:31:52 +00:00
Tim Hunt
b2694c0219 MDL-51090 question: further refinements to validating manual grades 2015-09-01 23:05:37 +01:00
Nelson Moller
52b08f5fce MDL-51090: mod_quiz grading validation of an essay question
An invalid format is casted to 0 (if a string) or to some truncated value in other cases (ex: 10..5).
2015-08-20 19:58:49 +01:00
Tim Hunt
f6579bea94 MDL-40992 question engine: new ways modify question usages
* A method to change the max mark for one question_attempt in the usage

* A method to replace one question in a usage with another, moving the
old question_attempt to the end.

* Methods to set and get metadata (string name value pairs) for each
question_attempt in the usage. This gets stored in the first step in a
way that should not interfere with anything else.
2015-03-26 17:46:48 +00:00
Tim Hunt
fd7a8af50b MDL-40990 qbehaviours: method to say if attempts can finish naturally 2015-03-13 14:23:02 +00:00
Tim Hunt
a8de866712 MDL-47740 question engine: let qs update variant later if appropriate
Variant has two purposes. First to determine which version of the
question the student will see. Hence it is used to set up the state
of the quetsion when the question is started. Then the internal state of
the question is saved in the first step.

Once that has been done, the variant number is purely informative, and
just used to break down the statistics.

In some cases (the one I have in mind is qtype_opaque) then there is a
complex randomisation process, which may lead to several inital variant
numbers acutally giving the same version of the question. In this case
it is nice if the question can update the stored variant number, to make
the statistics more meaningful.
2014-10-21 11:43:57 +01:00
Tim Hunt
f4fe3968a2 MDL-46212 questions: add {} whenver vars are put into "" strings
Having had one subtle bug cased be this, I decided to do a search and
fix all of these.
2014-07-03 14:02:39 +01:00
James Pratt
038014c415 MDL-41760 quiz_statistics : response analysis for first/last/all tries 2014-03-18 18:47:19 +07:00
James Pratt
99caa248a8 MDL-43478 quiz responses report : display last / first / all tries
when using multiple try question behaviour
2014-02-23 13:39:08 +07:00
Tim Hunt
1eb470fc42 MDL-43929 question manual grading: keep comment when validation fails.
If the validation failed, so the manual grading page was re-displayed
with a validation error, then any comment that had just been typed in
was getting lost. This fixes that.
2014-02-07 21:55:05 +00:00
Tim Hunt
3d96b4945a MDL-43733 use any auto-saved responses when questions are finished.
Before this, autosave was only working to save data when a student went
back in to continue an attempt. If the student, having crashed out,
never went back in and continued the attempt, their auto-saved responses
were not used when the attempt was automatically finished. That was a
rather bad oversight, which should now be fixed.
2014-01-17 16:58:13 +00:00
Tim Hunt
4e3d829350 MDL-42105 questions: let attempts have a max fraction > 1.
This parallels question_attempt->minfraction, which allows the
fractional mark to go below zere.

This is needed to allow the certainty-base marking behaviours to work
better.
2013-10-04 17:52:19 +01:00
Jamie Pratt
d50b05e696 MDL-41751 changes to api of question_response_analyser
and code refactoring and clean up.
2013-09-27 17:38:13 +07:00
Tim Hunt
afb1b3d03b MDL-39980 question engine: Attempt on last loses response files
When doing Each attempt builds on last, we need to copy any response
files into a draft file area, and then re-save them.

While writing the unit test for this, I had to deal with a todo in the
question engine so that questions with files in the response could be
unit-tested.

I also found an fixed a bug with qtype_essay_question::is_same_response
and fixed some notices in the existing essay/manual graded unit tests.
2013-08-15 12:55:13 +01:00
Tim Hunt
df7d175d0f MDL-41091 questions: fix get_all_submitted_qt_vars for unit testing. 2013-08-08 14:41:53 +01:00
Ruslan Kabalin
f8e28244cb MDL-31226: quiz: Fix message for attempts built on previous.
At the moment, when attempt is built on the last one, "not yet answered"
message is shown, which confuses many people. This patch modifies the state to
"complete" for attempt based on previous and modifies the output string.

Many thanks to Tim Hunt for guiding me through quiz infrastructure and some code
suggestions.
2013-08-02 16:19:18 +01:00
Tim Hunt
c7fbfe46f9 MDL-38538 question autosave: fix sequencecheck handling. 2013-04-04 15:32:32 +01:00
Tim Hunt
dc1ee5cb29 MDL-34640 question repsponse files: remaining tidy up of this code. 2013-03-30 21:16:18 +00:00
Mathieu Petit-Clair
d0782585c8 MDL-34640: adding code to pass contextid and question type to question_file_loader. 2013-03-30 19:57:03 +00:00
Tim Hunt
0a606a2be2 MDL-38538 question auto-save back end.
1. Autosave works in some ways just like a normal save. We ultimately
call $behaviour->process_save() to do the work, and create a new step to
hold the data.

2. However, we come in through a completely different route through the
API, starting with separate auto-save methods. This keeps the auto-save
changes mostly separate, and so reduced the chance of breaking existing
working code.

3. When the time comes to store the auto-save step in the database, we
save it using a negative sequence number.

This is a clever trick that not only distinguises these steps, but also
avoids unique key errors when an auto-save and a real action happen
simultaneously. (There are unit tests for these tricky edge cases.)

4. When we load the data back from the database, most of the time the
auto-save steps are loaded back as if they were a real save, and so the
auto-saved data is used when the question is then rendered.

5. However, before we process another action, we remove the auto-saved
step, so it does not appear in the final history.
2013-03-28 16:51:59 +00:00
Tim Hunt
53b8e25626 MDL-38311 questions: manual grading API should accept commentformat
Comment format (FORMAT_...) was correctly being processed when the
manual grading happened as the result of a form submission. It was only
when done using the question_usage or question_attempt API method that
there was no way to specify the format. (Although I think the only place
this API as used was in the unit tests.)

Note that question_attempt::manual_grade API had to change, but I don't
think that is a real API change. Calling code should be using
question_usage::question_attempt, which is backwards compatible.

Note that now, if you don't pass format, then no error is generated, but
a developer debugging message is generated.
2013-03-05 11:51:47 +00:00
Tim Hunt
2d2018abda MDL-37896 qtype_essay: correct PARAM_CLEANHTML -> PARAM_RAW.
It turns out that you should almost never use PARAM_CLEANHTML.
2013-02-08 12:51:21 +00:00
Tim Hunt
03cefcc91b MDL-37506 question code: incorrect preg_quote uses.
For preg_quote to work reliably, you must pass the delimiter you are
using for your regular expression. In many places we were failing to do
that.
2013-01-18 11:18:54 +00:00
Tim Hunt
2c76c89422 MDL-35419 question manual grading: valdiation must handle 0,5
Yet another , as decimal separator issue!

To fix this nicely, I refactored some code into question_utils.
2012-09-13 16:33:15 +01:00
Dan Poltawski
5082d87c03 Merge branch 'wip-mdl-32940' of git://github.com/rajeshtaneja/moodle 2012-07-24 13:39:59 +08:00
Rajesh Taneja
61cca0b7fc MDL-32940 libraries: Replaced deprecated PARAM_NUMBER with PARAM_FLOAT 2012-07-23 17:21:05 +08:00
Tim Hunt
dd7aa58386 MDL-34251 question engine: possible infinite loop loading usages
In the case where either a question_attempt had not steps, or a
question_usage had not question_attempts, the load_from_records methods
could get stuck in an infinite loop.

This fix ensures that does not happen, with unit tests to verify it. At
the same time, I noticed an error in the existing tests, which this
patch fixes.
2012-07-19 12:51:00 +01:00
Tim Hunt
9212fe7a79 MDL-32062 question engine: fix re-grading attempts from 2.0
The code to upgrade attempts from before Moodle 2.0 to 2.1 created
attempt data that was not exactly the same as a new attempt created in
2.1+. This did not matter very much - revew and the quiz reports all
worked OK - but it broke on re-grade.

These changes detect the problem data in the re-grade code, an apply a
work-around so that the re-grade gives the correct result.
2012-06-26 10:11:15 +01:00
Sam Hemelryk
ef844d0a15 Merge branch 'w12_MDL-32094_m23_phpstrict' of git://github.com/skodak/moodle 2012-03-20 16:47:17 +13:00
Petr Skoda
072db71c90 MDL-32094 fix question related E_STRICT problems 2012-03-18 18:33:54 +01:00
Tim Hunt
8cb7a6d512 MDL-31594 question manual grading: did not handle comma as decimal. 2012-03-15 18:46:43 +00:00
Tim Hunt
94815ccfa0 MDL-30484 question engine: don't lose response files when regrading.
The problem was mostly that, in the past, we did not worry if
question_attempt_step.id changed during regrade (because we deleted the
old step row and inserted a new one). However, now that steps can have
associated files, we can't be that slack, becuase the step id is used as
the file itemid.

So, now, we have to update the existing rows during a regrade. We do
this by having the question engine tell the question_engine_unit_of_work
that the step has first been deleted, and then added back. Then we make
the unit-of-work spot that delete + add = update.

This also means that during regrading, we have to pass around some extra
ids so that new steps know the id of the step they are replacing.

Naturally, this requires some quite trickly logic, so I finally got
around to writing unit tests for question_engine_unit_of_work, which is
a good thing.

Along the way I also got around to renaming
question_attempt->set_number_in_usage, which got missed out when
everthing else was renamed to slot ages ago.

Finally, while working on this code, I noticed and fixed some PHPdoc
comments.
2012-01-30 16:57:23 +00:00