Issue Details (XML | Word | Printable)

Key: MDL-12922
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Eloy Lafuente (stronk7)
Reporter: Kenneth Newquist
Votes: 19
Watchers: 10
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Course restores for non-admin users appear ~7 years early

Created: 11/Jan/08 06:00 AM   Updated: 06/Oct/09 10:09 AM
Return to search
Component/s: Backup
Affects Version/s: 1.8.3, 1.9.3
Fix Version/s: 1.8.8, 1.9.4

File Attachments: 1. Text File 192_restore_form_patch.txt (2 kB)
2. File backup_restore_fix.diff (0.8 kB)
3. File backup_restore_fix_1.9.diff (2 kB)

Environment: 1.8.3+ (2007021534)
Issue Links:
Relates
 

Database: MySQL
Participants: Barron Koralesky, David Kelly, Eloy Lafuente (stronk7), Kenneth Newquist, Martin Dougiamas, Marty Gilbert, Mary Parke, matt greenwolfe, Rahim Virani, Tim Hunt and Yolanda Ordoñez Rufat
Security Level: None
QA Assignee: Tim Hunt
Resolved date: 03/Jan/09
Affected Branches: MOODLE_18_STABLE, MOODLE_19_STABLE
Fixed Branches: MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
There is a problem in the restore component of backup that causes the dates on forum posts to be wildly off (7+ years) when a course with forums is restored by a teacher. If a course is restored by an admin, the forum post dates come in correctly.

What's happening is that /backup/restore_form.html has logic that checks to see if a course has a start date, and if it does, it gives the user the ability to modify that start date.

However the problem is that this start-date-checking logic is tied to the "course creator" capability -- if you don't have the coursecreator capability (and teachers don't) then it doesn't do the check, and assigns the start date to 0, which triggers some date offset calculations, which results in the wonky dates.

I've created a patch that fixes the problem by moving this logic out of the "coursecreator" portion of "restore_form.html". As a result, teachers will now see the "course startdate" field as well, and everything works as it should. The patch is attached to this bug report.


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Yolanda Ordoñez Rufat added a comment - 31/Jan/08 11:05 PM
There's also a problem with the post dates in the restore if you have the "course creator" capability. So moving the logic out of the "coursecreator" portion of "restore_form.html" doesn't work, sorry Kenneth.
I tried a restore as an admin and I change the start date of the course during restore and I get wrong forum post dates (they are set in the future).

I test it on a 1.8.3 moodle with a 8.2.4 postgres installed in a SUSE Linux Enterprise Server 10 SP1.


David Kelly added a comment - 08/Apr/08 05:48 AM
This is still a bug in 1.9, at least as of build 20080307.

Kenneth Newquist added a comment - 08/Apr/08 10:16 PM
I haven't tried it with the course creator role in Moodle 1.8.x; we don't make use of that particular one. I'll try and spend some time debugging this later this week or early next. I haven't tried it in Moodle 1.9 yet.

matt greenwolfe added a comment - 01/May/08 09:49 AM
Here is a diff file of the changes that worked for me, at least so far, in 1.9.
Following the diff file for 1.8.3, I edited /backup/restore_form.html by moving several lines out of the if statement. The date line shows up for teachers and seems to work correctly so long as the specified date is greater than or equal to the original course start date.

matt greenwolfe made changes - 01/May/08 09:49 AM
Field Original Value New Value
Attachment backup_restore_fix_1.9.diff [ 13817 ]
Kenneth Newquist added a comment - 17/Jul/08 10:58 PM
I can confirm the problem still exists for teachers in Moodle 1.9.2. Matt's patch failed for me so I've generated a new one based on Moodle 1.9.2 (Build: 20080711).

I can not recreate the problem with the Course Creator role; when logged in as a course creator I was able to see the start data form (which is the way the original code was supposed to work, as that functionality was reserved for course creators, even though non-course creating teachers needed it as well).


Kenneth Newquist made changes - 17/Jul/08 10:58 PM
Attachment 192_restore_form_patch.txt [ 14572 ]
Rahim Virani added a comment - 18/Jul/08 05:20 AM
I think the patch is broken ". Text File 192_restore_form_patch.txt (2 kb)"

We tried the ". Text File 192_restore_form_patch.txt (2 kb)" from a 1.9.2 intallation, the patch while it did take into account the current date, it did not honor the settings that we set for course start date, if we set the start-date to May 1st, the course startdate after the restore is still July 20th.


Kenneth Newquist added a comment - 21/Jul/08 08:45 PM
I'll re-check the patch later today.

Rahim Virani added a comment - 29/Aug/08 04:01 AM
EXCUSE THE CAPS, BUT I HOPE SOMEONE READS THIS THAT CAN PUT THE PATCH INTO THE DISTRIBUTION WE HAVE NOW A PROBLEM 171 ASSIGNMENTS IN OUR MOODLE INSTALL HAVE SILLY DUE DATES!!!

The patch has been verified and it works in 1.9.2, We had patched our 1.8.3 distribution but when we did the security upgrade to 1.8.6 we must have lost the patch, it wasnt included in the new distribution so if someone who has access to the main code repository might put this patch in (sorry I dont know how) then this might be avoided.

We have successfully used this patch in 1.8.3 and in 1.9.2 I really dont want to get bit by this again! - Thanks.


Rahim Virani added a comment - 25/Nov/08 07:46 AM
So, we checked, this still hasnt made it into Moodle 1.9.3, I'm glad I did my due diligence with this one.

Martin, what can I do to resolve this?

Please advise.


Martin Dougiamas added a comment - 30/Dec/08 08:50 AM
Eloy can you look at this please?

Martin Dougiamas made changes - 30/Dec/08 08:50 AM
Assignee Martin Dougiamas [ dougiamas ] Eloy Lafuente (stronk7) [ stronk7 ]
Fix Version/s 1.8.8 [ 10314 ]
Fix Version/s 1.9.4 [ 10300 ]
Eloy Lafuente (stronk7) committed 2 files to 'Moodle CVS' - 03/Jan/09 02:59 AM
MDL-12922 restore roll dates - prevent wrong rolls to 0 happening to teachers. Merged from 19_STABLE
MODIFY backup/restore_check.html   Rev. 1.63    (+3 -3 lines)
MODIFY backup/restore_form.html   Rev. 1.83    (+6 -1 lines)
Eloy Lafuente (stronk7) committed 2 files to 'Moodle CVS' on branch 'MOODLE_18_STABLE' - 03/Jan/09 03:00 AM
MDL-12922 restore roll dates - prevent wrong rolls to 0 happening to teachers. Backported from HEAD
MODIFY backup/restore_form.html   Rev. 1.43.2.9    (+7 -2 lines)
MODIFY backup/restore_check.html   Rev. 1.37.2.8    (+3 -3 lines)
Eloy Lafuente (stronk7) added a comment - 03/Jan/09 03:03 AM
Instead of using the patches above... I've continued with current approach, i.e. non-course-creators cannot roll dates at all.

I've committed fix for 18_STABLE, 19_STABLE and HEAD. Ciao


Eloy Lafuente (stronk7) made changes - 03/Jan/09 03:03 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Eloy Lafuente (stronk7) made changes - 03/Jan/09 03:03 AM
Affects Version/s 1.9.3 [ 10290 ]
Martin Dougiamas added a comment - 06/Jan/09 09:49 AM
Great, thanks Eloy!

Tim Hunt added a comment - 06/Jan/09 11:22 AM
Looks good to me. Thanks Eloy, and thanks for the clear bug report, sorry it took so long to fix.

Tim Hunt made changes - 06/Jan/09 11:22 AM
Status Resolved [ 5 ] Closed [ 6 ]
Tim Hunt made changes - 06/Jan/09 11:23 AM
QA Assignee timhunt
Mary Parke added a comment - 07/Jan/09 02:43 AM
Hi Eloy,

Thank you for this fix. However, I have to disagree with the current practice of making this so only "course creators" are allowed to roll the dates.

If you follow MDL-9367 (and other related trackers), you'll see that there is an overwhelming need by the community for faculty to be allowed to roll the dates in a course. If it is assumed only the admin is doing this, then an institution has to fund a whole team of folks with admin privileges (or "course creator") to do nothing but course restores from semester to semester. If instead, faculty (teacher role) are allowed to do restore and import with setting the course start date, then the burden is off the team and in the hands of the ones for which this function most effects: the instructors. Otherwise, faculty have to manually edit the dates on every activity every semester, thus defeating the purpose of this "roll forward" feature.

Logically, as a systems administrator, I would WANT my faculty to be able to set their own course start date (especially as courses start on differing dates throughout the semester), but I wouldn't want my faculty to be assigned to the course creator role in order to make this happen - because I wouldn't want them to have the ability to create whatever courses they wanted on the fly. We only host courses that have gone through a process (such as curriculum committee, dept approval, etc.).

If this fix could also be applied to at minimum the teacher role, this would greatly assist many institutions in the management of course rollover from semester to semester (term to term).

Thank you for listening,

Mary


Rahim Virani added a comment - 07/Jan/09 04:36 AM
I do agree with Mary,

If we were to give all the instructors Course-creator privs this would definatly be problematic. and well as Martin L put it "unsustainable"

We tend to have faculty..... yeah.

In short I do agree with Mary, I also do know of many other institutions that cannot afford the resources hand-holding such as ours.

Kind Regards,


Barron Koralesky added a comment - 07/Jan/09 07:48 AM

I agree with Mary and Rahim, if we are to make course restores a valuable self-service function for our instructors, the teacher role needs to be able to restore courses without getting wonky dates. Thank you for your help and work on this.


Marty Gilbert added a comment - 08/Jan/09 12:40 AM
I second Barron, Mary, and Rahim. I'm not about to give my faculty course-creator roles; that could be disasterous.

Eloy Lafuente (stronk7) made changes - 16/Jan/09 04:44 AM
Link This issue is blocked by MDL-17917 [ MDL-17917 ]
Eloy Lafuente (stronk7) made changes - 16/Jan/09 04:44 AM
Link This issue is blocked by MDL-17917 [ MDL-17917 ]
Eloy Lafuente (stronk7) made changes - 16/Jan/09 04:45 AM
Link This issue has been marked as being related by MDL-17917 [ MDL-17917 ]
Eloy Lafuente (stronk7) added a comment - 06/Oct/09 06:43 AM
So, one capability like:

'moodle/restore:rolldates'

enabled by default to admins and course creators (to have backward compatibility) but able to be assigned to other roles... sounds like a good solution to everybody here?

Ciao


Eloy Lafuente (stronk7) added a comment - 06/Oct/09 07:12 AM
and that capability should be able to work at course level or only at category level? I ask this because sometimes, on restore we don't know the target course until later in the process (for example, when creating a new course) or when restoring to existing, deleting first, the "teacher" haven't still that capability allowed.

So, perhaps it should be a "category-based" capability? and not a course one?


Eloy Lafuente (stronk7) committed 3 files to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 06/Oct/09 09:13 AM
MDL-12922 adding 'moodle/restore:rolldates' cap to control who can roll dates on restore
(defaults to current settings: only course creators (and admins) are able to roll)
MODIFY lang/en_utf8/role.php   Rev. 1.47.2.20    (+2 -1 lines)
MODIFY lib/db/access.php   Rev. 1.75.2.20    (+11 -1 lines)
MODIFY version.php   Rev. 1.563.2.664    (+1 -1 lines)
Eloy Lafuente (stronk7) committed 3 files to 'Moodle CVS' - 06/Oct/09 09:14 AM
MDL-12922 adding 'moodle/restore:rolldates' cap to control who can roll dates on restore
(defaults to current settings: only course creators (and admins) are able to roll) Merged from 19_STABLE
MODIFY lib/db/access.php   Rev. 1.108    (+11 -1 lines)
MODIFY version.php   Rev. 1.1275    (+1 -1 lines)
MODIFY lang/en_utf8/role.php   Rev. 1.95    (+2 -1 lines)
Eloy Lafuente (stronk7) committed 3 files to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 06/Oct/09 09:22 AM
MDL-12922 'moodle/restore:rolldates' capability - Implement logic on restore
MODIFY backup/restorelib.php   Rev. 1.283.2.79    (+24 -1 lines)
MODIFY backup/restore_check.html   Rev. 1.48.2.19    (+22 -2 lines)
MODIFY backup/restore_form.html   Rev. 1.60.2.20    (+11 -2 lines)
Eloy Lafuente (stronk7) committed 3 files to 'Moodle CVS' - 06/Oct/09 09:27 AM
MDL-12922 'moodle/restore:rolldates' capability - Implement logic on restore. Merged from 19_STABLE
MODIFY backup/restore_check.html   Rev. 1.78    (+22 -2 lines)
MODIFY backup/restore_form.html   Rev. 1.96    (+11 -2 lines)
MODIFY backup/restorelib.php   Rev. 1.396    (+23 -1 lines)
Eloy Lafuente (stronk7) committed 1 file to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 06/Oct/09 09:44 AM
MDL-12922 'moodle/restore:rolldates' capability - added missing string
MODIFY lang/en_utf8/moodle.php   Rev. 1.141.2.67    (+2 -1 lines)
Eloy Lafuente (stronk7) committed 1 file to 'Moodle CVS' - 06/Oct/09 09:58 AM
MDL-12922 'moodle/restore:rolldates' capability - added missing string. Merged from 19_STABLE
MODIFY lang/en_utf8/moodle.php   Rev. 1.260    (+2 -1 lines)
Eloy Lafuente (stronk7) added a comment - 06/Oct/09 10:04 AM
Done. New capability 'moodle/restore:rolldates' is available and allowed to admins and course creators by default (old behaviour). Can be allowed to other roles (at any level) in order to permit them to roll dates on restore.

Ciao


Eloy Lafuente (stronk7) added a comment - 06/Oct/09 10:09 AM
Please, test if and report any problem here ASAP, as this new capability will be available in tomorrow's weekly build and in next stable release (Moodle 1.9.6). TIA and re-ciao

martignoni committed 1 file to 'Lang CVS' - 23/Oct/09 05:35 AM
MDL-12922 String translated
MODIFY fr_utf8/role.php   Rev. 1.122    (+2 -1 lines)
martignoni committed 1 file to 'Lang CVS' - 23/Oct/09 05:38 AM
MDL-12922 New string added
MODIFY fr_utf8/moodle.php   Rev. 1.324    (+2 -1 lines)
martignoni committed 1 file to 'Lang CVS' - 23/Oct/09 05:40 AM
MDL-12922 Rewording
MODIFY fr_utf8/moodle.php   Rev. 1.325    (+2 -2 lines)