Index: db/install.xml =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/db/install.xml,v retrieving revision 1.7 diff -u -r1.7 install.xml --- db/install.xml 1 May 2009 14:07:44 -0000 1.7 +++ db/install.xml 1 Dec 2011 15:05:49 -0000 @@ -13,7 +13,8 @@ - - + + + Index: db/upgrade.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/db/upgrade.php,v retrieving revision 1.40 diff -u -r1.40 upgrade.php --- db/upgrade.php 2 Feb 2011 13:20:29 -0000 1.40 +++ db/upgrade.php 1 Dec 2011 15:12:55 -0000 @@ -153,6 +153,19 @@ /// assignment savepoint reached upgrade_mod_savepoint(true, 2009042001, 'assignment'); } + + if ($oldversion < 2011120100) { + + /// Rename field format on table assignment to introformat + $table = new xmldb_table('assignment'); + $field = new xmldb_field('anonymous', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'preventlate'); + + /// Launch rename field format + $dbman->add_field($table, $field); + + /// assignment savepoint reached + upgrade_mod_savepoint(true, 2011120100, 'assignment'); + } return true; } Index: lang/en/assignment.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/lang/en/assignment.php,v retrieving revision 1.26.2.1 diff -u -r1.26.2.1 assignment.php --- lang/en/assignment.php 18 May 2011 10:33:42 -0000 1.26.2.1 +++ lang/en/assignment.php 1 Dec 2011 16:31:04 -0000 @@ -32,6 +32,8 @@ $string['allowresubmit'] = 'Allow resubmitting'; $string['allowresubmit_help'] = 'If enabled, students will be allowed to resubmit assignments after they have been graded (for them to be re-graded).'; $string['alreadygraded'] = 'Your assignment has already been graded and resubmission is not allowed.'; +$string['anon'] = 'Anonymous'; +$string['anonymous'] = 'Anonymous marking?'; $string['assignmentdetails'] = 'Assignment details'; $string['assignment:exportownsubmission'] = 'Export own submission'; $string['assignment:exportsubmission'] = 'Export submission'; @@ -202,6 +206,7 @@ $string['uploadnofilefound'] = 'No file was found - are you sure you selected one to upload?'; $string['uploadnotregistered'] = '\'{$a}\' was uploaded OK but submission did not register!'; $string['uploadsuccess'] = 'Uploaded \'{$a}\' successfully'; +$string['user'] = 'User'; $string['usermisconf'] = 'User is misconfigured'; $string['usernosubmit'] = 'Sorry, you are not allowed to submit an assignment.'; $string['viewfeedback'] = 'View assignment grades and feedback'; Index: lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/lib.php,v retrieving revision 1.509.2.5 diff -u -r1.509.2.5 lib.php --- lib.php 19 Jul 2011 14:29:09 -0000 1.509.2.5 +++ lib.php 1 Dec 2011 16:55:01 -0000 @@ -1016,6 +1017,13 @@ $mformdata->lateness = $this->display_lateness($submission->timemodified); $mformdata->auser = $auser; $mformdata->user = $user; + + if($assignment->anonymous == 1){ + $mformdata->user->firstname = get_string('anon', 'assignment'); + $mformdata->user->lastname = get_string('user', 'assignment'); + $mformdata->user->picture = 0; + } + $mformdata->offset = $offset; $mformdata->userid = $userid; $mformdata->cm = $this->cm; @@ -1048,15 +1056,23 @@ } $submitform->set_data($mformdata); - - $PAGE->set_title($this->course->fullname . ': ' .get_string('feedback', 'assignment').' - '.fullname($user, true)); + + if($assignment->anonymous == 0){ + $PAGE->set_title($this->course->fullname . ': ' .get_string('feedback', 'assignment').' - '.fullname($user, true)); + }else{ + $PAGE->set_title($this->course->fullname . ': ' .get_string('feedback', 'assignment')); + } $PAGE->set_heading($this->course->fullname); $PAGE->navbar->add(get_string('submissions', 'assignment'), new moodle_url('/mod/assignment/submissions.php', array('id'=>$cm->id))); - $PAGE->navbar->add(fullname($user, true)); - + if($assignment->anonymous == 0){ + $PAGE->navbar->add(fullname($user, true)); + } echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('feedback', 'assignment').': '.fullname($user, true)); - + if($assignment->anonymous == 0){ + echo $OUTPUT->heading(get_string('feedback', 'assignment').': '.fullname($user, true)); + } else { + echo $OUTPUT->heading(get_string('feedback', 'assignment')); + } // display mform here... $submitform->display(); @@ -1234,19 +1250,35 @@ } } - $tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade'); + if ($assignment->anonymous != 1){ + $tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade'); + } else{ + $tablecolumns = array('grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade'); + } + + if ($uses_outcomes) { $tablecolumns[] = 'outcome'; // no sorting based on outcomes column } - $tableheaders = array('', - get_string('fullnameuser'), - get_string('grade'), - get_string('comment', 'assignment'), - get_string('lastmodified').' ('.get_string('submission', 'assignment').')', - get_string('lastmodified').' ('.get_string('grade').')', - get_string('status'), - get_string('finalgrade', 'grades')); + if ($assignment->anonymous == 1){ + $tableheaders = array(get_string('grade'), + get_string('comment', 'assignment'), + get_string('lastmodified').' ('.get_string('submission', 'assignment').')', + get_string('lastmodified').' ('.get_string('grade').')', + get_string('status'), + get_string('finalgrade', 'grades')); + } else{ + $tableheaders = array('', + get_string('fullnameuser'), + get_string('grade'), + get_string('comment', 'assignment'), + get_string('lastmodified').' ('.get_string('submission', 'assignment').')', + get_string('lastmodified').' ('.get_string('grade').')', + get_string('status'), + get_string('finalgrade', 'grades')); + } + if ($uses_outcomes) { $tableheaders[] = get_string('outcome', 'grades'); } @@ -1262,11 +1294,12 @@ $table->collapsible(true); $table->initialbars(true); - $table->column_suppress('picture'); - $table->column_suppress('fullname'); - - $table->column_class('picture', 'picture'); - $table->column_class('fullname', 'fullname'); + if ($assignment->anonymous == 0){ + $table->column_suppress('picture'); + $table->column_suppress('fullname'); + $table->column_class('picture', 'picture'); + $table->column_class('fullname', 'fullname'); + } $table->column_class('grade', 'grade'); $table->column_class('submissioncomment', 'comment'); $table->column_class('timemodified', 'timemodified'); @@ -1468,7 +1501,11 @@ } $userlink = '' . fullname($auser, has_capability('moodle/site:viewfullnames', $this->context)) . ''; - $row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade); + if($assignment->anonymous == 0){ + $row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade); + }else{ + $row = array($grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade); + } if ($uses_outcomes) { $row[] = $outcomes; } Index: mod_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/mod_form.php,v retrieving revision 1.24.2.1 diff -u -r1.24.2.1 mod_form.php --- mod_form.php 13 Apr 2011 20:20:41 -0000 1.24.2.1 +++ mod_form.php 1 Dec 2011 14:56:33 -0000 @@ -57,6 +57,9 @@ $mform->addElement('select', 'preventlate', get_string('preventlate', 'assignment'), $ynoptions); $mform->setDefault('preventlate', 0); + + $mform->addElement('select', 'anonymous', get_string('anonymous', 'assignment'), $ynoptions); + $mform->setDefault('anonymous', 0); // hack to support pluggable assignment type titles if (get_string_manager()->string_exists('type'.$type, 'assignment')) { Index: submissions.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/submissions.php,v retrieving revision 1.53 diff -u -r1.53 submissions.php --- submissions.php 20 Sep 2010 07:32:31 -0000 1.53 +++ submissions.php 1 Dec 2011 16:44:54 -0000 @@ -52,7 +52,7 @@ $assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm, $course); if($download == "zip") { - $assignmentinstance->download_submissions(); + $assignmentinstance->download_submissions($assignment->anonymous); } else { $assignmentinstance->submissions($mode); // Display or process the submissions } \ No newline at end of file Index: version.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/version.php,v retrieving revision 1.66 diff -u -r1.66 version.php --- version.php 26 Oct 2010 06:46:02 -0000 1.66 +++ version.php 1 Dec 2011 15:09:49 -0000 @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2010102600; +$module->version = 2011120100; $module->requires = 2010102600; // Requires this Moodle version $module->cron = 60; Index: type/online/assignment.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/type/online/assignment.class.php,v retrieving revision 1.117 diff -u -r1.117 assignment.class.php --- type/online/assignment.class.php 25 Jan 2011 18:48:10 -0000 1.117 +++ type/online/assignment.class.php 1 Dec 2011 16:50:49 -0000 @@ -385,7 +390,7 @@ /** * creates a zip of all assignment submissions and sends a zip to the browser */ - public function download_submissions() { + public function download_submissions($anon = 0) { global $CFG, $DB; raise_memory_limit(MEMORY_EXTRA); @@ -414,6 +419,12 @@ if ((groups_is_member($groupid,$a_userid)or !$groupmode or !$groupid)) { $a_assignid = $submission->assignment; //get name of this assignment for use in the file names. $a_user = $DB->get_record("user", array("id"=>$a_userid),'id,username,firstname,lastname'); //get user firstname/lastname + + if($anon == 1){ + $a_user->firstname = ''; + $a_user->lastname = ''; + } + $submissioncontent = "". format_text($submission->data1, $submission->data2). ""; //fetched from database //get file name.html $fileforzipname = clean_filename(fullname($a_user) . "_" .$a_userid.$filextn); Index: type/upload/assignment.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/type/upload/assignment.class.php,v retrieving revision 1.137 diff -u -r1.137 assignment.class.php --- type/upload/assignment.class.php 5 Nov 2010 02:53:53 -0000 1.137 +++ type/upload/assignment.class.php 1 Dec 2011 16:48:22 -0000 @@ -1087,7 +1087,7 @@ /** * creates a zip of all assignment submissions and sends a zip to the browser */ - public function download_submissions() { + public function download_submissions($anon = 0) { global $CFG,$DB; require_once($CFG->libdir.'/filelib.php'); $submissions = $this->get_submissions('',''); @@ -1110,6 +1110,11 @@ if ((groups_is_member($groupid,$a_userid)or !$groupmode or !$groupid)) { $a_assignid = $submission->assignment; //get name of this assignment for use in the file names. $a_user = $DB->get_record("user", array("id"=>$a_userid),'id,username,firstname,lastname'); //get user firstname/lastname + + if($anon == 1){ + $a_user->firstname = ''; + $a_user->lastname = ''; + } $files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false); foreach ($files as $file) { Index: type/uploadsingle/assignment.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/type/uploadsingle/assignment.class.php,v retrieving revision 1.78 diff -u -r1.78 assignment.class.php --- type/uploadsingle/assignment.class.php 2 Nov 2010 01:38:56 -0000 1.78 +++ type/uploadsingle/assignment.class.php 1 Dec 2011 16:51:12 -0000 @@ -353,7 +353,7 @@ /** * creates a zip of all assignment submissions and sends a zip to the browser */ - function download_submissions() { + function download_submissions($anon = 0) { global $CFG,$DB; require_once($CFG->libdir.'/filelib.php'); @@ -378,12 +378,18 @@ $a_assignid = $submission->assignment; //get name of this assignment for use in the file names. $a_user = $DB->get_record("user", array("id"=>$a_userid),'id,username,firstname,lastname'); //get user firstname/lastname + + if($anon == 1){ + $a_user->firstname = ''; + $a_user->lastname = ''; + } + $files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false); foreach ($files as $file) { //get files new name. $fileext = strstr($file->get_filename(), '.'); $fileoriginal = str_replace($fileext, '', $file->get_filename()); $fileforzipname = clean_filename(fullname($a_user) . "_" . $fileoriginal."_".$a_userid.$fileext); //save file name to array for zipping. $filesforzipping[$fileforzipname] = $file; }