Index: lams_tool_assessment/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r4a855e1d754a0564643bff058bc0f80948ab6e08 -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 4a855e1d754a0564643bff058bc0f80948ab6e08) +++ lams_tool_assessment/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -277,5 +277,12 @@ label.authoring.basic.export.qti =Export IMS QTI label.monitoring.heading =Assessment Monitoring +label.maximum.number.words =Maximum number of words +label.minimum.number.words =Minimum number of words +label.info.maximum.number.words =The instructor set the maximum allowed number of words for this question: {0} +label.info.minimum.number.words =The instructor set the minimum required number of words for this question: {0} +warn.answers.doesnt.reach.min.words.limit =In order to continue, please expand your answers to reach the minimum number of words limit. +warn.answers.exceed.max.words.limit =In order to continue, please shorten your answers to comply with maximum number of words limit. +label.words =Words: #======= End labels: Exported 270 labels for en AU ===== Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/AssessmentConstants.java =================================================================== diff -u -r38b6d49113930570f68778048950c2df1875a6be -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/AssessmentConstants.java (.../AssessmentConstants.java) (revision 38b6d49113930570f68778048950c2df1875a6be) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/AssessmentConstants.java (.../AssessmentConstants.java) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -201,7 +201,7 @@ public static final String ATTR_IS_USER_FAILED = "isUserFailed"; - public static final String ATTR_IS_REQUIRED_ANSWER_MISSED = "isRequiredAnswerMissed"; + public static final String ATTR_IS_ANSWERS_VALIDATION_FAILED = "isAnswersValidationFailed"; public static final String ATTR_FINISHED_LOCK = "finishedLock"; Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20140723.sql =================================================================== diff -u --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20140723.sql (revision 0) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20140723.sql (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -0,0 +1,15 @@ +-- Turn off autocommit, so nothing is committed if there is an error +SET AUTOCOMMIT = 0; +SET FOREIGN_KEY_CHECKS=0; +----------------------Put all sql statements below here------------------------- + +-- LDEV- +ALTER TABLE tl_laasse10_assessment_question ADD COLUMN max_words_limit integer; +ALTER TABLE tl_laasse10_assessment_question ADD COLUMN min_words_limit integer; + +----------------------Put all sql statements above here------------------------- + +-- If there were no errors, commit and restore autocommit to on +COMMIT; +SET AUTOCOMMIT = 1; +SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java =================================================================== diff -u -r3e771e28271a0ef14f3989fe84231546420df296 -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java (.../AssessmentQuestion.java) (revision 3e771e28271a0ef14f3989fe84231546420df296) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java (.../AssessmentQuestion.java) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -92,6 +92,11 @@ private Set units; + //only for essay type of question + private int maxWordsLimit; + //only for essay type of question + private int minWordsLimit; + // DTO fields: private String answerString; @@ -491,6 +496,42 @@ this.units = units; } + /** + * maxWordsLimit set in author. Used only for essay type of questions + * + * @hibernate.property column="max_words_limit" + * + * @return + */ + public int getMaxWordsLimit() { + return maxWordsLimit; + } + + /** + * @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 + * + * @hibernate.property column="min_words_limit" + * + * @return + */ + public int getMinWordsLimit() { + return minWordsLimit; + } + + /** + * @param minWordsLimit set in author. Used only for essay type of questions + */ + public void setMinWordsLimit(int minWordsLimit) { + this.minWordsLimit = minWordsLimit; + } + public String getAnswerString() { return answerString; } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/AuthoringAction.java =================================================================== diff -u -r38b6d49113930570f68778048950c2df1875a6be -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 38b6d49113930570f68778048950c2df1875a6be) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -1674,6 +1674,8 @@ form.setCaseSensitive(question.isCaseSensitive()); form.setCorrectAnswer(question.getCorrectAnswer()); form.setAllowRichEditor(question.isAllowRichEditor()); + form.setMaxWordsLimit(question.getMaxWordsLimit()); + form.setMinWordsLimit(question.getMinWordsLimit()); if (questionIdx >= 0) { form.setQuestionIndex(new Integer(questionIdx).toString()); } @@ -1759,6 +1761,8 @@ question.setFeedbackOnIncorrect(questionForm.getFeedbackOnIncorrect()); } else if ((type == AssessmentConstants.QUESTION_TYPE_ESSAY)) { question.setAllowRichEditor(questionForm.isAllowRichEditor()); + question.setMaxWordsLimit(questionForm.getMaxWordsLimit()); + question.setMinWordsLimit(questionForm.getMinWordsLimit()); } else if (type == AssessmentConstants.QUESTION_TYPE_ORDERING) { question.setPenaltyFactor(Float.parseFloat(questionForm.getPenaltyFactor())); question.setFeedbackOnCorrect(questionForm.getFeedbackOnCorrect()); Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java =================================================================== diff -u -r38b6d49113930570f68778048950c2df1875a6be -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java (.../LearningAction.java) (revision 38b6d49113930570f68778048950c2df1875a6be) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java (.../LearningAction.java) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -433,11 +433,11 @@ storeUserAnswersIntoSessionMap(request); //check all required questions got answered - int pageNumberWithUnasweredQuestions = checkAllRequiredQuestionsAnswered(sessionMap); + int pageNumberWithUnasweredQuestions = validateAnswers(sessionMap); //if some were not then forward to nextPage() if (pageNumberWithUnasweredQuestions != 0) { request.setAttribute(AssessmentConstants.ATTR_PAGE_NUMBER, pageNumberWithUnasweredQuestions); - request.setAttribute(AssessmentConstants.ATTR_IS_REQUIRED_ANSWER_MISSED, true); + request.setAttribute(AssessmentConstants.ATTR_IS_ANSWERS_VALIDATION_FAILED, true); return nextPage(mapping, form, request, response); } @@ -724,24 +724,24 @@ } /** - * Checks whether all questions set as requiring an answer was answered. + * Checks whether all required questions were answered and all essay question with min words limit have fullfilled that. * * @param sessionMap - * @return 0 if all required questions were answered, or number of a page that contains unanswered question + * @return 0 if all questions were answered OK, or a number of the first page that contains questions with issues */ - private int checkAllRequiredQuestionsAnswered(SessionMap sessionMap){ + private int validateAnswers(SessionMap sessionMap){ ArrayList> pagedQuestions = (ArrayList>) sessionMap.get(AssessmentConstants.ATTR_PAGED_QUESTIONS); //array of missing required questions boolean isAllQuestionsAnswered = true; + boolean isAllQuestionsReachedMinWordsLimit = true; //iterate through all pages to find first that contains missing required questions int pageCount; for (pageCount = 0; pageCount < pagedQuestions.size(); pageCount++) { LinkedHashSet questionsForOnePage = pagedQuestions.get(pageCount); - int questionCount = 0; for (AssessmentQuestion question : questionsForOnePage) { if (question.isAnswerRequired()) { @@ -776,12 +776,30 @@ } } + + if ((question.getType() == AssessmentConstants.QUESTION_TYPE_ESSAY) + && (question.getMinWordsLimit() > 0)) { - questionCount++; + String answer = new String(question.getAnswerString()); + + // HTML tags stripping + if (question.isAllowRichEditor()) { + answer = WebUtil.removeHTMLtags(answer); // answer.replaceAll("/<\/?[a-z][^>]*>/gi", ''); + } + + int wordCount = (answer.length() == 0) ? 0 : answer.replaceAll("[\'\";:,\\.\\?\\-!]+", "").split("\\S+").length;//.match(/\S+/g) || []) ; + + // check min words limit is reached + if (wordCount < question.getMinWordsLimit()) { + isAllQuestionsReachedMinWordsLimit = false; + break; + } + + } } - //if found un-answered question, stop here - if (!isAllQuestionsAnswered) { + //if found answers required to be fixed by learners, stop here + if (!isAllQuestionsAnswered || !isAllQuestionsReachedMinWordsLimit) { return pageCount + 1; } } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/form/AssessmentQuestionForm.java =================================================================== diff -u -r3e771e28271a0ef14f3989fe84231546420df296 -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/form/AssessmentQuestionForm.java (.../AssessmentQuestionForm.java) (revision 3e771e28271a0ef14f3989fe84231546420df296) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/form/AssessmentQuestionForm.java (.../AssessmentQuestionForm.java) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -57,6 +57,8 @@ private boolean caseSensitive; private boolean correctAnswer; private boolean allowRichEditor; + private int maxWordsLimit; + private int minWordsLimit; public String getSessionMapID() { return sessionMapID; @@ -217,5 +219,21 @@ public void setAllowRichEditor(boolean allowRichEditor) { this.allowRichEditor = allowRichEditor; } + + public int getMaxWordsLimit() { + return maxWordsLimit; + } + public void setMaxWordsLimit(int maxWordsLimit) { + this.maxWordsLimit = maxWordsLimit; + } + + public int getMinWordsLimit() { + return minWordsLimit; + } + + public void setMinWordsLimit(int minWordsLimit) { + this.minWordsLimit = minWordsLimit; + } + } Index: lams_tool_assessment/web/includes/css/addQuestion.css =================================================================== diff -u -r4d14e04ecb649047c874d2c9189a20a86212159d -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/web/includes/css/addQuestion.css (.../addQuestion.css) (revision 4d14e04ecb649047c874d2c9189a20a86212159d) +++ lams_tool_assessment/web/includes/css/addQuestion.css (.../addQuestion.css) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -1,9 +1,34 @@ -label { width: 10em; float: left; } -label.error { float: none; color: red; padding-left: .5em; vertical-align: top; font-weight: bold; font-style: italic;} -em { font-weight: bold; padding-right: 1em; vertical-align: top; } -input.error { border: 2px solid red;} -#content {width: 91%; margin-bottom: 10px;} -table.alternative-color td {padding-left: 0;} -input[type=text].shortInputText {width:10%;} -input[type=text] {width:98%;} -textarea {width:98%;} +label.error { + float: none; color: red; padding-left: .5em; vertical-align: top; font-weight: bold; font-style: italic; +} +em { + font-weight: bold; padding-right: 1em; vertical-align: top; +} +input.error { + border: 2px solid red; +} +#content { + width: 91%; margin-bottom: 10px; +} +table.alternative-color td { + padding-left: 0; +} +input[type=text].shortInputText { + width:10%; +} +input[type=text] { + width:98%; +} +textarea { + width:98%; +} + +.word-limit-label { + margin-right: 7px; +} + +#max-words-limit-checkbox, #min-words-limit-checkbox { + vertical-align: sub; +} + + Index: lams_tool_assessment/web/includes/css/assessment.css =================================================================== diff -u -r5db1b4b04cb030113cfa1affe061817bcb4f2a21 -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/web/includes/css/assessment.css (.../assessment.css) (revision 5db1b4b04cb030113cfa1affe061817bcb4f2a21) +++ lams_tool_assessment/web/includes/css/assessment.css (.../assessment.css) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -147,7 +147,6 @@ color:#47bc23; } - #pager { text-align: center; padding-top: 60px; @@ -166,10 +165,13 @@ border-bottom: 1px solid white !important; } -#warning-answers-required { +#warning-answers-required, #warning-max-words-limit, #warning-min-words-limit, .hidden { display: none; } -.hidden { - display: none; +.reg-padding .info { + margin-top: 10px; + margin-left: 10px; + margin-bottom: 10px; + width: 80%; } Index: lams_tool_assessment/web/pages/authoring/parts/addessay.jsp =================================================================== diff -u -r5db1b4b04cb030113cfa1affe061817bcb4f2a21 -r1668e000b0959071785e5cdd21732af39bd1505f --- lams_tool_assessment/web/pages/authoring/parts/addessay.jsp (.../addessay.jsp) (revision 5db1b4b04cb030113cfa1affe061817bcb4f2a21) +++ lams_tool_assessment/web/pages/authoring/parts/addessay.jsp (.../addessay.jsp) (revision 1668e000b0959071785e5cdd21732af39bd1505f) @@ -4,13 +4,15 @@ <%@ include file="/common/taglibs.jsp"%> + <%@ include file="/common/header.jsp"%> - + + @@ -350,10 +408,18 @@

-
+
+
+ +
+ +
+ +
+