Note:

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

Assignment Subtypes Combined: Difference between revisions

From MoodleDocs
No edit summary
Line 226: Line 226:


There is an admin tool available to upgrade individual assignments from the old assignment module to the new assign module. More features need to be added to this upgrade tool such as batch conversion and scheduling via cron.
There is an admin tool available to upgrade individual assignments from the old assignment module to the new assign module. More features need to be added to this upgrade tool such as batch conversion and scheduling via cron.
== Developer Information ==
=== Writing a plugin for mod_assign ===

Revision as of 06:14, 22 February 2012

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

The add module menu now only contains a single entry for "Assignment" as all assignment types (and combinations) are possible with the one module.


Add-Assignment-Standard.png

The assignment module contains the standard set of module configuration options.


Add-Assignment-Plugin-Settings.png

For each plugin (submission or feedback) the assignment module contains a setting to turn the plugin on or off and any custom settings provided by the plugin.


View-Assignment.png

The default view for the assignment contains up to 3 information tables depending on the status of the assignment and your permissions/enrolled status. If you are enrolled in the course and you have submit permission for the assignment (and it is visible) you will see the submission status table. If you have grading permission you will see the grading status table and if there is feedback on your submission you will see the feedback table. The other change from the old assignment module is there is a separate status field for grading and submissions - with a separate last modified field for each. This makes it clearer when a student updates their submission or a marker provides feedback.


Add-Submission.png

The add submission page contains a list of sections for the enabled submission plugins. If there are no submission plugins enabled that support submissions, then this page is not visible. Each plugin can add elements to the submission form and there are helper methods for dealing with rich text editors and file upload fields.


View-Assignment-With-Submission.png

This shows the assignment module with a current submission. The plugins each render a summary of their portion of the submission to the submission status table.


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

The submission comments uses the comments API to allow 2 way communication between students and markers about their submission. It does not add any elements to the submission form.


View-Grading-Table.png

The grading table is similar to the one from the old assignment but has separate columns for the last modified date of the submission and the grade.


Grade-Single-Assignment.png

The grade form contains the standard grade elements (which can include advanced grading methods ie. rubrics) followed by the form elements added by the feedback plugins.


View-Grading-Table-With-Grade.png

This shows the grading table with a grade applied.


View-Assignment-With-Feedback.png

The default view for the assignment now contains the feedback table where each feedback plugin can present a summary of their portion of the feedback.


Admin-Manage-Feedback-Plugins.png

The feedback plugins can be enabled and disabled for the entire site and the order can be adjusted here. This order affects the order that the elements appear in the grading form (and the assignment settings).


Admin-Manage-Submission-Plugins.png

The submission plugins can also be enabled and disabled for the entire site and the order can be adjusted here. This order affects the order that the elements appear in the submission form (and the assignment settings).


Admin-Upgrade-Assignments.png

There is an admin tool available to upgrade individual assignments from the old assignment module to the new assign module. More features need to be added to this upgrade tool such as batch conversion and scheduling via cron.


Developer Information

Writing a plugin for mod_assign