New assignment type to test out - version 1.0 - handles multiple files! Please help test!

New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
Number of replies: 23
Here's my new assignment type. It's called "uploadmulti" for now, but that doesn't actually capture the potential of this module, so I'll explain a bit in a minute.

DEVELOPERS!!!! Please lend a hand. I work in a CS dept, but I'm not a computer science major, and am really a systems guy, not a programmer.  Some of this code can probably be done more elegantly, more efficiently, correctly, etc.

First, to get it up and running, you need to untar the file into the  /mod/assignment/type directory. Then you need to add the following lines to /lang/en/assignment.php:

$string['helpuploadmulti'] = '<p>This type of assignment allows each participant to upload multiple files of arbitrary type.</p>';
$string['numreqfiles'] = 'Number of required files';
$string['typeuploadmulti'] = 'Upload multiple files';

Lastly, but probably most importantly, you need to create a (very small) table in your database. Here's the SQL to do that in MySQL (this is from my database):

CREATE TABLE `assignment_reqfiles` (
  `id` int(10) NOT NULL auto_increment,
  `courseid` int(10) NOT NULL default '0',
  `assignmentid` int(10) NOT NULL default '0',
  `filename` varchar(64) NOT NULL default '',
  `isoptional` tinyint(1) NOT NULL default '0',
  `comment` varchar(255) default NULL,
  PRIMARY KEY  (`id`),
  KEY `courseid` (`courseid`,`assignmentid`)
) TYPE=MyISAM AUTO_INCREMENT=90 ;


Here's how the basic workflow happens from a professor's point of view. If you're logged in as a prof, and you create a new assignment, a new assignment type shows up, labeled "upload multiple files". From there:

1. Prof specifies the number of "required" files (also kind of a misnomer), as well as whether or not to reject arbitrary file uploads, in addition to the normal stuff like "allow resubmitting" and "email alerts to teachers". Then hit next...

2. A new form comes up, where the prof fills in names and descriptions of the required files. A prof can also mark a given file as "optional".

3. Hitting next then presents the prof with a view of the assignment, showing the list of required files, in addition to a "delete" button next to each file which will immediately delete the required file, decrement the number of required files for that assignment, and refresh the display.

4. Profs also always get an upload form, so they can test. This can eventually go away or be made an option.

5. This module creates directories for the assignment using the assignment's *name* (and yes, multi-word names are ok). If a prof uses the "Files" interface to create a directory called "bin" under the assignment directory, he/she can then upload, to the bin directory, a script that will process a user's file submissions. If the directory exists, a "run script" button will also be enabled in the listing of required files. This button will result in an exec of the uploaded script, passing to it the directory where the logged in user's uploaded files live. This is great if students are required to upload spreadsheet data to be processed, or programs that users want to make sure compile on the server that the grading is being done on smile

6. Users will see the run script button enabled if all of the files not marked "optional" are turned in. They will also see a "XX" next to the files that are turned in, optional or not.

I hope this is just enough documentation to get you all started testing. I'm deploying this for further testing by my users today, but the more feedback the better.
Average of ratings: -
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
Hi Brian,
I just installed "uploadmulti" on Moodle1.5.2+ and 1.5.3+
When I'm trying to upload a file I'm getting the following warnig back
"Warning: Invalid argument supplied for foreach() in /home/oksanay/public_html/moodle/mod/assignment/type/uploadmulti/assignment.class.php on line 467"

I am also getting the message "File uploaded successfully" however no file has been uploaded.

In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
Ok, I figured out what happend. It was my fault, I forgot to create required files.
Probably it'd be better to have implememted 2 options:
- if there are required file(s);
- if there are no required file(s).
What do you think?

Another problem I'm facing is an error:
Fatal error: Call to undefined function: print_student_answer() in /home/oksanay/public_html/moodle153/moodle/mod/assignment/lib.php on line 986
As I can see there is no function  print_student_answer(...) in auploadmulti/assignment.class.php.
In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
Hi - and thanks for testing out the code in 1.5.3 - I'm just this minute about to do my first tests with it!!

I'll look into the print_student_answer() function call, but at first glance, I make no calls to that function in any of my code at all, so I'm not sure the issue lies with my code, but rather the moodle assignment module code.

Keep track of what you click to get the error, and then try doing the same thing using an assignment that is not an uploadmulti assignment type.

I've been off on another project for a while, but am getting back to this code because I need it!! I'll release some updated code, and that code, I believe, addresses your requests as well. I don't remember if I added the features before or after I uploaded that 1.0 version, but I believe the code I'm currently running allows for "0 files required", and adds the ability for a professor to mark a file as being "optional", in addition to one or two other minor changes.

Stay tuned!
brian.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
You are not using the  print_student_answer() in your code, but this function called by /assignment/submissions.php. Which generates the error
"Fatal error: Call to undefined function: print_student_answer() in /home/oksanay/public_html/moodle153/moodle/mod/assignment/lib.php on line 986"
when I click "View N submitted assignments" from /assignment/view.php?id=M

P.S. I'm running Moodle 1.5.3+
In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
>this function called by /assignment/submissions.php
What i mean is:

submission.php:
44: $assignmentinstance->submissions($mode);
lib.php:
440:  function submissions($mode) {
...
470: case 'all': // Main window, display everything
471: $this->display_submissions();
472: break;

..............
828:  function display_submissions() {
...
981: ///Prints student answer and student modified date
982: ///attach file or print link to student answer, depending on the type of the assignment.
983: ///Refer to print_student_answer in inherited classes.
984: if ($auser->timemodified > 0) {
985: $studentmodified = '<div id="ts'.$auser->id.'">'.$this->print_student_answer($auser->id).userdate($auser->timemodified).'</div>';

Where function print_student_answer(..) should be defined in the specific class. In our case it's "assignment_uploadmulti"

Correct me if I'm wrong somewhere

Cheers,
Oksana
In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
I'll not say you're wrong, because I haven't been able to look at the code since I last wrote (looks like I won't until next week) sad

However, do keep in mind that the class assignment_uploadmulti merely extends the base assignment class, so any functions that aren't actually defined in assignment/type/uploadmulti/assignment.class.php will be called from the base assignment class's version of that function.

Like I say, I will look into this as soon as I'm able to, but maybe that's a pointer that can help you (and, ultimately, me) now.

brian.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
Could you share an updated code with us (or with me at least;))? I would take a look and help as much as I can.

Oks
In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
Sure thing. It's attached here.

If I remember the differences properly, this version adds a few rudimentary (but nonetheless functional) versions of features to be dressed up later.

For one, students can now see if they've submitted a file - the interface displays a "XX" next to files they've submitted.

Also, a prof can mark any of the "required files" as optional.

There's a "Run Script" button (which may have been in 1.0, don't remember), which is activated only if the student has supplied all of the files not marked "optional", *and* the professor has placed a script called "submit.scr" in a directory under the assignment directory in the "Files" interface called "bin". The run script button passes to the script the location of the logged in student's files.

A professor can also delete files from the list of required files, but this functionality is going to move to the assignment update interface because it causes some confusion to have some admin features in the user interface and others in the admin interface.

There are also more features to be added, but 1.5.3 covered some of them for me -- namely, the grading interface should at least be deemed usable now, saving me from having to do anything there wink

I'm still in the midst of getting a 1.5.3 tree set up, and a subversion repository configured, but moodle is, as of now, my top priority project, and will be for at least another week or 10 days or so.

brian.

In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
OK - I've updated one of my development boxes to moodle 1.5.3, and applied my module from the package attached above. Note that I also created the mysql table from my original post, and added the proper lang entries. Everything, as far as I can tell, works without error.

I believe I've tested most of the major functions, except for the grading interface, which I'll get to shortly. If you see bugs that are *not* specific to the grading interface, let me know!

Also, future versions of the package will come with the sql file you need to apply to your moodle database to create the proper table.

brian.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
ok, I found your bug, Oksana. What I did on my dev machine is copy the print_student_answer function from the uploadsingle type straight over to uploadmulti/assignment.class.php. The uploadsingle type was the base template for the uploadmulti type, and this appears to work perfectly with the existing changes I had made to the submission display earlier. In fact, it looks nicer in 1.5.3 than 1.5.2!!

On a side note, I have requested a gna.org project and am waiting for approval. If I get an approval, you'll have a consistent link you can bookmark to go and grab the latest version of the code. This way you don't have to search the forums.

brian.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
Brian, I didn the same and I also modified one line in the function
Instaed of this:
$output = '<img align="middle" src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" />'.
'<a href="'.$ffurl.'" >'.$file.'</a><br />';
Used this:
$output .= '<img align="middle" src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" />'.
'<a href="'.$ffurl.'" >'.$file.'</a><br />';
It allows Teacher to see all submissions (page http://..../mod/assignment/submissions.php...)

I have a few more questions:
1. does back up works? I haven't tested it yet
2. when i selected "no resubmit", there is still a possibility to resubmit files
3. when student submit files, they are not displayed on the result page like it works for sinleupload.
In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
HI there,

First of all, I wanted to point you at my site, which will be housing the uploadmulti package --> http://www.linuxlaboratory.org/index.php?title=Category:Downloads

I'll put any future updated versions of the package there.

As to your other questions:

1. I don't remember, but I'll test it this week. I believe someone else once made a suggestion about how to get that to work, and I *think* I did it, but now I can't think of what it was to check! I believe it was in the other forum thread, so I'll have a look today.

2. I think that's a simple matter of code that was uncommented for testing or something. It's wrong. It's a bug, and I'll fix it, hopefully today.

3. Not sure what you mean by "result page". I'll play with uploadsingle and a few other things today to get back in the swing of things, and the rest of this week (I believe) will be spent on moodle, so hopefully lots of cool stuff will happen and we'll have a usable, backup-able module.

wink

brian.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
Hi Brian, thnx for the URL. I'll be checking it from time to timesmile

2. I fixed it by adding new parameter for if()
function view() {
.......
if ($this->isopen() && (!$filecount || $this->assignment->resubmit || !$submission->timemarked))
......

3. By "result page" I mean the page you see after submitting files and clicking "Continue" on the page with message "File uploaded successfully" (not sure I explain good enoughsad). So, it's the same page with upload form, but it also displays uploaded files if there are any.
I fixed this as well.

I have made some changes in your code, some fixes you might already made in the new version, but if you want I can give URL to the documentation describing  those fixes.

cheers,
Oksana

In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
I'm not a draconian code overlord or anything -- if you find uploadmulti worth coding for, then I'm happy to include bug fixes and new features (so long as they don't smash the toes of the users).

You can email if you like, or just post a link to the changes here. Perhaps we can share a cvs or svn repository somewhere.

As for the uploaded file display, I had to disable it during testing as well, because if you don't choose "yes" for "Reject arbitrary file uploads" then that screen can get somewhat messy. I just never got around to playing with the display of that data. If you've fixed it, I'm happy to include it (with full attribution of course).

brian.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
Oksana --

version 1.2 is at http://www.linuxlaboratory.org/index.php?title=Category:Downloads

I've implemented your grading display alteration, fixed the resubmit functionality, and have reimplemented the display of the logged in user's files in the "result" page.

I think I did some other stuff too, but all minor changes.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Will Taylor -
Just a quick note in case any noodle-headed Moodlers run into the same glitch that had me hung up for a bit on this (Most Excellent!) assignment enhancement -
when creating the assignment_reqfiles table in your MySQL database, be sure to add your table prefix (e.g. "mdl_").

e.g., alter the first line
CREATE TABLE `assignment_reqfiles` (
to
CREATE TABLE `mdl_assignment_reqfiles` (
or whatever

Thanks for developing this!

- will
In reply to Will Taylor

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
Hi Will!

Thanks for using it!
I'm just back from vacation and will return to work on it once I'm done returning emails wink  In the meantime, thanks for pointing out this glitch, which I wish would go away. Perhaps we can lobby Martin to make it a standard assignment type, and then I can make the SQL a part of the standard SQL that gets run when you install/upgrade moodle.

brian.
In reply to Will Taylor

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
Correct, 'assignment_reqfiles' table should be altered to use 'mdl_' prefix or  any other prefix you use in dbsmile
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Oksana Delgado -
Hi Brian, I was carried away by other tasks at work. But I'm back to multiuploads againsmile
I had some fixes done previously for my University. I'll check your last code, compare with mine and post comments if you dont' mindsmile

We have got an request from our profs about combining Upload&Review and UploadMulti types to give an opportunity to profs upload multiple feedback files.
Will you be interested in updating your module with our code? (note, i haven't started to implement it, it just a plansmile)

Oks

In reply to Oksana Delgado

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
Hi Oksana,

I'm always open to anything that users will find useful, and if people there are requesting it, then that's a good sign that it's useful wink

What would be nice would be if the moodle developers simple removed the "single file" assumption from the other assignment types. That would probably afford the most flexibility to the most people.  I'm not familiar with an "Upload&Review" assignment type, but if they can be cleanly merged, and the end result is useful, then do it!

brian.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Richard Page -
I just installed the latest version into Moodle 1.5.3. It worked until I had an assignment that had a colon : in it's name. For example, an assignment with the assignment name "Lab: description of lab". It makes a folder with that name, and the files upload OK, but they cannot be read when you go to the grade module.

I looked inside the moddata folder and into the folder where the uploads are placed. They are there, but if you try to access them, you will get an error from files.php.

I concluded that the : in the file name was the problem by creating the same assignment without the : in the name. Then everything seems to work OK.

By the way, I really like this module. It would also be nice to combine this with the upload and review functionality.

In reply to Richard Page

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Brian Jones -
I have to admit here that I have no idea what you mean by "upload and review functionality". Excuse my ignorance, but could you give us a link or explain what that is? Maybe if I knew, it could save me some coding! wink

As for the colon issue (lol) I can say two things: one is a question: have you been able to create uploadsingle assignments using a colon? My base code basically *is* uploadsingle which is why I ask. If there's a bigger bug to kill, then someone with cvs access should be notified. The second thing is that I will certainly have a look as time allows. I'm currently performing some other feats, though, so it may take some time, since there is at least a known workaround in this case.

brian.
In reply to Brian Jones

Re: New assignment type to test out - version 1.0 - handles multiple files! Please help test!

by Richard Page -
Upload and review is another contributed assignment module that allows the teacher to upload a document when grading.  So, for example, I could download a student's submission, correct it and upload it for the student to examine.  It would be nice to have that functionality with the multiple file upload.

The colon issue - I have done that with upload single.  When upload multiple files didn't work, the first thing I did was change the assignment type to uploadsingle.  I was able to submit and grade submissions.  When I took the colon out of the assignment description, upload Multi also worked.

I have never had occasion to look, but I was not aware that the other assignment types create a directory whose name matches the assignment description.  The problem I ran into is related to reading that directory.

I hope this helps.  The module is quite useable as it stands and, in my opinion, a much needed feature.

Richard
Average of ratings: Useful (1)