Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Assignment Subtypes Combined

From MoodleDocs

Introduction

This feature is part of the assignment module redevelopment project (https://docs.moodle.org/dev/Assignment). It involves creating a new module (mod_assign) that supersedes the previous one (mod_assignment). It provides all of the features of the four standard subtypes within one module (ie - you can enable file uploads, online text, notes, feedback etc).

Examples

See the use cases in the assignment redevelopment page.

This list is not exhaustive - the new assignment module will allow combinations that were not previously possible (e.g. An online assignment that also accepts file submissions)

Requirements

Core requirements

  • No loss of functionality from old assignment module to new assignment module
  • Supports Upgrade from old assignment module to new assignment module
  • Support for Portfolio API
  • Support for Plagiarism API
  • Full backup/restore support

Optional requirements

  • Allow subclasses to extend the standard assignment module (similar to the sub-types - but as a complete new module)

Pre-requisites

Moodle 2.3 required

Community bonding period

Milestones

  • Document proposed design and get community feedback
  • Decide list of settings
  • Decide code/file structure layout
  • Create mockups

Decisions

Base class

There are 3 options for creating this module. These have been proposed in the Meta-ticket (MDL-26997).

The decision was made to go with option C but it was extended to support feedback plugins as well as submission plugins. This will allow all of the existing assignment subtypes in the plugins database to be upgraded to support the new assignment module.

Option A (Not chosen)

Is to create a new assignmentlib.php which contains an abstract base class for creating assignments and can be overridden by sub-classes. The new mod_assign would be an example of a module implementing the abstract base class. This would allow other custom assignment types to reuse alot of code particularly in creating the user interfaces and supporting standard features from the base class. The sub-type could then customise the implementation by disabling standard features (such as file uploads) and adding new functionality (such as an alternative submission type). The question is whether there is enough custom code in the assignment module to make this worthwhile. The most complex user interface is currently the grading page and there has been discussion of moving this into the gradebook.

Option B (Not chosen)

Is to create the new module as a self contained module within the mod_assign folder. This would not allow people to extend it but they could copy the code into a new module and modify it as much as they like. This option is simpler but has drawbacks for maintaining forked code etc.

Option C (Chosen)

Although this sounds similar to the old assignment module - it is different.

Allow 2 types of plugins, submission and feedback that can:

  • add additional settings to the assignment
  • add additional elements to the submission/feedback form
  • do custom saving of a submission/grading
  • present a custom summary and view of a submission/feedback

These plugins save data in their own separate tables and only the core submission/grading info would be saved to the submissions/grades table. Plugins can implement their own install/upgrade/backup/restore code through the existing subplugin mechanism in Moodle. The standard submission and feedback types provide simple examples of how to implement this logic.

Benefits:

  • All of the assignment code is in the new assign module (instead of putting an assignmentlib.php in the core lib folder)
  • Custom assignment submission types must create their own tables to save data instead of all abusing the data1 and data2 columns.
  • Custom assignment submission modules to not need to re-implement the grading interface etc.
  • Custom assignment modules can be used in combination with the built in assignment submission modules - e.g. an online text + online audio assignment.

Coding period

Code is nearing completion and we are reviewing/documenting and performing initial QA before submitting the code for review by HQ.

Code repository

Unstable code in progress is available at:

https://github.com/netspotau/moodle-mod_assign/tree/MDL-31270

Milestones

  • Implement proposed design (new module only) - done
  • Implement Backup/Restore - done
  • Implement Upgrades - done (needs some more UI features)
  • Code complete - ready for integration

File structure

Files for the new mod_assign:

lib.php - Contains the standard moodle module hooks. Most functions create an assignment instance and call the relevant function from that class.
locallib.php - Contains the assignment class. This is the core functionality of this module.
assignment_plugin.php - Abstract class that is the parent of submission_plugin and feedback_plugin. They share similar interfaces and features so it makes sense to combine the common code. 
submission_plugin.php - Abstract class that needs to be implemented by all submission plugins. 
feedback_plugin.php - Abstract class that needs to be implemented by all feedback plugins. 
admin_manage_plugins.php - Used by the admin settings to manage both the feedback and submission plugins (but they appear on separate pages). Plugins can be reordered, uninstalled and configured here.
index.php - Include view.php - Prevent directory listing of the plugin folder.
mod_form.php - Include the base form for the module settings, grading interface and submission interface. This uses callbacks to allow the plugins to extend the forms.
portfolio_callback.php - Required class for the portfolio API.
renderer.php - Used to perform common functions such as rendering a list of files (with support for plagiarism and portfolios)
settings.php - Used to add pages to the admin navigation
style.css - Some simple css rules
assign.js - Change the default behaviour of the filepicker. 
upgradelib.php - Library for upgrading from mod_assignment to mod_assign
view.php - The entry point to the module - creates and assignment instance and then calls view on it.
version.php - Version information for the plugin
lang/en/assign.php - Language file (en, mod_assign)
db/access.php - Install capabilities
db/install.xml - Install the core database tables
db/events.php - Register the events produced by this module
db/log.php - Log definitions
db/messages.php - Notification definitions
db/subplugins - Register the subplugin types
db/upgrade.php - Upgrade code - should we put upgrade code from the old mod_assignment here (I dont think so)
backup/moodle2/backup_assign_task_activity.php - Backup activity class
backup/moodle2/backup_assign_stepslib.php - List of backup steps
backup/moodle2/restore_assign_stepslib.php - List of restore steps
backup/moodle2/backup_assign_task_activity.php - Restore activity class

submission/<plugin name> - List of submission plugins
feedback/<plugin name> - List of feedback plugins

Each submission plugin has this structure (relative to submission/<plugin-name>)

settings.php (optional) Define any admin settings for this module
lang/en/submission_<pluginname>.php - Language file (en)
db/install.php (optional) Install steps
db/upgrade.php (optional) Upgrade steps
db/install.xml (optional) Database tables
db/access.php (optional) Custom capabilities
lib.php (required) Must contain a class named submission_<plugin-name> that extends submission_plugin.
version.php (required) Version information for this plugin
backup/moodle2/backup_submission_<plugin-name>_subplugin.class.php (optional) Backup this plugin
backup/moodle2/restore_submission_<plugin-name>_subplugin.class.php (optional) Restore this plugin

Each feedback plugin has this structure (relative to feedback/<plugin-name>)

settings.php (optional) Define any admin settings for this module
lang/en/feedback_<pluginname>.php - Language file (en)
db/install.php (optional) Install steps
db/upgrade.php (optional) Upgrade steps
db/install.xml (optional) Database tables
db/access.php (optional) Custom capabilities
lib.php (required) Must contain a class named feedback_<plugin-name> that extends feedback_plugin.
version.php (required) Version information for this plugin
backup/moodle2/backup_feedback_<plugin-name>_subplugin.class.php (optional) Backup this plugin
backup/moodle2/restore_feedback_<plugin-name>_subplugin.class.php (optional) Restore this plugin

Class Diagram

Assignment Class Diagram.png

Screenshots

  • Subject to change

Add-Activity-Menu.png

Add-Assignment-Standard.png

Add-Assignment-Plugin-Settings.png

View-Assignment.png

Add-Submission.png

View-Assignment-With-Submission.png

View-Assignment-With-Submission-And-Comments.png

View-Grading-Table.png

Grade-Single-Assignment.png

View-Grading-Table-With-Grade.png

View-Assignment-With-Feedback.png

Admin-Manage-Feedback-Plugins.png

Admin-Manage-Submission-Plugins.png

Admin-Upgrade-Assignments.png