General developer forum

 
 
Picture of Enrique Castro
Reset course functionality - request for comments
Group Developers
We are preparing the new academic year at ULPGC. So we have engaged in completing the "reset course" functionality introduced with Moodle 1.6. Currently this admin function only "resets" forum instances within a course, and nothing more.

Our teachers find backup/restore "difficult", but they want to get a new course with their teacher-uploaded content just no student or student activity. For the teachers, the aim is to "clean" the system from student data leaving all the courses ready for a new run, keeping teacher input  if possible. That means keeping teacher wikis or glossaries, for example. From a sysadmin point of view, technic people want to "clean" the database from all non-needed data from past years (they do not want unusable or inaccesible records to accumulate in the database).

We have written the needed  functions
function {mod}_delete_userdata($data, $showfeedback=true)
function {mod}_reset_course_form($course)
for every module in standard moodle distribution and in other non-standard modules we use at ULPGC (Dialogue, Feedback, Scheduler).

You may find a piece of the Reset page below. This page will list all modules used in the course (not all instances) and present some checkboxes for establishing desired actions and options. What should be considered an option is the question and the reason of this post asking for opinions.

In the example below you see Forums and 'subscriptions' or 'ratings' treated as options. But, if we are deleting all student's posts, keeping records with the rating of those posts doesn't make much sense. Even more, those ratings apply to a given postid we have deleted, so those records are basically useless now. To keep database clean they should be deleted always, not as an option. The same can be applied to the glossary example. Comments or ratings for entries that are deleted are not usable any more. Identically for userfiles, if posts or glossary entries are deleted, the files uploaded as attachments should be deleted (without option). Without a valid postid or entryid  those files are not accesible anymore from within Moodle.

In other words, the right policy would be to _always_ delete records in other tables that depend on a given record being eliminated. Options should be used to ask teacher for data to keep or particular ways to manage teh existing option. In our current draft "options" are used more with a developer eye, to indicate what tables to touch.

I would appreciate any comments on this. In particular, usage examples and teacher-demanded  options.

Enrique

 
Average of ratings: -
Picture of Enrique Castro
Re: Reset course functionality - request for comments
Group Developers
I have attached here a zipped folder with some examples of what we are currently working on. You will see that we do a more deep cleaning of forum tables, for instance, not just deleting posts.
This is draft untested code. 
 
Average of ratings: -
Martin in black and white
Re: Reset course functionality - request for comments
Group DevelopersGroup Documentation writersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers
Thanks, Enrique!   It's great you are completing this!

When you get it better-tested let me know and I'll get it straight into 1.7.
 
Average of ratings: -
Picture of Joan Codina Filba
Re: Reset course functionality - request for comments
 

Does the course start date modify the start/end date of all activities?
 
Average of ratings: -
Picture of Enrique Castro
Re: Reset course functionality - request for comments
Group Developers
Not at this moment. Course reset do not alter the config settings of activities. The teacher has to got into each one to set new dates, as needed

What would be your desired behavior ¿resetting all to new course start date? ¿calculate new dates? It could  be difficult to get new meaningfull dates just by "move  by  x months" type of calculation. We can end  with dates in a holiday, in weekends etc.  So the teacher needs to supervise dates himself. I doubt that adding the  extra complexity to the reset function will payback.

Even, another idea here is to actually make "reset" to hide all sections but section 0 by default, and let the teacher to manually make them visible to students as he/she feels needed by actual teaching.

 
Average of ratings: -
Picture of Joan Codina Filba
Re: Reset course functionality - request for comments
 
If you compute the difference between the old and new start date and you apply it to all dates then this works pretty well when the start date is the same weekday
Of course there are some holydays but in a semester from year to year there are only minor changes.
But at least you only need to change the day not the month and/or  the year in each activity.
To help with this some of my students did a global planning tool that allows to view in a  kind of ganntt  diagram for all the activities in a course
 http://moodle.org/mod/forum/discuss.php?d=44909
You could also use it to change the values.
They did some code but is not good enough to be posted here... angry

 
Average of ratings: -
Picture of Bernard Boucher
Re: Reset course functionality - request for comments
 
Hi Enrique,
                two existing Moolde blocks may serve as "inpiration" for your reset functionnality:

1 - Brian  Koontz course date manager block permit to change the dates of courses activities for a fixed dated or with a relative offset.

2 - Michael Penny and CDC offer the course program block give more control about course activities.

Thanks for that enhancement.

I hope it may help,

Bernard

 
Average of ratings: -
Picture of Enrique Castro
Re: Reset course functionality - request for comments
Group Developers
OK, I am introducing the updating of activity dates.
The compromise I have set by is to compute a week offset between the old and new course start dates. All activity dates are moved a whole number of weeks. Thus, if an assigment opened a Tuesday and closed on Friday of next week, the same weekdays are used in the resetted course.

There is no provision for February 29th, neither checking if new dates spill into vacations periods.
 
Average of ratings: -
Picture of Michael Penney
Re: Reset course functionality - request for comments
Group Developers
Hi Enrique, have you looked at HSU's Course Program block (in CVS)? One of the things it does is provide a form (by topic/week) where all activity dates can be edited.

Mixed with your addition, this could provide a basic forwarding of all dates with your tool, and then using Course Program, where individual activity dates could be adjusted for holidays, leap years, etc. Since this is often country or locale or institionally specific, it would be hard to come up with a fully automated solution (though long run a direct tie in to institutional calendars would be a great leap forwardsmile)
 
Average of ratings: -
Picture of Joan Codina Filba
Re: Reset course functionality - request for comments
 
In the modules database
http://moodle.org/mod/data/view.php?d=13&rid=497
you can get this block that generates a gantt diagram (like microsoft project) of all the assignments in a course.
It also alows to change the dates of the assignments and save the changes. Its done using Ajax techniques.

I think it should be expanded with all the activities, not only assignments. And the code is a homework of some students that I had to arrange to make it work  (they did not a good job) But the code still has some flaws.
I Think that gives a good idea on how Moodle interface can become

This diagram could also include the themes/weeks and  allow vertical displacements of activities to organize the entire course.

I hope you will like it. If you need some extra info just ask.

Joan Codina
 
Average of ratings: -
Art Lader
Re: Reset course functionality - request for comments
Group Documentation writers
Wow, that looks super. smile

-- Art
 
Average of ratings: -
Picture of Samuli Karevaara
Re: Reset course functionality - request for comments
Group DevelopersGroup Particularly helpful MoodlersGroup Translators
We are also in the middle of migrating most of our Moodle courses to another semester. A configurable option for the defaults would be nice. Specifically, we'll leave the teachers and groups usually intact.

Also a shortcut to change the course full name and short name in this view would be super. I'm adding this to our Moodle, but just informing that others might have a similar bundling of course reset + name + short name "upgrade".

One final thing I'm implemeting is a silent automatic course backup to be done before the reset. The core backup functions are very messy at the moment, so it wasn't just a breeze to do this as I initially thought.
 
Average of ratings: -
Picture of A. T. Wyatt
Re: Reset course functionality - request for comments
 
I like these ideas very much.  Granular resetting looks terrific, the silent backup idea is great, and the option of changing the short name would mean that we can continue our current process of autoenrolling students for the instructors.

The only thing I worry about is the situation in which we need to retrieve a complete version of the orginal course, for example, in the case of a grade challenge or questions of instructor behavior/competency (these things often take some time to work through established channels).  Samuli, would the silent backup you are referring to be sufficient to completely restore the course in the case of a teacher accidentally resetting the course (through experimentation) or if there were some other need to retrieve it?  Other methods could be devised by the sysadmin, and should be, but when we try to give more and more control to instructors (which I support!) we must also make sure that we have backups for the unforeseen.  An instructor could possibly invoke the reset prior to the system snapshot date, and the sysadmin would never know that there was a problem with the data.  Until it was too late, of course.

Any thoughts on this type of circumstance?
atw
 
Average of ratings: -
Picture of Samuli Karevaara
Re: Reset course functionality - request for comments
Group DevelopersGroup Particularly helpful MoodlersGroup Translators
Yes, we are using the course backups as "snapshots", or "last known good". I was also thinking that if the course reset functionality starts to have a lot of hackish solutions and a lot of extra code in general, then a backup/restore-snapshotting could be a nice solution, though it would potentially eat a lot of disk space.

Automatic backups of all courses as Moodle zips is too heavy for large sites, but buttons for the teacher "my course is now about to start" (make a snapshot), "my course is finished" (make a snapshot, hide from students), "recycle this course" (make a snapshot and then restore to the "course starting" snapshot).

The backup snapshot mechanism makes it easier for the teacher to plant seeds in forums ("hello and welcome"), wikis ("use it like this") etc. as the combination of those might be quite difficult to "reset" without the snapshot.
 
Average of ratings: -
Picture of Enrique Castro
Re: Reset course functionality - request for comments
Group Developers
Yes, I agree with you for the most part. Backup/restore seems the way to go, and I have been re-considering the whole issue of "reset" while writing it. My mind was in "with a restore this would be safer and more "moodle-ish". In fact, in previous years what we had done was to make site-wide backups of all courses,  "delete" all courses by restoring a "template.zip" copy of a bare-bones course and putting in each course directory the backup from the previous year. In addition, the university policy is to ask all teachers to make a "personal" backup and store it in CD-R for archival (we do have whole-site backups on tape, but are cumbersome to use).

The key point is user interface/"usability".  The restore of a course without user data is seem as "an obscure trick" by most of our teachers. And full Backup/Restore sequence can be overhelming for many of them, even more now with more granularity.  Those buttons for easy (and almost silent) backup and restore are a very good idea.

What I do not understand is how backup/restore may make easier to plant teacher seeds. As fas as I know, you can restore all posts in a forum (with user data) or none at all (without user data). The same for wikis. That was the primary reason to engage in this reset affair,  and not going via backup/restore.

And goes back to the  main question of my post: what should be considered essential or taken for granted, and what as options that the teacher may tick or not when doing a Course Reset?

Can we delete all students posts but leave as an option if we delete posts ratings?
Or if deleting posts, their ratings must be deleted as well, without explicitly asking), and options used to set what type of posts to delete (student's but not teacher's, replys or discussion-starting) ?  I am more in favor of the latter, but implies more complex code.
Enrique
 
Average of ratings: -
Picture of Samuli Karevaara
Re: Reset course functionality - request for comments
Group DevelopersGroup Particularly helpful MoodlersGroup Translators
"What I do not understand is how backup/restore may make easier to plant teacher seeds. As fas as I know, you can restore all posts in a forum (with user data) or none at all (without user data). The same for wikis."

I meant that the teacher creates the course material and activities, then (s)he can create initial content in activities, like a welcome message on the forum. Then the course will be backed up with users (only the teacher at this point), then "with users/user data" restore can be used to reset the course to this initial state.
 
Average of ratings: -
Picture of Jim Peterson
Re: Reset course functionality - request for comments
 
My teachers would like the reset button to include the option of hiding all the weeks and topics so they do not have to go through and do that by hand. Then they could unveil the course each week as they start.
 
Average of ratings: -
Picture of Joseph Rézeau
Re: Reset course functionality - request for comments
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators
Jim > My teachers would like the reset button to include the option of hiding all the weeks and topics so they do not have to go through and do that by hand.

What a lazy bunch!evil But I agree it would a nice option to have.

 
Average of ratings: -
Picture of Joan Codina Filba
Re: Reset course functionality - request for comments
 
This could also be used to reset time, and readjust it, it only would need the hability to change the start date.
you can try it at
http://parles2.upf.es/test/
in this video you can see how it works:
it shows in a kind of Gantt diagram the start/end date of all assgnments( It could be improved with all course activities) and allows the user to graphically (with the mouse) change the start/end date of all them
 
Average of ratings: -
Picture of Chris Fryer
Re: Reset course functionality - request for comments
 
Hello all

Are there any plans to make this an administrative function? We'd like to be able to reset courses in bulk at the end of an academic year, rather than delegate this responsibility to the teachers. I'm afraid most of them will not do it.

Thanks,

Chris
 
Average of ratings: -
Picture of Tim DiVito
Re: Reset course functionality - request for comments
 
I also think that this is a good idea. I would much rather select the courses to reset rather than provide instructions to the faculty members to do so.

At the end of the year, doesn't everyone reset for a new group of students?


-Tim
 
Average of ratings: -
Capt. Moodle
Re: Reset course functionality - request for comments
Group DevelopersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers
Not everyone. While it may be somewhat more work for the end user, I choose to start each year with a clean slate and no content in any of the courses. The reason is that the teacher's schedules change so much. What the faculty members do is backup the data from last year's courses and import it into the current year. I keep each year as a separate installation. Peace - Anthony
 
Average of ratings:Useful (1)
me
Re: Reset course functionality - request for comments
 
I don't know whether Enrique or any other person finished this job or not.
As far as I know, this feature is still incomplete.
I just found an incomplete implementation for the Forum module in the moodle code.
Since I didn't find the implementation for other modules, I planed to implement them.

Currently, reset feature for the modules assignment, chat, choice, dialogue, forum, glossary, quiz, and survey has been finished.

The modules book, label, and resource do not need to be reset at all.

I've attached my code. Since my moodle code has been customized and has many differences from the original code, I just cut and paste the functions {module}_delete_userdata() and {module}_reset_course_form()

Cheers,
Shamim
 
Average of ratings: -
me
Re: Reset course functionality - request for comments
 
I made a little change to improve the calculation of the start/end time for each activity.
 
Average of ratings: -
Picture of Chad Badiyan
Re: Reset course functionality - request for comments
 
Shamim,

This is excellent! I hope it is added to the Moodle core.

Chad
 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Reset course functionality - request for comments
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
I added course reset functionalility for quiz to core recently.
 
Average of ratings: -
me
Re: Reset course functionality - request for comments
 

Hi Tim,

Thank you for the information.

I checked the mentioned code which is in revision 1.266 and found that my code, which is attached to this post, has at least two benefits:

  1. It updates the timeopen and timeclose of each quiz.
  2. The code runs faster.

Regards,
Shamim

 
Average of ratings: -
Picture of Arnaud Saint-Georges
Re: Reset course functionality = global admin feature?
 
Bonjour Shamim,

Are there still any plans to make this an administrative function? Like Chris Fryer said, I'd like to be able to reset courses in bulk (in particular deleting the students), for some course categories, at the end of the French academic year, rather than delegate this responsibility to each member of the register staff who has more than hundred courses to manage.
This global feature could be added to the Site Administration / Courses menu, just after "Backups".

Merci d'avance pour la réponse. smile
Arnaud

 
Average of ratings: -
me
Re: Reset course functionality = global admin feature?
 

Hi Arnaud,

you need to add the function modname_delete_all_course_userdata() to each module library.

also you have to add a function named reset_all_course_userdata() to /lib/moodlelib.php

finaly you should create a file named /course/reset_all.php which its content is similar to /course/reset.php with some changes.

that's all. now you have to put a link to reset_all.php in site administrator menu.
In order to do this, go to /admin/settings/top.php, find the following line
$ADMIN->add('root', new admin_category('courses', get_string('courses','admin')));
and insert
$ADMIN->add('courses', new admin_externalpage('resetallcourses', get_string('reset'), "$CFG->wwwroot/course/reset_all.php"));
after it.

I attached the code which resets all courses. You may modify the modname_delete_all_course_userdata() function for each module to reset just a particular courses. DO NOT replace your moodle files with them, just add their contents to your moodle files.

Regards,
Shamim

 
Average of ratings: -
Picture of Arnaud Saint-Georges
Re: Reset course functionality = global admin feature?
 
Merci Shamim,

I would like this will be integrated into future releases of Moodle.

I have opened this new issue: http://tracker.moodle.org/browse/MDL-11349
Vote for it if you are interesting.

Cordialement,
Arnaud
 
Average of ratings: -
Picture of Gerald Thomas
Re: Reset course functionality = global admin feature?
 

Hi, this is very interesting especially if there are a lot of courses and students.

I'm testing 1.9 and have added the code to the various modules but I have this fatal error:

PHP Fatal error:  Call to undefined function reset_all_course_userdata() in E:\www\moodle\course\reset_all.php on line 35

any ideas?

regards

Gerald

 
Average of ratings: -
me
Re: Reset course functionality = global admin feature?
 
Hi Gerald,

Sorry for my very late answer.

It seems that you did not update the file /lib/moodlelib.php

Cheers,
Shamim

 
Average of ratings: -
Picture of fabrizio cabrera
Re: Reset course functionality = global admin feature?
 

Awesome, Samin. Am a PHP Developer since years and with moodle have like 1 year.

The code you did its awesome, and integrates with moodle perfectly(i use 1.7, others may also work).

PERFECT!. A lot of work, well done.

 
Average of ratings: -
Picture of Chris Fryer
Re: Reset course functionality = global admin feature?
 
I didn't notice you had created this file before I went to work on this, so I'm not sure whether this wil be of use to anyone. But anyway, please find attached my attempt.

My reading of Shamim's code is that it will reset all courses that are not the site. My approach is to allow the user to choose which courses should be reset from a multi-select list at the top of the page.

It doesn't require any additions to the libraries: it's basically the same as /course/reset.php and /course/reset_form.php, except that it loops through the courses you select from the list at the top of the page.

I haven't included code to add a menu item to the Administration block, and it's not quite ready for internationali(s|z)ation, but it seems to work OK.

Chris
 
Average of ratings: -
engagement photo
Re: Reset course functionality = global admin feature?
 
I haven't tried this yet, but sounds great. I'm resetting courses now and it's a bit of a pain resetting 40+... I can't imagine the larger sites having to live without something like this. smile Thanks.
 
Average of ratings: -
Picture of Joseph Rézeau
Re: Reset course functionality - request for comments
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

Hello,

Using Moodle 1.8.2, I have reset a course, with all boxes checked (except teacher, of course).

The students and the forum discussions are deleted, but I am getting this error message:

Fatal error: Call to undefined function groups_remove_all_group_members() in /.../MOODLE_18_STABLE/lib/moodlelib.php on line 3205

All the forum discussions have been deleted, but on the Forums Activity page the number of discussions have not been reset to zero (see attached screen shot). Why is that?

Joseph


 
Average of ratings: -
me
Re: Reset course functionality - request for comments
 

Hi Joseph,

Current moodle code for reseting forums has bug. Also moodle does not reset other modules.

I fixed the bug for forum and implement the reset for some other modules. It seems you didn't update your code with the code snippets that I attached to my previous post.

Cheers,
Shamim

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Reset course functionality - request for comments
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators
Hi Shamin,
Are your recent modifications now available in moodle 1.8.2 CVS so that upgrading one's 1.8.2 stable installation will automatically integrate your modifications?
Joseph
 
Average of ratings: -
me
Re: Reset course functionality - request for comments
 
Hi Joseph,
No they are not added to CVS.

I don't know if I should do anything to add this part to CVS myself.

Shamim
 
Average of ratings: -
Picture of eva cutanda
Re: Reset course functionality - request for comments
 

Hello Shamin,

I have a problem with your code. I have made all changes in modules but when I start moodle the courses are lost (the central page is blank) and I have a message: Module "dialogue" is not readable-check permissions.

Can you help me?

Thank you very much.

 
Average of ratings: -
Picture of Shamim Rezaie
Re: Reset course functionality - request for comments
Group DevelopersGroup Particularly helpful MoodlersGroup Translators
HI Eva,

Sorry for the late response. I guess you are using a newer version of Moodle than the one I implemented those functions for.

I suggest you using the newest version of Moodle in which problems are solved already.
 
Average of ratings: -
Lei Zhang
Re: Reset course functionality - request for comments
 
After I applied Chris's code, soon we realised it's too hard to select courses from 1000+ courses that we have. So I added an extra ajax function using YUI to autocomplete course name; it also outputs information such as, which course is being reset during the process. Hope it helps some big schools/universities.
 
Average of ratings: -
Picture of Patrick Pollet
Re: Reset course functionality - request for comments
Group Particularly helpful Moodlers
Hello,

I have modified Chris's code to be more "Moodlish" . Ir runs with latest 1.9.8+ weekly

1) added language files
2) the script is know meant to run from Moodle's local directory
3) a link to it now appear in Adminstration 's courses sub-menu
4) fixed a bug when there is no course with id=2 (was used to fetch the standard roles to display)
5) changed course ordering from sortorder to fullname
Enjoy.

@lei : shall be interested by your ajax autocomplete to improve my version Thkx.

 
Average of ratings: -
Picture of Edward Hewlett
Re: Reset course functionality - request for comments
 

Does anyone here know if this code works with Moodle 2.0.2+ (current latest version)? I'm setting up for next year already and would like to reset all courses... Or is this functionality already built into Moodle 2 and I'm just not yet aware of where to look?

 
Average of ratings: -
Picture of ahmad hamwi
Re: Reset course functionality - request for comments
 

Hello,

I just wanted to ask you if anything came up for Moodle 2.

Did the code work on Moodle 2?

best regards,

 
Average of ratings: -
Picture of Patrick Pollet
Re: Reset course functionality - request for comments
Group Particularly helpful Moodlers

Since you have to patch the file admin/settings/courses.php to add the new menu item 'reset courses', don't forget to move the backup of this file away from the admin/settings folder ! Otherwise you shall get the courses menu twice as per the attached image.

Cheers.


 
Average of ratings: -
Picture of ahmad hamwi
Re: Reset course functionality - request for comments
 

Any news for moodle 2?

 
Average of ratings: -