Package com.darkhonor.rage.model

Examples of com.darkhonor.rage.model.Question


            // We were able to pull the GradedEvent object from the DB...now
            // we need to pull it's list of questions and then remove the selected
            // one from it's list and re-persist
            if (gevent != null)
            {
                Question quest = (Question) lstGradedEventQuestions.getSelectedValue();
                if (gevent.removeQuestion(quest))
                {
                    JOptionPane.showMessageDialog(this, "Question " + quest.getName()
                            + " removed from Graded Event " + gevent.getAssignment(),
                            "Success", JOptionPane.INFORMATION_MESSAGE);
                    modGradedEventQuestions.remove(lstGradedEventQuestions.getSelectedIndex());
                    LOGGER.info("Question " + quest.getName() + " removed from "
                            + "Graded Event.");
                } else
                {
                    JOptionPane.showMessageDialog(this, "ERROR: Question not removed",
                            "Error", JOptionPane.ERROR_MESSAGE);
View Full Code Here


       
        List<TestCase> testCases = new ArrayList<TestCase>();
        testCases.add(testCase3);
        testCases.add(testCase4);
       
        Question question1 = createPersistedQuestion(1L, category1, "Sequencer",
                "Test Question 1", true, false, testCases);
        Question question2 = createPersistedQuestion(2L, category2, "Looper",
                "Test Question 2", false, false, testCases);
        Question question3 = createPersistedQuestion(3L, category2, "Jumper",
                "Test Question 3", true, true, testCases);

        GradedEvent gradedEvent1 = createPersistedGradedEvent(5L, "Summer 2010", course1,
                "PEX1", false, "ALL");
        gradedEvent1 = addQuestionToGradedEvent(gradedEvent1, question1);
View Full Code Here

    private Question createPersistedQuestion(Long id, Category category, String name,
            String description, boolean verbatim, boolean orderedOutput,
            List<TestCase> testCases)
    {
        EntityManager em = emf.createEntityManager();
        Question question = null;

        try
        {
            question = findQuestionByName(name);
            LOGGER.warn("Question already exists: " + question);
        } catch (NoResultException ex)
        {
            question = new Question(name, category, description);
            question.setId(id);
            question.setVerbatim(verbatim);
            question.setOrderedOutput(orderedOutput);

            for (int i = 0; i < testCases.size(); i++)
            {
                TestCase testCase = em.find(TestCase.class, testCases.get(i).getId());
                question.addTestCase(testCase);
            }
           
            EntityTransaction tx = em.getTransaction();
            tx.begin();
            em.persist(question);
            tx.commit();
            LOGGER.debug("Question Id (post-persist): " + question.getId());
        }
        em.close();
        return question;
    }
View Full Code Here

                // Fill the QuestionListModel on the page
                modQuestionList.removeAll();
                int actual = 0;
                for (int i = 0; i < result.size(); i++)
                {
                    Question question = result.get(i);
                    LOGGER.debug("Adding Question: " + question.getName());
                    modQuestionList.add(question);
                    actual++;
                }
                LOGGER.debug("Added " + actual + " Questions");
                okButton.setEnabled(true);
View Full Code Here

            List<Question> questions = lstQuestions.getSelectedValuesList();
            LOGGER.debug("Adding " + questions.size() + " Questions to GradedEvent");
            int actual = 0;
            for (int i = 0; i < questions.size(); i++)
            {
                Question question = questions.get(i);
                try
                {
                    // TODO: RAGE-24 - Migrate to the QuestionDAO class
                    question = em.find(Question.class, question.getId());
                    gradedEvent.addQuestion(question);
                    actual++;
                } catch (IllegalArgumentException ex)
                {
                    LOGGER.error("Exception: " + ex.getLocalizedMessage());
View Full Code Here

                count = 0;
                questionResult = questionQuery.getResultList();
                modQuestionList.removeAll();
                for (int i = 0; i < questionResult.size(); i++)
                {
                    Question question = (Question) questionResult.get(i);
                    modQuestionList.add(question);
                    count++;
                }
                LOGGER.debug("Added " + count + " questions");
            } catch (NoResultException ex)
View Full Code Here

                int count = 0;
                for (int i = 0; i < objects.size(); i++)
                {
                    // TODO: RAGE-24 - Migrate to the QuestionDAO class. 
                    // Action: Update the Question in the current Persistence Context
                    Question question = objects.get(i);
                    try
                    {
                        question = em.merge(question);
                    } catch (Exception ex)
                    {
View Full Code Here

                    "WARNING", JOptionPane.WARNING_MESSAGE);
            LOGGER.warn("Quesiton Not Selected");
        } else
        {
            EntityManager em = emf.createEntityManager();
            Question quest = (Question) lstQuestions.getSelectedValue();
            // TODO: RAGE-24 - Migrate to the QuestionDAO class
            Question question = em.find(Question.class, quest.getId());

            JOptionPane.showMessageDialog(null, "You must select a Reference "
                    + "Program and Destination File before reloading this question to"
                    + " the database", "Warning", JOptionPane.WARNING_MESSAGE);

            List<TestCase> testCaseList = question.getTestCases();
            modTCList.removeAll();

            //Reset the total value of the testcases to zero before calculating
            //the new value.

            questionValue = questionValue.multiply(questionValue.ZERO);

            for (int i = 0; i < testCaseList.size(); i++)
            {

                modTCList.addTestCase(testCaseList.get(i));
                questionValue = questionValue.add(testCaseList.get(i).getValue());
            }
            //Check the question to see if we are expecting an ordered output
            // If we are, turn on the Ordered Output Checkbox

            if (question.getOrderedOutput() == true)
            {
                chkOrdered.setSelected(true);
            }

            //Check the question to see if we are expecting verbatim output
            //If so, turn on the Verbatium checkbox

            if (question.getVerbatim() == true)
            {
                chkVerbatim.setSelected(true);
            }

            //Set the description field with the description of the question
            txtDescription.setText(question.getDescription());
            //Use a tempory category object to grab the name of the category as
            // a string and set the category text box to that catgory name
            Category tempCategory = question.getCategory();
            txtCategory.setText(tempCategory.getName());
            txtValue.setText(questionValue.toPlainString());
            em.close();
        }
View Full Code Here

        gradedEvent.setDueDate("19 May 2010");
        gradedEvent.setPartialCredit(false);
        gradedEvent.setTerm("Fall 2010");
        gradedEvent.setVersion("ALL");

        Question newQuestion = new Question(42L, "TestQ", category,
                "This is a new test question");

        assertEquals(1, gradedEvent.getQuestions().size());
        gradedEvent.addQuestion(newQuestion);
View Full Code Here

    {
        System.out.println("updateAddExistingQuestion");
        assertTrue(instance.isOpen());

        QuestionDAO questionDAO = new QuestionDAO(testDb.getConnection());
        Question question = questionDAO.find(2L);


        GradedEvent gradedEvent = instance.find(new Long(3L));

        assertEquals(1, gradedEvent.getQuestions().size());
View Full Code Here

TOP

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

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.