ndunand / moodle-mod_choicegroup

Moodle "Group Choice" plugin
https://moodle.org/plugins/mod_choicegroup
35 stars 64 forks source link

Groups in multiple groupings can be added multiple times #218

Closed detomon closed 1 month ago

detomon commented 2 months ago

When groups are assigned to multiple groupings, groups can be added multiple times to "Selected Groups". For example, group "A" was assigned to grouping "X" and "Y":

Groups

This in itself is not a big problem and an acceptable behaviour IMO. But when saving the activity, group "A" will be shown multiple times on the select screen.

Selection

Also, duplicate groups will again be duplicated each time when saving (A, A, D => A, A, A, A, D).

susiestrath commented 1 month ago

We are also having the same issue. Groups are duplicated when the settings page loads and then saved. This makes it hard to make any changes, even just updating the title.

Marx1st commented 3 days ago

After updating the plugin to fix this problem we get this error when opening the settings of a choice group, that had this problem:

Fehler beim Lesen der Datenbank
Debug info: ERROR: function regexp_substr(character varying, unknown) does not exist
LINE 6: ORDER BY CAST(REGEXP_SUBSTR(name, '[0-9]+'...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
DECLARE crs1 NO SCROLL CURSOR WITH HOLD FOR SELECT grp_m.id grpmemberid, grp_m.userid, grp_o.id, grp_o.groupid, grp_o.maxanswers
FROM mdl_groups grp
INNER JOIN mdl_choicegroup_options grp_o on grp.id = grp_o.groupid
LEFT JOIN mdl_groups_members grp_m on grp_m.groupid = grp_o.groupid
WHERE grp_o.choicegroupid = $1
ORDER BY CAST(REGEXP_SUBSTR(name, '[0-9]+') AS INT) , name ASC
[array (
0 => '1287',
)]
Error code: dmlreadexception
Stack trace:

    line 494 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
    line 358 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->read_slave_query_end()
    line 919 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
    line 863 of /mod/choicegroup/lib.php: call to pgsql_native_moodle_database->get_recordset_sql()
    line 52 of /mod/choicegroup/view.php: call to choicegroup_get_choicegroup()

Fehler beim Lesen der Datenbank
Debug info: ERROR: function regexp_substr(character varying, unknown) does not exist
LINE 6: ORDER BY CAST(REGEXP_SUBSTR(name, '[0-9]+'...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
DECLARE crs9 NO SCROLL CURSOR WITH HOLD FOR SELECT grp_m.id grpmemberid, grp_m.userid, grp_o.id, grp_o.groupid, grp_o.maxanswers
FROM mdl_groups grp
INNER JOIN mdl_choicegroup_options grp_o on grp.id = grp_o.groupid
LEFT JOIN mdl_groups_members grp_m on grp_m.groupid = grp_o.groupid
WHERE grp_o.choicegroupid = $1
ORDER BY CAST(REGEXP_SUBSTR(name, '[0-9]+') AS INT) , name ASC
[array (
0 => '1287',
)]
Error code: dmlreadexception
Stack trace:

    line 494 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
    line 358 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->read_slave_query_end()
    line 919 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
    line 863 of /mod/choicegroup/lib.php: call to pgsql_native_moodle_database->get_recordset_sql()
    line 1092 of /mod/choicegroup/lib.php: call to choicegroup_get_choicegroup()
    line 4937 of /lib/navigationlib.php: call to choicegroup_extend_settings_navigation()
    line 4372 of /lib/navigationlib.php: call to settings_navigation->load_module_settings()
    line 838 of /lib/pagelib.php: call to settings_navigation->initialise()
    line 967 of /lib/pagelib.php: call to moodle_page->magic_get_settingsnav()
    line 227 of /lib/classes/navigation/views/secondary.php: call to moodle_page->__get()
    line 895 of /lib/pagelib.php: call to core\navigation\views\secondary->initialise()
    line 967 of /lib/pagelib.php: call to moodle_page->magic_get_secondarynav()
    line 118 of /theme/boost_union/layout/drawers.php: call to moodle_page->__get()
    line 1486 of /lib/outputrenderers.php: call to include()
    line 1412 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
    line 3037 of /lib/outputrenderers.php: call to core_renderer->header()
    line 1998 of /lib/setuplib.php: call to core_renderer->fatal_error()
    line 390 of /lib/setuplib.php: call to bootstrap_renderer->__call()
    line ? of unknownfile: call to default_exception_handler()
lucaboesch commented 3 days ago

Not this fix has cause this, @Marx1st but https://github.com/ndunand/moodle-mod_choicegroup/pull/221 .