Moodle

Reset not resetting correctly

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.6.1
  • Fix Version/s: 1.9, 2.0
  • Component/s: Administration
  • Labels:
    None
  • Environment:
    Linux
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_16_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE

Description

When choosing the 'Reset' option from the 'Administration' panel in a course, the forums' status are not being cleared as they should.

The actual discussions/posts are removed. However, when you click on the 'Forums' link in the 'Activities' block, the number shown in the 'Discussions' column still shows the number of posts that were in the forum before the reset was performed and is not reset to 0 as it should. If I click on that number, it takes me to the forum where indeed there are no posts. The number just doesn't get reset to 0.

  1. forum_lib.php.patch
    11/Dec/06 7:48 PM
    0.9 kB
    Samuli Karevaara
  2. lib.php
    28/Aug/07 3:50 PM
    14 kB
    Shamim Rezaie

Issue Links

Activity

Hide
Martin Dougiamas added a comment -

From (schmidt at amigos.org) Wednesday, 9 August 2006, 10:29 PM:

Upon further inspection, it looks like it's not just a matter of the number not resetting - the posts are still in my mdl_forum_discussions table as well.

Show
Martin Dougiamas added a comment - From (schmidt at amigos.org) Wednesday, 9 August 2006, 10:29 PM: Upon further inspection, it looks like it's not just a matter of the number not resetting - the posts are still in my mdl_forum_discussions table as well.
Hide
Petr Škoda (skodak) added a comment -

Course reset will be finished in 1.8, sorry

Show
Petr Škoda (skodak) added a comment - Course reset will be finished in 1.8, sorry
Hide
Thomas Robb added a comment -

Joseph Rézeau reports in http://moodle.org/mod/forum/discuss.php?d=57305

that:

...I was subsequently surprised to find out that a number of items have not been deleted by the reset function.

1. Forum discussions are removed but - on the main Forums page - the Discussions "counter" still displays the number of past discussions (which have been removed).
2. All attachments which had been attached to forum discussions are still present in the moddata files.
3. All attached files to assignments are still present in the moddata files.

Show
Thomas Robb added a comment - Joseph Rézeau reports in http://moodle.org/mod/forum/discuss.php?d=57305 that: ...I was subsequently surprised to find out that a number of items have not been deleted by the reset function. 1. Forum discussions are removed but - on the main Forums page - the Discussions "counter" still displays the number of past discussions (which have been removed). 2. All attachments which had been attached to forum discussions are still present in the moddata files. 3. All attached files to assignments are still present in the moddata files.
Hide
Samuli Karevaara added a comment -

I'm cleaning up the mdl_forum_discussions table with the following addition to /mod/forum/lib.php in forum_delete_userdata:

// Cleaning up: deleting forum discussions that have no posts in them
$sql = "DELETE FROM {$CFG->prefix}forum_discussions
WHERE firstpost NOT IN (
SELECT id FROM {$CFG->prefix}forum_posts
) AND course = {$data->courseid}";
if (execute_sql($sql, false) and $showfeedback) { notify($strreset.': '.get_string('resetdiscussions','forum'), 'notifysuccess'); }

I'll attach a path for 1.8 also.

Show
Samuli Karevaara added a comment - I'm cleaning up the mdl_forum_discussions table with the following addition to /mod/forum/lib.php in forum_delete_userdata: // Cleaning up: deleting forum discussions that have no posts in them $sql = "DELETE FROM {$CFG->prefix}forum_discussions WHERE firstpost NOT IN ( SELECT id FROM {$CFG->prefix}forum_posts ) AND course = {$data->courseid}"; if (execute_sql($sql, false) and $showfeedback) { notify($strreset.': '.get_string('resetdiscussions','forum'), 'notifysuccess'); } I'll attach a path for 1.8 also.
Hide
Samuli Karevaara added a comment -

This clean-up can be executed even if the forums are not chosen to be reset: it will only remove "null" discussions which have no posts in them and thus should be removed as there is no way (UI-wise) to add posts to these discussions anyway.

This needs a new string also, I didn't check if there was an existing one that would apply here...

Show
Samuli Karevaara added a comment - This clean-up can be executed even if the forums are not chosen to be reset: it will only remove "null" discussions which have no posts in them and thus should be removed as there is no way (UI-wise) to add posts to these discussions anyway. This needs a new string also, I didn't check if there was an existing one that would apply here...
Hide
Eric Schewe added a comment -

We've got a similar problem. Moodle 1.6.3+ (Built Dec. 26th, 2006), PHP 5.2.0, MySQL 5.0.27 on Redhat Enterprise Linux AS 4 and when we reset a course it leaves all of the forum data behind. This includes actual posts.

Show
Eric Schewe added a comment - We've got a similar problem. Moodle 1.6.3+ (Built Dec. 26th, 2006), PHP 5.2.0, MySQL 5.0.27 on Redhat Enterprise Linux AS 4 and when we reset a course it leaves all of the forum data behind. This includes actual posts.
Hide
Dariusz Górka added a comment -

After small investigation to "forums".
function delete_user_data (/mod/forum/lib.php)

$sql = 'DELETE FROM '.$CFG->prefix.'forum_posts .....

changing back to:

$sql = 'DELETE FROM fp ....

solves the problem with post deletion. It is a matter of SQL syntax.

Have a nice day

Show
Dariusz Górka added a comment - After small investigation to "forums". function delete_user_data (/mod/forum/lib.php) $sql = 'DELETE FROM '.$CFG->prefix.'forum_posts ..... changing back to: $sql = 'DELETE FROM fp .... solves the problem with post deletion. It is a matter of SQL syntax. Have a nice day
Hide
Stuart Anderson added a comment -

We also noticed that after reset any files uploaded in assingmens aren't removed, and if any students from the pre-reset course are participants in the post-reset course (e.g. students resitting a course) their previous submission still appear.

--Stuart.

Show
Stuart Anderson added a comment - We also noticed that after reset any files uploaded in assingmens aren't removed, and if any students from the pre-reset course are participants in the post-reset course (e.g. students resitting a course) their previous submission still appear. --Stuart.
Hide
Shamim Rezaie added a comment -

I fixed this issue.
The functions forum_delete_userdata( ) and forum_reset_course_form( ) are included in the attached file - lib.php

Also the functions for other modules could be found at http://moodle.org/mod/forum/discuss.php?d=53142#p349045

Show
Shamim Rezaie added a comment - I fixed this issue. The functions forum_delete_userdata( ) and forum_reset_course_form( ) are included in the attached file - lib.php Also the functions for other modules could be found at http://moodle.org/mod/forum/discuss.php?d=53142#p349045
Hide
Petr Škoda (skodak) added a comment -

Thank you for the patch, I hope I can get to this soon

Show
Petr Škoda (skodak) added a comment - Thank you for the patch, I hope I can get to this soon
Hide
Petr Škoda (skodak) added a comment -

I have committed rewritten course recent into cvs 1.9 and HEAD - it is based on code and ideas from Shamim Rezaei and Enrique Castro, thanks!
The changes are quite big and not fully backwards compatible, that is why it will not be backported into 1.8, sorry.

Please test the new code and report any problems.

Show
Petr Škoda (skodak) added a comment - I have committed rewritten course recent into cvs 1.9 and HEAD - it is based on code and ideas from Shamim Rezaei and Enrique Castro, thanks! The changes are quite big and not fully backwards compatible, that is why it will not be backported into 1.8, sorry. Please test the new code and report any problems.

Dates

  • Created:
    Updated:
    Resolved: