Class Submission


  • public class Submission
    extends Object
    • Constructor Detail

      • Submission

        public Submission()
    • Method Detail

      • isEmpty

        public boolean isEmpty()
      • createSingleSubmission

        public static Submission createSingleSubmission​(File src,
                                                        String submissionNaturalLanguage,
                                                        Integer maxSubmissionUnpackSizeKib,
                                                        String submissionRestrictionsDescription,
                                                        String submissionRestrictionsInternalDescription,
                                                        List<FileRestrictionTO> fileRestrictions,
                                                        ContentLogger log)
                                                 throws SubmissionException
        Create a submission object from a submitted file and treat it as a single submission. If the submitted file is a zip file, this method unzips the zip file and loads it into memory. Otherwise the submitted file is treated as a text file submission (usually java source code). When reading the files encodings are guessed and converted to utf8.
        Parameters:
        srcFile - The submitted zip file or src folder
        submissionNaturalLanguage - mandatory parameter, ISO 639-1 code of the language that is assumed as natural language in the submitted files. This will be used to guess the right 8-bit-encoding.
        maxSubmissionUnpackSizeKib - maximum size of sumissoin when nupacked to memory or disc
        log - hook for comments (@see CommentCollection)
        Returns:
        null, if failed
        Throws:
        SubmissionException
      • createMultiSubmission

        public static Map<String,​Submission> createMultiSubmission​(File srcZipFile,
                                                                         String submissionNaturalLanguage,
                                                                         Integer maxSubmissionUnpackSizeKib,
                                                                         String expectedRootFolderInSubmissionZip,
                                                                         Collection<String> expectedAssignmentKeys,
                                                                         Map<String,​List<FileRestrictionTO>> fileRestrictions,
                                                                         ContentLogger log)
                                                                  throws SubmissionException
        unzip a zip file and load it into memory Source file's encodings are guessed and converted to utf8. This method loads several submissions, one for each key in expectedAssignmentKeys. If the zip file does not contain files below one of the expected assignment subfolders, the respective entry in the result map is missing or points to an empty set.
        Parameters:
        srcZipFile - The submitted zip file
        submissionNaturalLanguage - mandatory parameter, ISO 639-1 code of the language that is assumed as natural language in the submitted files. This will be used to guess the right 8-bit-encoding.
        maxSubmissionUnpackSizeKib - maximum size of submission then unpacked to memory or disc
        expectedRootFolderInSubmissionZip - name of the expected root folder
        expectedAssignmentKeys - collection of assignment keys
        fileRestrictions - list of file restrictions, separately per assignment
        log - hook for comments (@see CommentCollection)
        Returns:
        null, if failed
        Throws:
        SubmissionException
      • write

        public boolean write​(Path destDir,
                             ContentLogger log)
        Writes all data to files.
        Parameters:
        destDir - Path to target directory where to unpack the files
        log - hook for comments (@see CommentCollection)
        Returns:
        true on success
      • createComment

        public Content createComment​(boolean createIntro,
                                     String header,
                                     boolean createOutro)