Package com.darkhonor.rage.model

Examples of com.darkhonor.rage.model.Instructor


    {
        System.out.println("deleteNullName");
        Course course = new Course("CS364");
        course.setId(2L);

        Instructor instructor = new Instructor("Sarah", "O'Reilly",
                "Sarah.OReilly");
        instructor.setId(6L);
        instructor.setDomainAccount("Sarah.OReilly");

        Section section = new Section();
        section.setId(4L);
        section.setCourse(course);
        section.setInstructor(instructor);
View Full Code Here


    {
        System.out.println("deleteEntityNotExist");
        Course course = new Course("CS364");
        course.setId(2L);

        Instructor instructor = new Instructor("Sarah", "O'Reilly",
                "Sarah.OReilly");
        instructor.setId(6L);
        instructor.setDomainAccount("Sarah.OReilly");

        Section section = new Section("T1A");
        section.setCourse(course);
        section.setId(5L);
        section.setInstructor(instructor);
View Full Code Here

                tx.commit();
                LOGGER.debug("(clearCourse) # Students in Section (Post): "
                        + dbSection.getStudents().size());

                // Find the Instructor for the Section in the Database
                Instructor dbInstructor = entityManager.find(Instructor.class,
                        dbSection.getInstructor().getId());
                if (dbInstructor == null)
                {
                    LOGGER.error("(clearCourse) Section " + dbSection
                            + " Instructor not found in DB");
View Full Code Here

            if (course.getCourseDirector() != null)
            {
                LOGGER.debug("- Course Director not null");
                LOGGER.debug("- New Course Director: "
                        + course.getCourseDirector().getDomainAccount());
                Instructor dbCourseDir = null;
                if (course.getCourseDirector().getId() != null)
                {
                    dbCourseDir = entityManager.find(Instructor.class,
                            course.getCourseDirector().getId());
                } else  // Course Director doesn't have an Id...search by Domain Acct
                {
                    CriteriaQuery<Instructor> cq = cb.createQuery(Instructor.class);
                    Root<Instructor> instructorRoot = cq.from(Instructor.class);
                    cq.where(cb.equal(instructorRoot.get("domainAccount"),
                            course.getCourseDirector().getDomainAccount()));
                    TypedQuery<Instructor> instructorQuery = entityManager.createQuery(cq);
                    try
                    {
                        dbCourseDir = instructorQuery.getSingleResult();
                    } catch (NoResultException ex)
                    {
                        dbCourseDir = null;
                    }
                }
                if (dbCourseDir != null)
                {
                    LOGGER.debug("- New Course Director exists in Database");
                    dbCourse.setCourseDirector(dbCourseDir);
                } else
                {
                    LOGGER.debug("- New Course Director doesn't exist in Database");
                    dbCourse.setCourseDirector(course.getCourseDirector());
                }
            } else
            {
                LOGGER.debug("- Course Director is null");
            }
            // Update the list of associated Instructors
            if (course.getInstructors().isEmpty())
            {
                LOGGER.debug("- There are no Instructors associated with the course");
                dbCourse.clearInstructors();
            } else
            {
                LOGGER.debug("- Need to update instructors to match.  Clearing old");
                dbCourse.clearInstructors();
                LOGGER.debug("- Database instructors cleared");
                LOGGER.debug("- # of Instructors in new Course: "
                        + course.getInstructors().size());
                for (int i = 0; i < course.getInstructors().size(); i++)
                {
                    LOGGER.debug("- Looping through Instructors.  Instance " + i);
                    Instructor instructor = null;
                    if (course.getInstructor(i).getId() != null)
                    {
                        LOGGER.debug("- Instructor has id = "
                                + course.getInstructor(i).getId());
                        instructor = entityManager.find(Instructor.class,
                                course.getInstructor(i).getId());
                    } else
                    {
                        LOGGER.debug("- Instructor doesn't have an Id.  Domain Acct: "
                                + course.getInstructor(i).getDomainAccount());
                        CriteriaQuery<Instructor> cq = cb.createQuery(Instructor.class);
                        Root<Instructor> instructorRoot = cq.from(Instructor.class);
                        cq.where(cb.equal(instructorRoot.get("domainAccount"),
                                course.getInstructor(i).getDomainAccount()));
                        TypedQuery<Instructor> instructorQuery =
                                entityManager.createQuery(cq);
                        try
                        {
                            instructor = instructorQuery.getSingleResult();
                        } catch (NoResultException ex)
                        {
                            instructor = null;
                        }
                    }
                    if (instructor != null)
                    {
                        LOGGER.debug("- Adding existing instructor: "
                                + instructor.getDomainAccount());
                        dbCourse.addInstructor(instructor);
                    } else
                    {
                        LOGGER.debug("- Adding non-existent instructor: "
                                + course.getInstructor(i).getDomainAccount());
View Full Code Here

            }
            LOGGER.debug(count + " assignments found for " + c.getName());

            // Add a new Instructor so that all instructors can be graded in
            // course
            instructorComboBoxModel.add(new Instructor("All", "000 - Instructors",
                    "All.Instructors"));
            count = 0;
            for (Instructor i : c.getInstructors())
            {
                instructorComboBoxModel.add(i);
View Full Code Here

        cboSectActive = false;
        sectionComboBoxModel.removeAll();
        studentComboBoxModel.removeAll();

        LOGGER.debug("Getting selected Instructor");
        Instructor selectedInstructor = (Instructor) cboInstructor.getSelectedItem();

        LOGGER.debug("Getting selected Course");
        Course selectedCourse = (Course) cboCourse.getSelectedItem();
        LOGGER.debug("Creating Section query");
        SectionDAO sectionDAO = new SectionDAO(emf.createEntityManager());
View Full Code Here

                multVersions = true;
            }

            String path = this.buildBasePath();

            Instructor selectedInstructor = null;
            Section selectedSection = null;
            Student selectedStudent = null;
            if (cboInstructor.getSelectedIndex() != -1)
            {
                selectedInstructor = (Instructor) cboInstructor.getSelectedItem();
            }
            if (cboSection.getSelectedIndex() != -1)
            {
                selectedSection = (Section) cboSection.getSelectedItem();
            }
            if (cboStudent.getSelectedIndex() != -1)
            {
                selectedStudent = (Student) cboStudent.getSelectedItem();
            }

//            // Derive the grading path from the selected comboboxes
//            String path = node.get("RootDir", "");
//            path = path.concat(File.separator);
//            path = path.concat(selectedCourse.getName());
//            path = path.concat(File.separator);
//            path = path.concat(selectedAssignment.getAssignment());

            /**
             * Get the selected Instructor and Section objects.  If either is
             * not selected, getSelectedIndex will return -1 and the object will
             * stay null.
             */
//            Instructor selectedInstructor = null;
//            Section selectedSection = null;
//            if (cboInstructor.getSelectedIndex() != -1)
//            {
//                selectedInstructor = (Instructor) cboInstructor.getSelectedItem();
//            }
//            if (cboSection.getSelectedIndex() != -1)
//            {
//                selectedSection = (Section) cboSection.getSelectedItem();
//            }
//
//            // Add the Instructor if one is selected
//            if (cboInstructor.getSelectedIndex() > 0)
//            {
//                path = path.concat(File.separator);
//
//                //InstructorDAO instructorDAO = new InstructorDAO(emf.createEntityManager());
//                //instructor = instructorDAO.find(selectedInstructor.getId());
//                path = path.concat(selectedInstructor.getWebID());
//
//                // Add the section if one is selected
//                if (cboSection.getSelectedIndex() > 0)
//                {
//                    //SectionDAO sectionDAO = new SectionDAO(emf.createEntityManager());
//                    //section = sectionDAO.find(selectedSection.getId());
//
//                    path = path.concat(File.separator);
//                    path = path.concat(selectedSection.getName());
//
//                    // Add the Student if one is selected
//                    if (cboStudent.getSelectedIndex() > 0)
//                    {
//                        path = path.concat(File.separator);
//                        name = cboStudent.getSelectedItem().toString().split(",");
//                        query = em.createQuery("SELECT p FROM Person p WHERE "
//                                + "p.firstName = :fname AND p.lastName = :lname");
//                        query.setParameter("fname", name[1].trim());
//                        query.setParameter("lname", name[0].trim());
//                        student = (Student) query.getSingleResult();
//                        path = path.concat(student.getWebID());
//                    }
//                }
//            }
            // Build the thread environment regardless of whether doing student or
            ProcessBuilder launcher = new ProcessBuilder();
            Map<String, String> environment = launcher.environment();
            launcher.redirectErrorStream(true);
            File outputFile = null;
            SectionReport sectionReport = null;
            Date dateStamp = new Date();
            String dateStampString = String.format("%tY%tm%td%tH%tM", dateStamp);

            /**
             * Grade All Instructors.  Section and Student are not selected
             */
            if ((cboAssignment.getSelectedIndex() >= 0)
                    && (cboInstructor.getSelectedIndex() == 0)
                    && (cboSection.getSelectedIndex() < 0)
                    && (cboStudent.getSelectedIndex() < 0))
            {
                LOGGER.debug("Grading All Instructors.  Section and Student are "
                        + "not selected");
                for (Instructor insIter : course.getInstructors())
                {
                    String tempPath = new String();
                    tempPath = path.concat(File.separator);
                    tempPath = tempPath.concat(insIter.getWebID());
                    for (Section sectionIter : insIter.getSections())
                    {
                        sectionReport = new SectionReport(course.getName(),
                                insIter, sectionIter.getName(),
                                selectedAssignment.getAssignment());
                        try
                        {
                            outputFile = new File(tempPath + File.separator
                                    + sectionIter.getName() + File.separator
                                    + sectionIter.getName() + dateStampString + ".html");
                            LOGGER.debug("Output File: " + outputFile.getCanonicalPath());
                            outputFile.createNewFile();
                        } catch (IOException ex)
                        {
                            LOGGER.error("ERROR: IOException caught.");
                            LOGGER.error(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,
                                    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
View Full Code Here

            // TODO: Remove Query once StudentDAO is finished.  All others clear
            Query query;
            String[] name;
            Student student = null;
            Course course;
            Instructor instructor = null;
            Section section = null;
            int counter = 0;
            File rootDir;
            File[] files;

            CourseDAO courseDAO = new CourseDAO(emf.createEntityManager());
           
            Course selectedCourse = (Course) cboCourse.getSelectedItem();
            //course = em.find(Course.class, selectedCourse.getId());
            course = courseDAO.find(selectedCourse.getId());
            //query = em.createQuery("SELECT c FROM Course c WHERE c.name = :name");
            //query.setParameter("name", cboCourse.getSelectedItem().toString().trim());
            //course = (Course)query.getSingleResult();

//            query = em.createQuery("SELECT g FROM GradedEvent g WHERE g.course = " +
//                 ":course AND g.term = :term AND g.assignment = :assignment");
//            query.setParameter("course", course);
//            query.setParameter("term", node.get("Term", ""));
//            query.setParameter("assignment", cboAssignment.getSelectedItem()
//                .toString().trim());
//            List<GradedEvent> gevents = query.getResultList();
//           
//            // We don't care about versions...only what the event is so we can find
//            // the right directory
//            gevent = gevents.get(0);   // Get the first one

            // Derive the grading path from the selected comboboxes
            //String path = buildBasePath(instructor, section, student);
            String path = node.get("RootDir", "");
            path = path.concat(File.separator);
            path = path.concat(course.getName());
            path = path.concat(File.separator);
            path = path.concat((String) cboAssignment.getSelectedItem());

            Instructor selectedInstructor = null;
            Section selectedSection = null;
            if (cboInstructor.getSelectedIndex() != -1)
            {
                selectedInstructor = (Instructor) cboInstructor.getSelectedItem();
            }
            if (cboSection.getSelectedIndex() != -1)
            {
                selectedSection = (Section) cboSection.getSelectedItem();
            }
            // Add the Instructor if one is selected
            if (cboInstructor.getSelectedIndex() > 0)
            {
                path = path.concat(File.separator);
                //name = cboInstructor.getSelectedItem().toString().split(",");
                // Pull Instructor webid from database
                //query = em.createQuery("SELECT p FROM Person p WHERE p.firstName " +
                //        "= :fname AND p.lastName = :lname");
                //query.setParameter("fname", name[1].trim());
                //query.setParameter("lname", name[0].trim());
                // Don't need to check for non-existent since cboInstructor was populated
                // from the database...have bigger problems if instructor is not there now
                //ins = (Instructor)query.getSingleResult();
                InstructorDAO instructorDAO = new InstructorDAO(emf.createEntityManager());
                instructor = instructorDAO.find(selectedInstructor.getId());
                //instructor = em.find(Instructor.class, selectedInstructor.getId());
                path = path.concat(instructor.getWebID());

                // Add the section if one is selected
                if (cboSection.getSelectedIndex() > 0)
View Full Code Here

                    + userName);
            InstructorDAO instructorDAO = null;
            try
            {
                instructorDAO = new InstructorDAO(emf.createEntityManager());
                Instructor instructor =
                        instructorDAO.findInstructorByDomainAccount(userName);
                LOGGER.debug("(connectAction) Instructor found.");
                if (node.getBoolean("UsePassword", true))
                {
                    // TODO: Add Password option
                    // Prompt the user for a password and check the response with what
                    // is now stored in appUser.password.  If it's ok, move on.  Otherwise
                    // exit the program with an error message stating the user is not
                    // authorized.  Perhaps give them a couple of tries.
                }
                statusMessageLabel.setText("Welcome " + instructor.getFirstName()
                        + " " + instructor.getLastName());
                LOGGER.debug("(connectAction) Closing InstructorDAO connection");
                instructorDAO.closeConnection();
            } catch (NoResultException ex)
            {
                LOGGER.error("(connectAction) Instructor not found in the data "
View Full Code Here

            /**
             * Get the selected Instructor and Section objects.  If either is
             * not selected, getSelectedIndex will return -1 and the object will
             * stay null.
             */
            Instructor selectedInstructor = null;
            Section selectedSection = null;
            if (cboInstructor.getSelectedIndex() != -1)
            {
                selectedInstructor = (Instructor) cboInstructor.getSelectedItem();
            }
            if (cboSection.getSelectedIndex() != -1)
            {
                selectedSection = (Section) cboSection.getSelectedItem();
            }

            // Add the Instructor if one is selected
            if (selectedInstructor != null)
            {
                path = path.concat(File.separator);
                path = path.concat(selectedInstructor.getWebID());
                LOGGER.debug("Instructor Selected: " + selectedInstructor.getLastName()
                        + ", " + selectedInstructor.getFirstName());
                // Add the section if one is selected
                if (selectedSection != null)
                {
                    path = path.concat(File.separator);
                    path = path.concat(selectedSection.getName());
View Full Code Here

TOP

Related Classes of com.darkhonor.rage.model.Instructor

Copyright © 2018 www.massapicom. 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.