Random assignment19

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Random assignment19.

Basic functionality of the module

Documentation for Moodle version 1.8 or 1.9


  • Each student gets one file from a given directory randomly.
  • If the file has extension htm or html, it will be shown directly at the assignment page. Otherwise, only a link to file will be shown.


  • Teacher specifies a directory containing one or more files for assignments and (optionally) a directory with solutions
  • In the assignment feedback page, teacher sees the assignment file and optionally the solution file as well. However, assignments are assigned to students (and teacher sees links to them) only after they see them for the first time.

Directory structure

The following structure of directories must be created in the course area


The assignments and solutions are then stored in subdirectories of these directories with numerical names (that need not be the same), for example


We can for example have


and (if needed)



  • Copy directory random/ to moodle/mod/assignment/type/.
  • Copy directory lang/ to moodledata/. Language files are stored in _local directories and thus do not interfere with standard assignment.php language files.
  • Optionally, for better security, add the content in file.php (file.part.php) regarding random assignment to the corresponding place in moodle/file.php (otherwise, students can guess the solution directory name and then they can read the solution directly from server). Only if there are solutions.

Preparation for assignments

  • In the files area check whether directory 'moddata' exists. If not, create it.
  • In the directory moddata, create directory 'random'.
  • In the directory random, create two directories: 'assignment' and 'solution'.

Creation of an assignment

  • Create a directory with numerical name in directory 'assignment'. Numerical name can be for example 1, 2, 10, 300, ...
  • Copy files with assignments to this directory.
  • Optionally, create a directory in directory 'solution' with numerical name and copy the files with the same names as before. These contain solutions or hints to solutions for teachers.
  • Create activity: random assignment and specify directories for assignments and solutions.


The activity has been designed and built with the contributions of the following people:

  • Lubos Cirka - Slovak Technical University in Bratislava > development
  • Miroslav Fikar - Slovak Technical University in Bratislava > design concept



  • Course restore without user data does not restore assignment and solution files: The random assignment files are stored in userdata area of backups. In the case that the course is backupped or restored without user data, the files are not preserved. Therefore, it is always advisable to zip the whole moddata/random directory at the server outside moddata directory and not accessible to students. If the course is restored without used data (for example in preparation for a new semester), it will afterwards be very easy to restore the directory structure from the zip file.
  • Assignments provided in HTML files should be UTF-8 encoded. As inline display strips HTML file to its body, it is assumed that the file is in UTF-8 encoding and can cause the file to be shown incorrectly.