Package com.vst.model

Examples of com.vst.model.Question


        List questions;
        if (request.getParameter("isSearched") == null) {
            questions = questionManager.getQuestions(null);
        } else {
            Question question = new Question();
            Integer constructionTypeId = (Integer) Integer.parseInt(request.getParameter("constructionTypeId"));
            Integer questionTypeId = (Integer) Integer.parseInt(request.getParameter("questionTypeId"));
            question.setConstructionTypeId(constructionTypeId);
            if (questionTypeId.equals(new Integer(1))) {
                question.setQuestionTypeId(new Integer(1));
            }
            if (questionTypeId.equals(new Integer(2))) {
                question.setQuestionTypeId(new Integer(1));
                question.setForObjectStructure(true);
            }

            if (questionTypeId.equals(new Integer(3))) {
                question.setQuestionTypeId(new Integer(0));
            }
            questions = questionManager.findQuestions(question);
            request.setAttribute("currentConstructionTypeId", constructionTypeId);
            request.setAttribute("currentQuestionTypeId", questionTypeId);
        }
View Full Code Here


            }

            List questionList = hint.getQuestions();
            List baseQuestionList = new ArrayList();
            for (int i = 0; i < questionList.size(); i++) {
                Question question = (Question) questionList.get(i);
                baseQuestionList.add(questionManager.getQuestion(question.getQuestionId().toString()));

            }
            hint.setQuestions(baseQuestionList);
            hintManager.saveHint(hint);
View Full Code Here

                                              Object command,
                                              BindException errors)
            throws Exception {
        Hint hint = (Hint) command;
        if (request.getParameter("addQuestion") != null) {
            hint.getQuestions().add(new Question());
            return new ModelAndView("hintForm", "hint", hint);
        }
        if (request.getParameter("deleteQuestion") != null) {
            hint.getQuestions().remove(hint.getQuestionNumber());
            return new ModelAndView("hintForm", "hint", hint);
View Full Code Here

        request = newGet("/editQuestion.html");
        request.addParameter("questionId", "1");

        mv = c.handleRequest(request, new MockHttpServletResponse());

        Question question = (Question) mv.getModel().get(c.getCommandName());
        assertNotNull(question);
        request = newPost("/editQuestion.html");
        super.objectToRequestParameters(question, request);

        // update the form's fields and add it back to the request
View Full Code Here

        request.setAttribute("questionTypeList", questionTypeManager.getQuestionTypes(null));
        request.setAttribute("documentTypeList", documentTypeManager.getDocumentTypes(null));

        if (!isFormSubmission(request)) {
            String questionId = request.getParameter("questionId");
            Question question = null;

            if (!StringUtils.isEmpty(questionId)) {
                question = questionManager.getQuestion(questionId);
                questionManager.evict(question);
                questionManager.setQuestionVisualType(question);
                questionManager.makeNotNull(question);
            } else {
                question = new Question();
            }
            if (request.getParameter("edited") != null) {
                request.setAttribute("addition", "?edited=1");
                question.setEdited(true);
            }
            question.setDocLocation(request.getParameter("docLocation"));

            return question;
        }
        return super.formBackingObject(request);
    }
View Full Code Here

            throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("entering 'onSubmit' method...");
        }

        Question question = (Question) command;
        boolean isNew = (question.getQuestionId() == null);
        Locale locale = request.getLocale();

        if (request.getParameter("delete") != null) {
            questionManager.removeQuestion(question.getQuestionId().toString());

            saveMessage(request, getText("question.deleted", locale));
        } else {
            Integer questionTypeId = question.getQuestionType().getQuestionTypeId();
            if (!questionTypeId.equals(new Integer(-1))) {
                question.setQuestionType(questionTypeManager.getQuestionType(questionTypeId.toString()));
            }

            Integer documentTypeId = question.getDocumentType().getDocumentTypeId();
            if (!documentTypeId.equals(new Integer(-1))) {
                question.setDocumentType(documentTypeManager.getDocumentType(documentTypeId.toString()));
            } else {
                question.setDocumentType(null);
            }


            if (question.getQuestionType().getQuestionTypeId().equals(new Integer(0))) {
                List constructionTypeList = new ArrayList();
                List constructionTypeListFromForm = question.getConstructionTypes();
                for (int i = 0; i < constructionTypeListFromForm.size(); i++) {
                    ConstructionType constructionType = (ConstructionType) constructionTypeListFromForm.get(i);
                    constructionTypeList.add(constructionTypeManager.getConstructionType(constructionType.getConstructionTypeId().toString()));
                }
                question.setConstructionTypes(constructionTypeList);
            }


            List answerListFromForm = question.getAnswers();
            for (int i = 0; i < answerListFromForm.size(); i++) {
                Answer answer = (Answer) answerListFromForm.get(i);
                answer.setQuestion(null);
                answerManager.saveAnswer(answer);
            }
            questionManager.saveQuestion(question);
            for (int i = 0; i < answerListFromForm.size(); i++) {
                Answer answer = (Answer) answerListFromForm.get(i);
                answer.setQuestion(question);
                answerManager.saveAnswer(answer);
            }
            String key = (isNew) ? "question.added" : "question.updated";
            saveMessage(request, getText(key, locale));
            if (question.isEdited()) {
                return new ModelAndView("redirect:updating.html?id=" + question.getQuestionId() + "&fieldId=" + request.getParameter("fieldId"));
            }
        }

        return new ModelAndView("redirect:" + question.getDocLocation());
    }
View Full Code Here

    public ModelAndView processFormSubmission(HttpServletRequest request,
                                              HttpServletResponse response,
                                              Object command,
                                              BindException errors)
            throws Exception {
        Question question = (Question) command;
        //System.out.println("QuestiontypeId=="+question.getQuestionTypeId());
        if (request.getParameter("addConstructionType") != null) {
            question.getConstructionTypes().add(new ConstructionType());
            return new ModelAndView("questionForm", "question", question);
        }
        if (request.getParameter("deleteConstructionType") != null) {
            question.getConstructionTypes().remove(question.getConstructionNumber());
            return new ModelAndView("questionForm", "question", question);
        }

        if (request.getParameter("addAnswer") != null) {
            question.getAnswers().add(new Answer());
            return new ModelAndView("questionForm", "question", question);
        }
        if (request.getParameter("deleteAnswer") != null) {
            question.getAnswers().remove(question.getAnswerNumber());
            return new ModelAndView("questionForm", "question", question);
        }

        return super.processFormSubmission(request,
                response,
View Full Code Here

    public boolean hasHint(String questionId) {
        return dao.hasHint(questionId);
    }

    public void raisePriority(String questionId) {
        Question curQuestion = getQuestion(questionId);
        dao.raisePriority(curQuestion);
    }
View Full Code Here

    public void setQuestionDao(QuestionDao dao) {
        this.dao = dao;
    }

    public void testAddQuestion() throws Exception {
        Question question = new Question();

        // set required fields

        dao.saveQuestion(question);

        // verify a primary key was assigned
        assertNotNull(question.getQuestionId());

        // verify set fields are same after save
    }
View Full Code Here

        // verify set fields are same after save
    }

    public void testGetQuestion() throws Exception {
        Question question = dao.getQuestion(questionId);
        assertNotNull(question);
    }
View Full Code Here

TOP

Related Classes of com.vst.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.