Moodle Homework Submission ZIP Processor

This Python script is specifically designed to process and organize zip files containing student homework submissions downloaded from Moodle using the "Download all submissions" feature. It extracts files from the Moodle-generated zip archive, renames them based on the submitter's name, and organizes them in a new directory structure for easier grading and management.

Authorship

This program was written collaboratively by Claude.ai and Pito Salas.

Features

  • Processes zip files generated by Moodle's "Download all submissions" feature for homework assignments
  • Handles PDF, HTML, Python (.py), and Markdown (.md) files
  • Extracts and organizes internal zip files
  • Renames files based on the submitter's name
  • Creates a clean output directory structure

Moodle Compatibility

This script is tailored for the specific format of zip files produced by Moodle when an instructor uses the "Download all submissions" option for a homework assignment. It expects:

  • A single zip file containing multiple folders, one for each student submission
  • Each folder named according to Moodle's convention: typically the student's name or ID, followed by an underscore and additional submission information
  • Submitted files to be contained within these individual student folders

Requirements

  • Python 3.x

Usage

  1. After downloading the "All submissions" zip file from your Moodle homework assignment, place the script (ze.py) in the same directory as the zip file (or be prepared to provide the path to the zip file when running the script).

  2. Run the script from the command line:

    python ze.py [input_zip_file]
    

    If no input file is specified, the script will look for a file named in.zip in the current directory.

  3. The script will create a new directory with the processed files. The output directory will be named after the input zip file with "out" appended to it.

Output

  • PDF, HTML, Python, and Markdown files will be renamed using the submitter's name and placed in the root of the output directory.
  • ZIP files will be extracted into subdirectories named after the submitter.
  • Other file types will be skipped.

Example

If you have downloaded a file named homework1_submissions.zip from Moodle:

python ze.py homework1_submissions.zip

This will create a directory named homework1_submissionsout containing the processed files.

Creating a macOS Executable

To make this script easier to use on macOS, you can create a standalone executable. This will allow you to run the script by double-clicking an icon, without needing to use the command line. Here's how to do it:

  1. First, ensure you have Python installed on your Mac. The script is compatible with Python 3.x.

  2. Install PyInstaller, which we'll use to create the executable:

    pip install pyinstaller
    
  3. Open Terminal and navigate to the directory containing the ze.py script:

    cd /path/to/script/directory
    
  4. Use PyInstaller to create the executable:

    pyinstaller --onefile --name ze ze.py
    

    This command does the following:

    • --onefile: Creates a single executable file
    • --name ze: Names the executable "ze" (lowercase)
  5. PyInstaller will create a dist folder in your current directory. Inside this folder, you'll find the executable file named ze.

  6. You can now move this executable file to any location on your Mac.

  7. To use the executable:

    • Double-click the ze file
    • It will prompt you to select the Moodle submission zip file you want to process
    • After selection, it will process the file and create an output directory as described in the Usage section above

Note: When you first run the executable, macOS might warn you about running software from an unidentified developer. To bypass this:

  • Right-click (or Control-click) the ze executable and select "Open"
  • Click "Open" in the dialog box that appears
  • In future, you'll be able to open the executable by double-clicking

This executable will function the same as the Python script but provides a more user-friendly way to run the tool on macOS.

Notes

  • The script assumes that each submission folder in the Moodle zip file is named with the submitter's name followed by an underscore and additional information, as per Moodle's standard naming convention.
  • Any existing output directory will be deleted and recreated during processing.

Troubleshooting

If you encounter any issues:

  • Ensure you have Python 3.x installed.
  • Check that the input zip file exists and is not corrupted.
  • Verify that you have write permissions in the directory where the script is run.
  • Confirm that the zip file was indeed generated by Moodle's "Download all submissions" feature for a homework assignment.
  • If you encounter issues with the macOS executable, try running the Python script directly to see if there are any error messages that might help identify the problem.

For any other issues or feature requests, please contact the script maintainers.

Acknowledgements

Special thanks to Claude.ai and Pito Salas for their collaborative effort in creating this script. This project demonstrates the potential of human-AI collaboration in developing practical software solutions for educational technology needs.