Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java,v diff -u -r1.26 -r1.27 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java 31 Jul 2015 08:01:37 -0000 1.26 +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java 20 Jan 2016 16:33:47 -0000 1.27 @@ -52,82 +52,84 @@ private String title; private String question; - + private int sequenceId; /** * Default grade set in author. */ private int defaultGrade; - + private float penaltyFactor; - + private boolean answerRequired; - + private String generalFeedback; - + private String feedback; - + private boolean multipleAnswersAllowed; - + private boolean incorrectAnswerNullifiesMark; - + private String feedbackOnCorrect; - + private String feedbackOnPartiallyCorrect; - + private String feedbackOnIncorrect; private boolean shuffle; - + private boolean caseSensitive; - + private boolean correctAnswer; - + private boolean allowRichEditor; private Date createDate; - + private AssessmentUser createBy; - + private Set options; - + private Set units; - - //only for essay type of question + + // only for essay type of question private int maxWordsLimit; - //only for essay type of question + // only for essay type of question private int minWordsLimit; - - //only for hedging mark type of question + + // only for hedging mark type of question private boolean hedgingJustificationEnabled; - + // DTO fields: private String answerString; - + private float answerFloat; - + private boolean answerBoolean; - + private String questionFeedback; - + private String titleEscaped; - + private boolean responseSubmitted; - + /** * Grade acquired from QUestionReference in learner. */ private int grade; - + private float mark; - + private float penalty; - + + private float answerTotalGrade; + private Set matchingPairOptions; - + private List questionResults; - + public AssessmentQuestion() { options = new TreeSet(new SequencableComparator()); units = new TreeSet(new SequencableComparator()); @@ -138,7 +140,7 @@ try { obj = (AssessmentQuestion) super.clone(); ((AssessmentQuestion) obj).setUid(null); - + // clone options if (options != null) { Iterator iter = options.iterator(); @@ -150,7 +152,7 @@ } obj.options = set; } - + // clone units if (units != null) { Iterator iter = units.iterator(); @@ -162,14 +164,14 @@ } obj.units = set; } - + } catch (CloneNotSupportedException e) { log.error("When clone " + AssessmentQuestion.class + " failed"); } return obj; } - + @Override public boolean equals(Object o) { if (this == o) @@ -179,9 +181,10 @@ final AssessmentQuestion genericEntity = (AssessmentQuestion) o; - return new EqualsBuilder().append(this.getUid(), genericEntity.getUid()).append(this.getSequenceId(), genericEntity.getSequenceId()).isEquals(); + return new EqualsBuilder().append(this.getUid(), genericEntity.getUid()) + .append(this.getSequenceId(), genericEntity.getSequenceId()).isEquals(); } - + @Override public int compareTo(Object o) { if ((o != null) && o instanceof AssessmentQuestion) { @@ -191,7 +194,7 @@ return 1; } } - + @Override public String toString() { return new ToStringBuilder(this).append("uid", getUid()).toString(); @@ -220,7 +223,7 @@ public void setUid(Long userID) { this.uid = userID; } - + /** * @hibernate.property column="question_type" * @return @@ -232,7 +235,7 @@ public void setType(short type) { this.type = type; } - + /** * @hibernate.property column="title" length="255" * @return @@ -244,7 +247,7 @@ public void setTitle(String title) { this.title = title; } - + /** * @hibernate.property column="question" type="text" * @return @@ -256,7 +259,7 @@ public void setQuestion(String question) { this.question = question; } - + /** * Returns image sequence number. * @@ -272,7 +275,7 @@ * Sets image sequence number. * * @param sequenceId - * image sequence number + * image sequence number */ public void setSequenceId(int sequenceId) { this.sequenceId = sequenceId; @@ -290,7 +293,8 @@ } /** - * @param defaultGrade Default grade set in author. To be used only in author + * @param defaultGrade + * Default grade set in author. To be used only in author */ public void setDefaultGrade(int defaultGrade) { this.defaultGrade = defaultGrade; @@ -307,7 +311,7 @@ public void setPenaltyFactor(float penaltyFactor) { this.penaltyFactor = penaltyFactor; } - + /** * @hibernate.property column="answer_required" * @return @@ -331,7 +335,7 @@ public void setGeneralFeedback(String generalFeedback) { this.generalFeedback = generalFeedback; } - + /** * @hibernate.property column="feedback" type="text" * @return @@ -343,7 +347,7 @@ public void setFeedback(String feedback) { this.feedback = feedback; } - + /** * @hibernate.property column="multiple_answers_allowed" * @return @@ -355,7 +359,7 @@ public void setMultipleAnswersAllowed(boolean multipleAnswersAllowed) { this.multipleAnswersAllowed = multipleAnswersAllowed; } - + /** * @hibernate.property column="incorrect_answer_nullifies_mark" * @return @@ -369,7 +373,7 @@ } /** - * @hibernate.property column="feedback_on_correct" type="text" + * @hibernate.property column="feedback_on_correct" type="text" * @return */ public String getFeedbackOnCorrect() { @@ -379,9 +383,9 @@ public void setFeedbackOnCorrect(String feedbackOnCorrect) { this.feedbackOnCorrect = feedbackOnCorrect; } - + /** - * @hibernate.property column="feedback_on_partially_correct" type="text" + * @hibernate.property column="feedback_on_partially_correct" type="text" * @return */ public String getFeedbackOnPartiallyCorrect() { @@ -391,9 +395,9 @@ public void setFeedbackOnPartiallyCorrect(String feedbackOnPartiallyCorrect) { this.feedbackOnPartiallyCorrect = feedbackOnPartiallyCorrect; } - + /** - * @hibernate.property column="feedback_on_incorrect" type="text" + * @hibernate.property column="feedback_on_incorrect" type="text" * @return */ public String getFeedbackOnIncorrect() { @@ -403,7 +407,7 @@ public void setFeedbackOnIncorrect(String feedbackOnIncorrect) { this.feedbackOnIncorrect = feedbackOnIncorrect; } - + /** * @hibernate.property column="shuffle" * @return @@ -415,7 +419,7 @@ public void setShuffle(boolean shuffle) { this.shuffle = shuffle; } - + /** * @hibernate.property column="case_sensitive" * @return @@ -427,7 +431,7 @@ public void setCaseSensitive(boolean caseSensitive) { this.caseSensitive = caseSensitive; } - + /** * @hibernate.property column="correct_answer" * @return @@ -439,7 +443,7 @@ public void setCorrectAnswer(boolean correctAnswer) { this.correctAnswer = correctAnswer; } - + /** * @hibernate.property column="allow_rich_editor" * @return @@ -463,7 +467,7 @@ public void setCreateDate(Date createDate) { this.createDate = createDate; } - + /** * @hibernate.many-to-one cascade="none" column="create_by" * @@ -476,7 +480,7 @@ public void setCreateBy(AssessmentUser createBy) { this.createBy = createBy; } - + /** * * @hibernate.set cascade="all" order-by="sequence_id asc" @@ -490,12 +494,13 @@ } /** - * @param options options to set. + * @param options + * options to set. */ public void setOptions(Set options) { this.options = options; } - + /** * * @hibernate.set cascade="all" order-by="sequence_id asc" @@ -509,12 +514,13 @@ } /** - * @param options units to set. + * @param options + * units to set. */ public void setUnits(Set units) { this.units = units; } - + /** * maxWordsLimit set in author. Used only for essay type of questions * @@ -527,12 +533,13 @@ } /** - * @param maxWordsLimit set in author. Used only for essay type of questions + * @param maxWordsLimit + * set in author. Used only for essay type of questions */ public void setMaxWordsLimit(int maxWordsLimit) { this.maxWordsLimit = maxWordsLimit; } - + /** * minWordsLimit set in author. Used only for essay type of questions * @@ -545,12 +552,13 @@ } /** - * @param minWordsLimit set in author. Used only for essay type of questions + * @param minWordsLimit + * set in author. Used only for essay type of questions */ public void setMinWordsLimit(int minWordsLimit) { this.minWordsLimit = minWordsLimit; } - + /** * @hibernate.property column="hedging_justification_enabled" * @return @@ -562,88 +570,107 @@ public void setHedgingJustificationEnabled(boolean hedgingJustificationEnabled) { this.hedgingJustificationEnabled = hedgingJustificationEnabled; } - + public String getAnswerString() { return answerString; } + public void setAnswerString(String answerString) { this.answerString = answerString; } - + public float getAnswerFloat() { return answerFloat; } + public void setAnswerFloat(float answerFloat) { this.answerFloat = answerFloat; } - + public boolean getAnswerBoolean() { return answerBoolean; } + public void setAnswerBoolean(boolean answerBoolean) { this.answerBoolean = answerBoolean; - } - + } + public void setQuestionFeedback(String questionFeedback) { this.questionFeedback = questionFeedback; } + public String getQuestionFeedback() { return questionFeedback; } - + public String getTitleEscaped() { return titleEscaped; } + public void setTitleEscaped(String titleEscaped) { this.titleEscaped = titleEscaped; } - + /** * @return Grade acquired from QUestionReference in learner. */ public int getGrade() { return grade; } - + /** - * @param grade Grade acquired from QuestionReference in learner. + * @param grade + * Grade acquired from QuestionReference in learner. */ public void setGrade(int grade) { this.grade = grade; } - + public Float getMark() { return mark; } + public void setMark(Float mark) { this.mark = mark; } - + public Float getPenalty() { return penalty; } + public void setPenalty(Float penalty) { this.penalty = penalty; } - + public Set getMatchingPairOptions() { return matchingPairOptions; } + public void setMatchingPairOptions(Set matchingPairOptions) { this.matchingPairOptions = matchingPairOptions; } - + public List getQuestionResults() { return questionResults; } + public void setQuestionResults(List questionResults2) { this.questionResults = questionResults2; } - + public boolean isResponseSubmitted() { return responseSubmitted; } + public void setResponseSubmitted(boolean responseSubmitted) { this.responseSubmitted = responseSubmitted; } + + public float getAnswerTotalGrade() { + return answerTotalGrade; + } + + public void setAnswerTotalGrade(float answerTotalGrade) { + this.answerTotalGrade = answerTotalGrade; + } } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java,v diff -u -r1.68 -r1.69 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java 30 Dec 2015 19:08:24 -0000 1.68 +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java 20 Jan 2016 16:33:47 -0000 1.69 @@ -561,8 +561,10 @@ float maxMark = question.getGrade(); if (question.getType() == AssessmentConstants.QUESTION_TYPE_MULTIPLE_CHOICE) { boolean isMarkNullified = false; + float totalGrade = 0; for (AssessmentQuestionOption option : question.getOptions()) { if (option.getAnswerBoolean()) { + totalGrade += option.getGrade(); mark += option.getGrade() * maxMark; // if option of "incorrect answer nullifies mark" is ON check if selected answer has a zero grade @@ -572,6 +574,8 @@ } } } + // set it so front end knows whether the question was answered correctly/partly/incorrectly even if mark=0 + question.setAnswerTotalGrade(totalGrade); if (isMarkNullified) { mark = 0; Index: lams_tool_assessment/web/pages/learning/parts/multiplechoice.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_assessment/web/pages/learning/parts/multiplechoice.jsp,v diff -u -r1.12 -r1.13 --- lams_tool_assessment/web/pages/learning/parts/multiplechoice.jsp 26 Jul 2014 00:00:05 -0000 1.12 +++ lams_tool_assessment/web/pages/learning/parts/multiplechoice.jsp 20 Jan 2016 16:33:47 -0000 1.13 @@ -71,15 +71,15 @@
- + - + - + - +