Index: assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java =================================================================== --- assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java (revision 3227) +++ assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java (revision 3228) @@ -3098,8 +3098,8 @@ String contextString = (String) state.getAttribute(STATE_CONTEXT_STRING); context.put("contextString", contextString); context.put("accessPointUrl", (ServerConfigurationService.getAccessUrl()).concat(AssignmentService.submissionsZipReference( - contextString, (String) state.getAttribute(EXPORT_ASSIGNMENT_REF)))); - + contextString, (String) state.getAttribute(EXPORT_ASSIGNMENT_REF))) + + "?studentSubmissionText=true&studentSubmissionAttachment=true&gradeFile=true&feedbackTexts=true&feedbackComments=true&feedbackAttachments=true&viewString=all&searchString=&searchFilterOnly=false&contextString=" + contextString); String assignmentRef = (String) state.getAttribute(EXPORT_ASSIGNMENT_REF); Assignment a = getAssignment(assignmentRef, "build_instructor_download_upload_all", state); if (a != null) @@ -11200,6 +11200,8 @@ // and if have any folder structures, those folders should be named after at least one site user (zip file could contain user names who is no longer inside the site) boolean zipHasFolder = false; boolean zipHasFolderValidUserId = false; + String badpath = null; + String firstentry = null; FileOutputStream tmpFileOut = null; File tempFile = null; @@ -11211,20 +11213,24 @@ try { - tempFile = File.createTempFile(String.valueOf(System.currentTimeMillis()),""); + tempFile = File.createTempFile(String.valueOf(System.currentTimeMillis()),""); tmpFileOut = new FileOutputStream(tempFile); writeToStream(fileContentStream, tmpFileOut); tmpFileOut.flush(); tmpFileOut.close(); + System.out.println("temp file " + tempFile.getPath() + " " + tempFile.length()); ZipFile zipFile = new ZipFile(tempFile, "UTF-8"); Enumeration zipEntries = zipFile.getEntries(); + System.out.println("have entrie? " + zipEntries.hasMoreElements()); ZipEntry entry; while (zipEntries.hasMoreElements() && validZipFormat) { entry = zipEntries.nextElement(); String entryName = entry.getName(); + firstentry = entryName; + System.out.println("entry " + entryName); if (!entry.isDirectory() && entryName.indexOf("/.") == -1) { if (entryName.endsWith("grades.csv")) @@ -11292,6 +11298,8 @@ String[] pathParts = entryName.split("/"); if (pathParts.length <=2) { + if (validZipFormat) + badpath = entryName; validZipFormat=false; } else @@ -11430,8 +11438,22 @@ || (zipHasFolder && !zipHasFolderValidUserId) // generate error when there is folder structure but not matching one user id || !validZipFormat) // should have right structure of zip file { - // alert if the zip is of wrong format - addAlert(state, rb.getString("uploadall.alert.wrongZipFormat")); + if (firstentry == null) + addAlert(state, "There were no readable files in this ZIP file. This suggests that it is not a ZIP file or that the file is corrupted in some way."); + else { + addAlert(state, "The first entry in this file was \"" + firstentry + "\". "); + addAlert(state, "Please verify that this entry is of the form \"FOLDER/grades.csv\" or \"FOLDER/STUDENTNAME(USERNAME)/item\". Note that the STUDENTNAME is not checked -- only the USERNAME."); + + if (!validZipFormat) + addAlert(state, "Something other than grades.csv or a student folder appears in the ZIP file: " + badpath); + else if (!zipHasGradeFile && !zipHasFolder) + addAlert(state, "The ZIP file has neither grades.csv nor any student folders"); + else if (zipHasFolder && !zipHasFolderValidUserId) + addAlert(state, "The ZIP file has student folders, but none of the students are in this site."); + else + addAlert(state, "The contents of the ZIP file are invalid."); + + } } return submissionTable; } @@ -12374,8 +12396,9 @@ byte[] buffer = new byte[INPUT_BUFFER_SIZE]; try { - while (in.read(buffer) > 0) { - out.write(buffer); + int len = 0; + while ((len=in.read(buffer)) > 0) { + out.write(buffer, 0, len); } } catch (IOException e) { throw e;