Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/AuthoringController.java =================================================================== diff -u -rf46547f428248b90283a77617357314fb0767cba -r11ead3b7d38d7cfd66e5066468f55ce1ff0ceac6 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/AuthoringController.java (.../AuthoringController.java) (revision f46547f428248b90283a77617357314fb0767cba) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 11ead3b7d38d7cfd66e5066468f55ce1ff0ceac6) @@ -58,8 +58,6 @@ import org.lamsfoundation.lams.qb.model.QbQuestion; import org.lamsfoundation.lams.qb.model.QbQuestionUnit; import org.lamsfoundation.lams.qb.service.IQbService; -import org.lamsfoundation.lams.questions.Question; -import org.lamsfoundation.lams.questions.QuestionExporter; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.assessment.AssessmentConstants; import org.lamsfoundation.lams.tool.assessment.model.Assessment; @@ -68,7 +66,6 @@ import org.lamsfoundation.lams.tool.assessment.model.AssessmentUser; import org.lamsfoundation.lams.tool.assessment.model.QuestionReference; import org.lamsfoundation.lams.tool.assessment.service.IAssessmentService; -import org.lamsfoundation.lams.tool.assessment.util.QTIUtil; import org.lamsfoundation.lams.tool.assessment.util.SequencableComparator; import org.lamsfoundation.lams.tool.assessment.web.form.AssessmentForm; import org.lamsfoundation.lams.tool.assessment.web.form.AssessmentQuestionForm; @@ -506,39 +503,6 @@ } /** - * Parses questions extracted from IMS QTI file and adds them as new items. - */ - @RequestMapping("/saveQTI") - public String saveQTI(HttpServletRequest request) throws UnsupportedEncodingException { - SessionMap sessionMap = getSessionMap(request); - String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); - SortedSet questionList = getQuestionList(sessionMap); - - QTIUtil.saveQTI(request, questionList, contentFolderID); - - reinitializeAvailableQuestions(sessionMap); - return "pages/authoring/parts/questionlist"; - } - - /** - * Prepares Assessment content for QTI packing - */ - @RequestMapping("/exportQTI") - public String exportQTI(HttpServletRequest request, HttpServletResponse response) - throws UnsupportedEncodingException { - SessionMap sessionMap = getSessionMap(request); - SortedSet questionList = getQuestionList(sessionMap); - - List questions = QTIUtil.exportQTI(questionList); - - String title = request.getParameter("title"); - QuestionExporter exporter = new QuestionExporter(title, questions.toArray(Question.QUESTION_ARRAY_TYPE)); - exporter.exportQTIPackage(request, response); - - return null; - } - - /** * Remove assessment question from HttpSession list and update page display. As authoring rule, all persist only * happen when user submit whole page. So this remove is just impact HttpSession values. */ Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java =================================================================== diff -u -rf46547f428248b90283a77617357314fb0767cba -r11ead3b7d38d7cfd66e5066468f55ce1ff0ceac6 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java (.../AuthoringController.java) (revision f46547f428248b90283a77617357314fb0767cba) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 11ead3b7d38d7cfd66e5066468f55ce1ff0ceac6) @@ -504,128 +504,6 @@ } /** - * Parses questions extracted from IMS QTI file and adds them as new items. - */ - @RequestMapping("/saveQTI") - private String saveQTI(HttpServletRequest request) throws UnsupportedEncodingException { - // big part of code was taken from saveItem() method - String sessionMapId = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); - SortedSet itemList = getItemList(sessionMap); - - Question[] questions = QuestionParser.parseQuestionChoiceForm(request); - for (Question question : questions) { - ScratchieItem item = new ScratchieItem(); - item.setQbQuestionModified(IQbService.QUESTION_MODIFIED_ID_BUMP); - QbQuestion qbQuestion = new QbQuestion(); - item.setQbQuestion(qbQuestion); - - int maxSeq = 1; - if (itemList != null && itemList.size() > 0) { - ScratchieItem last = itemList.last(); - maxSeq = last.getDisplayOrder() + 1; - } - item.setDisplayOrder(maxSeq); - qbQuestion.setName(question.getTitle()); - qbQuestion.setDescription(QuestionParser.processHTMLField(question.getText(), false, - contentFolderID, question.getResourcesFolderPath())); - - TreeSet optionList = new TreeSet<>(); - String correctOption = null; - int orderId = 1; - if (question.getAnswers() != null) { - for (Answer answer : question.getAnswers()) { - String answerText = QuestionParser.processHTMLField(answer.getText(), false, contentFolderID, - question.getResourcesFolderPath()); - if (correctOption != null && correctOption.equals(answerText)) { - log.warn("Skipping an answer with same text as the correct answer: " + answerText); - continue; - } - QbOption option = new QbOption(); - option.setName(answerText); - option.setDisplayOrder(orderId++); - - if ((answer.getScore() != null) && (answer.getScore() > 0)) { - if (correctOption == null) { - option.setCorrect(true); - correctOption = answerText; - } else { - log.warn( - "Choosing only the first correct option, despite another one was found: " + answerText); - option.setCorrect(false); - } - } else { - option.setCorrect(false); - } - - optionList.add(option); - } - } - - if (correctOption == null) { - log.warn("No correct option found for question: " + question.getText()); - continue; - } - - qbQuestion.setQbOptions(new ArrayList<>(optionList)); - itemList.add(item); - if (log.isDebugEnabled()) { - log.debug("Added question: " + question.getText()); - } - } - - request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapId); - return "pages/authoring/parts/itemlist"; - } - - /** - * Prepares Scratchie content for QTI packing - */ - @SuppressWarnings({ "unchecked" }) - @RequestMapping("/exportQTI") - private String exportQTI(HttpServletRequest request, HttpServletResponse response) - throws UnsupportedEncodingException { - String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapID); - SortedSet itemList = getItemList(sessionMap); - List questions = new LinkedList<>(); - - for (ScratchieItem item : itemList) { - Question question = new Question(); - QbQuestion qbQuestion = item.getQbQuestion(); - - question.setType(Question.QUESTION_TYPE_MULTIPLE_CHOICE); - question.setTitle(qbQuestion.getName()); - question.setText(qbQuestion.getDescription()); - - List answers = new ArrayList<>(); - Set scratchieOptions = new TreeSet<>(); - scratchieOptions.addAll(qbQuestion.getQbOptions()); - - for (QbOption itemAnswer : scratchieOptions) { - Answer answer = new Answer(); - answer.setText(itemAnswer.getName()); - // there is no LAMS interface to adjust, so use the default 1 point - Float score = itemAnswer.isCorrect() ? 1F : 0; - answer.setScore(score); - answers.add(answer); - } - - question.setAnswers(answers); - questions.add(question); - } - - String title = request.getParameter("title"); - QuestionExporter exporter = new QuestionExporter(title, questions.toArray(Question.QUESTION_ARRAY_TYPE)); - exporter.exportQTIPackage(request, response); - - return null; - } - - /** * Ajax call, remove the given line of instruction of resource item. * * @param mapping