Examples of StudentReport


Examples of com.darkhonor.rage.model.StudentReport

            for (int i = 0; i < sectionReport.getStudentReports().size(); i++)
            {
                File studentResponseFile;
                FileOutputStream responseOutputStream = null;
                PrintWriter responseWriter = null;
                StudentReport sReport = sectionReport.getStudentReports().get(i);
                if (saveResponses)
                {
                    studentResponseFile = new File(responseDirectory,
                            sReport.getStudent().getWebID() + ".html");
                    try
                    {
                        LOGGER.debug("Creating student report file with headers");
                        studentResponseFile.createNewFile();
                        responseOutputStream = new FileOutputStream(studentResponseFile,
                                false);
                        responseWriter = new PrintWriter(responseOutputStream, true);
                        responseWriter.println("<html>\n<head>");
                        responseWriter.println("<title>CourseGrader Student Report"
                                + "</title>\n</head>\n<body>");
                        responseWriter.println("<h1><center><u>CourseGrader Student "
                                + "Report</u></center></h1>\n");
                        responseWriter.println("<p><a href=\"../"
                                + sReport.getSection().getName()
                                + ".html\">Back</a></p>");
                        responseWriter.println("<p><b>Student</b>: "
                                + sReport.getStudent().getLastName() + ", "
                                + sReport.getStudent().getFirstName() + "</p>");
                        LOGGER.debug("File created with headers.");
                    } catch (IOException ex)
                    {
                        LOGGER.warn("Problem creating response file for student: "
                                + sReport.getStudent().getLastName() + ", "
                                + sReport.getStudent().getFirstName());
                        LOGGER.warn(ex.getLocalizedMessage());
                        saveResponses = false;
                    }
                }
                BigDecimal overallScore = new BigDecimal("0");
                // Print student name
                reportWriter.print("\t\t<tr><td><a href=\"responses/"
                        + sReport.getStudent().getWebID() + ".html\">"
                        + sReport.getStudent().getLastName()
                        + ", " + sReport.getStudent().getFirstName() + "</a></td>");
                // Print results to each question
                for (int j = 0; j < sReport.getResults().size(); j++)
                {
                    int questionResult = sReport.getResults().get(j).getScore().compareTo(sReport.getResults().get(j).getValue());
                    boolean completeMiss = sReport.getResults().get(j).getScore().compareTo(BigDecimal.ZERO) == 0;
                    if (questionResult == 0)
                    {
                        reportWriter.print("<td>");
                    } else if (completeMiss)
                    {
                        reportWriter.print("<td bgcolor=\"Red\" style=\"font-weight:bold;\">");
                    } else
                    {
                        reportWriter.print("<td bgcolor=\"Yellow\">");
                    }
                    reportWriter.print(sReport.getResults().get(j).getScore()
                            + "</td>");
                    overallScore =
                            overallScore.add(sReport.getResults().get(j).getScore());
                    if (saveResponses)
                    {
                        responseWriter.println("<p><b>Question: "
                                + sReport.getResults().get(j).getQuestion().getName()
                                + "<br />\n<b>Result: "
                                + sReport.getResults().get(j).getScore().toPlainString()
                                + "</p>");
                        responseWriter.println("<table border='1'>\n<tr>\n<th>Test Case</th>");
                        responseWriter.println("<th>Inputs</th><th>Expected Output</th>");
                        responseWriter.println("<th>Actual Output</th>\n</tr>\n");
                        Question question = sReport.getResults().get(j).getQuestion();
                        // Loop through all the Test Cases
                        for (int k = 0; k < question.getTestCases().size(); k++)
                        {
                            int testCaseIndex = k + 1;
                            responseWriter.println("<tr>\n<td>" + testCaseIndex
                                    + "</td>");
                            responseWriter.println("<td><center>");
                            TestCase testCase = question.getTestCases().get(k);
                            for (int m = 0; m < testCase.getInputs().size(); m++)
                            {
                                responseWriter.println(testCase.getInputs().get(m)
                                        + "<br />");
                            }
                            responseWriter.println("</center></td>");
                            responseWriter.println("<td><center>");
                            for (int m = 0; m < testCase.getOutputs().size(); m++)
                            {
                                responseWriter.println(testCase.getOutputs().get(m)
                                        + "<br />");
                            }
                            responseWriter.println("</center></td>");
                            responseWriter.println("<td><center>");
                            Response response;
                            try
                            {
                                response =
                                        sReport.getResults().get(j).getResponses().get(k);
                            } catch (Exception ex1)
                            {
                                response = null;
                            }
                            if (response != null && response.getAnswers().size() > 0)
                            {
                                for (int m = 0; m < response.getAnswers().size(); m++)
                                {
                                    responseWriter.println(response.getAnswers().get(m)
                                            + "<br />");
                                }
                            } else
                            {
                                responseWriter.println(" ");
                            }
                            responseWriter.println("</center></td>\n</tr>\n");
                        }
                        responseWriter.println("</table>\n");
                    }
                }
                // Print overall score for student and close the row
                reportWriter.println("<td>" + overallScore.toPlainString() + "</td></tr>");
                // Close the Student Response Report if it's open
                if (saveResponses)
                {
                    responseWriter.println("<p><a href=\"../"
                            + sReport.getSection().getName()
                            + ".html\">Back</a></p>");
                    responseWriter.println("</body>\n</html>");
                    responseWriter.close();
                    try
                    {
View Full Code Here

Examples of com.darkhonor.rage.model.StudentReport

                        // No else needed since if there are no multiple versions,
                        // gevent is already set above

                        for (Student studentIter : sectionIter.getStudents())
                        {
                            StudentReport studentReport = new StudentReport(studentIter,
                                    sectionIter);
                            String newPath = new String();
                            newPath = tempPath.concat(File.separator);
                            newPath = newPath.concat(sectionIter.getName());
                            newPath = newPath.concat(File.separator);
                            newPath = newPath.concat(studentIter.getWebID());
                            LOGGER.debug("Path to grade: " + newPath);
                            statusMessageLabel.setText("Grading: "
                                    + studentIter.getLastName()
                                    + ", " + studentIter.getFirstName());
                            LOGGER.info("Grading: " + studentIter.getLastName()
                                    + ", " + studentIter.getFirstName());
                            try
                            {
                                File directory = new File(newPath);
                                LOGGER.debug("Grading path: " + directory.getCanonicalPath());
                                launcher.directory(directory);
                                Runnable r = new GraderThread(node, launcher, directory,
                                        gevent, studentReport, type);
                                grader_thread = new Thread(r);
                                grader_thread.start();
                                while (grader_thread.isAlive())
                                {
                                }
                                // After grader is complete, add StudentReport to
                                // SectionReport
                                sectionReport.addStudentReport(studentReport);
                            } catch (IOException ex)
                            {
                                LOGGER.error("IO Exception: " + ex.getLocalizedMessage());
                            }
                        }
                        sectionReport.sortStudentReports();
                        RageLib.printSectionReport(outputFile, sectionReport);
                    }
                }
            } /**
             * Grade a single instructor, but All Sections is selected
             */
            else if ((cboInstructor.getSelectedIndex() > 0)
                    && (cboSection.getSelectedIndex() == 0)
                    && (cboStudent.getSelectedIndex() < 0))
            {
                LOGGER.debug("Grading all sections for Instructor "
                        + selectedInstructor.getLastName() + ", "
                        + selectedInstructor.getFirstName());

                // Pull the Instructor from the Data Source to be able to grab Sections
                InstructorDAO instructorDAO = new InstructorDAO(emf.createEntityManager());
                Instructor instructor = instructorDAO.find(selectedInstructor.getId());
                for (Section sectionIter : instructor.getSections())
                {
                    sectionReport = new SectionReport(course.getName(),
                            instructor, sectionIter.getName(),
                            selectedAssignment.getAssignment());
                    try
                    {
                        outputFile = new File(path + File.separator
                                + sectionIter.getName() + File.separator
                                + sectionIter.getName() + dateStampString + ".html");
                        LOGGER.debug("Output File: " + outputFile.getCanonicalPath());
                        outputFile.createNewFile();
                    } catch (IOException ex)
                    {
                        LOGGER.error("IOException caught: "
                                + ex.getLocalizedMessage());
                    }
                    /**
                     * If a section is selected and there are multiple versions,
                     * pull the right one for the gevent variable...can we
                     * search the list and return the right one?
                     */
                    if (multVersions)
                    {
                        /**
                         * If there are multiple versions of the GradedEvent,
                         * pull only the one for this section
                         */
                        gevent = RageLib.getGradedEventFromSectionName(gevents,
                                sectionIter.getName());
                    }
                    // No else needed since if there are no multiple versions,
                    // gevent is already set above

                    for (Student studentIter : sectionIter.getStudents())
                    {
//                        StudentReport studentReport = new StudentReport(studentIter);
                        StudentReport studentReport = new StudentReport(studentIter,
                                sectionIter);
                        String newPath = new String();
                        newPath = path.concat(File.separator);
                        newPath = newPath.concat(sectionIter.getName());
                        newPath = newPath.concat(File.separator);
                        newPath = newPath.concat(studentIter.getWebID());
                        LOGGER.debug("Path to grade: " + newPath);
                        statusMessageLabel.setText("Grading: " + studentIter.getLastName()
                                + ", " + studentIter.getFirstName());
                        LOGGER.info("Grading: " + studentIter.getLastName()
                                + ", " + studentIter.getFirstName());
                        File directory = new File(newPath);
                        launcher.directory(directory);
                        Runnable r = new GraderThread(node, launcher, directory,
                                gevent, studentReport, type);
                        grader_thread = new Thread(r);
                        grader_thread.start();
                        while (grader_thread.isAlive())
                        {
                        }
                        sectionReport.addStudentReport(studentReport);
                    }
                    sectionReport.sortStudentReports();
                    RageLib.printSectionReport(outputFile, sectionReport);
                }
                // Close the connection to the Data Source
                instructorDAO.closeConnection();
            } /**
             * Grade all students in a single section
             */
            else if ((cboStudent.getSelectedIndex() == 0)
                    && (cboSection.getSelectedIndex() > 0))
            {
                LOGGER.debug("Grading all students in section "
                        + selectedSection.getName());

                // Pull the Section from the Data Source to get the full list of
                // Students
                SectionDAO sectionDAO = new SectionDAO(emf.createEntityManager());
                Section section = sectionDAO.find(selectedSection.getId());
                sectionReport = new SectionReport(course.getName(), selectedInstructor,
                        section.getName(), selectedAssignment.getAssignment());
                try
                {
                    outputFile = new File(path + File.separator
                            + selectedSection.getName() + dateStampString + ".html");
                    LOGGER.debug("Output File: " + outputFile.getCanonicalPath());
                    outputFile.createNewFile();
                    /**
                     * If a section is selected and there are multiple versions,
                     * pull the right one for the gevent variable...can we
                     * search the list and return the right one?
                     */
                    if (multVersions)
                    {
                        /**
                         * If there are multiple versions of the GradedEvent,
                         * pull only the one for this section
                         */
                        gevent = RageLib.getGradedEventFromSectionName(gevents,
                                selectedSection.getName());
                    }
                    // No else needed since if there are no multiple versions,
                    // gevent is already set above

                } catch (FileNotFoundException ex)
                {
                    // Do nothing...the file should be created if it's not there
                } catch (IOException ex)
                {
                    LOGGER.error("ERROR: IOException caught.");
                    LOGGER.error(ex.getLocalizedMessage());
                }
                for (Student studentIter : section.getStudents())
                {
                    StudentReport studentReport = new StudentReport(studentIter, section);
//                    StudentReport studentReport = new StudentReport(studentIter);
                    String newPath = new String();
                    newPath = path.concat(File.separator);
                    newPath = newPath.concat(studentIter.getWebID());
                    LOGGER.debug("Path to grade: " + newPath);
                    statusMessageLabel.setText("Grading: " + studentIter.getLastName()
                            + ", " + studentIter.getFirstName());
                    LOGGER.info("Grading: " + studentIter.getLastName() + ", "
                            + studentIter.getFirstName());
                    File directory = new File(newPath);
                    launcher.directory(directory);
                    Runnable r = new GraderThread(node, launcher, directory, gevent,
                            studentReport, type);
                    grader_thread = new Thread(r);
                    grader_thread.start();

                    while (grader_thread.isAlive())
                    {
                    }
                    sectionReport.addStudentReport(studentReport);
                }
                sectionReport.sortStudentReports();
                RageLib.printSectionReport(outputFile, sectionReport);

                // Close the connection to the Data Source
                sectionDAO.closeConnection();
            } /**
             * Just grade a single student
             */
            else
            {
                LOGGER.debug("Grading a single Student:" + selectedStudent.getWebID());
                LOGGER.debug("Path to grade: " + path);
                File directory = null;
                try
                {
                    directory = new File(path);
                    LOGGER.debug("Creating Output File");
                    outputFile = new File(directory.getParent()
                            + File.separator + selectedStudent.getWebID()
                            + dateStampString + ".html");
                    LOGGER.debug("Output File: " + outputFile.getCanonicalPath());
                    outputFile.createNewFile();
                    /**
                     * If a section is selected and there are multiple versions,
                     * pull the right one for the gevent variable...can we
                     * search the list and return the right one?
                     */
                    if (multVersions)
                    {
                        /**
                         * If there are multiple versions of the GradedEvent,
                         * pull only the one for this section
                         */
                        gevent = RageLib.getGradedEventFromSectionName(gevents,
                                selectedSection.getName());
                    }
                    // No else needed since if there are no multiple versions,
                    // gevent is already set above
                } catch (FileNotFoundException ex)
                {
                    // Do nothing...the file should be created if it's not there
                } catch (IOException ex)
                {
                    LOGGER.error("IOException caught.");
                    LOGGER.error(ex.getLocalizedMessage());
                } catch (NullPointerException ex)
                {
                    LOGGER.error("Null Pointer Exception: " + ex.getLocalizedMessage());
                } catch (Exception ex)
                {
                    LOGGER.error("Exception caught: " + ex.getLocalizedMessage());
                }
                LOGGER.info("Grading: " + selectedStudent.getLastName() + ", "
                        + selectedStudent.getFirstName());
                try
                {
                    LOGGER.debug("Grading Directory: " + directory.getCanonicalPath());
                    launcher.directory(directory);
                    StudentReport studentReport = new StudentReport(selectedStudent,
                            selectedSection);
                    Runnable r = new GraderThread(node, launcher, directory, gevent,
                            studentReport, type);
                    grader_thread = new Thread(r);
                    grader_thread.start();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.