Skip to content

Commit

Permalink
MDL-31284: New feature for mod_assign: Team assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Sep 3, 2012
1 parent 9e79517 commit 12a1a0d
Show file tree
Hide file tree
Showing 11 changed files with 723 additions and 120 deletions.
11 changes: 9 additions & 2 deletions mod/assign/backup/moodle2/backup_assign_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,20 @@ protected function define_structure() {
'allowsubmissionsfromdate',
'grade',
'timemodified',
'completionsubmit'));
'completionsubmit',
'requiresubmissionstatement',
'teamsubmission',
'requireallteammemberssubmit',
'teamsubmissiongroupingid'));

$submissions = new backup_nested_element('submissions');

$submission = new backup_nested_element('submission', array('id'),
array('userid',
'timecreated',
'timemodified',
'status'));
'status',
'groupid'));

$grades = new backup_nested_element('grades');

Expand Down Expand Up @@ -116,8 +121,10 @@ protected function define_structure() {

// Define id annotations
$submission->annotate_ids('user', 'userid');
$submission->annotate_ids('group', 'groupid');
$grade->annotate_ids('user', 'userid');
$grade->annotate_ids('user', 'grader');
$assign->annotate_ids('grouping', 'teamsubmissiongroupingid');

// Define file annotations
$assign->annotate_files('mod_assign', 'intro', null); // This file area hasn't itemid
Expand Down
10 changes: 9 additions & 1 deletion mod/assign/backup/moodle2/restore_assign_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ protected function process_assign($data) {
$data->timemodified = $this->apply_date_offset($data->timemodified);
$data->allowsubmissionsfromdate = $this->apply_date_offset($data->allowsubmissionsfromdate);
$data->duedate = $this->apply_date_offset($data->duedate);
if ($data->teamsubmissiongroupingid > 0) {
$data->teamsubmissiongroupingid = $this->get_mappingid('grouping', $data->teamsubmissiongroupingid);
}

if (!isset($data->cutoffdate)) {
$data->cutoffdate = 0;
Expand Down Expand Up @@ -105,7 +108,12 @@ protected function process_assign_submission($data) {

$data->timemodified = $this->apply_date_offset($data->timemodified);
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->userid = $this->get_mappingid('user', $data->userid);
if ($data->userid > 0) {
$data->userid = $this->get_mappingid('user', $data->userid);
}
if ($data->groupid > 0) {
$data->groupid = $this->get_mappingid('group', $data->groupid);
}

$newitemid = $DB->insert_record('assign_submission', $data);

Expand Down
13 changes: 9 additions & 4 deletions mod/assign/db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time the settings for this assign module instance were last modified." PREVIOUS="grade" NEXT="requiresubmissionstatement"/>
<FIELD NAME="requiresubmissionstatement" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Forces the student to accept a submission statement when submitting an assignment" PREVIOUS="timemodified" NEXT="completionsubmit"/>
<FIELD NAME="completionsubmit" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If this field is set to 1, then the activity will be automatically marked as 'complete' once the user submits their assignment." PREVIOUS="requiresubmissionstatement" NEXT="cutoffdate"/>
<FIELD NAME="cutoffdate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The final date after which submissions will no longer be accepted for this assignment without an extensions." PREVIOUS="completionsubmit"/>
<FIELD NAME="cutoffdate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The final date after which submissions will no longer be accepted for this assignment without an extensions." PREVIOUS="completionsubmit" NEXT="teamsubmission"/>
<FIELD NAME="teamsubmission" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Do students submit in teams?" PREVIOUS="cutoffdate" NEXT="requireallteammemberssubmit"/>
<FIELD NAME="requireallteammemberssubmit" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="If enabled, a submission will not be accepted until all team members have submitted it." PREVIOUS="teamsubmission" NEXT="teamsubmissiongroupingid"/>
<FIELD NAME="teamsubmissiongroupingid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="A grouping id to get groups for team submissions" PREVIOUS="requireallteammemberssubmit"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="The unique id for this assignment instance."/>
</KEYS>
<INDEXES>
<INDEX NAME="course" UNIQUE="false" FIELDS="course" COMMENT="The course this assignment instance belongs to."/>
<INDEX NAME="course" UNIQUE="false" FIELDS="course" COMMENT="The course this assignment instance belongs to." NEXT="teamsubmissiongroupingid"/>
<INDEX NAME="teamsubmissiongroupingid" UNIQUE="false" FIELDS="teamsubmissiongroupingid" COMMENT="The grouping id for team submissions" PREVIOUS="course"/>
</INDEXES>
</TABLE>
<TABLE NAME="assign_submission" COMMENT="This table keeps information about student interactions with the mod/assign. This is limited to metadata about a student submission but does not include the submission itself which is stored by plugins." PREVIOUS="assign" NEXT="assign_grades">
Expand All @@ -38,7 +42,8 @@
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="assignment" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time of the first student submission to this assignment." PREVIOUS="userid" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The last time this assignment submission was modified by a student." PREVIOUS="timecreated" NEXT="status"/>
<FIELD NAME="status" TYPE="char" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The status of this assignment submission. The current statuses are DRAFT and SUBMITTED." PREVIOUS="timemodified"/>
<FIELD NAME="status" TYPE="char" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The status of this assignment submission. The current statuses are DRAFT and SUBMITTED." PREVIOUS="timemodified" NEXT="groupid"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The group id for team submissions" PREVIOUS="status"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="The unique id for this assignment submission." NEXT="assignment"/>
Expand Down Expand Up @@ -90,4 +95,4 @@
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
55 changes: 47 additions & 8 deletions mod/assign/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ function xmldb_assign_upgrade($oldversion) {

if ($oldversion < 2012051700) {

// Define field sendlatenotifications to be added to assign
// Define field to be added to assign.
$table = new xmldb_table('assign');
$field = new xmldb_field('sendlatenotifications', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'sendnotifications');

// Conditionally launch add field sendlatenotifications
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
Expand All @@ -47,16 +47,17 @@ function xmldb_assign_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2012051700, 'assign');
}

// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.3.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2012071800) {

// Define field requiresubmissionstatement to be added to assign
// Define field requiresubmissionstatement to be added to assign.
$table = new xmldb_table('assign');
$field = new xmldb_field('requiresubmissionstatement', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'timemodified');

// Conditionally launch add field requiresubmissionstatement
// Conditionally launch add field requiresubmissionstatement.

if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
Expand All @@ -67,11 +68,11 @@ function xmldb_assign_upgrade($oldversion) {

if ($oldversion < 2012081600) {

// Define field sendlatenotifications to be added to assign.
// Define field to be added to assign.
$table = new xmldb_table('assign');
$field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'timemodified');

// Conditionally launch add field sendlatenotifications.
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
Expand Down Expand Up @@ -118,6 +119,44 @@ function xmldb_assign_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2012082100, 'assign');
}

// Team assignment support.
if ($oldversion < 2012082300) {

// Define field to be added to assign.
$table = new xmldb_table('assign');
$field = new xmldb_field('teamsubmission', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0', 'cutoffdate');

// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('requireallteammemberssubmit', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0', 'teamsubmission');
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('teamsubmissiongroupingid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0', 'requireallteammemberssubmit');
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$index = new xmldb_index('teamsubmissiongroupingid', XMLDB_INDEX_NOTUNIQUE, array('teamsubmissiongroupingid'));
// Conditionally launch add index.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$table = new xmldb_table('assign_submission');
$field = new xmldb_field('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'status');
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2012082300, 'assign');
}


return true;
}
Expand Down
43 changes: 43 additions & 0 deletions mod/assign/gradingtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgr
$headers[] = get_string('status');
}

// Team submission columns
if ($assignment->get_instance()->teamsubmission) {
$columns[] = 'team';
$headers[] = get_string('submissionteam', 'assign');

$columns[] = 'teamstatus';
$headers[] = get_string('teamsubmissionstatus', 'assign');
}

// Grade
$columns[] = 'grade';
Expand Down Expand Up @@ -205,6 +213,11 @@ function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgr
$this->no_sorting('select');
$this->no_sorting('outcomes');

if ($assignment->get_instance()->teamsubmission) {
$this->no_sorting('team');
$this->no_sorting('teamstatus');
}

foreach ($this->assignment->get_submission_plugins() as $plugin) {
if ($plugin->is_visible() && $plugin->is_enabled()) {
$this->no_sorting('assignsubmission_' . $plugin->get_type());
Expand Down Expand Up @@ -254,6 +267,36 @@ function display_grade($grade, $editable, $userid, $modified) {
return $o;
}

/**
* Get the team info for this user
*
* @param stdClass $row
* @return string The team name
*/
function col_team(stdClass $row) {
$group = $this->assignment->get_submission_group($row->id);
if ($group) {
return $group->name;
}
return get_string('defaultteam', 'assign');
}

/**
* Get the team info for this user
*
* @param stdClass $row
* @return string The team name
*/
function col_teamstatus(stdClass $row) {
$submission = $this->assignment->get_group_submission($row->id, 0, false);
$status = '';
if ($submission) {
$status = $submission->status;
}
return get_string('submissionstatus_' . $status, 'assign');
}


/**
* Format a list of outcomes
*
Expand Down
12 changes: 12 additions & 0 deletions mod/assign/lang/en/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
$string['allowsubmissionsanddescriptionfromdatesummary'] = 'The assignment details and submission form will be available from <strong>{$a}</strong>';
$string['alwaysshowdescription'] = 'Always show description';
$string['alwaysshowdescription_help'] = 'If disabled, the Assignment Description above will only become visible to students at the "Allow submissions from" date.';
$string['applytoteam'] = 'Apply grades and feedback to entire team';
$string['assign:addinstance'] = 'Add a new assignment';
$string['assign:exportownsubmission'] = 'Export own submission';
$string['assign:grade'] = 'Grade assignment';
Expand Down Expand Up @@ -86,6 +87,7 @@
$string['cutoffdatefromdatevalidation'] = 'Cut-off date must be after the allow submissions from date.';
$string['defaultplugins'] = 'Default assignment settings';
$string['defaultplugins_help'] = 'These settings define the defaults for all new assignments.';
$string['defaultteam'] = 'Default team';
$string['deletepluginareyousure'] = 'Delete assignment plugin {$a}: are you sure?';
$string['deletepluginareyousuremessage'] = 'You are about to completely delete the assignment plugin {$a}. This will completely delete everything in the database associated with this assignment plugin. Are you SURE you want to continue?';
$string['deletingplugin'] = 'Deleting plugin {$a}.';
Expand Down Expand Up @@ -193,6 +195,7 @@
$string['numberofparticipants'] = 'Participants';
$string['numberofsubmittedassignments'] = 'Submitted';
$string['numberofsubmissionsneedgrading'] = 'Needs grading';
$string['numberofteams'] = 'Teams';
$string['offline'] = 'No online submissions required';
$string['open'] = 'Open';
$string['overdue'] = '<font color="red">Assignment is overdue by: {$a}</font>';
Expand All @@ -210,6 +213,8 @@
$string['quickgrading_help'] = 'Quick grading allows you to assign grades (and outcomes) directly in the submissions table. Quick grading is not compatible with advanced grading and is not recommended when there are multiple markers.';
$string['requiresubmissionstatement'] = 'Require that students accept the submission statement';
$string['requiresubmissionstatement_help'] = 'Require that students accept the submission statement for all assignment submissions for this entire Moodle installation. If this setting is not enabled, then submission statements can be enabled or disabled in the settings for each assignment.';
$string['requireallteammemberssubmit'] = 'Require all team members submit';
$string['requireallteammemberssubmit_help'] = 'If enabled, all members of the student team must click the submit button for this assignment before the team submission will be considered as submitted. If disabled, the team submission will be considered as submitted as soon as any member of the student team clicks the submit button.';
$string['reverttodraftforstudent'] = 'Revert submission to draft for student: (id={$a->id}, fullname={$a->fullname}).';
$string['reverttodraft'] = 'Revert the submission to draft status.';
$string['reverttodraftshort'] = 'Revert the submission to draft';
Expand Down Expand Up @@ -259,6 +264,7 @@
$string['submissionstatus_'] = 'No submission';
$string['submissionstatus'] = 'Submission status';
$string['submissionstatus_submitted'] = 'Submitted for grading';
$string['submissionteam'] = 'Team';
$string['submission'] = 'Submission';
$string['submitaction'] = 'Submit';
$string['submitassignment_help'] = 'Once this assignment is submitted you will not be able to make any more changes';
Expand All @@ -267,6 +273,11 @@
$string['submittedlate'] = 'Assignment was submitted {$a} late';
$string['submittedlateshort'] = '{$a} late';
$string['submitted'] = 'Submitted';
$string['teamsubmission'] = 'Students submit in teams';
$string['teamsubmission_help'] = 'If enabled students will be divided into teams based on the default set of groups or a custom grouping. A team submission will be shared among team members and all members of the team will see each others changes to the submission.';
$string['teamsubmissiongroupingid'] = 'Grouping for student teams';
$string['teamsubmissiongroupingid_help'] = 'This is the grouping that the assignment will use to find groups for student teams. If not set - the default set of groups will be used.';
$string['teamsubmissionstatus'] = 'Team submission status';
$string['textinstructions'] = 'Assignment instructions';
$string['timemodified'] = 'Last modified';
$string['timeremaining'] = 'Time remaining';
Expand All @@ -276,6 +287,7 @@
$string['updatetable'] = 'Save and update table';
$string['upgradenotimplemented'] = 'Upgrade not implemented in plugin ({$a->type} {$a->subtype})';
$string['userextensiondate'] = 'Extension granted until: {$a}';
$string['userswhoneedtosubmit'] = 'Users who need to submit: {$a}';
$string['viewfeedback'] = 'View feedback';
$string['viewfeedbackforuser'] = 'View feedback for user: {$a}';
$string['viewfullgradingpage'] = 'Open the full grading page to provide feedback';
Expand Down
Loading

0 comments on commit 12a1a0d

Please sign in to comment.