Index: lib/LAE/zip.php =================================================================== --- lib/LAE/zip.php (.../vendor/moodle/1.9weekly) (revision 0) +++ lib/LAE/zip.php (.../branches/1.9.5-LAE1.0/AssignmentZip) (revision 139) @@ -0,0 +1,25 @@ +zipsecret)) { + $SESSION->zipsecret = md5(uniqid(rand(), true)) . md5(uniqid(rand(), true)) . md5(uniqid(rand(), true)); +} + +function file_collection_form($files_tozip, $collection_name) { + global $CFG, $SESSION; + + $payload = array('files' => $files_tozip, 'name' => $collection_name); + $encoded = encrypt_and_encode(serialize($payload), $SESSION->zipsecret); + + $output = '
'; + + return $output; +} + +?> Property changes on: lib/LAE/zip.php ___________________________________________________________________ Added: svn:keywords + Id Index: lib/LAE/xor.php =================================================================== --- lib/LAE/xor.php (.../vendor/moodle/1.9weekly) (revision 0) +++ lib/LAE/xor.php (.../branches/1.9.5-LAE1.0/AssignmentZip) (revision 139) @@ -0,0 +1,57 @@ +zipsecret); +} + +function decrypt_and_decode($str) { + global $SESSION; + + return XORDecode($str, $SESSION->zipsecret); +} + +?> Property changes on: lib/LAE/xor.php ___________________________________________________________________ Added: svn:keywords + Id Index: mod/assignment/lib.php =================================================================== --- mod/assignment/lib.php (.../vendor/moodle/1.9weekly) (revision 139) +++ mod/assignment/lib.php (.../branches/1.9.5-LAE1.0/AssignmentZip) (revision 139) @@ -5,6 +5,8 @@ * This class provides all the functionality for an assignment */ +require_once($CFG->dirroot . '/lib/LAE/zip.php'); + DEFINE ('ASSIGNMENT_COUNT_WORDS', 1); DEFINE ('ASSIGNMENT_COUNT_LETTERS', 2); @@ -1158,7 +1160,6 @@ 'WHERE '.$where.'u.id IN ('.implode(',',$users).') '; $table->pagesize($perpage, count($users)); - ///offset used to calculate index of student in that particular query, needed for the pop up to know who's next $offset = $page * $perpage; @@ -1166,6 +1167,25 @@ $strgrade = get_string('grade'); $grademenu = make_grades_menu($this->assignment->grade); + + if (class_exists('ZipArchive')) { + $files_tozip = array(); // zip assignment files + + require_once($CFG->dirroot.'/mod/assignment/type/'.$assignment->assignmenttype.'/assignment.class.php'); + $assignmentclass = 'assignment_'.$assignment->assignmenttype; + $assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm, $course); + + foreach (assignment_get_all_submissions($assignment, '', 'DESC') as $sub) { + $filearea = $assignmentinstance->file_area_name($sub->userid); + $fullpath = $CFG->dataroot . '/' . $filearea; + $subuser = get_record('user', 'id', $sub->userid); + + if ($files = get_directory_list($fullpath, 'responses')) + foreach ($files as $key => $file) + $files_tozip[$file] = array('path' => $fullpath . "/" . $file . " ", 'author' => $subuser->firstname . " " . $subuser->lastname); + } + } + if (($ausers = get_records_sql($select.$sql.$sort, $table->get_page_start(), $table->get_page_size())) !== false) { $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers)); foreach ($ausers as $auser) { @@ -1299,7 +1319,7 @@ } } - $userlink = '' . fullname($auser) . ''; + $userlink = '' . fullname($auser) . ''; $row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade); if ($uses_outcomes) { $row[] = $outcomes; @@ -1336,6 +1356,10 @@ } /// End of fast grading form + if(class_exists('ZipArchive') && sizeof($files_tozip) > 1) { + echo file_collection_form($files_tozip, $assignment->name); + } + /// Mini form for setting user preference echo '