Submissions Library: Difference between revisions
David Mudrak (talk | contribs) m (Text replacement - "</code>" to "</syntaxhighlight>") |
|||
(8 intermediate revisions by 3 users not shown) | |||
Line 16: | Line 16: | ||
# Assignment: no comment. | # Assignment: no comment. | ||
# Workshop: uses submissions but it's another code doing the same. | # Workshop: uses submissions but it's another code doing the same. | ||
# Community module: for example, [[POAS Assignment development|Assignment with individual tasks]] could not re-implement all existing submission types. | # Community module: for example, [[POAS Assignment development|Assignment with individual tasks]] could not re-implement all existing submission types. | ||
# Non- | # Non-module usage? Essay or similar manually graded question types could use assignments plugins to imporve their functionality, scope and standartisation. | ||
== Database schema == | == Database schema == | ||
Line 24: | Line 23: | ||
=== submissions_bindings === | === submissions_bindings === | ||
Identifies all connected submission plugins to an activity modules. | Identifies all connected submission plugins to an activity modules. | ||
{| class=" | {| class="wikitable" | ||
|- | |- | ||
! Field | ! Field | ||
Line 54: | Line 53: | ||
=== submissions_pluginconfig === | === submissions_pluginconfig === | ||
Stores plugins configuration. | Stores plugins configuration. | ||
{| class=" | {| class="wikitable" | ||
|- | |- | ||
! Field | ! Field | ||
Line 84: | Line 83: | ||
=== submissions_instances === | === submissions_instances === | ||
Identifies all submissions. A data associated with the submission is stored by plugin. | Identifies all submissions. A data associated with the submission is stored by plugin. | ||
{| class=" | {| class="wikitable" | ||
|- | |- | ||
! Field | ! Field | ||
Line 124: | Line 123: | ||
=== submissionplugin_onlinetext === | === submissionplugin_onlinetext === | ||
This is a table example for "Online text" plugin. This table is not a part of library. | This is a table example for "Online text" plugin. This table is not a part of library. | ||
{| class=" | {| class="wikitable" | ||
|- | |- | ||
! Field | ! Field | ||
Line 154: | Line 153: | ||
=== submissionplugin_file === | === submissionplugin_file === | ||
This is a table example for "File submission" plugin. This table is not a part of library. | This is a table example for "File submission" plugin. This table is not a part of library. | ||
{| class=" | {| class="wikitable" | ||
|- | |- | ||
! Field | ! Field | ||
Line 183: | Line 182: | ||
==== Activity instance settings form ==== | ==== Activity instance settings form ==== | ||
In order to add a plugin settings elements on activity settings page the following method of moodleform_mod should be used: | In order to add a plugin settings elements on activity settings page the following method of moodleform_mod should be used: | ||
< | <syntaxhighlight lang="php">$this->standard_submission_coursemodule_elements();</syntaxhighlight> | ||
==== Displaying a submission ==== | ==== Displaying a submission ==== | ||
Activity module should access the submissions using a submission class. | Activity module should access the submissions using a submission class. | ||
< | <syntaxhighlight lang="php">$submission = new submission($context, $area);</syntaxhighlight> | ||
First, a submission_instance object should be retrieved. | First, a submission_instance object should be retrieved. | ||
< | <syntaxhighlight lang="php">$submissioninstance = $submission->get_submission_instance($itemid);</syntaxhighlight> | ||
Next, it can be displayed. | Next, it can be displayed. | ||
< | <syntaxhighlight lang="php">if ($submissioninstance) { | ||
$submissioninstance->display(); | $submissioninstance->display(); | ||
// or | // or | ||
$html = $submissioninstance->render(); | $html = $submissioninstance->render(); | ||
}</ | }</syntaxhighlight> | ||
==== Displaying submission form ==== | ==== Displaying submission form ==== | ||
Activity module should access the submissions using a submission class. | Activity module should access the submissions using a submission class. | ||
< | <syntaxhighlight lang="php">$submission = new submission($context, $area);</syntaxhighlight> | ||
A special method should be used to add elements on submission form. A previous submission can be loaded by specifying $baseitemid. | A special method should be used to add elements on submission form. A previous submission can be loaded by specifying $baseitemid. | ||
< | <syntaxhighlight lang="php">$submission->add_submission_form_elements($mform, $baseitemid);</syntaxhighlight> | ||
==== Save/update submission ==== | ==== Save/update submission ==== | ||
Activity module should access the submissions using a submission class. | Activity module should access the submissions using a submission class. | ||
< | <syntaxhighlight lang="php">$submission = new submission($context, $area);</syntaxhighlight> | ||
To save or update the submission a special method should be used. It accepts submitted form data as its only argument. | To save or update the submission a special method should be used. It accepts submitted form data as its only argument. | ||
< | <syntaxhighlight lang="php">$submission->save($formdata);</syntaxhighlight> | ||
==== Delete submission ==== | ==== Delete submission ==== | ||
All submissions associated with the activity module instance can be deleted by using the following static method: | All submissions associated with the activity module instance can be deleted by using the following static method: | ||
< | <syntaxhighlight lang="php">submission::delete_all_for_context($context);</syntaxhighlight> | ||
Individual submissions can be deleted this way: | Individual submissions can be deleted this way: | ||
< | <syntaxhighlight lang="php">$submission = new submission($context, $area); | ||
$submission->delete($itemid);</ | $submission->delete($itemid);</syntaxhighlight> | ||
=== General workflow details === | === General workflow details === | ||
Line 233: | Line 232: | ||
==== Someone tries to download a file from submissionplugin_file ==== | ==== Someone tries to download a file from submissionplugin_file ==== | ||
[[{{ns:file}}:submissionlib accessfile.png|200px|thumb|none|UML Sequence Diagram: someone tries to download a file]] | [[{{ns:file}}:submissionlib accessfile.png|200px|thumb|none|UML Sequence Diagram: someone tries to download a file]] | ||
See also: [[#Accessing files]] | |||
TODO: add more details | TODO: add more details | ||
Line 253: | Line 255: | ||
=== Submission plugin development === | === Submission plugin development === | ||
A main plugin class should be calles submissionplugin_<pluginnname> and it should be inherited from abstract class submissionplugin. | |||
TODO: add detailed description on methods plugin must implement. | |||
== Backup/restore == | == Backup/restore == | ||
The submission must be a part of activity module instances. | |||
== What else to consider == | == What else to consider == | ||
== See also == | == See also == | ||
* [[Assign submission plugins]] | |||
* [[Advanced grading methods]] - if we have a multiple grading areas, each of those area may require a submissions. |
Latest revision as of 20:20, 14 July 2021
Project goal
Make activity module developers (not only Assignment developers) able to use submission types: both standard and community-developed.
Project scope
A library providing API for activity module submission types support implementation. Actual proposition is to make assignsubmission plugins system-level.
The existing modules requiring submissions (Assignment, Workshop) should use this library.
Relevant tracker issues
- MDL-47344 - Allow usage of submission methods in other plugins
Use cases
- Assignment: no comment.
- Workshop: uses submissions but it's another code doing the same.
- Community module: for example, Assignment with individual tasks could not re-implement all existing submission types.
- Non-module usage? Essay or similar manually graded question types could use assignments plugins to imporve their functionality, scope and standartisation.
Database schema
submissions_bindings
Identifies all connected submission plugins to an activity modules.
Field | Type | Default | Description |
---|---|---|---|
id | bigint | Auto-numbered. | |
context | bigint | Activity context. | |
area | varchar(100) | An area within activity module. A module may have a few. | |
method | varchar(100) | Submission plugin name. It is considered that the plugin is activated in these area of these activity module instance. |
submissions_pluginconfig
Stores plugins configuration.
Field | Type | Default | Description |
---|---|---|---|
id | bigint | Auto-numbered. | |
binding | bigint | Activated plugin. Points to submissions_bindings record. | |
option | varchar(100) | Plugin setting name. | |
value | text | Setting value. |
submissions_instances
Identifies all submissions. A data associated with the submission is stored by plugin.
Field | Type | Default | Description |
---|---|---|---|
id | bigint | Auto-numbered. | |
binding | bigint | Activated plugin. Points to submissions_bindings record. | |
itemid | bigint | null | Identifies an element within area. For example, answer or user id. |
timecreated | bigint | 0 | When the submission was created. |
timemodified | bigint | 0 | Latest submission modification time. |
status | int | 0 | Draft (default), Latest, Archived. |
submissionplugin_onlinetext
This is a table example for "Online text" plugin. This table is not a part of library.
Field | Type | Default | Description |
---|---|---|---|
id | bigint | Auto-numbered. | |
submissioninstance | bigint | Point to submission from submissions_instances table. | |
onlinetext | text | Actual submission data. | |
onlineformat | int | 0 | Text format. |
submissionplugin_file
This is a table example for "File submission" plugin. This table is not a part of library.
Field | Type | Default | Description |
---|---|---|---|
id | bigint | Auto-numbered. | |
submissioninstance | bigint | Point to submission from submissions_instances table. | |
numfiles | bigint | Number of submitted files. |
How it works
API for activity modules
Activity instance settings form
In order to add a plugin settings elements on activity settings page the following method of moodleform_mod should be used:
$this->standard_submission_coursemodule_elements();
Displaying a submission
Activity module should access the submissions using a submission class.
$submission = new submission($context, $area);
First, a submission_instance object should be retrieved.
$submissioninstance = $submission->get_submission_instance($itemid);
Next, it can be displayed.
if ($submissioninstance) {
$submissioninstance->display();
// or
$html = $submissioninstance->render();
}
Displaying submission form
Activity module should access the submissions using a submission class.
$submission = new submission($context, $area);
A special method should be used to add elements on submission form. A previous submission can be loaded by specifying $baseitemid.
$submission->add_submission_form_elements($mform, $baseitemid);
Save/update submission
Activity module should access the submissions using a submission class.
$submission = new submission($context, $area);
To save or update the submission a special method should be used. It accepts submitted form data as its only argument.
$submission->save($formdata);
Delete submission
All submissions associated with the activity module instance can be deleted by using the following static method:
submission::delete_all_for_context($context);
Individual submissions can be deleted this way:
$submission = new submission($context, $area);
$submission->delete($itemid);
General workflow details
Student makes a submission
TODO: add more details
Teacher views student's submission
TODO: add more details
Someone tries to download a file from submissionplugin_file
See also: #Accessing files
TODO: add more details
Course module deletion
submission::delete_all_for_context(...) call should be added to course_delete_module(...) function.
Note: all associated files will be deleted when course_delete_module(...) function calls deletion of all files associated with the module's context. Perhaps submission plugins should not rely on this.
How "File submission" plugin stores files
File submission plugin stores all files at file areas identified by:
- context — activity context (from submissions_bindings)
- component name — submissionplugin_file
- area type — submissionplugin_file_<area> (<area> from submissions_bindings)
- itemid — submission instance id.
Accessing files
The activity module should be responsible of giving access to files stored by submission plugins, because only activity module can interpret area and itemid correctly.
Submission plugin development
A main plugin class should be calles submissionplugin_<pluginnname> and it should be inherited from abstract class submissionplugin.
TODO: add detailed description on methods plugin must implement.
Backup/restore
The submission must be a part of activity module instances.
What else to consider
See also
- Assign submission plugins
- Advanced grading methods - if we have a multiple grading areas, each of those area may require a submissions.