Patch for Downloading assignment files as one Zip file.

Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Number of replies: 75
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
This patch allows you to download all assignment submissions as a single zip file, to mark off-line, I haven't created a function to upload them back again, but I might get round to that eventually.

- I think there may be a problem with caching - if the assignment files change within a couple of minutes of the last time you downloaded the full zip, I'm not sure if it collects the new zip correctly. - let me know if you manage to test this!

the attached text file contains a function you need to add to mod\assignment\type\uploadsingle\assignment.class.php


then to trigger this code you need to put a link or button somewhere.... - I used this code for testing it in mod\assignment\submissions.php
replace this line at the bottom of the page:
$assignmentinstance->submissions($mode);  // Display or process the submissions

with these lines
    if ($download) {
        $assignmentinstance->download_submissions();
    } else {
        $assignmentinstance->submissions($mode);  // Display or process the submissions
    }

then when viewing your submissions for an assignment eg http://moodle.org/mod/assignment/submissions.php?id=1
add "&download=sfddsafa" to the end of your url.

:-)

Dan
*edit* - put function into text file - post looked a bit long!


Average of ratings: -
In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
you may also need to alter the function get_submissions in your moodle install \moodle\mod\assignment\lib.php

to this:

function get_submissions($sort='', $dir='DESC') {
/// Return all assignment submissions by ENROLLED students (even empty)
global $CFG;

if ($sort == "lastname" or $sort == "firstname") {
$sort = "u.$sort $dir";
} else if (empty($sort)) {
$sort = "a.timemodified DESC";
} else {
$sort = "a.$sort $dir";
}

$select = "s.course = '".$this->assignment->course."' AND";
$site = get_site();
if ($this->assignment->course == $site->id) {
$select = '';
}

return get_records_sql("SELECT a.*
FROM {$CFG->prefix}assignment_submissions a,
{$CFG->prefix}user_students s,
{$CFG->prefix}user u,
{$CFG->prefix}user_teachers t
WHERE (a.userid = s.userid OR a.userid = t.userid)
AND u.id = a.userid
AND $select a.assignment = '".$this->assignment->id."'
ORDER BY $sort");
}


NOTE: - this will then include all teachers responses in the download as well as the students.

smile

Dan
In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Josep M. Fontana -
Hi Dan,

I used your patch and I want to report that it doesn't seem to work with the upload review type.

Josep M.
In reply to Josep M. Fontana

Re: Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
bummer! - did you get any errors, or did it just "not work"?

- I might get a chance to look at it sometime this week.....

smile
In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Josep M. Fontana -
No, I didn't get any errors. It simply didn't work. No link or button appears saying that you can download all the submissions. In fact I've left your modifications in the files since they don't seem to affect anything negatively either.

I think the upload review plugin (if it is technically a plugin) works somewhat different from the standard assignment types. I have a non-standard block that tells you which activities have been graded and which ones still have to be graded and while it can monitor the assignments when they are in the 'upload a single file' mode, it doesn't "see" any assignments when I use the 'upload review' mode.

Josep M.

Josep M.
In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

here's a new version of this script - the old one had a few issues with larger numbers of assignments - the script timed out instead of zipping all the files, and also if the file was quite large it wasn't downloading the whole file.

Note: - this script will take a while to process if you have a large number of submissions.

In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Dhiraj Bhartu -
Hi i did modify the codes as per your instructions but i came across some error. Below is the error i encountered.

Warning: Invalid argument supplied for foreach() in C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php on line 22

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php:22) in C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php on line 72

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php:22) in C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php on line 73

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php:22) in C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php on line 74

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php:22) in C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php on line 75

Fatal error: Call to undefined function readfile_chunked() in C:\wamp\www\moodle\mod\assignment\type\uploadsingle\assignment.class.php on line 76

Anyway help on this will be very much appreiated.

The firefox downloadthemall does work fine but not all lecturers here use it.

Thanks to all for the advice.
In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Nicolas Sicard -
Hi,

Great hack, but it doesn't seem to work on our fresh Moodle 1.8 install triste.
I can't find where it comes from...

Any idea ?

Thanks

nico
In reply to Nicolas Sicard

Re: Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Hi Nicolas - it's working for me here, bounce me an e-mail off-line and I'll send you a zip of my assignment folder.

smile

Dan

In reply to Dan Marsden

Download all files as Zip V3

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
This version shuold be a bit better - displays a "clean" error when no submissions are found, and also checks to make sure values exist before trying to use them.

Follow the instructions in the attached file to add this to your install

smile

Dan
In reply to Dan Marsden

Re: Download all files as Zip V3

by Julian Ridden -
I have tried to implement this in a feresh nightly build of 1.6 and am getting the following error:

Fatal error: Call to undefined function: strripos() in /home/Moodle/public_html/mod/assignment/type/uploadsingle/assignment.class.php on line 53

Where is this function defined?
In reply to Julian Ridden

Re: Download all files as Zip V3

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Julian,

that's a PHP function (or so I thought) - turns out it only appeared in php 5 - my bad sorry! I'll rewrite that to use non php 5 specific commands, and update the file today or tomorrow!

thanks!

smile

Dan
In reply to Julian Ridden

Download all files as Zip V4

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
not sure why I was using strripos - replace it with strrpos (no i) - it will do the same thing. - I've attached a new file to this as well.

thanks!

smile

Dan
In reply to Dan Marsden

Re: Download all files as Zip V4

by Julian Ridden -
Absolute sheer brilliance smile

On behalf of my faculty, I salute you big grin
In reply to Julian Ridden

Re: Download all files as Zip V4

by Art Lader -
Any chance you would put this in the Playpen, Julian?

-- Art
In reply to Art Lader

Re: Download all files as Zip V4

by Julian Ridden -
Happy too. I am moving Playpen to 1.6 Beta this weekend and will add this feature.
In reply to Dan Marsden

Re: Download all files as Zip V4

by Deon Metelski -

Hi Dan,

I was wondering if you had a chance to look at the upload/review type to see if this can work with that?

Thanks,
Deon

In reply to Deon Metelski

Re: Download all files as Zip V4

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Deon,

no sorry, I haven't had a chance - I'll keep it on my list of things todo though!

smile

Dan
In reply to Dan Marsden

Re: Download all files as Zip V4

by C Lopez -
i've been hacking at the "advanced upload" type to see if I can get a "download_submissions()" function for it. The idea is that for multi-file submissions, you would download a zip file that contains a directory for the assignment, with directories for each user, containing the files with the original file names. We like this because for programming assignments we don't want to change the file names. Would there be interested in such an extension?

I think downloading and uploading files and grades sound like two different tasks that should be done more or less separately. If there's a need for some kind of canonical file name to allow mappings between users and ids, or assignments and ids, then I think there should be helper functions to do it in a consistent way.
In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Julian Ridden -
I would like to know if we could try and get this incorporated into the 1.7 release.

Over the last few months this code has proven to be a standout addition inmy install and many of my teachers have praised the abilities it puts forward.

Have others been using this in production yet?
In reply to Julian Ridden

Downloading assignment patch in 1.7?.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
our teachers are using it extensively, but there is also a requirement to be able to upload a list of marks to the system as well - allows for all to be "marked" at the same time so students all see their marks at the same time, and allows lecturers to mark them off-line.

I also want to create a function that uploads the files back to moodle for the upload/review assignment type.

smile

Dan

P.s. (MD if you see this and are happy with it, if you gave me access to the assignment mod in cvs, I'd be happy to commit, maintain it) smile
In reply to Dan Marsden

Re: Downloading assignment patch in 1.7?.

by Josep M. Fontana -
>I also want to create a function that uploads the files back to moodle for the
>upload/review assignment type.

This will be great, Dan!

I'm curious to know how you are planning to achieve that.  How will the files be identified so that the system knows which user do they belong to?

>there is also a requirement to be able to upload a list of marks to the system as
>well - allows for all to be "marked" at the same time so students all see their
>marks at the same time, and allows lecturers to mark them off-line.

This would also be a great improvement. Will it be possible to upload the marks in the form of an excel file?

Josep M.
In reply to Josep M. Fontana

Re: Downloading assignment patch in 1.7?.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Josep,

sorry - just saw this! -

The download files include a users username in the name of the file. - it renames the files that a user uploads to include some extra info.

The marks import will hopefully work for both Excel files and CSV - I'll probably get the CSV one working first. - Been pretty busy here so haven't had a chance to do it yet!

smile

Dan

In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -
I am working on this patch for use with the "online text" assignment.  It now creates a zip file of html files.  At the moment it is not "integrated" but our teachers would like to see this functionality for all assignment types.  My php programming skill is about -1 on a scale of 1 to 10, so if anyone is making a decent job of this it would be great to hear from them.
In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -

Attached is the patch modified for both online and uploadsingle assignments.  I have applied it to version 1.7 and it seems to work OK, but I haven't tested it exhaustively!

I would like to see the zip facility available in the standard Moodle release but I don't know how to make that happen sad.

Chris

In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by Art Lader -
Hi, Chris,

Do you think it would work with 1.6, too?

Thanks,
Art
In reply to Art Lader

Re: Patch for Downloading assignment files as one Zip file.

by Wen Hao Chuang -
Yeah I'm curious about this too (and whether this would work OK with 1.5.4+ codes). By the way it would be really GREAT if someone could come up with a solution not just allow instructors to download ALL assignment files, but also allow instructors to upload a Excel spreadsheet to update the Gradebook. Currently we do not have enough bandwidth to take on this project... If any team is working on this please let me know, thanks!
In reply to Art Lader

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -

Hi Art,  I developed it on 1.6 - so just double check the line numbers of where things go in lib.php, the code should be fine.

Regards Chris

In reply to Art Lader

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -
Art - sorry blush I have only just spotted this question -yes the patch originally worked with 1.6, but the line numbers will need checking and the patch re-testing.
In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by Jérôme DEMIAUX -
hi all,

I tested your patch on two differents moodle server with exactly the same database (course, theme, ...)

windows, moodle 1.7.1+, mysql 5.0.21, php 5.1.4
linux , moodle 1.7, mysql 5.0.16, php 5.1.1

it works good with window/1.7.1+ but i've only a blank page with linux/1.7

Any ideas ?

Jérôme.

In reply to Jérôme DEMIAUX

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -

Jérôme, I'm not a php coder and i had a problem getting the "download" switch to work.  When I clicked the "zip" button nothing happened.  I tried the optional_parameter function and that seemed to fix things  (we're windows/php/mysql).  Try some mtrace debugging to make sure the function download_submission is being called properly.

Chris

In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by Jérôme DEMIAUX -
I don't know why but when i leave blank this empty field (path to zip), it's work.
But now, it is the entire backup which is blocked.

Huum, difficult choice no ?

Jérôme.

Attachment path2.gif
In reply to Jérôme DEMIAUX

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -

Ouch!

The 1.7 forums seem full of backup problems...

So - Mondays, Wednesdays and Fridays you do backups

Tuesdays and Thursdays  staff can zip their files...

Sorry I'm being facetious.  I've only ever used the internal zip routines.

Chris

In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by Chris Fryer -
I've tested this and it seems to work fine for online, single-file and advanced upload assignments in Moodle 1.8.

If you want it included in the core, I suggest you create a new feature request in the bug tracker and attach your modified files.
In reply to Chris Fryer

Re: Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Hi Chris,

It's already in the tracker - see MDL-7206

Have I missed something? - the main thing holding me back from putting this in core was that I hadn't written and hadn't seen anyone else do the advanced upload script.... - are you sure it works for the advanced upload type?

thanks,

smile

Dan

In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Julian Ridden -
I had nearly forgotten about this great piece of code you wrote Dan.

I have applied it to my 1.8 and 1.9alpha with no issues to report.

It is working in the advanced upload assignment type, but currently only grabs the files, not the notes. This is enough for me at the moment.

I have attached my patched 1.8.1 code to this post. For those tha want to use it, just over-write your existing assignment files with these ones.

P.S. Obviously back up first!!
Average of ratings: Useful (1)
In reply to Julian Ridden

Re: Patch for Downloading assignment files as one Zip file.

by Dirk Herr-Hoyman -
Hi Julian- Could I get you to post a diff version?
What you do is
diff -c old/assignment new/assignment > assignment-1zip.diff

where old is the directory with the original version and
new is the patched version. This will create a context diff
file.

What I want to do is use the unix patch utility to
apply this "patch".
See http://en.wikipedia.org/wiki/Patch_(Unix)
for background. What patch does is to look at the output
of diff and apply this as a "difference". This is a long time technique in the
unix community to send patches in discussion forums
(originally in network news). As long as
your original files are in sync, using diffs works fine.
The advantage of this approach
is easier management of patches using diff.
For example, you can create a "backup" of the original
with the patch -b option. This will work with a whole
directory tree where multiple files are being changed.
Where I'm going with this is the patch could be listed
in the Moodle Modules and plugins.

I'm working in 1.8.1 (on about May 5th), which is what
you said you have.
I tried to create my own diff -c, but there were quite
a few files that are missing. Rather than guessing at
this, I thought I get you to generate it for me.

Thanks --Dirk
In reply to Dirk Herr-Hoyman

Re: Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Hi Dirk,

I've just attached a diff to MDL-7206

I'm not soo keen putting it in Modules and Plugins - I'm aiming to have it in the main download....

thanks,

smile

Dan

In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Julian Ridden -
I'm all for getting this into the core.

Have you raised this with Martin? Whats the status?

JR
In reply to Julian Ridden

Re: Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

yup - aiming for 1.9 - I just need nto test using the function sendfile to send files to the user instead of the method currently used. - I'm on holiday these next few weeks, but hope to get it in over that time!

smile

Da

In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Julian Ridden -
Any news on this in the core? It looks like it didnt make it.

I have got it working in 1.9 beta on both the 'Upload single' and 'online' assignment types. Am a little lost getting it going in 'Advanced upload' assignments however.

Open to advice/answers here wink
In reply to Julian Ridden

Re: Patch for Downloading assignment files as one Zip file.

by Jay Melton -
I just added the one directory and two .php files to my assignment directory (moodle 1.8+), and it worked like a charm. I've been taking at least 15 minutes to download around 25 files using Firefox. I tried it out with Safari (moodle seems to be a lot faster in Safari on OSX) and it took all of 15 seconds!

Wonderful job, guys! This should be in any standard install of moodle!

Jay in Japan
In reply to Jay Melton

Re: Patch for Downloading assignment files as one Zip file.

by Jay Melton -
Just to follow up. The patch in the message I replied to gives a BLANK page when going to the offline assignments modules. There's a bug in there somewhere.

I have not checked the other kinds of assignments.
In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by Jim Johnston -
I applied the patch and get the following error message

PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to open archive './assignment.zip' in wb mode

Do I have permissions in a directory set wrong? (Linux system)

TIA...

Jim
In reply to Jim Johnston

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -
Hi Jim - which files did you use, mine or Julian's? (The threading seems a bit awry - when I click in Show parent on your message it takes me to the very top of the thread)

Regards Chris
In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by Julian Ridden -
Cant have been mine. Mine was posted hours after his post. The threading does get difficult. I find myself looking at timestamps more often than not to confirm.
In reply to Jim Johnston

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -

Jim, my zip file was created on windows.  Just unpack to a new directory then copy files out from there.

Chris

In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Mark Pearson -

I've been working on getting the ZIP assignment operational with my test Moodle 1.8.3. Basically, a number of 'power users' are crying out for the ability to download all the assignment submissions as a single zip file. I am happy to announce that it now worketh.

All the gory details are in my Moodle Issues TiddlyWiki under the tag assignment_zip

I have tested this with the latest Moodle 1.8.3 so I cannot guarantee that it'll work with anything younger.

Mark

In reply to Mark Pearson

Re: Patch for Downloading assignment files as one Zip file.

by Julian Ridden -
great stuff..thanks for the upload. Am I correct in assuming you also go this to work with the 'Advanced uploading file' assignment type?

Julian
In reply to Julian Ridden

Re: Patch for Downloading assignment files as one Zip file.

by Mark Pearson -
Yep. It works with 'advanced uploading' and single file uploading, but not 'online' (which is not surprising really, since you'd not normally want to download online assignments). Check out my TiddlyWiki site for what I did. I'm quite confident that this will play nicely with 1.8.3 because I did comb through all the code. Ain't Open Source grand?

Mark
In reply to Mark Pearson

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -
Hi Mark, My users are pushing for the zip file ability again - lost when I upgraded the system to 1.8.

I've had a go using your mods and hit the problem with the responses directory. I've installed a work-around which uses str_replace to change the '/' character to a '_' character for the destination file name. If anyone is interested I'll post the patch.

Have you any idea how to limit the download to a group? Or maybe put the group name into the file name?

Regarding on-line, I need to get that working. We use that for an Edexcel on-line exam where students are allowed a total of 4 hours access to their on-line document. The activity is hidden when they are not in class (so they can't alter anything from home for example).

If you have any suggestions as to what's wrong with the on-line code I'd be pleased to receive them.

Chris
In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -
Further to yesterday's post...

The online assignment stores user contributions in the database, not in folders. This means that the folder located :-
'course'/moddata/assignment/'number'
doesn't exist, but the call to file_area_name($userid) returns :-
'course'/moddata/assignment/'number'/'userid'

So the mkdir call to create the temp file fails.

I've got a test setup working where I check the existence of 'course'/moddata/assignment/'number' - and create it if it doesn't exist.

Then the call to mkdir('course'/moddata/assignment/'number'/temp) works.

To make sure that the folders moddata/assignment were created, I created an 'upload' assignment in the same course, AND had to upload a file.

If anyone knows where the code is that creates the missing folders please let me know because it should (imho) be added to the on-line submission code.

Another fix would be to use a function like mkdir which creates missing directory tree elements - that would make all this much simpler...perhaps there is one already smile

Chris


In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -
Another update - mkdir can create trees eg mkdir($path,0777,true); smile

Now I can tidy up my hacking. Merry Xmas all.
In reply to Julian Ridden

Re: Patch for Downloading assignment files as one Zip file.

by Mark Pearson -
Julian,

Also, have you got an account with Eduspaces ? It's a really great social networking for eduhackers based on elgg. I have a 'community' there called Moodle Vanguard which you may like to join. Or anyone else for that matter.

[England lost the world cup final -- boo hoo smile]

M
In reply to Mark Pearson

Re: Patch for Downloading assignment files as one Zip file in 1.9

by Julian Ridden -
Great news to report.

I finally got round to installing this, and through following your dif's am happy to report that this works in 1.9 as well.

great work.

JR
In reply to Julian Ridden

Re: Patch for Downloading assignment files as one Zip file in 1.9

by Bones Kendall -
This modification is fantastic for me. I really appreciate that someone did it. I hope it becomes part of the core.

In the meantime, how can I change it so that it will add the student's first and last names to the file instead of or in addition to the username?

Thanks,
Evan
In reply to Bones Kendall

Re: Patch for Downloading assignment files as one Zip file in 1.9

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Evan,

just noticed a couple of inconsistencies! - the online assignment saves files using the firstname/lastname, and the upload saves by username:

find this:
$filesforzip = $desttemp . $a_user->username . "_" . $filenewname . "_" . $file;

replace it with this:
$filesforzip = $desttemp . $a_user->firstname ."_". $a_user->lastname . $file;

and that should do it!

This isn't going to make it into 1.9 unfortunately - I didn't get it in time before the feature freeze - will try for 2.0!


In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file in 1.9

by Bones Kendall -
Wow, Dan!

Thanks. Seems to work just as I want. Awesome...

I'll let you know if I have any problems...

- Evan
In reply to Dan Marsden

Patch for Downloading assignment files - by groups

by Thomas Robb -
Thanks Dan for the work you have done since 2005 for the bulk downloading of Assignment files. I tried it out and it worked on my 1.9.3 version (early Jan. 2009 release) but one problem that I ran up against was that it downloaded all of the assignments, not just those for my own class. I have therefore reworked it so that it will download only the currently visible group.

I've also re-jiggered the name of the zip directory since before multiple downloads all downloaded as "assignment.zip". The attached version uses "assmt." + shortname of the course + groupname (if exists) + internal id number of the assignment in order to keep the assignments unique.

Also, since I tend to give l-o-n-g names to the assignment links, like "Upload your project here by Jan. 20th!" it didn't make sense to include all of this in each student's file name, so my version uses this formula: username+assmt internal id + uploaded file name.

I've zipped this all into a folder called "type.zip" which can simply replace the "type" folder inside the assignments module. It includes the code for the offline assmt type for completeness even though it hasn't been touched. As a precaution, you might want to rename the old assignment type folder to "type-old" before copying this into the mod/assignment folder just to be on the safe side. All assignment types however work for me in *my* environment!

Dan, feel free to take any part of this revision and incorporate it into yours. I don't intend to maintain this further, although if people report bugs with the code, I'm certainly willing to fix it.

Cheers,
Tom
In reply to Thomas Robb

Re: Patch for Downloading assignment files - by groups

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Thanks Tom,

the version of the patch in MDL-7206 has been able to handle groups for a while, and possibly has a range of other fixes that you haven't put into place.

I've been thinking a lot about the naming of files - I like your suggestions around the naming of the main assignment.zip file, and the individual files. I've had a lot of queries regarding having the Student ID number (not the userid) as the first part of the file (but it's not a required field in Moodle and most people using Moodle probably don't populate it.) - I've also had queries from people asking for the firstname/lastname to be included as well. It would be good if you could post some feedback on MDL-7206 - I'm keen to get it in Core in the next couple of weeks!
In reply to Dan Marsden

Re: Patch for Downloading assignment files - by groups

by Jonathan Smith -

Thanks for this. I hope to try out the patch over the next few days.

It seems an ideal answer for a member of staff who has a very unreliable home internet connection. She can download the pupils' work whilst at school and then take it home on a USB for marking.

Question: Is any work being done on the reverse process? How could she easily upload the marked work with comments back to the students? I know she could access the pupils one at a time from the marking screen and reupload their marked work back to them - but is there any way to speed up the process?

Jonathan Smith
ICT Coordinator
Portsmouth High School

In reply to Jonathan Smith

Re: Patch for Downloading assignment files - by groups

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Jonathan,

no work on the reverse process at this stage, but I've had a lot of interest, just needs someone to front up with the funding to get it done! (let me know if you're interested!) smile
In reply to Dan Marsden

Re: Patch for Downloading assignment files - by groups

by Amanda Doughty -
Picture of Core developers Picture of Plugin developers

I've had a go at doing this because we are reducing the turnaround time for feedback and need to speed up the process of uploading marked scripts. I had to make some changes to your download code to achieve a directory structure that suited our needs.

I have attached the patch and this is the help file explaining how it works:

Bulk upload feedback

In order to use this feature, you must first download all submissions using the button 'Bulk download all submissions'. The download will be a zip file which, when extracted, will be of the format:

[course shortname]_[assignment name]_[assno]
[lastname]_[firstname]_[userid]
filename.ext
[lastname]_[firstname]_[userid]
filename.ext
...
do_not_edit.txt

eg:

EDM116_PRD1_2009_10_Discuss_Life_42
Doughty_Amanda_1029
myassignment.docx
Hughes_Mike_6057
myattempt.xls
...
do_not_edit.txt


You can edit the downloaded files or add extra files to the [lastname]_[firstname]_[userid] directories. But DO NOT rename or add directories.

When all feedback is complete, zip up the [course shortname]_[assignment name]_[assno] folder and upload it using this form.

The uploaded files will not overwrite the student files. They will be renamed and saved in a sub directory for each user (within the file structure courseid/moddata/assignment):

assignmentid
userid
responses
filename_feedback.ext
filename.ext
userid
responses
filename_feedback.ext
extrafile_feedback.ext
filename.ext
...

eg:

42
1029
responses
myassignment_feedback.docx
myassignment.docx
6057
responses
myattempt_feedback.xls
notes_feedback.txt
myattempt.xls
...

IMPORTANT - Do not edit or delete the 'do_not_edit.txt' file. This is used to verify that you are uploading the correct zip file for the current course and assignment.

Also note that each time you use this feature, any feedback files will be overwritten, unless you rename them.

eg:

1. bulk download files as above example
2. edit myassignment.docx
3. bulk upload the files

This results in a new file .../responses/myassignment_feedback.docx

repeat steps 1 - 3

File .../responses/myassignment_feedback.docx is overwritten with the uploaded file.

Now try
1. bulk download files as above
2. rename myassignment.docx as myassignment2.docx and edit it
3. bulk upload the files

This results in a new file .../responses/myassignment2_feedback.docx, whilst
.../responses/myassignment_feedback.docx is preserved.

Once feedback is released. the student will see all files that reside in their corresponding responses directory.

So in this example student abbf999 will see:
myassignment_feedback.docx
myassignment_feedback2.docx

 

In reply to Amanda Doughty

Re: Patch for Downloading assignment files - by groups

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

great to see that you've had a look at this!

I see you've done this work based on 1.9 - the patch for MDL-7206 is now in 2.0 core - would be great if you had a chance to generate a patch for 2.0

the code in 2.0 includes the userid as part of the names of the files (just before the ext) - and includes the original filename - you shouldn't need to use the do_not_edit file and should be able to check to see if the userid exists in the course, then calculate the original file name used by the student and check to make sure that file exists too.

Thanks for sharing your code - if you don't have time to work on a 2.0 version of this someone else could pick up your code and run with it!

In reply to Dan Marsden

Re: Patch for Downloading assignment files - by groups

by Amanda Doughty -
Picture of Core developers Picture of Plugin developers
Yep, I'd love to give it a go! I'll take your advice onboard and start working on it.
In reply to Amanda Doughty

Re: Patch for Downloading assignment files - by groups

by Amanda Doughty -
Picture of Core developers Picture of Plugin developers

Hi Dan, I have this 80% complete now. My code works but needs some more testing, commenting and refactoring. I have to leave it for a week, but I'll have it ready for you look at before Grimass.

I love the new file handling code in Moodle 2.0!

In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Charlie McDowell -
We just installed the patch and I can now download the zip file. This is a BIG improvement. I have created a python script (attached) that will take the contents of the expanded zip file and make one directory for each student with their files in that directory. This is important when the submissions are programs and I want to run tests on the individual submissions.

To use the script:
1. download the submissions (you get assignment.zip)
2. expand the zip, you get a directory assignment filled with files
3. cd into the assignment directory
4. run the script, moodle.py

In reply to Dan Marsden

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Patch for Downloading assignment files as one Zip file.

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
In reply to Dan Marsden

Re: Patch for Downloading assignment files as one Zip file.

by Peter Boutros -

i try to create a button in order to download all files submitted and it works. but the problem is obtained when in the same course there is multiple section and each section is given by one tutor, selecting specific section and trying to download all the assigment related will result of downloading all the assigment without considering the section specified. Any help with my case....Thank you in advanced.

In reply to Peter Boutros

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -

Peter,  the download can be controlled using groups.  Each teacher can have a group for each section.  I hope this helps.  Chris

In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by Peter Boutros -

Dear Chris,

Tutors on my moodle has separate groups in assigments section and zip and download all assigments button. the problem is that i need to give my tutor the ability to download the assigment for all the students in a specific section ( choosen from the drop down list of separate groups)

In reply to Peter Boutros

Re: Patch for Downloading assignment files as one Zip file.

by chris dennison -

Peter,  the download is specific to a particular assignment - and therefore to a section.

At the moment the patch depends on the 'view submissions' functionality.  Either you download  all submissions or you choose one group to view then download as a zip file.

Would it solve your problem if you could choose more than one of the groups to view then download?

In reply to chris dennison

Re: Patch for Downloading assignment files as one Zip file.

by Peter Boutros -

Chris,

Even if i choose all participants from the drop down list and i hit on zip and download all assigments i only obtain the one section downloaded. this is an example of a tutor that teachs two sections in a course and would like to download all assigments for that course. tutor in moodle does have that privelege to do so...

In reply to Peter Boutros

Re: Patch for Downloading assignment files as one Zip file.

by Lynda Thater -

Hi Peter

Did you ever get the zip download working for a tutor that teaches two sections?

Cheers,

Lynda