For the new semester, we are switching over from the old gradebook to gradebook_cdc on our server. I just downloaded the latest CVS version Monday, and have modified it to support this style of CSV data importation (As well as to show usernames along with first/last names). Basically, the newly imported CSV data simply goes directly into the assignment module's table, which is completely transparent to all the new gradebook features.
So my question is: would any of the gradebook_cdc developers like to see this admittedly rudimentary version of uploading merged into gradebook_cdc? If so, I'd be happy to provide my code.
We'll release the version with backups in the next week or so, and then if your feature still works (or if you can get it working again, we'd be happy to merge it in.
I don't foresee that your code should stop working with the gradebook_cdc table restructuring. Based on what you have described the gradebook code will not know the difference since the data you are modifying is in a different module. This will be a wonderful addition for numerous users as this is the most requested feature on the moodle forum that we have not implemented.
If you would like us to include it, I would suggest testing it with the new code that was placed in CVS/contrib yesterday. Please note however that some gradebook settings may be lost upon upgrade due to the table restructuring since I have not had much time to test the code, and have adjusted our server manually. All new information will work properly however. For further info please see the post yesterday from Michael Penney.
The only problem I saw was I received the "Could not remap modname to modid for table ..." error twice when the new version tried to update my table structure. All the tables looked correct, structure-wise, so I ended up just emptying the course_grade_exceptions and course_grade_item tables to be on the safe side.
Uploads work as expected.
One added bonus: you can actually upload grades for multiple assignments at once--just add more columns, each with a different assignment number (see the link in my original post above for info on format).
Two caveats: First, this only really works for assignments in the assignment module. I have no idea about other activities, but I don't think it works for them. Second, it will work for custom scales, but the values in the uploaded files must be integers 0, 1, ..., N, representing the custom scale labels you've set up for an assignment (with 0-N corresponding to the order of values in your custom scale definition).
The attaached zip has a slightly modified version of the original import_grades.php cited in the other post (I increased the timeout limit to allow for larger uploads), together with a simple context diff patch file capturing the differences in the two gradebook_cdc files I had to modify to get this to work. The diff was taken against a CVS download from about 20 minutes ago.
Please let me know if this works!
The first time I hit the grade book, I got a fatal php error during stage 2 of the upgrade process on line 164 of gradeslib.php for trying to use a $stdClass object as an array. I'm guessing that is because the course_grade_item table was empty. I just reloaded the page, and the remainder of the process went as expected and everything works fine.
Just a "heads up" so the appropriate special-case code can be added by you guys. And thanks for all the hard work!
A couple of questions for you.
What happens if an instructor uploads the same file twice, what about if they make changes to their file and then upload again, or the refresh button is clicked twice? . ie. does it update the existing ones, add new ones, or ignore the file?
What is the level of error checking done? Is the user protected from mistakes at all.
Are there any "gotchas"or other problems that may show up currently?
Each upload action is completely independent, so the second just "overwrites" the first. If the second file is exactly the same as the first, there won't be any observable difference in the gradebook from a single upload, AFAIK.
In the upload process, the first line in the CSV is used to determine the attribute used to identify students (typically "username"), together with the assignment number (or numbers) for which scores are being uploaded. Each subsequent line is then split, and for each assignment column, one row in the assignment submissions table is updated (or created) with the corresponding user id and assignment id. This row is given the uploaded score, appropriate timestamps, the teacher's id, and a generic "Imported from text file" feedback comment. I'm not sure exactly what happens for assignments that allow multiple submissions (each upload may go in as a separate submission, but I have no idea--I haven't checked, as I never set up off-line assignments that way).
Note that this means no action at all is taken for students who are not listed in the file--their scores remain unchanged. Thus, partial uploads are possible. Any upload action simply updates the current submission scores for the students listed in the CSV file.
> what about if they make changes to their file and then upload
See above. No problem.
> or the refresh button is clicked twice?
AFAIK, refresh has no effect. If you mean what happens if they click the "Import Grades" button twice, I believe the second upload just overwrites the first.
> What is the level of error checking done?
Appropriate errors are displayed for users in the CSV file that are not found enrolled in the course and (I think!) for assignment numbers that are invalid.
The biggest "gotcha" is if you accidentally enter an incorrect (but valid) assignment number in the CSV file. As long as the assignment number is for an assignment in this course (actually, I'm not sure if this is even checked! you'll have to dig in the code), the upload will cheerfully proceed, overwriting any scores in that other assignment. I've never had this happen, but can imagine how it could.
OTOH, I don't think there is any way around this problem if you specify the assignment in the CSV file by hand. It would be possible to add a bit more error checking (say, echo the assignment name for the given assignment in the CSV file in a confirmation window before proceeding) than is already there.
Could you provide an example CSV file that follows your described format?
Sorry about that. A brief example and other info was in Zbigniew Fiedorowicz's original post, which I'd referred to at the start of this thread:
Here's a brief re-quote:
The import file format looks like this:username,### smith,27 jones,43 james,78
Here ### in the first line should be replaced by the assignment number into which you are uploading the grades. If you click on the assignment link the url will look like: http://yourmoodlesite/mod/assignment/view.php?id=###
Thank you for your offer to share code. I have been requesting a response from Michael Penny & Jason Cole about incorporating another one of Zbigniew's "cool codes" into either or both of the Gradebook2s since November 14, 2004. No response from either developer.
The code I am referring to is,
Grade distribution statistics and graphing
Hope you have better luck getting a response.
Thanks for your response.
I also believe that it would be useful for a eventual MoodleParent page which would allow parents/guardians to view how their kids are doing in class. Some parents may not understand English well in the US school system but they can understand a visual graph of where their child 's grades in a subject are relative to the rest of the class.
I played around with it a little this afternoon. It seems that the phplot.php file included with the grade_stat distro issues a warning on more recent versions of PHP, which prevents the graph from being viewable. I only had to change one line to get it working.
Line 167 in lib/phplot/phplot.php was:
var $line_widths = 1; // single value or array
I changed it to:
var $line_widths = array( 1 );
With this change, the stats graphing started working just fine. Of course, it only graphs the raw points in the module's table, not any weighted/curved derived score shown in the gradebook_cdc view, but that is to be expected. Let me know if this works for you.
We have no plans to add graphing to it (we're fixing backup now and then on to other things), but if someone else would like to add it, we'd be happy to include the code if it is solid.
Thanks for your response.
Looks like Stephen is going to work on the possibility of incorporating Zbigniew's grade graphics code into the GradeBook if he gets some time this semester.
C:\Program Files\EasyPHP1-7\www\course>patch grades.php upload.patch
patching file grades.php
Hunk #1 succeeded at 33 (offset 4 lines).
Hunk #2 succeeded at 362 with fuzz 2 (offset 31 lines).
Hunk #3 FAILED at 601.
Hunk #4 FAILED at 1552.
2 out of 4 hunks FAILED -- saving rejects to file grades.php.rej
patching file gradeslib.php
Reversed (or previously applied) patch detected! Assume -R? [n] y
Hunk #1 succeeded at 347 (offset 29 lines).
Hunk #2 FAILED at 355.
Hunk #3 succeeded at 1093 (offset 75 lines).
Hunk #4 FAILED at 1113.
2 out of 4 hunks FAILED -- saving rejects to file gradeslib.php.rej
I downloaded the most recent versions, but patching it gives me errors. Could someone give me their files? I am trying to be able to use the upload patch.