Class TransformBetweenTaskZipAndStarter


  • public class TransformBetweenTaskZipAndStarter
    extends Object

    This class gets one or several assignments and a student submission as input and produces a request file, that subsequently can be graded by Graja.

    The converter makes simplifying assumptions about the requested types of documents, that need to be generated by Graja (= {INFO,SEVERE} x {TEACHER,STUDENT} x {html,plain}).

    • Constructor Detail

      • TransformBetweenTaskZipAndStarter

        public TransformBetweenTaskZipAndStarter()
    • Method Detail

      • generateFrontendProformaSubmissionRequestTOFromTaskZip

        public static FrontendProformaSubmissionRequestTO generateFrontendProformaSubmissionRequestTOFromTaskZip​(String srcPathToSubmission,
                                                                                                                 String srcPathToTaskZip,
                                                                                                                 String submissionNaturalLanguage,
                                                                                                                 Integer maxSubmissionUnpackSizeKib,
                                                                                                                 BigDecimal scoreMax,
                                                                                                                 Integer scorePrecision,
                                                                                                                 DebugSwitchesTO debugSwitches,
                                                                                                                 ResultSpecTO resultSpecIn,
                                                                                                                 Path tmpdir)
                                                                                                          throws IllegalArgumentException,
                                                                                                                 IOException,
                                                                                                                 javax.xml.bind.JAXBException

        This method creates an instance of FrontendProformaSubmissionRequestTO from an assignment and a submission. The resulting object can be used as input to Graja for grading.

        Parameters:
        srcPathToSubmission - input zip file or input folder for the student submission
        srcPathToTaskZip - input file for the assignment in proforma task.zip format
        submissionNaturalLanguage - ISO-639-1 code of the language that is assumed to be used in the submitted files. This will be used to guess the right 8-bit-encoding.
        maxSubmissionUnpackSizeKib - maximum KiB allowed for unzipped submission
        scoreMax - the target maximum score. If not null, the resulting assignment will be scaled to that target score.
        scorePrecision - number of decimal digits of scaled scores.
        debugSwitches - input data for debug switches
        resultSpec - input data for result specification
        tmpdir - must point to an existing path that can be used to create temporary files.
        Returns:
        A request of the specified type
        Throws:
        IllegalArgumentException
        IOException
        javax.xml.bind.JAXBException
      • getProformaSubmissionFeedbackLevel

        public static FeedbackLevelType getProformaSubmissionFeedbackLevel​(Level lvl)
      • generateGrajaSingleFrontendRequestTOFromTaskZip

        public static FrontendGrajaSingleRequestTO generateGrajaSingleFrontendRequestTOFromTaskZip​(boolean proforma,
                                                                                                   String pathToSubmission,
                                                                                                   String pathToTaskZip,
                                                                                                   String submissionNaturalLanguage,
                                                                                                   Integer maxSubmissionUnpackSizeKib,
                                                                                                   BigDecimal scoreMax,
                                                                                                   Integer scorePrecision,
                                                                                                   DebugSwitchesTO debugSwitches,
                                                                                                   ResultSpecTO resultSpec,
                                                                                                   Path tmpdir)
                                                                                            throws IllegalArgumentException,
                                                                                                   IOException,
                                                                                                   javax.xml.bind.JAXBException

        This method creates an instance of FrontendGrajaSingleRequestTO or BackendRequestTO from an assignment and a submission. The resulting object can be used as input to Graja for grading.

        Parameters:
        proforma - if true, this method returns a Variant.FRONTEND_GRAJA_SINGLE_PROFORMA object, else a Variant.FRONTEND_GRAJA_SINGLE_PLAINOLD object. and specifies, which request type is generated.
        pathToSubmission - input zip file or input folder for the student submission
        pathToTaskZip - input file for the assignment in proforma task.zip format
        submissionNaturalLanguage - ISO-639-1 code of the language that is assumed to be used in the submitted files. This will be used to guess the right 8-bit-encoding.
        maxSubmissionUnpackSizeKib - maximum KiB allowed for unzipped submission
        scoreMax - the target maximum score. If not null, the resulting assignment will be scaled to that target score.
        scorePrecision - number of decimal digits of scaled scores.
        debugSwitches - input data for debug switches
        resultSpec - input data for result specification
        tmpdir - must point to an existing path that can be used to create temporary files.
        Returns:
        A request of the specified type
        Throws:
        IllegalArgumentException
        ResourceDBLockedException
        IOException
        javax.xml.bind.JAXBException
      • generateGrajaMultiRequestTOFromTaskZipList

        public static RequestTO generateGrajaMultiRequestTOFromTaskZipList​(Variant variant,
                                                                           String pathToSubmissionZip,
                                                                           String expectedRootFolderInSubmissionZip,
                                                                           ArrayList<Map.Entry<String,​String>> pathsToTaskZips,
                                                                           String submissionNaturalLanguage,
                                                                           Integer maxSubmissionUnpackSizeKib,
                                                                           ArrayList<BigDecimal> scoreMaxList,
                                                                           Integer scorePrecision,
                                                                           DebugSwitchesTO debugSwitches,
                                                                           ResultSpecTO resultSpec,
                                                                           Path tmpdir)
                                                                    throws IllegalArgumentException,
                                                                           IOException,
                                                                           javax.xml.bind.JAXBException

        This method creates an instance of FrontendGrajaMultiRequestTO from a collection of assignments and a submission. The resulting object can be used as input to Graja for grading.

        Parameters:
        variant - must be one of { Variant.FRONTEND_GRAJA_MULTI_PLAINOLD, Variant.FRONTEND_GRAJA_MULTI_PROFORMA } and specifies, which request type is generated.
        pathToSubmissionZip - input file for the student submission
        expectedRootFolderInSubmissionZip - denotes the expected root folder in the submission
        pathsToTaskZips - input files for the assignment in proforma task.zip format. Every entry is a pair of an assignment key and an assignment. The key serves as an expected directory name inside the submission zip file.
        submissionNaturalLanguage - ISO-639-1 code of the language that is assumed to be used in the submitted files. This will be used to guess the right 8-bit-encoding.
        maxSubmissionUnpackSizeKib - maximum KiB allowed for unzipped submission
        scoreMax - the target maximum score (one for each task). If not null, the resulting assignments will be scaled to that target score.
        scorePrecision - number of decimal digits of scaled scores.
        debugSwitches - input data for debug switches
        resultSpec - input data for result specification
        tmpdir - must point to an existing path that can be used to create temporary files.
        Returns:
        A request of the specified variant
        Throws:
        IllegalArgumentException
        IOException
        javax.xml.bind.JAXBException
      • extractTaskZip1stPhase

        public static TaskZipExtracted extractTaskZip1stPhase​(String pathToTaskZip,
                                                              Path workspace)
                                                       throws IllegalArgumentException,
                                                              IOException,
                                                              javax.xml.bind.JAXBException
        Performs the first phase including: unzip, create necessary directories, read and unmarshal tpl file (if any). On success the following data of the result object is included: unzipOk=true, exception=null, all path* are set, all tpl* are set, taskXmlFilename is set, task=null. On error, instead an exception is thrown.
        Throws:
        IllegalArgumentException
        IOException
        javax.xml.bind.JAXBException
      • extractTaskZip1stPhaseReturnException

        public static TaskZipExtracted extractTaskZip1stPhaseReturnException​(String pathToTaskZip,
                                                                             Path workspace)
        Performs the first phase including: unzip, create necessary directories, read and unmarshal tpl file (if any). On success the following data of the result object is included: unzipOk=true, exception=null, all path* are set, all tpl* are set, taskXmlFilename is set, task=null. On error, exception is set (!=null).
      • extractTaskZip2ndPhaseReturnException

        public static TaskZipExtracted extractTaskZip2ndPhaseReturnException​(TaskZipExtracted tzeIncomplete,
                                                                             BigDecimal scoreMax,
                                                                             Integer scorePrecision)
        Parameters:
        tzeIncomplete - must include the following data: unzip=true, exception=null, all path* are set, all tpl* are set, taskXmlFilename is set, task=null.
      • readTaskXml

        public static Task readTaskXml​(Path pathToTaskXml)
                                throws javax.xml.bind.JAXBException,
                                       IOException
        Throws:
        javax.xml.bind.JAXBException
        IOException
      • getTestByTestType

        public static Test getTestByTestType​(List<Test> tests,
                                             String testType)