Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -re88830091139dd447cdd6a7f30c129c777104dac -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision e88830091139dd447cdd6a7f30c129c777104dac) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -888,6 +888,8 @@ authoring.tbl.delete.mcq.prompt = Do you want to delete the RAT Question {0}? authoring.application.exercise.allow.multiple.responses = Allow multiple responses authoring.application.exercise.allow.multiple.responses.tooltip = When learners are allowed to select multiple answers the grade is the sum of the grade for all correct responses selected. +authoring.tbl.mark.hedging = Mark hedging +authoring.tbl.mark.hedging.tooltip = Students assign marks to options depending how sure they feel about each of them. message.teacher.role.not.recognized = Please wait for a teacher to start the lesson. (You were logged in as a learner, as your current role does not conform LTI specification). label.multiple.lessons = Multiple lessons label.add.lessons.to.subgroups = Add lesson to all selected subcourses Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== diff -u -r033b4433c56c998d7fedb3f710ff3eaaaa3faa83 -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 033b4433c56c998d7fedb3f710ff3eaaaa3faa83) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -1652,7 +1652,8 @@ Integer questionDisplayOrder = question.get(RestTags.DISPLAY_ORDER).asInt(); Integer defaultGrade = JsonUtil.optInt(question, "defaultGrade", 1); references.add(JsonNodeFactory.instance.objectNode().put(RestTags.DISPLAY_ORDER, questionDisplayOrder) - .put("questionDisplayOrder", questionDisplayOrder).put("defaultGrade", defaultGrade)); + // default grade is name maxMark for reference + .put("questionDisplayOrder", questionDisplayOrder).put("maxMark", defaultGrade)); } toolContentJSON.set("references", references); } Index: lams_central/src/java/org/lamsfoundation/lams/authoring/template/Assessment.java =================================================================== diff -u -r844d0cb18f2b257c4536301fc3b85aee44dc3e8a -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_central/src/java/org/lamsfoundation/lams/authoring/template/Assessment.java (.../Assessment.java) (revision 844d0cb18f2b257c4536301fc3b85aee44dc3e8a) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/template/Assessment.java (.../Assessment.java) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -31,6 +31,7 @@ import java.util.Set; import java.util.TreeSet; +import org.lamsfoundation.lams.qb.model.QbQuestion; import org.lamsfoundation.lams.rest.RestTags; import org.lamsfoundation.lams.util.JsonUtil; @@ -41,17 +42,7 @@ /** Simple assessment object used for parsing survey data before conversion to JSON */ public class Assessment { - // assessment type - copied from ResourceConstants - // question type; - public static final short ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE = 1; -// public static final short ASSESSMENT_QUESTION_TYPE_MATCHING_PAIRS = 2; -// public static final short ASSESSMENT_QUESTION_TYPE_SHORT_ANSWER = 3; -// public static final short ASSESSMENT_QUESTION_TYPE_NUMERICAL = 4; -// public static final short ASSESSMENT_QUESTION_TYPE_TRUE_FALSE = 5; - public static final short ASSESSMENT_QUESTION_TYPE_ESSAY = 6; -// public static final short ASSESSMENT_QUESTION_TYPE_ORDERING = 7; - - short type = 6; + int type = 6; String title = null; String text = null; Boolean required = false; @@ -62,23 +53,23 @@ List learningOutcomes; Long collectionUid; - public void setType(short type) { + public void setType(int type) { this.type = type; - if (type == 1 && this.answers == null) { + if ((type == QbQuestion.TYPE_MULTIPLE_CHOICE || type == QbQuestion.TYPE_MARK_HEDGING) && this.answers == null) { // JSP template pages expect this list to be in correct order this.answers = new TreeSet<>(Comparator.comparingInt(AssessMCAnswer::getSequenceId)); } } public void setType(String type) { if (type != null && type.equalsIgnoreCase("mcq")) { - setType(ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE); + setType(QbQuestion.TYPE_MULTIPLE_CHOICE); } else { - setType(ASSESSMENT_QUESTION_TYPE_ESSAY); + setType(QbQuestion.TYPE_ESSAY); } } - public short getType() { + public int getType() { return type; } @@ -158,8 +149,8 @@ json.put(RestTags.DISPLAY_ORDER, displayOrder); json.put("answerRequired", required); json.put("defaultGrade", defaultGrade); - if (type == ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE) { - json.put("type", ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE); + if (type == QbQuestion.TYPE_MULTIPLE_CHOICE || type == QbQuestion.TYPE_MARK_HEDGING) { + json.put("type", type); ArrayNode answersJSON = JsonNodeFactory.instance.arrayNode(); for (AssessMCAnswer answer : answers) { answersJSON.add(answer.getAsObjectNode()); @@ -169,7 +160,7 @@ json.put("multipleAnswersAllowed", multipleAnswersAllowed); json.put("incorrectAnswerNullifiesMark", multipleAnswersAllowed); } else { - json.put("type", ASSESSMENT_QUESTION_TYPE_ESSAY); + json.put("type", QbQuestion.TYPE_ESSAY); } if (learningOutcomes != null && !learningOutcomes.isEmpty()) { json.set(RestTags.LEARNING_OUTCOMES, JsonUtil.readArray(learningOutcomes)); @@ -183,7 +174,7 @@ public boolean validate(List errorMessages, ResourceBundle appBundle, MessageFormat formatter, Integer applicationExerciseNumber, String applicationExerciseTitle, Integer questionNumber) { boolean errorsExist = false; - if (type == ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE) { + if (type == QbQuestion.TYPE_MULTIPLE_CHOICE) { if (answers.size() == 0) { errorMessages.add(TextUtil.getText(appBundle, formatter, "authoring.error.application.exercise.must.have.answer.num", Index: lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java =================================================================== diff -u -r1597a42cd0d882c7554053e17481671ed45513fb -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java (.../LdTemplateController.java) (revision 1597a42cd0d882c7554053e17481671ed45513fb) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java (.../LdTemplateController.java) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -1359,7 +1359,7 @@ model.addAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, qbQuestion.getContentFolderId()); model.addAttribute("question", question); - if (question.getType() == Assessment.ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE) { + if (question.getType() == QbQuestion.TYPE_MULTIPLE_CHOICE) { Set answers = question.getAnswers(); for (QbOption qbOption : qbQuestion.getQbOptions()) { AssessMCAnswer answer = new AssessMCAnswer(qbOption.getDisplayOrder(), qbOption.getName(), @@ -1380,10 +1380,11 @@ QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid); Assessment question = new Assessment(); - question.setType(Assessment.ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE); + question.setType(qbQuestion.getType()); question.setTitle(qbQuestion.getName()); question.setText(qbQuestion.getDescription()); question.setUuid(qbQuestion.getUuid().toString()); + question.setDefaultGrade(qbQuestion.getMaxMark()); Set answers = question.getAnswers(); for (QbOption qbOption : qbQuestion.getQbOptions()) { @@ -1418,7 +1419,7 @@ assessment.setUuid(question.getQbUUID()); if (isMultipleChoice) { - assessment.setType(Assessment.ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE); + assessment.setType(QbQuestion.TYPE_MULTIPLE_CHOICE); assessment.setMultipleAnswersAllowed(false); String correctAnswer = null; @@ -1458,7 +1459,7 @@ } } else if (isMultipleResponse) { - assessment.setType(Assessment.ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE); + assessment.setType(QbQuestion.TYPE_MULTIPLE_CHOICE); assessment.setMultipleAnswersAllowed(true); if (question.getAnswers() != null) { @@ -1489,7 +1490,7 @@ } } } else { - assessment.setType(Assessment.ASSESSMENT_QUESTION_TYPE_ESSAY); + assessment.setType(QbQuestion.TYPE_ESSAY); } assessment.setDefaultGrade(defaultGrade); Index: lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/TBLTemplateController.java =================================================================== diff -u -r1597a42cd0d882c7554053e17481671ed45513fb -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/TBLTemplateController.java (.../TBLTemplateController.java) (revision 1597a42cd0d882c7554053e17481671ed45513fb) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/TBLTemplateController.java (.../TBLTemplateController.java) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -36,6 +36,8 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -47,6 +49,7 @@ import org.lamsfoundation.lams.authoring.template.PeerReviewCriteria; import org.lamsfoundation.lams.authoring.template.TemplateData; import org.lamsfoundation.lams.authoring.template.TextUtil; +import org.lamsfoundation.lams.qb.model.QbQuestion; import org.lamsfoundation.lams.rest.RestTags; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.AuthoringJsonTags; @@ -75,6 +78,7 @@ private static Logger log = Logger.getLogger(TBLTemplateController.class); private static String templateCode = "TBL"; private static final DateFormat LESSON_SCHEDULING_DATETIME_FORMAT = new SimpleDateFormat("MM/dd/yy HH:mm"); + private static final Pattern IRAT_QUESTION_DISPLAY_ORDER_PATTERN = Pattern.compile("question(\\d+)"); /** * Sets up the CKEditor stuff @@ -448,40 +452,41 @@ while (parameterNames.hasMoreElements()) { String name = (String) parameterNames.nextElement(); if (useIRATRA && name.startsWith("question")) { + Matcher questionDisplayOrderMather = IRAT_QUESTION_DISPLAY_ORDER_PATTERN.matcher(name); + questionDisplayOrderMather.find(); + int questionDisplayOrder = Integer.parseInt(questionDisplayOrderMather.group(1)); + ObjectNode question = testQuestions.get(questionDisplayOrder); + if (question == null) { + // init iRAT question + boolean isMarkHedging = WebUtil.readBooleanParam(request, + "question" + questionDisplayOrder + "markHedging", false); + String title = getTrimmedString(request, "question" + questionDisplayOrder + "title", false); + String text = getTrimmedString(request, "question" + questionDisplayOrder, true); + String[] learningOutcomes = request + .getParameterValues("question" + questionDisplayOrder + "learningOutcome"); + Long collectionUid = WebUtil.readLongParam(request, + "question" + questionDisplayOrder + "collection", true); + String uuid = getTrimmedString(request, "question" + questionDisplayOrder + "uuid", false); + Integer mark = WebUtil.readIntParam(request, "question" + questionDisplayOrder + "mark", true); + question = processTestQuestion( + isMarkHedging ? QbQuestion.TYPE_MARK_HEDGING : QbQuestion.TYPE_MULTIPLE_CHOICE, text, + title, questionDisplayOrder, mark, uuid, learningOutcomes, collectionUid); + } + int correctIndex = name.indexOf("correct"); if (correctIndex > 0) { // question1correct - Integer questionDisplayOrder = Integer.valueOf(name.substring(questionOffset, correctIndex)); Integer correctValue = WebUtil.readIntParam(request, name); correctAnswers.put(questionDisplayOrder, correctValue); - } else { - int optionIndex = name.indexOf("option"); - if (optionIndex > 0) { - Integer questionDisplayOrder = Integer.valueOf(name.substring(questionOffset, optionIndex)); - Integer optionDisplayOrder = Integer.valueOf(name.substring(optionIndex + 6)); - processTestQuestion(name, null, null, questionDisplayOrder, null, optionDisplayOrder, - getTrimmedString(request, name, true), null, null); - } else { - int titleIndex = name.indexOf("title"); - if (titleIndex > 0) { // question1title - Integer questionDisplayOrder = Integer - .valueOf(name.substring(questionOffset, titleIndex)); - // get all learning outcomes straight away instead of iterating over them - String[] learningOutcomes = request - .getParameterValues("question" + questionDisplayOrder + "learningOutcome"); - Long collectionUid = WebUtil.readLongParam(request, - "question" + questionDisplayOrder + "collection", true); - processTestQuestion(name, null, getTrimmedString(request, name, false), - questionDisplayOrder, null, null, null, learningOutcomes, collectionUid); - } else if (name.indexOf("uuid") < 0 && name.indexOf("learningOutcome") < 0 - && name.indexOf("collection") < 0) { - Integer questionDisplayOrder = Integer.valueOf(name.substring(questionOffset)); - processTestQuestion(name, getTrimmedString(request, name, true), null, - questionDisplayOrder, - getTrimmedString(request, "question" + questionDisplayOrder + "uuid", false), - null, null, null, null); - } - } + continue; } + + int optionIndex = name.indexOf("option"); + if (optionIndex > 0) { + Integer optionDisplayOrder = Integer.valueOf(name.substring(optionIndex + 6)); + String optionText = getTrimmedString(request, name, true); + processTestOption(question, optionDisplayOrder, optionText); + } + } else if (usePeerReview && name.startsWith("peerreview")) { processInputPeerReviewRequestField(name, request); } @@ -620,7 +625,7 @@ assessment.setDefaultGrade(mark); } - if (assessment.getType() == Assessment.ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE) { + if (assessment.getType() == QbQuestion.TYPE_MULTIPLE_CHOICE) { assessment.setMultipleAnswersAllowed( WebUtil.readBooleanParam(request, assessmentPrefix + "multiAllowed", false)); String optionPrefix = new StringBuilder("divass").append(appexNumber).append("assmcq").append(i) @@ -683,17 +688,28 @@ return criteria; } - void processTestQuestion(String name, String questionText, String questionTitle, Integer questionDisplayOrder, - String questionUuid, Integer optionDisplayOrder, String optionText, String[] learningOutcomes, + void processTestOption(ObjectNode question, Integer optionDisplayOrder, String optionText) { + if (optionDisplayOrder != null && optionText != null) { + ObjectNode newOption = JsonNodeFactory.instance.objectNode(); + newOption.put(RestTags.DISPLAY_ORDER, optionDisplayOrder); + newOption.put(RestTags.CORRECT, false); + newOption.put(RestTags.ANSWER_TEXT, optionText); + ((ArrayNode) question.get(RestTags.ANSWERS)).add(newOption); + } + } + + ObjectNode processTestQuestion(int questionType, String questionText, String questionTitle, + Integer questionDisplayOrder, Integer mark, String questionUuid, String[] learningOutcomes, Long collectionUid) { - ObjectNode question = testQuestions.get(questionDisplayOrder); - if (question == null) { - question = JsonNodeFactory.instance.objectNode(); - question.put("type", Assessment.ASSESSMENT_QUESTION_TYPE_MULTIPLE_CHOICE); - question.set(RestTags.ANSWERS, JsonNodeFactory.instance.arrayNode()); - question.put(RestTags.DISPLAY_ORDER, questionDisplayOrder); - testQuestions.put(questionDisplayOrder, question); + ObjectNode question = JsonNodeFactory.instance.objectNode(); + question.put("type", questionType); + question.set(RestTags.ANSWERS, JsonNodeFactory.instance.arrayNode()); + question.put(RestTags.DISPLAY_ORDER, questionDisplayOrder); + testQuestions.put(questionDisplayOrder, question); + + if (questionTitle != null) { + question.put(RestTags.QUESTION_TITLE, questionTitle); } if (questionText != null) { @@ -704,22 +720,14 @@ } } - if (questionTitle != null) { - question.put(RestTags.QUESTION_TITLE, questionTitle); + if (mark != null) { + question.put("defaultGrade", mark); } if (questionUuid != null) { question.put(RestTags.QUESTION_UUID, questionUuid); } - if (optionDisplayOrder != null && optionText != null) { - ObjectNode newOption = JsonNodeFactory.instance.objectNode(); - newOption.put(RestTags.DISPLAY_ORDER, optionDisplayOrder); - newOption.put(RestTags.CORRECT, false); - newOption.put(RestTags.ANSWER_TEXT, optionText); - ((ArrayNode) question.get(RestTags.ANSWERS)).add(newOption); - } - if (learningOutcomes != null && learningOutcomes.length > 0) { try { ArrayNode learningOutcomesJSON = JsonUtil.readArray(learningOutcomes); @@ -733,6 +741,8 @@ if (collectionUid != null) { question.put(RestTags.COLLECTION_UID, collectionUid); } + + return question; } void updateCorrectAnswers(TreeMap correctAnswers) { Index: lams_central/src/java/org/lamsfoundation/lams/web/qb/SearchQBController.java =================================================================== diff -u -rbcb806e82cb1d2f15b11791aeb5e8ff7335e0163 -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_central/src/java/org/lamsfoundation/lams/web/qb/SearchQBController.java (.../SearchQBController.java) (revision bcb806e82cb1d2f15b11791aeb5e8ff7335e0163) +++ lams_central/src/java/org/lamsfoundation/lams/web/qb/SearchQBController.java (.../SearchQBController.java) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -133,7 +133,14 @@ //CommonConstants.TOOL_SIGNATURE_QA } else if ("laqa11".equals(toolSignature)) { questionTypeDefault = QbQuestion.TYPE_ESSAY; + } else if ("tblIrat".equals(toolSignature)) { + // this is a special tool "signature" which allows mcq and mark hedging + // used by iRAT page in TBL template + questionTypesAvailable.append(QbQuestion.TYPE_MULTIPLE_CHOICE); + questionTypesAvailable.append(","); + questionTypesAvailable.append(QbQuestion.TYPE_MARK_HEDGING); } + request.setAttribute("questionType", questionTypeDefault); request.setAttribute("questionTypesAvailable", questionTypesAvailable.toString()); //let jsp know it's Scratchie, so we can disable VSA questions not compatible with TBL Index: lams_central/web/authoring/template/tbl/tbl.jsp =================================================================== diff -u -r2ae92878c21c1cfeff66305f60e630191d1c64aa -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_central/web/authoring/template/tbl/tbl.jsp (.../tbl.jsp) (revision 2ae92878c21c1cfeff66305f60e630191d1c64aa) +++ lams_central/web/authoring/template/tbl/tbl.jsp (.../tbl.jsp) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -172,8 +172,8 @@ // this action returns ID of the created QB question // which is put into itemArea div returnUrl: "qb/edit/returnQuestionUid.do", - // limit question to multiple choice (ira) or essay and multiple choice (ae) - toolSignature: appexNumber ? "lasurv11" : "lamc11" + // limit question to multiple choice and mark hedging (ira) or essay and multiple choice (ae) + toolSignature: appexNumber ? "lasurv11" : "tblIrat" }, function(){ container.scrollIntoView(true); } @@ -284,11 +284,11 @@ -
  • +
  • ...
  • -
  • +
  • ...
  • Index: lams_central/web/authoring/template/tool/mcquestion.jsp =================================================================== diff -u -r844d0cb18f2b257c4536301fc3b85aee44dc3e8a -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_central/web/authoring/template/tool/mcquestion.jsp (.../mcquestion.jsp) (revision 844d0cb18f2b257c4536301fc3b85aee44dc3e8a) +++ lams_central/web/authoring/template/tool/mcquestion.jsp (.../mcquestion.jsp) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -28,7 +28,22 @@ - +
    + + + + +
    +
    +
    + +
    @@ -100,4 +115,7 @@ }).on('shown', onShownForXEditable) .on('hidden', onHiddenForXEditable); + $(document).ready(function(){ + $('[data-toggle="tooltip"]').tooltip(); + }); \ No newline at end of file Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -r0ebaba46f0ce87b5138e8e70cc1965887c1c7787 -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 0ebaba46f0ce87b5138e8e70cc1965887c1c7787) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -3707,7 +3707,8 @@ for (JsonNode questionJSONData : questions) { AssessmentQuestion question = new AssessmentQuestion(); - Integer type = JsonUtil.optInt(questionJSONData, "type"); + Integer type = JsonUtil.optInt(questionJSONData, "type", QbQuestion.TYPE_MULTIPLE_CHOICE); + int mark = JsonUtil.optInt(questionJSONData, "defaultGrade", 1); question.setToolContentId(toolContentID); question.setDisplayOrder(JsonUtil.optInt(questionJSONData, RestTags.DISPLAY_ORDER)); question.setAnswerRequired(JsonUtil.optBoolean(questionJSONData, "answerRequired", Boolean.FALSE)); @@ -3721,6 +3722,11 @@ oldQbQuestion = qbService.getQuestionByUUID(UUID.fromString(uuid)); } boolean isModification = oldQbQuestion != null; + // if user imported MCQ or mark hedging question and then changed its type in checkbox + // then it must be a new question + if (isModification && !oldQbQuestion.getType().equals(type)) { + isModification = false; + } // are we modifying an existing question or creating a new one if (isModification) { @@ -3740,7 +3746,6 @@ JsonUtil.optBoolean(questionJSONData, RestTags.ALLOW_RICH_TEXT_EDITOR, Boolean.FALSE)); qbQuestion.setCaseSensitive(JsonUtil.optBoolean(questionJSONData, "caseSensitive", Boolean.FALSE)); qbQuestion.setCorrectAnswer(JsonUtil.optBoolean(questionJSONData, "correctAnswer", Boolean.FALSE)); - qbQuestion.setMaxMark(JsonUtil.optInt(questionJSONData, "defaultGrade", 1)); qbQuestion.setFeedback(JsonUtil.optString(questionJSONData, "feedback")); qbQuestion.setFeedbackOnCorrect(JsonUtil.optString(questionJSONData, "feedbackOnCorrect")); qbQuestion.setFeedbackOnIncorrect(JsonUtil.optString(questionJSONData, "feedbackOnIncorrect")); @@ -3755,6 +3760,10 @@ qbQuestion.setPenaltyFactor(JsonUtil.optDouble(questionJSONData, "penaltyFactor", 0.0).floatValue()); if (!isModification) { + // default question is set only for new question + // for existing question only reference is updated + qbQuestion.setMaxMark(mark); + // UUID normally gets generated in the DB, but we need it immediately, // so we generate it programmatically. // Re-reading the QbQuestion we just saved does not help as it is read from Hibernate cache, @@ -3894,7 +3903,6 @@ // collection for (JsonNode referenceJSONData : references) { QuestionReference reference = new QuestionReference(); - reference.setMaxMark(JsonUtil.optInt(referenceJSONData, "maxMark", 1)); reference.setSequenceId(JsonUtil.optInt(referenceJSONData, RestTags.DISPLAY_ORDER)); AssessmentQuestion matchingQuestion = matchQuestion(newQuestionSet, JsonUtil.optInt(referenceJSONData, "questionDisplayOrder")); @@ -3903,6 +3911,10 @@ + referenceJSONData.get("questionDisplayOrder") + ". Data:" + toolContentJSON); } reference.setQuestion(matchingQuestion); + // either take the parameter or get default question grade + Integer referenceMark = JsonUtil.optInt(referenceJSONData, "maxMark"); + reference.setMaxMark( + referenceMark == null ? matchingQuestion.getQbQuestion().getMaxMark() : referenceMark); reference.setRandomQuestion(JsonUtil.optBoolean(referenceJSONData, "randomQuestion", Boolean.FALSE)); newReferenceSet.add(reference); } @@ -3926,9 +3938,9 @@ // TODO Implement REST support for all types and then remove checkType method void checkType(Integer type) throws IOException { - if ((type != QbQuestion.TYPE_ESSAY) && (type != QbQuestion.TYPE_MULTIPLE_CHOICE)) { + if ((type != QbQuestion.TYPE_ESSAY) && (type != QbQuestion.TYPE_MULTIPLE_CHOICE) && (type != QbQuestion.TYPE_MARK_HEDGING)) { throw new IOException( - "Assessment Tool does not support REST Authoring for anything but Essay Type and Multiple Choice. Found type " + "Assessment Tool does not support REST Authoring for anything but Essay, Multiple Choice and Mark Hedging types. Found type " + type); } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -rbcb806e82cb1d2f15b11791aeb5e8ff7335e0163 -r4a3f535791663e116bc76960f4fc1a4933eacabd --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision bcb806e82cb1d2f15b11791aeb5e8ff7335e0163) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) @@ -1794,7 +1794,8 @@ for (ScratchieUser user : users) { int questionCount = 1; for (ScratchieItemDTO itemDto : summary.getItemDtos()) { - boolean isMcqItem = itemDto.getType() == QbQuestion.TYPE_MULTIPLE_CHOICE || itemDto.getType() == QbQuestion.TYPE_MARK_HEDGING; + boolean isMcqItem = itemDto.getType() == QbQuestion.TYPE_MULTIPLE_CHOICE + || itemDto.getType() == QbQuestion.TYPE_MARK_HEDGING; row = spssAnalysisSheet.initRow(); // learner name @@ -2755,6 +2756,7 @@ ObjectNode questionData = (ObjectNode) questions.get(i); ScratchieItem item = new ScratchieItem(); + int type = JsonUtil.optInt(questionData, "type", QbQuestion.TYPE_MULTIPLE_CHOICE); item.setDisplayOrder(JsonUtil.optInt(questionData, RestTags.DISPLAY_ORDER)); item.setAnswerRequired(JsonUtil.optBoolean(questionData, "answerRequired", Boolean.FALSE)); item.setToolContentId(scratchie.getContentId()); @@ -2766,6 +2768,9 @@ if (StringUtils.isNotBlank(uuid)) { qbQuestion = qbService.getQuestionByUUID(UUID.fromString(uuid)); } + if (qbQuestion != null && !qbQuestion.getType().equals(type)) { + qbQuestion = null; + } Long collectionUid = JsonUtil.optLong(questionData, RestTags.COLLECTION_UID); boolean addToCollection = collectionUid != null;