Quiz duplicating error Moodle 4.5.4+

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -
回帖数:20

Hi Moodle Community

After Upgrading to Moodle 4.5.4+, I am not able to copy quizzes within courses. All other activities work as expected. I receive the following error message. Does anyone of you have an idea how to solve this bug?

To resolve a bug in Moodle preventing quiz duplication within a course. I upgraded from Moodle 4.3 to Moodle 4.5.4+. All other activities are possible to duplicate. Please find the error message attached. The error message is the following: Error code: emptycmids * line 1165 of /course/format/classes/stateactions.php: core\exception\moodle_exception thrown * line 983 of /course/format/classes/stateactions.php: call to core_courseformat\stateactions->validate_cms() * line 629 of /course/format/classes/stateactions.php: call to core_courseformat\stateactions->cm_state() * line 137 of /course/format/classes/external/update_course.php: call to core_courseformat\stateactions->cm_duplicate() * line ? of unknownfile: call to core_courseformat\external\update_course::execute() * line 253 of /lib/external/classes/external_api.php: call to call_user_func_array() * line 83 of /lib/ajax/service.php: call to core_external\external_api::call_external_function()

附件 error_duplicating_quiz.png
回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Ken Task -
Particularly helpful Moodlers的头像

When you upgraded, did you copy back into new code from old code all the addons?   Are you using a course format plugin?

'SoS', Ken

回复Ken Task

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -

Dear Ken

Thanks for your answer. Yes, I double checked, all add ons are copied from the old moodle version. 
Yes, we are using the kickstart plugin as course format. With the kickstart plugin, we can create templates to use: https://moodle.org/plugins/format_kickstart
I tried to change the course format too, but the error remains the same.

Any ideas on how to solve this bug?

Best, Rainer

回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Ken Task -
Particularly helpful Moodlers的头像

Kickstart
https://moodle.org/plugins/format_kickstart/versions
shows compat up to 4.5 which is what you have.  I see Sergio has submitted a tracker ... sooooo ????

'SoS', Ken

回复Ken Task

Quiz duplicating error Moodle 4.5.4+

Sergio Rabellino -
Particularly helpful Moodlers的头像 Plugin developers的头像

Sergio myself ? What tracker ?

What's not clear to me is whether other courses with different course formats work or not. Check this also: https://moodle.org/mod/forum/discuss.php?d=467893, which seems to me to have the same problem but with another course format.

Could you check your web server logs, because I believe that the error shown is only a symptom and not the main cause.

回复Sergio Rabellino

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -
Hi Sergio
Thank you very much for your answer. It also happens when I change to boost theme.
Everytime when I want to copy the quiz, i receive the following error message. Does this help to find the solution?

image.png
回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Greg Pedder -
Hi Rainer,
If it helps - I've seen a similar error for some of our plugin's after we'd upgraded to M4.5.4+ - the following link - while not directly related to the above plugin, explains the steps needed which should apply to plugins that run into this issue: https://tracker.moodle.org/browse/MDL-82427
To resolve the above, I think you simply need to:
1) Rename the class inside filter/edwiserformlink/filter.php to "class text_filter" - leaving any other keywords intact.
2) Rename filter/edwiserformlink/filter.php to text_filter.php
3) Move filter/edwiserformlink/text_filter.php to filter/edwiserformlink/classes/

This should then silence the PHP errors.

HTH
回复Greg Pedder

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -

Thank you very much

I was now able to silence the PHP errors, but the problem with duplicating quiz still remains. Does anyone have additional hints?

回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Sergio Rabellino -
Particularly helpful Moodlers的头像 Plugin developers的头像

But after cleaning up this "noise", what are the logged errors (all) when the duplicate fails ?

回复Sergio Rabellino

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -
No error anymore (s. Screenshot). The problem I identified in the database is that the quizzes does not have a course module id assigned. I made this statement and the output is null (because no cmid). When I do the same on my testserver, I see a lot of quizzes.

SELECT q.id AS quizid, q.name AS quizname, q.course AS courseid, cm.id AS coursemoduleid, c.fullname AS coursename FROM mdl_quiz q JOIN mdl_course_modules cm ON cm.instance = q.id JOIN mdl_modules m ON m.id = cm.module JOIN mdl_course c ON c.id = q.course WHERE m.name = 'quiz';

image.png
回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Sergio Rabellino -
Particularly helpful Moodlers的头像 Plugin developers的头像
But this is the "access.log", not the error log or the PHP log file: they can/should differ, depending on your specific configuration/hosting/housing.
So it's normal that here there are no "errors" at all.
回复Sergio Rabellino

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -

Hi Sergio
Thanks for clarifying. The error logs show no message when duplicating a quiz. We found out that when copying a quiz, the php session cannot hold the course module id (it is displayed in the database, but is not saved in the php session). I have checked the payload it is taking the cmids and course as well. Do you know what can be the cause for it?

Best, Rainer

 
回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Ken Task -
Particularly helpful Moodlers的头像

What does this query look like on your system?

mysql> select id,shortname,format,visible,theme from mdl_course;

could be a format vs theme hickup?

How many formats are installed?

'SoS', Ken

回复Ken Task

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -

Hi Ken

I processed your sql and this is the output (below). I have two formats installed (edwiser and kickstart). The theme is also edwiser which offers also a course format. But the course format we use is kickstart.

You might be right with the format vs theme hickup? Do you have an idea on how to solve it?


image.png

回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Ken Task -
Particularly helpful Moodlers的头像

"Do you have an idea on how to solve it?"

Nope!  Sorry!  Think you will have to backup a course - no user - with a quiz and restore it - hidden.   Then change parameters to that course to make it stock ... boost/classic theme - no edwiser ... it's a standalone moodle only course.

Then try duplicating a quiz in that course.   If it works, then????

Do know that Edwiser is an interface from a WordPress (WP) store front.   WP uses .htaccess rules that are not compat with Moodle so where is the moodle code in relationship to the WP store front?

'SoS', Ken

回复Ken Task

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -
Hi Ken
Thanks for your answer. When I want to restore a course, the quiz activities simply disappear. It seems that moodle cannot backup the quizzes maybe because they don't have a course module id assigned when I create a quiz. Does this help to solve the problem?
回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Rainer Winkler -
Hi Ken
We found out that the php session cannot hold the course module id, this is why we receive the error message (no coursemoduleid).
回复Rainer Winkler

Quiz duplicating error Moodle 4.5.4+

Ken Task -
Particularly helpful Moodlers的头像

Confusing ...

There was a bug in sessions ... default for moodle is to save sessions to files ... not use DB.
So this: "php session cannot hold the course module id" indicates sessions are being saved to the DB ... mdl_sessions?

mysql> explain mdl_sessions;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | bigint       | NO   | PRI | NULL    | auto_increment |
| state        | bigint       | NO   | MUL | 0       |                |
| sid          | varchar(128) | NO   | UNI |         |                |
| userid       | bigint       | NO   | MUL | NULL    |                |
| sessdata     | longtext     | YES  |     | NULL    |                |
| timecreated  | bigint       | NO   | MUL | NULL    |                |
| timemodified | bigint       | NO   | MUL | NULL    |                |
| firstip      | varchar(45)  | YES  |     | NULL    |                |
| lastip       | varchar(45)  | YES  |     | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+
9 rows in set (0.01 sec)

select * from mdl_sessions;
should show an empty set if sessions are saved to files and not the DB.

What table holds "course module id"?

And what does your server's PHP config have for sessions?

'SoS', Ken