Merge branch 'MDL-31291-POST23' of git://github.com/netspotau/moodle-mod_assign

This commit is contained in:
Aparup Banerjee
2012-09-06 19:43:15 +08:00
16 changed files with 426 additions and 34 deletions
+1 -1
View File
@@ -216,7 +216,7 @@ abstract class assign_plugin {
*
* @return bool - if false - this plugin will not accept submissions / feedback
*/
public final function is_enabled() {
public function is_enabled() {
return $this->get_config('enabled');
}
@@ -60,7 +60,9 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
'requiresubmissionstatement',
'teamsubmission',
'requireallteammemberssubmit',
'teamsubmissiongroupingid'));
'teamsubmissiongroupingid',
'blindmarking',
'revealidentities'));
$submissions = new backup_nested_element('submissions');
+10
View File
@@ -93,6 +93,16 @@ $capabilities = array(
'clonepermissionsfrom' => 'gradereport/grader:view'
),
'mod/assign:revealidentities' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
);
+16 -2
View File
@@ -25,7 +25,9 @@
<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"/>
<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" NEXT="blindmarking"/>
<FIELD NAME="blindmarking" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Hide student/grader identities until the reveal identities action is performed" PREVIOUS="teamsubmissiongroupingid" NEXT="revealidentities"/>
<FIELD NAME="revealidentities" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Show identities for a blind marking assignment" PREVIOUS="blindmarking"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="The unique id for this assignment instance."/>
@@ -75,7 +77,7 @@
<INDEX NAME="mailed" UNIQUE="false" FIELDS="mailed" COMMENT="True if notifications have been sent about the most recent grader update about this submission." PREVIOUS="userid"/>
</INDEXES>
</TABLE>
<TABLE NAME="assign_plugin_config" COMMENT="Config data for an instance of a plugin in an assignment." PREVIOUS="assign_grades">
<TABLE NAME="assign_plugin_config" COMMENT="Config data for an instance of a plugin in an assignment." PREVIOUS="assign_grades" NEXT="assign_user_mapping">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="assignment"/>
<FIELD NAME="assignment" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="plugin"/>
@@ -94,5 +96,17 @@
<INDEX NAME="name" UNIQUE="false" FIELDS="name" COMMENT="The name of this plugin setting." PREVIOUS="subtype"/>
</INDEXES>
</TABLE>
<TABLE NAME="assign_user_mapping" COMMENT="Map an assignment specific id number to a user" PREVIOUS="assign_plugin_config">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="assignment"/>
<FIELD NAME="assignment" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="assignment"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Unique ID for this user/assignment combination." NEXT="assignment"/>
<KEY NAME="assignment" TYPE="foreign" FIELDS="assignment" REFTABLE="assign" REFFIELDS="id" COMMENT="The assignment instance" PREVIOUS="primary" NEXT="user"/>
<KEY NAME="user" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" COMMENT="The user to map to an id" PREVIOUS="assignment"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
+1
View File
@@ -30,6 +30,7 @@ $logs = array(
array('module'=>'assign', 'action'=>'download all submissions', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'grade submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'lock submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'reveal identities', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'revert submission to draft', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'submission statement accepted', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'submit', 'mtable'=>'assign', 'field'=>'name'),
+30
View File
@@ -156,6 +156,36 @@ function xmldb_assign_upgrade($oldversion) {
}
upgrade_mod_savepoint(true, 2012082300, 'assign');
}
if ($oldversion < 2012082400) {
// Define field to be added to assign
$table = new xmldb_table('assign_user_mapping');
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('assignment', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
$table->add_key('assignment', XMLDB_KEY_FOREIGN, array('assignment'), 'assign', array('id'));
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
$table = new xmldb_table('assign');
$field = new xmldb_field('blindmarking', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'teamsubmissiongroupingid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$table = new xmldb_table('assign');
$field = new xmldb_field('revealidentities', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'blindmarking');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2012082400, 'assign');
}
return true;
+22 -6
View File
@@ -144,13 +144,19 @@ class assign_grading_table extends table_sql implements renderable {
$headers[] = get_string('edit');
}
// User picture
$columns[] = 'picture';
$headers[] = get_string('pictureofuser');
// User picture.
if (!$this->assignment->is_blind_marking()) {
$columns[] = 'picture';
$headers[] = get_string('pictureofuser');
// Fullname
$columns[] = 'fullname';
$headers[] = get_string('fullname');
// Fullname.
$columns[] = 'fullname';
$headers[] = get_string('fullname');
} else {
// Record ID.
$columns[] = 'recordid';
$headers[] = get_string('recordid', 'assign');
}
// Submission status
if ($assignment->is_any_submission_plugin_enabled()) {
@@ -236,6 +242,16 @@ class assign_grading_table extends table_sql implements renderable {
}
/**
* Add a column with an ID that uniquely identifies this user in this assignment
*
* @return string
*/
function col_recordid(stdClass $row) {
return get_string('hiddenuser', 'assign', $this->assignment->get_uniqueid_for_user($row->userid));
}
/**
* Add the userid to the row class so it can be updated via ajax
*
+10
View File
@@ -37,6 +37,7 @@ $string['assign:addinstance'] = 'Add a new assignment';
$string['assign:exportownsubmission'] = 'Export own submission';
$string['assign:grade'] = 'Grade assignment';
$string['assign:grantextension'] = 'Grant extension';
$string['assign:revealidentities'] = 'Reveal student identities';
$string['assign:submit'] = 'Submit assignment';
$string['assign:view'] = 'View assignment';
$string['assignfeedback'] = 'Feedback plugin';
@@ -68,6 +69,8 @@ $string['batchoperationconfirmreverttodraft'] = 'Revert selected submissions to
$string['batchoperationlock'] = 'lock submissions';
$string['batchoperationunlock'] = 'unlock submissions';
$string['batchoperationreverttodraft'] = 'revert submissions to draft';
$string['blindmarking'] = 'Blind marking';
$string['blindmarking_help'] = 'Blind marking hides the identity of students to markers. Blind marking settings will be locked once a submission or grade has been made in relation to this assignment.';
$string['changegradewarning'] = 'This assignment has graded submissions and changing the grade will not automatically re-calculate existing submission grades. You must re-grade all existing submissions, if you wish to change the grade.';
$string['comment'] = 'Comment';
$string['completionsubmit'] = 'Student must submit to this activity to complete it';
@@ -156,6 +159,7 @@ $string['gradingstatus'] = 'Grading status';
$string['gradingstudentprogress'] = 'Grading student {$a->index} of {$a->count}';
$string['gradingsummary'] = 'Grading summary';
$string['hideshow'] = 'Hide/Show';
$string['hiddenuser'] = 'Participant {$a}';
$string['instructionfiles'] = 'Instruction files';
$string['invalidgradeforscale'] = 'The grade supplied was not valid for the current scale';
$string['invalidfloatforgrade'] = 'The grade provided could not be understood: {$a}';
@@ -202,6 +206,7 @@ $string['overdue'] = '<font color="red">Assignment is overdue by: {$a}</font>';
$string['outlinegrade'] = 'Grade: {$a}';
$string['page-mod-assign-x'] = 'Any assignment module page';
$string['page-mod-assign-view'] = 'Assignment module main and submission page';
$string['participant'] = 'Participant';
$string['pluginadministration'] = 'Assignment administration';
$string['pluginname'] = 'Assignment';
$string['preventsubmissions'] = 'Prevent the user from making any more submissions to this assignment.';
@@ -215,6 +220,9 @@ $string['requiresubmissionstatement'] = 'Require that students accept the submis
$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['recordid'] = 'Identifier';
$string['revealidentities'] = 'Reveal student identities';
$string['revealidentitiesconfirm'] = 'Are you sure you want to reveal student identities for this assignment. This operation cannot be undone. Once the student identities have been revealed, the marks will be released to the gradebook.';
$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';
@@ -299,3 +307,5 @@ $string['viewownsubmissionstatus'] = 'View own submission status page.';
$string['viewsubmissionforuser'] = 'View submission for user: {$a}';
$string['viewsubmission'] = 'View submission';
$string['viewsubmissiongradingtable'] = 'View submission grading table.';
$string['viewrevealidentitiesconfirm'] = 'View reveal student identities confirmation page.';
+9 -1
View File
@@ -113,7 +113,7 @@ function assign_grading_areas_list() {
* @return void
*/
function assign_extend_settings_navigation(settings_navigation $settings, navigation_node $navref) {
global $PAGE;
global $PAGE, $DB;
$cm = $PAGE->cm;
if (!$cm) {
@@ -144,6 +144,14 @@ function assign_extend_settings_navigation(settings_navigation $settings, naviga
$node = $navref->add(get_string('downloadall', 'assign'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/assign:revealidentities', $context)) {
$assignment = $DB->get_record('assign', array('id'=>$cm->instance), 'blindmarking, revealidentities');
if ($assignment && $assignment->blindmarking && !$assignment->revealidentities) {
$link = new moodle_url('/mod/assign/view.php', array('id' => $cm->id,'action'=>'revealidentities'));
$node = $navref->add(get_string('revealidentities', 'assign'), $link, navigation_node::TYPE_SETTING);
}
}
}
+264 -12
View File
@@ -215,6 +215,28 @@ class assign {
return $this->submissionplugins;
}
/**
* Is blind marking enabled and reveal identities not set yet?
*
* @return bool
*/
public function is_blind_marking() {
return $this->get_instance()->blindmarking && !$this->get_instance()->revealidentities;
}
/**
* Does an assignment have submission(s) or grade(s) already?
*
* @return bool
*/
public function has_submissions_or_grades() {
$allgrades = $this->count_grades();
$allsubmissions = $this->count_submissions();
if (($allgrades == 0) && ($allsubmissions == 0)) {
return false;
}
return true;
}
/**
* get a specific submission plugin by its type
@@ -353,6 +375,9 @@ class assign {
if ($this->process_save_extension($mform)) {
$action = 'grading';
}
} else if ($action == 'revealidentitiesconfirm') {
$this->process_reveal_identities();
$action = 'grading';
}
$returnparams = array('rownum'=>optional_param('rownum', 0, PARAM_INT));
@@ -384,6 +409,8 @@ class assign {
$o .= $this->check_submit_for_grading($mform);
} else if ($action == 'grantextension') {
$o .= $this->view_grant_extension($mform);
} else if ($action == 'revealidentities') {
$o .= $this->view_reveal_identities_confirm($mform);
} else {
$o .= $this->view_submission_page();
}
@@ -427,6 +454,7 @@ class assign {
$update->teamsubmission = $formdata->teamsubmission;
$update->requireallteammemberssubmit = $formdata->requireallteammemberssubmit;
$update->teamsubmissiongroupingid = $formdata->teamsubmissiongroupingid;
$update->blindmarking = $formdata->blindmarking;
$returnid = $DB->insert_record('assign', $update);
$this->instance = $DB->get_record('assign', array('id'=>$returnid), '*', MUST_EXIST);
@@ -651,6 +679,7 @@ class assign {
$update->teamsubmission = $formdata->teamsubmission;
$update->requireallteammemberssubmit = $formdata->requireallteammemberssubmit;
$update->teamsubmissiongroupingid = $formdata->teamsubmissiongroupingid;
$update->blindmarking = $formdata->blindmarking;
$result = $DB->update_record('assign', $update);
@@ -1028,7 +1057,48 @@ class assign {
}
/**
* Load a count of users enrolled in the current course with the specified permission and group (optional)
* Load a count of grades
*
* @return int number of grades
*/
public function count_grades() {
global $DB;
if (!$this->has_instance()) {
return 0;
}
$sql = 'SELECT COUNT(id) FROM {assign_grades} WHERE assignment = ?';
$params = array($this->get_course_module()->instance);
return $DB->count_records_sql($sql, $params);
}
/**
* Load a count of submissions
*
* @return int number of submissions
*/
public function count_submissions() {
global $DB;
if (!$this->has_instance()) {
return 0;
}
$sql = 'SELECT COUNT(id) FROM {assign_submission} WHERE assignment = ?';
$params = array($this->get_course_module()->instance);
if ($this->get_instance()->teamsubmission) {
// only look at team submissions
$sql .= ' AND userid = ?';
$params[] = 0;
}
return $DB->count_records_sql($sql, $params);
}
/**
* Load a count of submissions with a specified status
*
* @param string $status The submission status - should match one of the constants
* @return int number of matching submissions
@@ -1147,7 +1217,8 @@ class assign {
$timenow = time();
// Collect all submissions from the past 24 hours that require mailing.
$sql = "SELECT s.*, a.course, a.name, g.*, g.id as gradeid, g.timemodified as lastmodified
$sql = "SELECT s.*, a.course, a.name, a.blindmarking, a.revealidentities,
g.*, g.id as gradeid, g.timemodified as lastmodified
FROM {assign} a
JOIN {assign_grades} g ON g.assignment = a.id
LEFT JOIN {assign_submission} s ON s.assignment = a.id AND s.userid = g.userid
@@ -1249,7 +1320,15 @@ class assign {
$eventtype = 'assign_notification';
$updatetime = $submission->lastmodified;
$modulename = get_string('modulename', 'assign');
self::send_assignment_notification($grader, $user, $messagetype, $eventtype, $updatetime, $mod, $contextmodule, $course, $modulename, $submission->name);
$uniqueid = 0;
if ($submission->blindmarking && !$submission->revealidentities) {
$uniqueid = self::get_uniqueid_for_user_static($submission->assignment, $user->id);
}
self::send_assignment_notification($grader, $user, $messagetype, $eventtype, $updatetime,
$mod, $contextmodule, $course, $modulename, $submission->name,
$submission->blindmarking && !$submission->revealidentities,
$uniqueid);
$grade = new stdClass();
$grade->id = $submission->gradeid;
@@ -1404,6 +1483,10 @@ class assign {
$submission = $this->get_user_submission($member->id, false);
if ($submission && $submission->status != ASSIGN_SUBMISSION_STATUS_DRAFT) {
unset($members[$id]);
} else {
if ($this->is_blind_marking()) {
$members[$id]->alias = get_string('hiddenuser', 'assign') . $this->get_uniqueid_for_user($id);
}
}
}
return $members;
@@ -1688,7 +1771,11 @@ class assign {
$user = $DB->get_record("user", array("id"=>$userid),'id,username,firstname,lastname', MUST_EXIST);
$prefix = clean_filename(fullname($user) . "_" .$userid . "_");
if ($this->is_blind_marking()) {
$prefix = clean_filename(get_string('participant', 'assign') . "_" . $this->get_uniqueid_for_user($userid) . "_");
} else {
$prefix = clean_filename(fullname($user) . "_" . $this->get_uniqueid_for_user($userid) . "_");
}
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
@@ -1873,7 +1960,12 @@ class assign {
}
$user = $DB->get_record('user', array('id' => $userid));
if ($user) {
$o .= $this->output->render(new assign_user_summary($user, $this->get_course()->id, has_capability('moodle/site:viewfullnames', $this->get_course_context())));
$o .= $this->output->render(new assign_user_summary($user,
$this->get_course()->id,
has_capability('moodle/site:viewfullnames',
$this->get_course_context()),
$this->is_blind_marking(),
$this->get_uniqueid_for_user($user->id)));
}
$submission = $this->get_user_submission($userid, false);
$submissiongroup = null;
@@ -1899,8 +1991,7 @@ class assign {
if ($grade) {
$extensionduedate = $grade->extensionduedate;
}
$showedit = has_capability('mod/assign:submit', $this->context) &&
$this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled());
$showedit = $this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled());
if ($teamsubmission) {
$showsubmit = $showedit && $teamsubmission && ($teamsubmission->status == ASSIGN_SUBMISSION_STATUS_DRAFT);
@@ -1931,7 +2022,8 @@ class assign {
$showsubmit,
$viewfullnames,
$extensionduedate,
$this->get_context()));
$this->get_context(),
$this->is_blind_marking()));
}
if ($grade) {
$data = new stdClass();
@@ -1962,6 +2054,34 @@ class assign {
return $o;
}
/**
* Show a confirmation page to make sure they want to release student identities
*
* @return string
*/
private function view_reveal_identities_confirm() {
global $CFG, $USER;
require_capability('mod/assign:revealidentities', $this->get_context());
$o = '';
$o .= $this->output->render(new assign_header($this->get_instance(),
$this->get_context(), false, $this->get_course_module()->id));
$confirmurl = new moodle_url('/mod/assign/view.php', array('id'=>$this->get_course_module()->id,
'action'=>'revealidentitiesconfirm',
'sesskey'=>sesskey()));
$cancelurl = new moodle_url('/mod/assign/view.php', array('id'=>$this->get_course_module()->id,
'action'=>'grading'));
$o .= $this->output->confirm(get_string('revealidentitiesconfirm', 'assign'), $confirmurl, $cancelurl);
$o .= $this->view_footer();
$this->add_to_log('view', get_string('viewrevealidentitiesconfirm', 'assign'));
return $o;
}
/**
@@ -2005,6 +2125,10 @@ class assign {
$downloadurl = '/mod/assign/view.php?id=' . $this->get_course_module()->id . '&action=downloadall';
$links[$downloadurl] = get_string('downloadall', 'assign');
}
if ($this->is_blind_marking() && has_capability('mod/assign:revealidentities', $this->get_context())) {
$revealidentitiesurl = '/mod/assign/view.php?id=' . $this->get_course_module()->id . '&action=revealidentities';
$links[$revealidentitiesurl] = get_string('revealidentities', 'assign');
}
$gradingactions = new url_select($links);
@@ -2371,7 +2495,8 @@ class assign {
$showsubmit,
$viewfullnames,
$extensionduedate,
$this->get_context()));
$this->get_context(),
$this->is_blind_marking()));
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/grade/grading/lib.php');
@@ -2540,6 +2665,10 @@ class assign {
*/
private function gradebook_item_update($submission=NULL, $grade=NULL) {
// Do not push grade to gradebook if blind marking is active as the gradebook would reveal the students.
if ($this->is_blind_marking()) {
return false;
}
if ($submission != NULL) {
if ($submission->userid == 0) {
// This is a group submission update.
@@ -2854,11 +2983,16 @@ class assign {
*/
public static function send_assignment_notification($userfrom, $userto, $messagetype, $eventtype,
$updatetime, $coursemodule, $context, $course,
$modulename, $assignmentname) {
$modulename, $assignmentname, $blindmarking,
$uniqueidforuser) {
global $CFG;
$info = new stdClass();
$info->username = fullname($userfrom, true);
if ($blindmarking) {
$info->username = get_string('participant', 'assign') . ' ' . $uniqueidforuser;
} else {
$info->username = fullname($userfrom, true);
}
$info->assignment = format_string($assignmentname,true, array('context'=>$context));
$info->url = $CFG->wwwroot.'/mod/assign/view.php?id='.$coursemodule->id;
$info->timeupdated = strftime('%c',$updatetime);
@@ -2897,7 +3031,11 @@ class assign {
* @return void
*/
public function send_notification($userfrom, $userto, $messagetype, $eventtype, $updatetime) {
self::send_assignment_notification($userfrom, $userto, $messagetype, $eventtype, $updatetime, $this->get_course_module(), $this->get_context(), $this->get_course(), $this->get_module_name(), $this->get_instance()->name);
self::send_assignment_notification($userfrom, $userto, $messagetype, $eventtype,
$updatetime, $this->get_course_module(), $this->get_context(),
$this->get_course(), $this->get_module_name(),
$this->get_instance()->name, $this->is_blind_marking(),
$this->get_uniqueid_for_user($userfrom->id));
}
/**
@@ -3229,6 +3367,53 @@ class assign {
return get_string('quickgradingchangessaved', 'assign');
}
/**
* Reveal student identities to markers (and the gradebook)
*
* @return void
*/
private function process_reveal_identities() {
global $DB, $CFG;
require_capability('mod/assign:revealidentities', $this->context);
if (!confirm_sesskey()) {
return false;
}
// Update the assignment record.
$update = new stdClass();
$update->id = $this->get_instance()->id;
$update->revealidentities = 1;
$DB->update_record('assign', $update);
// Refresh the instance data.
$this->instance = null;
// Release the grades to the gradebook.
// First create the column in the gradebook.
$this->update_gradebook(false, $this->get_course_module()->id);
// Now release all grades.
$adminconfig = $this->get_admin_config();
$gradebookplugin = $adminconfig->feedback_plugin_for_gradebook;
$grades = $DB->get_records('assign_grades', array('assignment'=>$this->get_instance()->id));
$plugin = $this->get_feedback_plugin_by_type($gradebookplugin);
foreach ($grades as $grade) {
// Fetch any comments for this student.
if ($plugin && $plugin->is_enabled() && $plugin->is_visible()) {
$grade->feedbacktext = $plugin->text_for_gradebook($grade);
$grade->feedbackformat = $plugin->format_for_gradebook($grade);
}
$this->gradebook_item_update(NULL, $grade);
}
$this->add_to_log('reveal identities', get_string('revealidentities', 'assign'));
}
/**
* save grading options
*
@@ -4045,5 +4230,72 @@ class assign {
return $grades;
}
/**
* Call the static version of this function
*
* @param int $userid The userid to lookup
* @return int The unique id
*/
public function get_uniqueid_for_user($userid) {
return self::get_uniqueid_for_user_static($this->get_instance()->id, $userid);
}
/**
* Foreach participant in the course - assign them a random id
*
* @param int $assignid The assignid to lookup
*/
public static function allocate_unique_ids($assignid) {
global $DB;
$cm = get_coursemodule_from_instance('assign', $assignid, 0, false, MUST_EXIST);
$context = context_module::instance($cm->id);
$currentgroup = groups_get_activity_group($cm, true);
$users = get_enrolled_users($context, "mod/assign:submit", $currentgroup, 'u.id');
// shuffle the users
shuffle($users);
$record = new stdClass();
$record->assignment = $assignid;
foreach ($users as $user) {
if (!$DB->get_record('assign_user_mapping', array('assignment'=>$assignid, 'userid'=>$user->id), 'id')) {
$record->userid = $user->id;
$DB->insert_record('assign_user_mapping', $record);
}
}
}
/**
* Lookup this user id and return the unique id for this assignment
*
* @param int $userid The userid to lookup
* @return int The unique id
*/
public static function get_uniqueid_for_user_static($assignid, $userid) {
global $DB;
// Search for a record.
if ($record = $DB->get_record('assign_user_mapping', array('assignment'=>$assignid, 'userid'=>$userid), 'id')) {
return $record->id;
}
// Be a little smart about this - there is no record for the current user.
// We should ensure any unallocated ids for the current participant list are distrubited randomly
self::allocate_unique_ids($assignid);
// Retry the search for a record.
if ($record = $DB->get_record('assign_user_mapping', array('assignment'=>$assignid, 'userid'=>$userid), 'id')) {
return $record->id;
}
// The requested user must not be a participant. Add a record anyway.
$record = new stdClass();
$record->assignment = $assignid;
$record->userid = $userid;
return $DB->insert_record('assign_user_mapping', $record);
}
}
+7
View File
@@ -127,6 +127,13 @@ class mod_assign_mod_form extends moodleform_mod {
$mform->setDefault('teamsubmissiongroupingid', 0);
$mform->disabledIf('teamsubmissiongroupingid', 'teamsubmission', 'eq', 0);
$mform->addElement('selectyesno', 'blindmarking', get_string('blindmarking', 'assign'));
$mform->addHelpButton('blindmarking', 'blindmarking', 'assign');
$mform->setDefault('blindmarking', 0);
if ($assignment->has_submissions_or_grades() ) {
$mform->freeze('blindmarking');
}
// plagiarism enabling form
if (!empty($CFG->enableplagiarism)) {
+12 -2
View File
@@ -116,6 +116,10 @@ class assign_user_summary implements renderable {
public $courseid;
/** @var bool $viewfullnames */
public $viewfullnames = false;
/** @var bool $blindmarking */
public $blindmarking = false;
/** @var int $uniqueidforuser */
public $uniqueidforuser;
/**
* Constructor
@@ -123,10 +127,12 @@ class assign_user_summary implements renderable {
* @param int $courseid
* @param bool $viewfullnames
*/
public function __construct(stdClass $user, $courseid, $viewfullnames) {
public function __construct(stdClass $user, $courseid, $viewfullnames, $blindmarking, $uniqueidforuser) {
$this->user = $user;
$this->courseid = $courseid;
$this->viewfullnames = $viewfullnames;
$this->blindmarking = $blindmarking;
$this->uniqueidforuser = $uniqueidforuser;
}
}
@@ -329,6 +335,8 @@ class assign_submission_status implements renderable {
public $extensionduedate = 0;
/** @var context context */
public $context = 0;
/** @var bool blindmarking - Should we hide student identities from graders? */
public $blindmarking = false;
/**
* constructor
@@ -356,13 +364,14 @@ class assign_submission_status implements renderable {
* @param bool $canviewfullnames
* @param int $extensionduedate - Any extension to the due date granted for this user
* @param context $context - Any extension to the due date granted for this user
* @param blindmarking $blindmarking - Should we hide student identities from graders?
*/
public function __construct($allowsubmissionsfromdate, $alwaysshowdescription, $submission,
$teamsubmissionenabled, $teamsubmission, $submissiongroup,
$submissiongroupmemberswhoneedtosubmit, $submissionsenabled,
$locked, $graded, $duedate, $cutoffdate, $submissionplugins, $returnaction, $returnparams,
$coursemoduleid, $courseid, $view, $canedit, $cansubmit, $canviewfullnames, $extensionduedate,
$context) {
$context, $blindmarking) {
$this->allowsubmissionsfromdate = $allowsubmissionsfromdate;
$this->alwaysshowdescription = $alwaysshowdescription;
$this->submission = $submission;
@@ -386,6 +395,7 @@ class assign_submission_status implements renderable {
$this->canviewfullnames = $canviewfullnames;
$this->extensionduedate = $extensionduedate;
$this->context = $context;
$this->blindmarking = $blindmarking;
}
}
+15 -7
View File
@@ -131,12 +131,16 @@ class mod_assign_renderer extends plugin_renderer_base {
}
$o .= $this->output->container_start('usersummary');
$o .= $this->output->box_start('boxaligncenter usersummarysection');
$o .= $this->output->user_picture($summary->user);
$o .= $this->output->spacer(array('width'=>30));
$o .= $this->output->action_link(new moodle_url('/user/view.php',
array('id' => $summary->user->id,
'course'=>$summary->courseid)),
fullname($summary->user, $summary->viewfullnames));
if ($summary->blindmarking) {
$o .= get_string('hiddenuser', 'assign', $summary->uniqueidforuser);
} else {
$o .= $this->output->user_picture($summary->user);
$o .= $this->output->spacer(array('width'=>30));
$o .= $this->output->action_link(new moodle_url('/user/view.php',
array('id' => $summary->user->id,
'course'=>$summary->courseid)),
fullname($summary->user, $summary->viewfullnames));
}
$o .= $this->output->box_end();
$o .= $this->output->container_end();
@@ -425,7 +429,11 @@ class mod_assign_renderer extends plugin_renderer_base {
$userslist = array();
foreach ($members as $member) {
$url = new moodle_url('/user/view.php', array('id' => $member->id, 'course'=>$status->courseid));
$userslist[] = $this->output->action_link($url, fullname($member, $status->canviewfullnames));
if ($status->view == assign_submission_status::GRADER_VIEW && $status->blindmarking) {
$userslist[] = $member->alias;
} else {
$userslist[] = $this->output->action_link($url, fullname($member, $status->canviewfullnames));
}
}
if (count($userslist) > 0) {
$userstr = join(', ', $userslist);
@@ -164,4 +164,17 @@ class assign_submission_comments extends assign_submission_plugin {
return false;
}
/**
* If blind marking is enabled then disable this plugin (it shows names)
*
* @return bool
*/
public function is_enabled() {
if ($this->assignment->has_instance() && $this->assignment->is_blind_marking()) {
return false;
}
return parent::is_enabled();
}
}
+12 -1
View File
@@ -250,7 +250,18 @@ class assign_submission_onlinetext extends assign_submission_plugin {
if ($onlinetextsubmission) {
$user = $DB->get_record("user", array("id"=>$submission->userid),'id,username,firstname,lastname', MUST_EXIST);
$prefix = clean_filename(fullname($user) . "_" .$submission->userid . "_");
if (!$this->assignment->is_blind_marking()) {
$filename = str_replace('_', '', fullname($user)) . '_' .
$this->assignment->get_uniqueid_for_user($userid) . '_' .
$this->get_name() . '_';
$prefix = clean_filename($filename);
} else {
$filename = get_string('participant', 'assign') . '_' .
$this->assignment->get_uniqueid_for_user($userid) . '_' .
$this->get_name() . '_';
$prefix = clean_filename($filename);
}
$finaltext = str_replace('@@PLUGINFILE@@/', $prefix, $onlinetextsubmission->onlinetext);
$submissioncontent = "<html><body>". format_text($finaltext, $onlinetextsubmission->onlineformat, array('context'=>$this->assignment->get_context())). "</body></html>"; //fetched from database
+1 -1
View File
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$module->component = 'mod_assign'; // Full name of the plugin (used for diagnostics)
$module->version = 2012082300; // The current module version (Date: YYYYMMDDXX)
$module->version = 2012082400; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2012061700; // Requires this Moodle version
$module->cron = 60;