Unable to Remove assignments in AU type

Unable to Remove assignments in AU type

by Mike Lee -
Number of replies: 8
I have decied to start a new thread with this one.  I originally had posted some of these issues in the Drop box thread.

In Moodle 1.6, the AU Assighment type works well.  Everything works well except for the removal of submitted material.  The problem is that moodle carries out all of the steps to removing the file, only it doesn't.  I have been informed that maybe it could be a mysql problem and not a moodle problem.  I have just recently upgraded from moodle 1.5.4 and mysql 4.1.21 on Mac OS x to moodle 1.6 and mysql 5.0.21 on Win XP.  I have looked over many lines of code in hopes of finding the problem but that didn't help either.  Any clues?

TIA
Average of ratings: -
In reply to Mike Lee

Re: Unable to Remove assignments in AU type

by Mike Lee -
New issue.  At first I thought that I couldn't delete the files I had uploaded.  Then I thought that I would submit them anyways.  I tried to but I got...


No file was found for submitting - are you sure you uploaded any?

Now I know I had files because I have this on my submissions page...

au_test.txt [12 bytes][
Remove]
text.gifup_and_rev_test.txt [24 bytes][Remove]
text.gifup_and_rev_test2.txt [24 bytes][Remove]

Submission status: Draft

I clearly have three files uploaded.  But yet I am told I have no files to submit.
But there's more.  I turned on debug and I get this line...

(mysql): UPDATE mdl_assignment_submissions SET assignment = '7', userid = '6', timecreated = '1151518321', timemodified = '0', numfiles = '-1', data1 = 'Draft', data2 = '', grade = '-1', comment = '', format = '0', teacher = '0', timemarked = '0', mailed = '0' WHERE id = '9' 

I don't know how or why I have a -1 for numfiles.  I checked with moodle 1.5.4+ and it gave me only the number of files I had or a 0 for no files.

I am bewildered by this unfortunate situation.

Please help!!!

In reply to Mike Lee

Re: Unable to Remove assignments in AU type

by Mike Lee -
I have narrowed down the problem.  i believe that mysql is not deleting the files.  For example...

$filecount = $this->count_user_files($USER->id) still reads 3 files even after I have deleted all three.  The numfiles still reads as -1 but after doing a query on mysql, i have found that it just the coding that makes it read this way.

so, the problem now is that $filecount is reading 3 files when numfiles has none.  so there are no files but there are three files showing.  I just need help deleting the files in $filecount if possible.  TIA
In reply to Mike Lee

Re: Unable to Remove assignments in AU type

by Mike Lee -
I now know why the files are not deleting.  My files for the AU type is held in a file with the id of 7.  But when moodle goes to delete the files it looks in the folder with an id of 8 which happens to be my upload & review folder.

This is an image of what the page looks like...
-------------------------------------------------------------------------------------------------
Available from: Wednesday, 21 June 2006, 01:15 PM
Due date: Tuesday, 27 June 2006, 11:05 AM
1

8

text.gifau_test.txt [12 bytes][Remove]
Submission status: Draft

Step 1: Attach file(s) to assignment (Max size: 16MB)


Step 2: Submit assignment for marking.

Once the assignment is sent for marking, you will no longer be able to delete or attach file(s).

------------------------------------------------------------------------------------------------

the number 1 represents the php coding: notify ($filecount). So mysql sees that there is one file in the folder.

the number 8 represents the php coding: notify ($id), the folder id where the files are held.  And as I had stated above, this file and all AU file types are held in folder id 7 not 8.

Does anyone know how to make is so that $id is looking in the right place?

In reply to Mike Lee

Re: Unable to Remove assignments in AU type

by Mike Lee -
I just checked my upload and review assignment and the &id on this is supposed to be 8.  After doing a notify($id), it returned an $id of 9.  So some how I think mysql is incrementing or doing something screwy to my id files.
In reply to Mike Lee

Re: Unable to Remove assignments in AU type

by Mike Lee -
I am once again wrong about why my files won't delete.  So close though.  So, I have been told that it could be that the application code is not correct and it won't clear the database when I go to remove files.  Does anyone know how to fix this?
In reply to Mike Lee

Re: Unable to Remove assignments in AU type

by Mike Lee -
I have finally solved my problem!!!  I had to use the assignment_delete_instance in order to delete the files.

Now I have but one issue to solve.  The files are deleting from the database, but not from the directory.  I have been advised to use the fulldelete function but I still need a little help coding it in.  TIA
In reply to Mike Lee

Re: Unable to Remove assignments in AU type

by Mike Lee -
I have tired the fulldelete function, but it doesn't work.

This is how I did it...

...
$file    = optional_param('file', '', PARAM_PATH); (If I'm right, this is where the file is held)
...
fulldelete($file);

and I also did it this way...
$name    = optional_param('name'); (I believe that this is the file itself)
...
fulldelete($name);

I think that this is right because I looked at the fulldelete() function and it asked for a location or file.
After I call this function, I still see that the file is in the same location instead of being deleted.  Help please.
In reply to Mike Lee

Re: Unable to Remove assignments in AU type

by Mike Lee -
The $file and the $name optional_params did not.  I had to manually code in the directory using the $filearea object and the $name param inorder to obtain the correct file path and file name so that I could use fulldelete() to remove the file(s).

Here is an example of what I had to do.
ex:

$filearea = $this->file_area_name($userid);

//path where AU assignment is located
$filepath = "$CFG->dataroot/$filearea/$name";
.
.
.
fulldelete($filepath);

This solved my problem in moodle 1.6 beta 5.