Script to convert Journals to Assignments

Script to convert Journals to Assignments

by Howard Miller -
Number of replies: 33
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
With due respect to Bruno Vernier and whoever the original author was, I have updated the script to convert Journals to Assignments for 1.9. It now fixes a bug in the original database upgrade (back in Moodle 1.5 I think) and handles grades properly.

Get it here...

http://cvs.moodle.org/contrib/tools/journal2assignment/

Instructions are in the comments at the top.
Average of ratings: -
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Ryan Smith -
Howard,

I just tested the script on a fresh install of Moodle 1.9 with a sample course and sample journal.

I graded the journal entry a 42/100, then ran the conversion script. It added an online text assignment with the same name, and the grade and comments were transferred over correctly to the assignment.

When I go into the gradebook, however, the online text assignment is listed but shows no grade entered for the test student. Any ideas why this is happening?

Thanks for your help.
In reply to Ryan Smith

Re: Script to convert Journals to Assignments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Mmm.... I'll look into that. Thanks for the feedback!
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Ryan Smith -
Thanks! Let us know if you need us to test another version of the script...we've got around 600 journals on our install that aren't being included in the gradebook at all right now. sad
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Matthew Davidson -
Picture of Core developers Picture of Plugin developers
I think that the problem we are having with the script is because the mdl_grade_grades table isn't given a record for the new assignment item.

Also, some things to do...

1. The newly created assignment needs to be placed in the teachers page in the exact same location as the pre-existing journal item.

2. Make a flag, default set to false, that will delete the journal after the assignment is created.
In reply to Matthew Davidson

Re: Script to convert Journals to Assignments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
There was a bug in Moodle that propagated to the script. This is now fixed, make sure you have the latest version of the script.

The assignment *should* be immediately above the old Journal.

I decided not to delete the Journals so you can check it. You can do that very easily in the Modules screen in the Site Administration.
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Matt Campbell -
Hi, Howard.

Your script worked like a charm and I've converted all my Journals to Assignments and hid the Journal activity.

I did notice that on 1.9, it doesn't put the new assignments into a gradebook category and I had to go in manually and match those back up. Not sure what sort of effort that may take, or if you even want to - you'd have to build a check for what Moodle version they're using, wouldn't you?

Thanks,
Matt
In reply to Matt Campbell

Re: Script to convert Journals to Assignments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Matt,

I'm *really* hazy about the gradebook because we don't use it. I don't really understand. Can you spell out the problem and I'll have a look.

You did use the very latest version? It's up to 1.5 now smile

Howard

EDIT:
Ahhh... it doesn't transfer the "common module settings" at all. There's something else where I'm unsure how it works. Off to trawl through code tongueout
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
...and another thing...

Journals don't have grade categories. I'm confused!
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Matthew Davidson -
Picture of Core developers Picture of Plugin developers
Here is a fix for the journal conversion that adds the mdl_grade_grades table entries.
In reply to Matthew Davidson

Re: Script to convert Journals to Assignments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Wooh - Hoo!!

One less job, thanks very much smile

Updated in CVS.
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Matthew Davidson -
Picture of Core developers Picture of Plugin developers
My latest fixes...

Places new grade items in correct category and gives it correct sort order.
Moves old journal grade items to the back and hides them from students.
Skips journal items left over from deleted courses
Debug items added but debug is default turned off.
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Ryan Smith -
Howard,

Would you mind checking out Matthew's latest conversion script? If it looks good can you check it into CVS? Thanks!
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Scott Marlowe -
Maybe I'm not seeing the obvious, but since there is no "read me" in the archive, exactly where do you put the script to install it in your Moodle directories?
In reply to Scott Marlowe

Re: Script to convert Journals to Assignments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Fair point... the instructions are in a big comment at the top of the script, but how would you know that smile

Simply stick it in the root of your Moodle installation and run it from a web browser. You need to be logged in as admin first.
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Marc Grober -
It just occurred to me to ask (I didn't find where this was addressed, which of course doesn't mean that it hasn't been) whether the functionality of the script Howard has developed will be part of the Moodle 2 upgrade? If not, and the user does not convert journals to assignments before an attempted upgrade, what will result.
In reply to Marc Grober

Re: Script to convert Journals to Assignments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
We didn't actually discuss that but it is designed to be a separate script, not part of the upgrade process, so I doubt it will be included. I think you might be too young (in Moodle years) but Journals where "removed" during the upgrade to (IIRC) Moodle 1.5.

There is no Journal code in Moodle 2.0, so the Journal tables will be left completely alone by the upgrade. The script should still function.

You have reminded me to check that the script works at all under 2.0. I think we'll need to do a different version for that anyway.

EDIT:
Yes indeed, the script will (as it stands) not work under Moodle 2.0 so, until I can get it sorted, the advice is to fix Journals before upgrade. I know that won't cut it though sad
In reply to Howard Miller

Re: Script to convert Journals to Assignments

by Marc Grober -
While still in Moodle short pants I start using journals in 1.8 in part because of the title of the activity, as journal betokens more perhaps what one thinks of today as blogging than an online assignment, i.e. something that is immediate, takes place as part of experience if you will, not after, and is on-going. While the functionality does indeed exist elsewhere, the "journal" as a functional centerpiece of reflective practice, will be sorely missed.... perhaps I should replace all instances of "online assignment" with "journal" ;=}

However, to the functional issue!

I am, I guess, surprised that an upgrade from Moodle 1.x to Moodle 2 where the Moodle has courses with journals will run smoothly. I had expected that it would result in making quite a mess of the coursees assignments and gradebook, but assuming that is not the case, it seems to me that it makes sense to ensure that the Moodle 2 setup checks the db to determine if there are journals and then offers the option to convert or cancel, as there are quite a few people who continue to use journals (whether they are romatics like me or just uninformed of the obsolescence) and this could be a worse experience than that of upgrading to 1.9 and discovering that all your gradebooks now resemble badly scrambled eggs while grades are due in 48 hrs......

I guess here again I am trying to look at the situation from the perspective of the gazillion users who are not obsessive about forum postings or implementing the latest stable (there are lots of folks still using Moodle 1.4 because it provides them what they need....) What will Joe User, with a moodle with dozens of existing courses which have contained journals for some years, have to deal with when he decides to go ahead and upgrade to Moodle 2 and then get calls from teachers saying that none of their journals work? If one is going to claim that Moodle is so easy to use that even a "teacher" can manage it, then we had better make sure we trap all issues before they create some meltdown for Joe.....
In reply to Marc Grober

Re: Script to convert Journals to Assignments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It does work... it's had quite a lot of testing and refinement (I hope).

The name of the Assignment module has been a bugbear for a lot of people, I know. I guess you can always name it something else in the Language pack.

If you think the upgrade should be in core, you should raise a tracker report that can be voted on. It would be easy enough to make part of the upgrade (it was developed from the original 1.5 code after all).
In reply to Howard Miller

Re: Script to convert Journals to Assignments - Tracker item to include in core 2.0 setup

by Marc Grober -
In reply to Marc Grober

Re: Script to convert Journals to Assignments - Tracker item to include in core 2.0 setup

by rui gomes -
Hello,

We have version 1.9.8 and getting this error:

Error reading journals from database


Anyone help?

Regards,

João Neves
In reply to rui gomes

Re: Script to convert Journals to Assignments - Tracker item to include in core 2.0 setup

by Mario Santonastaso -
Not sure if this is the issue, but I recently had an issue where all forums were showing no posts. In my Moodle installation, under Site Administration, I have a Server>Database link that brings me to MySQL Admin. The the MySQL Admin is available online for Moodle and adds that menu item to Site Administration under Server. Here you can perform repairs on the various database tables that Moodle uses to store its information. If you can't read the Journal posts, you might look here to see if that table needs repair.

In reply to Mario Santonastaso

Re: Script to convert Journals to Assignments - Tracker item to include in core 2.0 setup

by rui gomes -
I have repaired the tables, didnt help.

The error message only appear when we try to run the journal php.
In reply to Marc Grober

Re: Script to convert Journals to Assignments

by Paul Webster -

I recently upgraded from 1.9 to 2.0.  I didn't realize journal was not going to be supported anymore.  Is it too late to run the journal2assignment script?  I put the php file in the root of my moodle and then put it in the address of my browser.

I get an error: get_records() not available anymore

 

Any ideas?

I appreciate your help.

In reply to Paul Webster

Re: Script to convert Journals to Assignments

by Greg Padberg -

I still have a lot of Journal activities on my server, last year we migrated from Moodle 1.9 and are now at 2.2 with plans to upgrade to 2.4 or possibly newer.  I must have elected not to convert the Journal activities to Assignments at some point during previous upgrades.  As Moodle 2.5 has now been released and the Journal add-on module is not yet available beyond Moodle 2.4, I am looking towards the future and hope to not leave any Journal data behind.

I found the following:

https://github.com/jamesballard/moodle-misc_journal2assignment

Can anybody vouch that the convert script works with Moodle 2.2?

In reply to Greg Padberg

Re: Script to convert Journals to Assignments

by Greg Padberg -

I tried the script on my Moodle 2.2.10 installation with the following result (debugging turned on):

Converting Journal 'Are you ergonomically correct??' (433)

 

Error writing to database

More information about this error

Debug info: Column 'grade' cannot be null
INSERT INTO mdl_assignment (course,name,intro,introformat,assignmenttype,resubmit,preventlate,emailteachers,var1,var2,var3,var4,var5,maxbytes,timedue,timeavailable,grade,timemodified) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
[array (
0 => '95',
1 => 'Are you ergonomically correct??',
2 => 'Many people have a hard time working at the computer in an ergonomically correct way.  People have a habit of sitting at the ccomputer in a certain way that may not be ergonomically correct.  For me, I have a difficult time keeping my feet flat on the floor.  In a short paragraph, tell me what are the most difficult things for <em>you</em> to be ergonomically correct and how you are going to try and correct it.  Name at least 2 things.  In the long run, it will be good for you. This will be counted in your \\"Real life Applicatiom\\" mark. ',
3 => '1',
4 => 'online',
5 => 1,
6 => 0,
7 => 0,
8 => 1,
9 => 0,
10 => 0,
11 => 0,
12 => 0,
13 => 0,
14 => 0,
15 => '1251180000',
16 => NULL,
17 => '1251579874',
)]
Stack trace:
  • line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 973 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1015 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 99 of /journal2assignment.php: call to mysqli_native_moodle_database->insert_record()

 

Any experts here that can help me resolve this?

In reply to Greg Padberg

Re: Script to convert Journals to Assignments

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

The error is caused by the line of code $assignment->grade = $journal->assessed; The word "assessed" needs to be changed to "grade" instead. It is in line 97 of journal2assignment.php located at https://github.com/jamesballard/moodle-misc_journal2assignment.

Further discussion about this is at https://moodle.org/mod/forum/discuss.php?d=229770#p999415

I have tested this on Moodle 2.2 and 2.6dev and it works on both. Just be aware that the converted assignments are the old style and you will need to run Assignment upgrade helper to fix them. In Moodle 2.6 the converted journal will not even be visible until you run Assignment upgrade helper.

HTH,

AL

In reply to AL Rachels

Re: Script to convert Journals to Assignments

by James Ballard -

I have committed this change. I am not specifically working with Moodle at the moment so have not had a chance to test.

Hope this works for you

Yours

James

In reply to James Ballard

Re: Script to convert Journals to Assignments

by Greg Padberg -

The journal2assignment.php script worked successfully on my Moodle 2.2.10 installation.

Thanks for your help!

In reply to Greg Padberg

Re: Script to convert Journals to Assignments

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

You're welcome Greg. Also thanks to James for the commit.

AL