Index: lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java =================================================================== diff -u -r4a3f535791663e116bc76960f4fc1a4933eacabd -r71ecf7fae19f2c5bb42f613c3a72b062b145767e --- lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java (.../LdTemplateController.java) (revision 4a3f535791663e116bc76960f4fc1a4933eacabd) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java (.../LdTemplateController.java) (revision 71ecf7fae19f2c5bb42f613c3a72b062b145767e) @@ -1411,7 +1411,7 @@ boolean isMultipleChoice = Question.QUESTION_TYPE_MULTIPLE_CHOICE.equals(question.getType()); boolean isMultipleResponse = Question.QUESTION_TYPE_MULTIPLE_RESPONSE.equals(question.getType()); - int defaultGrade = 1; + Integer defaultGrade = question.getScore(); assessment.setText(QuestionParser.processHTMLField(question.getText(), false, contentFolderID, question.getResourcesFolderPath())); @@ -1438,8 +1438,10 @@ if ((answer.getScore() != null) && (answer.getScore() > 0)) { if (correctAnswer == null) { - // whatever the correct answer holds, it becomes the question score - defaultGrade = Double.valueOf(Math.ceil(answer.getScore())).intValue(); + if (defaultGrade == null) { + // if grade not explicitly set, whatever the correct answer holds, it becomes the question score + defaultGrade = Double.valueOf(Math.ceil(answer.getScore())).intValue(); + } // 100% goes to the correct answer newAnswer.setGrade(1F); correctAnswer = answerText; @@ -1470,7 +1472,10 @@ totalScore += answer.getScore(); } } - defaultGrade = Double.valueOf(Math.round(totalScore)).intValue(); + if (defaultGrade == null) { + // if grade not explicitly set, user total score as grade + defaultGrade = Double.valueOf(Math.round(totalScore)).intValue(); + } int displayOrder = 1; for (Answer answer : question.getAnswers()) { @@ -1493,7 +1498,7 @@ assessment.setType(QbQuestion.TYPE_ESSAY); } - assessment.setDefaultGrade(defaultGrade); + assessment.setDefaultGrade(defaultGrade == null ? 1 : defaultGrade); assessment.setLearningOutcomes(question.getLearningOutcomes()); } Index: lams_central/src/java/org/lamsfoundation/lams/web/qb/ImsQtiController.java =================================================================== diff -u -r126d6740a7a106bc9dbb91f4ea6a4c54be636858 -r71ecf7fae19f2c5bb42f613c3a72b062b145767e --- lams_central/src/java/org/lamsfoundation/lams/web/qb/ImsQtiController.java (.../ImsQtiController.java) (revision 126d6740a7a106bc9dbb91f4ea6a4c54be636858) +++ lams_central/src/java/org/lamsfoundation/lams/web/qb/ImsQtiController.java (.../ImsQtiController.java) (revision 71ecf7fae19f2c5bb42f613c3a72b062b145767e) @@ -129,7 +129,7 @@ qbQuestion.setQuestionId(questionId); qbQuestion.setVersion(1); - int questionMark = 1; + Integer questionMark = question.getScore(); boolean isMultipleChoice = Question.QUESTION_TYPE_MULTIPLE_CHOICE.equals(question.getType()); boolean isMarkHedgingType = Question.QUESTION_TYPE_MARK_HEDGING.equals(question.getType()); boolean isVsaType = Question.QUESTION_TYPE_FILL_IN_BLANK.contentEquals(question.getType()); @@ -175,8 +175,10 @@ option.setQbQuestion(qbQuestion); if ((answer.getScore() != null) && (answer.getScore() > 0) && (correctAnswer == null)) { - // whatever the correct answer holds, it becomes the question score - questionMark = Double.valueOf(Math.ceil(answer.getScore())).intValue(); + if (questionMark == null) { + // whatever the correct answer holds, it becomes the question score + questionMark = Double.valueOf(Math.ceil(answer.getScore())).intValue(); + } // 100% goes to the correct answer option.setMaxMark(1); correctAnswer = answerText; @@ -209,7 +211,9 @@ totalScore += answer.getScore(); } } - questionMark = Double.valueOf(Math.round(totalScore)).intValue(); + if (questionMark == null) { + questionMark = Double.valueOf(Math.round(totalScore)).intValue(); + } TreeSet optionList = new TreeSet<>(); int orderId = 1; @@ -244,7 +248,9 @@ for (Answer answer : question.getAnswers()) { if ((answer.getScore() != null) && (answer.getScore() > 0)) { qbQuestion.setCorrectAnswer(Boolean.parseBoolean(answer.getText())); - questionMark = Double.valueOf(Math.ceil(answer.getScore())).intValue(); + if (questionMark == null) { + questionMark = Double.valueOf(Math.ceil(answer.getScore())).intValue(); + } } if (!StringUtils.isBlank(answer.getFeedback())) { // set feedback for true/false answers @@ -268,7 +274,9 @@ totalScore += answer.getScore(); } } - questionMark = Double.valueOf(Math.round(totalScore)).intValue(); + if (questionMark == null) { + questionMark = Double.valueOf(Math.round(totalScore)).intValue(); + } TreeSet optionList = new TreeSet<>(); int orderId = 1; @@ -303,7 +311,7 @@ continue; } - qbQuestion.setMaxMark(questionMark); + qbQuestion.setMaxMark(questionMark == null ? 1 : questionMark); userManagementService.save(qbQuestion); if (question.getLearningOutcomes() != null && !question.getLearningOutcomes().isEmpty()) { Index: lams_common/src/java/org/lamsfoundation/lams/questions/Question.java =================================================================== diff -u -r50f84b60c632e10ccc6981f1ce142e28b23eb44c -r71ecf7fae19f2c5bb42f613c3a72b062b145767e --- lams_common/src/java/org/lamsfoundation/lams/questions/Question.java (.../Question.java) (revision 50f84b60c632e10ccc6981f1ce142e28b23eb44c) +++ lams_common/src/java/org/lamsfoundation/lams/questions/Question.java (.../Question.java) (revision 71ecf7fae19f2c5bb42f613c3a72b062b145767e) @@ -56,6 +56,7 @@ private Map matchMap; private List learningOutcomes; private String resourcesFolderPath; + private Integer score; // UUID in QTI question label is LAMS custom idea public String getQbUUID() { @@ -143,6 +144,14 @@ this.resourcesFolderPath = resourcesFolderPath; } + public Integer getScore() { + return score; + } + + public void setScore(Integer mark) { + this.score = mark; + } + @Override public int hashCode() { return new HashCodeBuilder().append(text).toHashCode(); Index: lams_common/src/java/org/lamsfoundation/lams/questions/QuestionWordParser.java =================================================================== diff -u -r126d6740a7a106bc9dbb91f4ea6a4c54be636858 -r71ecf7fae19f2c5bb42f613c3a72b062b145767e --- lams_common/src/java/org/lamsfoundation/lams/questions/QuestionWordParser.java (.../QuestionWordParser.java) (revision 126d6740a7a106bc9dbb91f4ea6a4c54be636858) +++ lams_common/src/java/org/lamsfoundation/lams/questions/QuestionWordParser.java (.../QuestionWordParser.java) (revision 71ecf7fae19f2c5bb42f613c3a72b062b145767e) @@ -65,6 +65,7 @@ private final static String ANSWER_TAG = "answer:"; private final static String CORRECT_TAG = "correct:"; private final static String INCORRECT_TAG = "incorrect:"; + private final static String MARK_TAG = "mark:"; private final static String FEEDBACK_TAG = "feedback:"; private final static String LEARNING_OUTCOME_TAG = "lo:"; private static final String CUSTOM_IMAGE_TAG_REGEX = "\\[IMAGE: .*?]"; @@ -144,6 +145,7 @@ String title = null; String description = null; + String mark = null; String feedback = null; List answers = new ArrayList<>(); Answer correctVsaAnswer = null; @@ -244,6 +246,14 @@ continue; } + if (text.startsWith(MARK_TAG)) { + optionsStarted = true; + feedbackStarted = false; + + mark = WebUtil.removeHTMLtags(text).replaceAll("(?i)" + MARK_TAG + "\\s*", "").strip(); + continue; + } + if (text.startsWith(FEEDBACK_TAG)) { optionsStarted = true; feedbackStarted = true; @@ -317,6 +327,15 @@ question.setAnswers(answers); } + if (mark != null) { + try { + question.setScore(Integer.valueOf(mark)); + } catch (Exception e) { + log.error("Malformed mark, it must be an integer number: " + mark); + continue; + } + } + question.setResourcesFolderPath(TEMP_IMAGE_FOLDER); question.setTitle(title); question.setText(description);