Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml (.../QaContent.hbm.xml) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml (.../QaContent.hbm.xml) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -18,7 +18,6 @@ - - - - - - - + + + + + + + + + + + + - Avg rating {1} out of {2} votes +label.average.rating =Average rating {0}/{1} votes +label.rate.limits.reminder =Rating limitation: Minimum {0} and Maximum {1}. +label.rate.limits.topic.reminder =You have rated {0} responses already. +label.rate.limits.reminder.min = You must rate at least {0} responses. +label.rate.limits.reminder.max = You can only rate up to {0} responses. +js.warning.max.min.limit = There is an error with the minimum and/or maximum set for ratings. Please check and try again. +label.minimum =Minimum: +label.maximum =Maximum: +label.no.minimum =No minimum +label.no.maximum =No maximum +label.minimum.number.words =Minimum number of words in a response{0} +label.comment.minimum.number.words =Minimum number of words in a comment{0} +warning.minimum.number.words =There is a minimum required number of words in a comment: {0}. So far you've entered {1} word(s). +warning.comment.blank =Comment can not be blank. #======= End labels: Exported 254 labels for en AU ===== Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== diff -u -refbaf6ddcc506fed7b594bc9b663b81a03b1283f -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -32,8 +32,6 @@ public static final int SORT_BY_NO = 0; public static final int SORT_BY_ANSWER_ASC = 1; public static final int SORT_BY_ANSWER_DESC = 2; - public static final int SORT_BY_AVG_RATING_ASC = 3; - public static final int SORT_BY_AVG_RATING_DESC = 4; public static final String MY_SIGNATURE = "laqa11"; public static final String TOOL_CONTENT_ID = "toolContentID"; @@ -76,6 +74,8 @@ public static final String ALLOW_RATE_ANSWERS = "allowRateAnswers"; public static final String NOTIFY_TEACHERS_ON_RESPONSE_SUBMIT = "notifyTeachersOnResponseSubmit"; public static final String QUESTIONS_SEQUENCED = "questionsSequenced"; + public static final String MAXIMUM_RATES = "maximumRates"; + public static final String MINIMUM_RATES = "minimumRates"; public static final String SOURCE_MC_STARTER = "sourceMcStarter"; public static final Integer MAX_QUESTION_COUNT = new Integer(50); @@ -199,6 +199,7 @@ public static final String REQUEST_PREVIEW = "requestPreview"; public static final String REQUEST_LEARNING_REPORT_VIEWONLY = "requestLearningReportViewOnly"; public static final String REVISITED_LEARNER_REP = "revisitedLearnerRep"; + public static final String IS_DISABLED = "isDisabled"; /* * Monitoring Mode constants Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java (.../QaCondition.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java (.../QaCondition.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -65,7 +65,7 @@ super(conditionDTO); for (QaQueContent question : conditionDTO.getQuestions()) { QaQueContent questionCopy = new QaQueContent(question.getQuestion(), question.getDisplayOrder(), null, - question.isRequired(), null); + question.isRequired(), question.getMinWordsLimit(), null); getQuestions().add(questionCopy); } } @@ -136,7 +136,7 @@ for (QaQueContent question : getQuestions()) { QaQueContent questionCopy = new QaQueContent(question.getQuestion(), question.getDisplayOrder(), null, - question.isRequired(), null); + question.isRequired(), question.getMinWordsLimit(), null); questionsCopy.add(questionCopy); } return new QaCondition(null, newConditionUIID, orderId, name, displayName, allWords, phrase, anyWords, Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java (.../QaContent.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java (.../QaContent.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -34,6 +34,7 @@ import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; +import org.lamsfoundation.lams.rating.model.LearnerItemRatingCriteria; /** * QaContent Value Object The value object that maps to our model database table: tl_laqa11_content The relevant @@ -103,7 +104,13 @@ private Date updateDate; private Date submissionDeadline; + + private int maximumRates; + private int minimumRates; + + private Set ratingCriterias; + /** persistent field */ private Set qaQueContents; @@ -121,8 +128,9 @@ String monitoringReportTitle, long createdBy, boolean questionsSequenced, boolean usernameVisible, boolean allowRateAnswers, boolean notifyTeachersOnResponseSubmit, boolean lockWhenFinished, boolean showOtherAnswers, boolean reflect, String reflectionSubject, Date creationDate, Date updateDate, - Set qaQueContents, Set qaSessions, Set conditions, boolean allowRichEditor, - boolean useSelectLeaderToolOuput) { + Set qaQueContents, Set qaSessions, Set conditions, boolean allowRichEditor, + boolean useSelectLeaderToolOuput, int maximumRates, int minimumRates, + Set ratingCriterias) { this.qaContentId = qaContentId; this.content = content; this.title = title; @@ -145,6 +153,9 @@ this.conditions = conditions; this.allowRichEditor = allowRichEditor; this.useSelectLeaderToolOuput = useSelectLeaderToolOuput; + this.maximumRates = maximumRates; + this.minimumRates = minimumRates; + this.ratingCriterias = ratingCriterias; } /** @@ -163,17 +174,32 @@ qa.isUsernameVisible(), qa.isAllowRateAnswers(), qa.isNotifyTeachersOnResponseSubmit(), qa.isLockWhenFinished(), qa.isShowOtherAnswers(), qa.isReflect(), qa.getReflectionSubject(), qa.getCreationDate(), qa.getUpdateDate(), new TreeSet(), new TreeSet(), new TreeSet( - new TextSearchConditionComparator()), qa.isAllowRichEditor(), qa.isUseSelectLeaderToolOuput()); + new TextSearchConditionComparator()), qa.isAllowRichEditor(), qa.isUseSelectLeaderToolOuput(), + qa.maximumRates, qa.minimumRates, new TreeSet()); newContent.setQaQueContents(qa.deepCopyQaQueContent(newContent)); + + newContent.setRatingCriterias(qa.deepCopyRatingCriterias(newContent)); newContent.setConditions(qa.deepCopyConditions(newContent)); return newContent; } + + public Set deepCopyRatingCriterias(QaContent newQaContent) { - public Set deepCopyQaQueContent(QaContent newQaContent) { - Set newQaQueContent = new TreeSet(); - for (Iterator i = this.getQaQueContents().iterator(); i.hasNext();) { + Set newCriterias = new TreeSet(); + for (Iterator i = ratingCriterias.iterator(); i.hasNext();) { + LearnerItemRatingCriteria criteria = i.next(); + LearnerItemRatingCriteria newCriteria = (LearnerItemRatingCriteria) criteria.clone(); + newCriteria.setToolContentId(newQaContent.qaContentId); + newCriterias.add(newCriteria); + } + return newCriterias; + } + + public Set deepCopyQaQueContent(QaContent newQaContent) { + Set newQaQueContent = new TreeSet(); + for (Iterator i = this.getQaQueContents().iterator(); i.hasNext();) { QaQueContent queContent = (QaQueContent) i.next(); newQaQueContent.add(QaQueContent.newInstance(queContent, newQaContent)); } @@ -553,7 +579,41 @@ public void setShowOtherAnswers(boolean showOtherAnswers) { this.showOtherAnswers = showOtherAnswers; } + + /** + * @return + */ + public int getMaximumRates() { + return maximumRates; + } + public void setMaximumRates(int maximumRate) { + this.maximumRates = maximumRate; + } + + /** + * @return + */ + public int getMinimumRates() { + return minimumRates; + } + + public void setMinimumRates(int minimumRates) { + this.minimumRates = minimumRates; + } + + /** + * + * @return + */ + public Set getRatingCriterias() { + return ratingCriterias; + } + + public void setRatingCriterias(Set ratingCriterias) { + this.ratingCriterias = ratingCriterias; + } + public Set getConditions() { return conditions; } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java (.../QaQueContent.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java (.../QaQueContent.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -55,25 +55,28 @@ private boolean required; + private int minWordsLimit; + /** nullable persistent field */ private QaContent qaContent; /** default constructor */ public QaQueContent() { } - public QaQueContent(String question, int displayOrder, String feedback, boolean required, + public QaQueContent(String question, int displayOrder, String feedback, boolean required, int minWordsLimit, QaContent qaContent) { this.question = question; this.displayOrder = displayOrder; this.feedback = feedback; this.required = required; + this.minWordsLimit = minWordsLimit; this.qaContent = qaContent; } public static QaQueContent newInstance(QaQueContent queContent, QaContent newQaContent) { QaQueContent newQueContent = new QaQueContent(queContent.getQuestion(), queContent.getDisplayOrder(), - queContent.getFeedback(), queContent.isRequired(), newQaContent); + queContent.getFeedback(), queContent.isRequired(), queContent.minWordsLimit, newQaContent); return newQueContent; } @@ -118,8 +121,23 @@ public boolean isRequired() { return required; } + + /** + * @param minWordsLimit + * minWordsLimit + */ + public void setMinWordsLimit(int minWordsLimit) { + this.minWordsLimit = minWordsLimit; + } /** + * @return minWordsLimit + */ + public int getMinWordsLimit() { + return minWordsLimit; + } + + /** * @param displayOrder * The displayOrder to set. */ Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java =================================================================== diff -u -refbaf6ddcc506fed7b594bc9b663b81a03b1283f -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java (.../QaUsrResp.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java (.../QaUsrResp.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -29,6 +29,7 @@ import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; +import org.lamsfoundation.lams.rating.dto.ItemRatingDTO; /** * @@ -64,8 +65,7 @@ private String timezone; //DTO fields - private String averageRating; - private String numberOfVotes; + private ItemRatingDTO itemRatingDto; /** full constructor */ public QaUsrResp(Long responseId, String answer, Date attemptTime, String timezone, @@ -237,20 +237,12 @@ this.visible = visible; } - public String getNumberOfVotes() { - return numberOfVotes; + public ItemRatingDTO getItemRatingDto() { + return itemRatingDto; } - public void setNumberOfVotes(String numberOfVotes) { - this.numberOfVotes = numberOfVotes; + public void setItemRatingDto(ItemRatingDTO itemRatingDto) { + this.itemRatingDto = itemRatingDto; } - public String getAverageRating() { - return averageRating; - } - - public void setAverageRating(String averageRating) { - this.averageRating = averageRating; - } - } Fisheye: Tag dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/ResponseRating.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IResponseRatingDAO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java =================================================================== diff -u -raa23416ad623b838b1bc6b1a425ff3da67550240 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (.../QaUsrRespDAO.java) (revision aa23416ad623b838b1bc6b1a425ff3da67550240) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (.../QaUsrRespDAO.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -25,11 +25,9 @@ import java.util.List; -import org.apache.poi.ss.formula.functions.Rate; import org.hibernate.FlushMode; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaUsrResp; -import org.lamsfoundation.lams.tool.qa.ResponseRating; import org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; @@ -46,10 +44,6 @@ private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT = "from qaUsrResp in class QaUsrResp " + "where qaUsrResp.qaQueUser.qaSession.qaSessionId=:qaSessionId AND qaUsrResp.qaQuestion.uid=:questionId AND qaUsrResp.qaQueUser.queUsrId!=:excludeUserId order by "; - private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_ORDER_BY_AVG_RATING = "SELECT resp FROM " - + " ResponseRating as rating RIGHT JOIN rating.response as resp " - + " WHERE resp.qaQueUser.qaSession.qaSessionId=:qaSessionId AND resp.qaQuestion.uid=:questionId AND resp.qaQueUser.queUsrId!=:excludeUserId GROUP BY resp.responseId ORDER BY AVG(rating.rating) "; - private static final String LOAD_ATTEMPT_FOR_USER = "from qaUsrResp in class QaUsrResp " + "where qaUsrResp.qaQueUser.uid=:userUid order by qaUsrResp.qaQuestion.displayOrder asc"; @@ -113,31 +107,12 @@ case QaAppConstants.SORT_BY_ANSWER_DESC: sortingOrder = "answer DESC"; break; - case QaAppConstants.SORT_BY_AVG_RATING_ASC: - sortingOrder = "ASC"; - break; - case QaAppConstants.SORT_BY_AVG_RATING_DESC: - sortingOrder = "DESC"; - break; } - if (sorting == QaAppConstants.SORT_BY_AVG_RATING_ASC || sorting == QaAppConstants.SORT_BY_AVG_RATING_DESC) { - - List list = getSession().createQuery(LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_ORDER_BY_AVG_RATING + sortingOrder) - .setLong("qaSessionId", qaSessionId.longValue()).setLong("questionId", questionId.longValue()) - .setLong("excludeUserId", excludeUserId.longValue()).setFirstResult(page * size) - .setMaxResults(size).list(); - - return list; - - } else { - return getSession().createQuery(LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT + sortingOrder) - .setLong("qaSessionId", qaSessionId.longValue()).setLong("questionId", questionId.longValue()) - .setLong("excludeUserId", excludeUserId.longValue()).setFirstResult(page * size) - .setMaxResults(size).list(); - } - - + return getSession().createQuery(LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT + sortingOrder) + .setLong("qaSessionId", qaSessionId.longValue()).setLong("questionId", questionId.longValue()) + .setLong("excludeUserId", excludeUserId.longValue()).setFirstResult(page * size).setMaxResults(size) + .list(); } @Override Fisheye: Tag dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/ResponseRatingDAO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20150511.sql =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20150511.sql (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20150511.sql (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -0,0 +1,19 @@ +-- 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- Set max and min rates limits +ALTER TABLE tl_laqa11_content ADD COLUMN minimum_rates integer DEFAULT 0; +ALTER TABLE tl_laqa11_content ADD COLUMN maximum_rates integer DEFAULT 0; + +ALTER TABLE tl_laqa11_que_content ADD COLUMN min_words_limit integer DEFAULT 0; + +UPDATE lams_tool SET tool_version='20150511' WHERE tool_signature='laqa11'; + +----------------------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 Fisheye: Tag dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/AverageRatingDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java (.../QaConditionDTO.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java (.../QaConditionDTO.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -38,7 +38,7 @@ super(condition, toolActivityUIID); for (QaQueContent question : condition.getQuestions()) { QaQueContent questionCopy = new QaQueContent(question.getQuestion(), question.getDisplayOrder(), null, - question.isRequired(), null); + question.isRequired(), question.getMinWordsLimit(), null); getQuestions().add(questionCopy); } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaGeneralAuthoringDTO.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaGeneralAuthoringDTO.java (.../QaGeneralAuthoringDTO.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaGeneralAuthoringDTO.java (.../QaGeneralAuthoringDTO.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -48,6 +48,8 @@ protected String reflectionSubject; protected Boolean allowRichEditor; protected Boolean useSelectLeaderToolOuput; + protected int maximumRates; + protected int minimumRates; protected String httpSessionID; @@ -336,5 +338,27 @@ public void setUseSelectLeaderToolOuput(Boolean useSelectLeaderToolOuput) { this.useSelectLeaderToolOuput = useSelectLeaderToolOuput; } + + /** + * @return + */ + public int getMaximumRates() { + return maximumRates; + } + public void setMaximumRates(int maximumRates) { + this.maximumRates = maximumRates; + } + + /** + * @return + */ + public int getMinimumRates() { + return minimumRates; + } + + public void setMinimumRates(int minimumRates) { + this.minimumRates = minimumRates; + } + } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaMonitoredUserDTO.java =================================================================== diff -u -r91f0740e75daa643981b757e49d1ed2ed7f0a528 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaMonitoredUserDTO.java (.../QaMonitoredUserDTO.java) (revision 91f0740e75daa643981b757e49d1ed2ed7f0a528) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaMonitoredUserDTO.java (.../QaMonitoredUserDTO.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -59,10 +59,6 @@ private String questionUid; private String visible; - - private String averageRating; - - private String numberOfVotes; private Map usersAttempts; @@ -230,38 +226,8 @@ public void setVisible(String visible) { this.visible = visible; } - - /** - * @return Returns the averageRating. - */ - public String getAverageRating() { - return averageRating; - } /** - * @param averageRating - * The averageRating to set. - */ - public void setAverageRating(String averageRating) { - this.averageRating = averageRating; - } - - /** - * @return Returns the numberOfVotes. - */ - public String getNumberOfVotes() { - return numberOfVotes; - } - - /** - * @param numberOfVotes - * The numberOfVotes to set. - */ - public void setNumberOfVotes(String numberOfVotes) { - this.numberOfVotes = numberOfVotes; - } - - /** * @return Returns the attemptTime. */ public Date getAttemptTime() { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java (.../QaQuestionDTO.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java (.../QaQuestionDTO.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -36,12 +36,14 @@ private String displayOrder; private String feedback; private boolean required; + private int minWordsLimit; public QaQuestionDTO(QaQueContent que) { this.question = que.getQuestion(); this.displayOrder = new Integer(que.getDisplayOrder()).toString(); this.feedback = que.getFeedback() != null ? que.getFeedback() : " "; this.required = que.isRequired(); + this.minWordsLimit = que.getMinWordsLimit(); this.uid = que.getUid(); } @@ -50,6 +52,7 @@ this.displayOrder = displayOrder; this.feedback = feedback; this.required = required; + this.minWordsLimit = minWordsLimit; } public int compareTo(Object o) { @@ -136,8 +139,23 @@ public void setRequired(boolean required) { this.required = required; } + + /** + * @return minWordsLimit + */ + public int getMinWordsLimit() { + return minWordsLimit; + } + /** + * @param minWordsLimit + * minWordsLimit + */ + public void setMinWordsLimit(int minWordsLimit) { + this.minWordsLimit = minWordsLimit; + } + @Override public boolean equals(Object o) { if (o instanceof QaQuestionDTO) { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml =================================================================== diff -u -r4d139bddc3cdd41d32d9f3033f2100c711d8c0c5 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml (.../qaApplicationContext.xml) (revision 4d139bddc3cdd41d32d9f3033f2100c711d8c0c5) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml (.../qaApplicationContext.xml) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -49,10 +49,6 @@ - - - - @@ -78,7 +74,6 @@ - @@ -88,6 +83,7 @@ + @@ -109,7 +105,6 @@ PROPAGATION_REQUIRED,-QaApplicationException PROPAGATION_REQUIRED,-QaApplicationException PROPAGATION_REQUIRED,-QaApplicationException - PROPAGATION_REQUIRED,-QaApplicationException Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java =================================================================== diff -u -r890f666ec88ba3ffd1679ac0d19243a947f9d940 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 890f666ec88ba3ffd1679ac0d19243a947f9d940) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -30,6 +30,7 @@ import java.util.SortedSet; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.rating.ToolRatingManager; import org.lamsfoundation.lams.tool.IToolVO; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; @@ -41,7 +42,6 @@ import org.lamsfoundation.lams.tool.qa.QaSession; import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.QaWizardCategory; -import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO; import org.lamsfoundation.lams.tool.qa.dto.GroupDTO; import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.dto.ReflectionDTO; @@ -53,7 +53,7 @@ * * @author Ozgur Demirtas */ -public interface IQaService { +public interface IQaService extends ToolRatingManager { /** * @param user @@ -112,11 +112,7 @@ int page, int size, int sorting); int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId); - - Map getAverageRatingDTOByQuestionAndSession(Long questionUid, Long qaSessionId); - Map getAverageRatingDTOByUserAndContentId(Long userUid, Long contentId); - /** * Creates or updates response with answer submitted by user. * @@ -322,10 +318,6 @@ */ String getLearnerContentFolder(Long toolSessionId, Long userId); - AverageRatingDTO rateResponse(Long responseId, Long userId, Long toolSessionID, float rating); - - AverageRatingDTO getAverageRatingDTOByResponse(Long responseId); - /** * Return reflection data for all sessions. * Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java (.../QaImportContentVersionFilter.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java (.../QaImportContentVersionFilter.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -63,4 +63,14 @@ this.removeField(QaContent.class, "contentLocked"); this.removeField(QaContent.class, "synchInMonitor"); } + + /** + * Import 20140822 version content to 20150511 version tool server. + */ + public void up20140822To20150511() { + this.addField(QaContent.class, "minimumRates", 0); + this.addField(QaContent.class, "maximumRates", 0); + + this.addField(QaQueContent.class, "minWordsLimit", 0); + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== diff -u -racf48dfa2651bb60b7ea02898d804d79e444aa73 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision acf48dfa2651bb60b7ea02898d804d79e444aa73) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -39,6 +39,7 @@ import java.util.TreeMap; import java.util.TreeSet; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; @@ -54,6 +55,9 @@ import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; +import org.lamsfoundation.lams.rating.dto.ItemRatingDTO; +import org.lamsfoundation.lams.rating.model.RatingCriteria; +import org.lamsfoundation.lams.rating.service.IRatingService; import org.lamsfoundation.lams.rest.RestTags; import org.lamsfoundation.lams.rest.ToolRestManager; import org.lamsfoundation.lams.tool.IToolVO; @@ -75,16 +79,13 @@ import org.lamsfoundation.lams.tool.qa.QaSession; import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.QaWizardCategory; -import org.lamsfoundation.lams.tool.qa.ResponseRating; import org.lamsfoundation.lams.tool.qa.dao.IQaConfigItemDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaContentDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaQueUsrDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaQuestionDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaSessionDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaWizardDAO; -import org.lamsfoundation.lams.tool.qa.dao.IResponseRatingDAO; -import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO; import org.lamsfoundation.lams.tool.qa.dto.GroupDTO; import org.lamsfoundation.lams.tool.qa.dto.QaMonitoredAnswersDTO; import org.lamsfoundation.lams.tool.qa.dto.QaMonitoredUserDTO; @@ -114,7 +115,7 @@ * @author Ozgur Demirtas */ public class QaServicePOJO implements IQaService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager, ToolRestManager, - QaAppConstants { + QaAppConstants { private static Logger logger = Logger.getLogger(QaServicePOJO.class.getName()); private IQaContentDAO qaDAO; @@ -123,7 +124,6 @@ private IQaSessionDAO qaSessionDAO; private IQaQueUsrDAO qaQueUsrDAO; private IQaUsrRespDAO qaUsrRespDAO; - private IResponseRatingDAO qaResponseRatingDAO; private IToolContentHandler qaToolContentHandler = null; private IUserManagementService userManagementService; @@ -136,6 +136,7 @@ private IQaWizardDAO qaWizardDAO; private ICoreNotebookService coreNotebookService; + private IRatingService ratingService; private IEventNotificationService eventNotificationService; private MessageService messageService; @@ -310,16 +311,6 @@ public int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId) { return qaUsrRespDAO.getCountResponsesBySessionAndQuestion(qaSessionId, questionId, excludeUserId); } - - @Override - public Map getAverageRatingDTOByQuestionAndSession(Long questionUid, Long qaSessionId) { - return qaResponseRatingDAO.getAverageRatingDTOByQuestionAndSession(questionUid, qaSessionId); - } - - @Override - public Map getAverageRatingDTOByUserAndContentId(Long userUid, Long contentId) { - return qaResponseRatingDAO.getAverageRatingDTOByUserAndContentId(userUid, contentId); - } @Override public void updateUserResponse(QaUsrResp resp) { @@ -601,11 +592,6 @@ for (QaSession session : (Set) content.getQaSessions()) { QaQueUsr user = qaQueUsrDAO.getQaUserBySession(userId.longValue(), session.getQaSessionId()); if (user != null) { - List ratings = qaResponseRatingDAO.getRatingsByUser(user.getUid()); - for (ResponseRating rating : ratings) { - qaResponseRatingDAO.removeResponseRating(rating); - } - for (QaUsrResp response : (Set) user.getQaUsrResps()) { qaUsrRespDAO.removeUserResponse(response); } @@ -623,30 +609,6 @@ } @Override - public AverageRatingDTO rateResponse(Long responseId, Long userId, Long toolSessionID, float rating) { - QaQueUsr imageGalleryUser = this.getUserByIdAndSession(userId, toolSessionID); - ResponseRating responseRating = qaResponseRatingDAO.getRatingByResponseAndUser(responseId, userId); - QaUsrResp response = qaUsrRespDAO.getResponseById(responseId); - - // persist ResponseRating changes in DB - if (responseRating == null) { // add - responseRating = new ResponseRating(); - responseRating.setUser(imageGalleryUser); - responseRating.setResponse(response); - } - responseRating.setRating(rating); - qaResponseRatingDAO.saveObject(responseRating); - - // to make available new changes be visible in jsp page - return qaResponseRatingDAO.getAverageRatingDTOByResponse(responseId); - } - - @Override - public AverageRatingDTO getAverageRatingDTOByResponse(Long responseId) { - return qaResponseRatingDAO.getAverageRatingDTOByResponse(responseId); - } - - @Override public List getReflectList(QaContent content, String userID) { // reflection data for all sessions @@ -786,9 +748,6 @@ boolean isLearnerRequest, String sessionId, String userId) { List> listMonitoredAttemptsContainerDTO = new LinkedList>(); - Map mapResponseIdToAverageRating = getAverageRatingDTOByQuestionAndSession(new Long( - questionUid), new Long(sessionId)); - List responses = new ArrayList(); if (!isLearnerRequest) { /* request is for monitoring summary */ @@ -852,22 +811,6 @@ qaMonitoredUserDTO.setQuestionUid(questionUid); qaMonitoredUserDTO.setVisible(new Boolean(response.isVisible()).toString()); - // set averageRating - if (qaContent.isAllowRateAnswers()) { - - AverageRatingDTO averageRating = mapResponseIdToAverageRating.get(response.getResponseId()); - // AverageRatingDTO averageRating = - // qaService.getAverageRatingDTOByResponse(response.getResponseId()); - if (averageRating == null) { - qaMonitoredUserDTO.setAverageRating("0"); - qaMonitoredUserDTO.setNumberOfVotes("0"); - } else { - qaMonitoredUserDTO.setAverageRating(averageRating.getRating()); - qaMonitoredUserDTO.setNumberOfVotes(averageRating.getNumberOfVotes()); - } - - } - qaMonitoredUserDTOs.add(qaMonitoredUserDTO); } } @@ -1090,7 +1033,43 @@ } } + + @Override + public List getRatingCriterias(Long toolContentId) { + return ratingService.getCriteriasByToolContentId(toolContentId); + } + + @Override + public void saveRatingCriterias(HttpServletRequest request, Collection oldCriterias, Long toolContentId) { + ratingService.saveRatingCriterias(request, oldCriterias, toolContentId); + } + + @Override + public boolean isCommentsEnabled(Long toolContentId) { + return ratingService.isCommentsEnabled(toolContentId); + } + + @Override + public ItemRatingDTO getRatingCriteriaDtos(Long contentId, Long itemId, Long userId) { + + LinkedList itemIds = new LinkedList(); + itemIds.add(itemId); + ItemRatingDTO ratingCriteria = getRatingCriteriaDtos(contentId, itemIds, false, userId).get(0); + + return ratingCriteria; + } + + @Override + public List getRatingCriteriaDtos(Long contentId, Collection itemIds, boolean isAllItemResultsRequested, Long userId) { + return ratingService.getRatingCriteriaDtos(contentId, itemIds, isAllItemResultsRequested, userId); + } + + @Override + public int getCountItemsRatedByUser(Long toolContentId, Integer userId) { + return ratingService.getCountItemsRatedByUser(toolContentId, userId); + } + /** * ToolSessionManager CONTRACT */ @@ -1159,37 +1138,12 @@ } /** - * @return Returns the qaQuestionDAO. - */ - public IQaQuestionDAO getQaQuestionDAO() { - return qaQuestionDAO; - } - - /** - * @return Returns the qaQueUsrDAO. - */ - public IQaQueUsrDAO getQaQueUsrDAO() { - return qaQueUsrDAO; - } - - /** - * @return Returns the toolService. - */ - public ILamsToolService getToolService() { - return toolService; - } - - /** * @return Returns the userManagementService. */ public IUserManagementService getUserManagementService() { return userManagementService; } - public ILearnerService getLearnerService() { - return learnerService; - } - public void setLearnerService(ILearnerService learnerService) { this.learnerService = learnerService; } @@ -1214,38 +1168,13 @@ this.qaUsrRespDAO = qaUsrRespDAO; } - public void setQaResponseRatingDAO(IResponseRatingDAO responseRatingDAO) { - this.qaResponseRatingDAO = responseRatingDAO; - } - /** * @return Returns the qaDAO. */ public IQaContentDAO getQaDAO() { return qaDAO; } - /** - * @return Returns the qaSessionDAO. - */ - public IQaSessionDAO getQaSessionDAO() { - return qaSessionDAO; - } - - /** - * @return Returns the qaUsrRespDAO. - */ - public IQaUsrRespDAO getQaUsrRespDAO() { - return qaUsrRespDAO; - } - - /** - * @return Returns the IResponseRatingDAO. - */ - public IResponseRatingDAO getQaResponseRatingDAO() { - return qaResponseRatingDAO; - } - public void setUserManagementService(IUserManagementService userManagementService) { this.userManagementService = userManagementService; } @@ -1255,13 +1184,6 @@ } /** - * @return Returns the qaToolContentHandler. - */ - public IToolContentHandler getQaToolContentHandler() { - return qaToolContentHandler; - } - - /** * @param qaToolContentHandler * The qaToolContentHandler to set. */ @@ -1375,6 +1297,10 @@ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { this.coreNotebookService = coreNotebookService; } + + public void setRatingService(IRatingService ratingService) { + this.ratingService = ratingService; + } public void setEventNotificationService(IEventNotificationService eventNotificationService) { this.eventNotificationService = eventNotificationService; @@ -1528,6 +1454,8 @@ qa.setLockWhenFinished(JsonUtil.opt(toolContentJSON, RestTags.LOCK_WHEN_FINISHED, Boolean.FALSE)); qa.setAllowRichEditor(JsonUtil.opt(toolContentJSON, RestTags.ALLOW_RICH_TEXT_EDITOR, Boolean.FALSE)); qa.setUseSelectLeaderToolOuput(JsonUtil.opt(toolContentJSON, RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, Boolean.FALSE)); + qa.setMinimumRates(JsonUtil.opt(toolContentJSON, RestTags.MINIMUM_RATES, 0)); + qa.setMaximumRates(JsonUtil.opt(toolContentJSON, RestTags.MAXIMUM_RATES, 0)); qa.setShowOtherAnswers(JsonUtil.opt(toolContentJSON, "showOtherAnswers", Boolean.TRUE)); qa.setUsernameVisible(JsonUtil.opt(toolContentJSON, "usernameVisible", Boolean.FALSE)); qa.setAllowRateAnswers(JsonUtil.opt(toolContentJSON, "allowRateAnswers", Boolean.FALSE)); @@ -1550,7 +1478,8 @@ QaQueContent question = new QaQueContent(questionData.getString(RestTags.QUESTION_TEXT), questionData.getInt(RestTags.DISPLAY_ORDER), JsonUtil.opt(questionData,"feedback",(String)null), - JsonUtil.opt(questionData, "required", Boolean.FALSE), qa ); + JsonUtil.opt(questionData, "required", Boolean.FALSE), + questionData.getInt("minWordsLimit"), qa ); saveOrUpdateQuestion(question); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java =================================================================== diff -u -r4d139bddc3cdd41d32d9f3033f2100c711d8c0c5 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java (.../QaUtils.java) (revision 4d139bddc3cdd41d32d9f3033f2100c711d8c0c5) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java (.../QaUtils.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -32,6 +32,7 @@ import org.lamsfoundation.lams.tool.qa.dto.QaGeneralAuthoringDTO; import org.lamsfoundation.lams.tool.qa.service.IQaService; import org.lamsfoundation.lams.tool.qa.web.form.QaAuthoringForm; +import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.util.AttributeNames; /** @@ -71,6 +72,16 @@ String lockWhenFinished = request.getParameter("lockWhenFinished"); qaAuthoringForm.setLockWhenFinished(lockWhenFinished); qaGeneralAuthoringDTO.setLockWhenFinished(lockWhenFinished); + + int minimumRates = WebUtil.readIntParam(request, MINIMUM_RATES, true) == null ? 0 : WebUtil.readIntParam( + request, MINIMUM_RATES); + qaAuthoringForm.setMinimumRates(minimumRates); + qaGeneralAuthoringDTO.setMinimumRates(minimumRates); + + int maximumRates = WebUtil.readIntParam(request, MAXIMUM_RATES, true) == null ? 0 : WebUtil.readIntParam( + request, MAXIMUM_RATES); + qaAuthoringForm.setMaximumRates(maximumRates); + qaGeneralAuthoringDTO.setMaximumRates(maximumRates); String reflect = request.getParameter(REFLECT); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java =================================================================== diff -u -r4d139bddc3cdd41d32d9f3033f2100c711d8c0c5 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 4d139bddc3cdd41d32d9f3033f2100c711d8c0c5) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -46,6 +46,7 @@ import org.lamsfoundation.lams.tool.qa.util.QaQuestionContentDTOComparator; import org.lamsfoundation.lams.tool.qa.web.form.QaAuthoringForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -56,8 +57,6 @@ */ public class AuthoringUtil implements QaAppConstants { - - protected static List reorderUpdateQuestionDTOs(List questionDTOs, QaQuestionDTO qaQuestionContentDTONew, String editableQuestionIndex) { @@ -74,19 +73,22 @@ String displayOrder = qaQuestionDTO.getDisplayOrder(); String feedback = qaQuestionDTO.getFeedback(); boolean required = qaQuestionDTO.isRequired(); + int minWordsLimit = qaQuestionDTO.getMinWordsLimit(); if (displayOrder.equals(editableQuestionIndex)) { qaQuestionDTO.setQuestion(qaQuestionContentDTONew.getQuestion()); qaQuestionDTO.setDisplayOrder(qaQuestionContentDTONew.getDisplayOrder()); qaQuestionDTO.setFeedback(qaQuestionContentDTONew.getFeedback()); - qaQuestionDTO.setRequired(required); + qaQuestionDTO.setRequired(qaQuestionContentDTONew.isRequired()); + qaQuestionDTO.setMinWordsLimit(qaQuestionContentDTONew.getMinWordsLimit()); listFinalQuestionDTO.add(qaQuestionDTO); } else { qaQuestionDTO.setQuestion(question); qaQuestionDTO.setDisplayOrder(displayOrder); qaQuestionDTO.setFeedback(feedback); qaQuestionDTO.setRequired(required); + qaQuestionDTO.setMinWordsLimit(minWordsLimit); listFinalQuestionDTO.add(qaQuestionDTO); @@ -95,165 +97,6 @@ return listFinalQuestionDTO; } - public static QaContent saveOrUpdateQaContent(List questionDTOs, IQaService qaService, - HttpServletRequest request, QaContent qaContent, String strToolContentID, Set conditions) { - UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - String usernameVisible = request.getParameter(QaAppConstants.USERNAME_VISIBLE); - String allowRateQuestions = request.getParameter(QaAppConstants.ALLOW_RATE_ANSWERS); - String notifyTeachersOnResponseSubmit = request.getParameter(QaAppConstants.NOTIFY_TEACHERS_ON_RESPONSE_SUBMIT); - String showOtherAnswers = request.getParameter("showOtherAnswers"); - String questionsSequenced = request.getParameter(QaAppConstants.QUESTIONS_SEQUENCED); - String lockWhenFinished = request.getParameter("lockWhenFinished"); - String allowRichEditor = request.getParameter("allowRichEditor"); - String useSelectLeaderToolOuput = request.getParameter("useSelectLeaderToolOuput"); - String reflect = request.getParameter(QaAppConstants.REFLECT); - String reflectionSubject = request.getParameter(QaAppConstants.REFLECTION_SUBJECT); - - boolean questionsSequencedBoolean = false; - boolean lockWhenFinishedBoolean = false; - boolean usernameVisibleBoolean = false; - boolean allowRateQuestionsBoolean = false; - boolean notifyTeachersOnResponseSubmitBoolean = false; - boolean showOtherAnswersBoolean = false; - boolean reflectBoolean = false; - boolean allowRichEditorBoolean = false; - boolean useSelectLeaderToolOuputBoolean = false; - - if (questionsSequenced != null && questionsSequenced.equalsIgnoreCase("1")) { - questionsSequencedBoolean = true; - } - - if (lockWhenFinished != null && lockWhenFinished.equalsIgnoreCase("1")) { - lockWhenFinishedBoolean = true; - } - - if (usernameVisible != null && usernameVisible.equalsIgnoreCase("1")) { - usernameVisibleBoolean = true; - } - - if (allowRateQuestions != null && allowRateQuestions.equalsIgnoreCase("1")) { - allowRateQuestionsBoolean = true; - } - - if (notifyTeachersOnResponseSubmit != null && notifyTeachersOnResponseSubmit.equalsIgnoreCase("1")) { - notifyTeachersOnResponseSubmitBoolean = true; - } - - if (showOtherAnswers != null && showOtherAnswers.equalsIgnoreCase("1")) { - showOtherAnswersBoolean = true; - } - - if (allowRichEditor != null && allowRichEditor.equalsIgnoreCase("1")) { - allowRichEditorBoolean = true; - } - - if (useSelectLeaderToolOuput != null && useSelectLeaderToolOuput.equalsIgnoreCase("1")) { - useSelectLeaderToolOuputBoolean = true; - } - - if (reflect != null && reflect.equalsIgnoreCase("1")) { - reflectBoolean = true; - } - long userId = 0; - if (toolUser != null) { - userId = toolUser.getUserID().longValue(); - } else { - HttpSession ss = SessionManager.getSession(); - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - if (user != null) { - userId = user.getUserID().longValue(); - } else { - userId = 0; - } - } - - boolean newContent = false; - if (qaContent == null) { - qaContent = new QaContent(); - newContent = true; - } - - qaContent.setQaContentId(new Long(strToolContentID)); - qaContent.setTitle(richTextTitle); - qaContent.setInstructions(richTextInstructions); - qaContent.setUpdateDate(new Date(System.currentTimeMillis())); - /** keep updating this one */ - qaContent.setCreatedBy(userId); - /** make sure we are setting the userId from the User object above */ - - qaContent.setUsernameVisible(usernameVisibleBoolean); - qaContent.setAllowRateAnswers(allowRateQuestionsBoolean); - qaContent.setNotifyTeachersOnResponseSubmit(notifyTeachersOnResponseSubmitBoolean); - qaContent.setShowOtherAnswers(showOtherAnswersBoolean); - qaContent.setQuestionsSequenced(questionsSequencedBoolean); - qaContent.setLockWhenFinished(lockWhenFinishedBoolean); - qaContent.setReflect(reflectBoolean); - qaContent.setReflectionSubject(reflectionSubject); - qaContent.setAllowRichEditor(allowRichEditorBoolean); - qaContent.setUseSelectLeaderToolOuput(useSelectLeaderToolOuputBoolean); - - qaContent.setConditions(new TreeSet(new TextSearchConditionComparator())); - if (newContent) { - qaService.createQaContent(qaContent); - } else { - qaService.updateQaContent(qaContent); - } - - qaContent = qaService.getQaContent(new Long(strToolContentID).longValue()); - - for (QaCondition condition : conditions) { - condition.setQuestions(new TreeSet(new QaQueContentComparator())); - for (QaQuestionDTO dto : condition.temporaryQuestionDTOSet) { - for (QaQueContent queContent : (Set) qaContent.getQaQueContents()) { - if (dto.getDisplayOrder().equals(String.valueOf(queContent.getDisplayOrder()))) { - condition.getQuestions().add(queContent); - } - } - } - } - qaContent.setConditions(conditions); - qaService.updateQaContent(qaContent); - - // persist questions - int displayOrder = 0; - for (QaQuestionDTO questionDTO : questionDTOs) { - - String questionText = questionDTO.getQuestion(); - - // skip empty questions - if (questionText.isEmpty()) { - continue; - } - - ++displayOrder; - - QaQueContent question = qaService.getQuestionByUid(questionDTO.getUid()); - - // in case question doesn't exist - if (question == null) { - question = new QaQueContent(questionText, displayOrder, questionDTO.getFeedback(), - questionDTO.isRequired(), qaContent); - qaContent.getQaQueContents().add(question); - question.setQaContent(qaContent); - - // in case question exists already - } else { - - question.setQuestion(questionText); - question.setFeedback(questionDTO.getFeedback()); - question.setDisplayOrder(displayOrder); - question.setRequired(questionDTO.isRequired()); - } - - qaService.saveOrUpdateQuestion(question); - } - - return qaContent; - } - public static boolean checkDuplicateQuestions(List questionDTOs, String newQuestion) { for (QaQuestionDTO questionDTO : questionDTOs) { if (questionDTO.getQuestion() != null && questionDTO.getQuestion().equals(newQuestion)) { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java =================================================================== diff -u -r4d139bddc3cdd41d32d9f3033f2100c711d8c0c5 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (.../LearningUtil.java) (revision 4d139bddc3cdd41d32d9f3033f2100c711d8c0c5) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (.../LearningUtil.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -97,7 +97,7 @@ /** */ - public static void populateAnswers(Map sessionMap, QaContent qaContent, QaQueUsr qaQueUsr, + public static void populateAnswers(Map sessionMap, QaContent qaContent, QaQueUsr user, Map mapQuestions, GeneralLearnerFlowDTO generalLearnerFlowDTO, IQaService qaService) { @@ -110,8 +110,8 @@ Map mapAnswersFromDb = new TreeMap(); for (QaQueContent question : qaContent.getQaQueContents()) { Long questionUid = question.getUid(); - QaUsrResp dbResponse = qaService.getResponseByUserAndQuestion(qaQueUsr.getQueUsrId(), questionUid); - String answer = (dbResponse == null) ? null : dbResponse.getAnswer(); + QaUsrResp response = qaService.getResponseByUserAndQuestion(user.getQueUsrId(), questionUid); + String answer = (response == null) ? null : response.getAnswer(); mapAnswersFromDb.put(String.valueOf(question.getDisplayOrder()), answer); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAction.java =================================================================== diff -u -r4d139bddc3cdd41d32d9f3033f2100c711d8c0c5 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAction.java (.../QaAction.java) (revision 4d139bddc3cdd41d32d9f3033f2100c711d8c0c5) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAction.java (.../QaAction.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -27,6 +27,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -37,6 +38,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -46,6 +48,8 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; +import org.lamsfoundation.lams.rating.model.RatingCriteria; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaCondition; @@ -56,19 +60,27 @@ import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.service.IQaService; import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy; +import org.lamsfoundation.lams.tool.qa.util.QaQueContentComparator; import org.lamsfoundation.lams.tool.qa.util.QaQuestionContentDTOComparator; import org.lamsfoundation.lams.tool.qa.util.QaUtils; import org.lamsfoundation.lams.tool.qa.web.form.QaAuthoringForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; /** + * Q&A Tool's authoring methods. Additionally, there is one more method that initializes authoring and it's located in + * QaStarterAction.java. + * * @author Ozgur Demirtas */ public class QaAction extends LamsDispatchAction implements QaAppConstants { private static Logger logger = Logger.getLogger(QaAction.class.getName()); + + private static IQaService qaService; public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { @@ -82,14 +94,15 @@ HttpServletResponse response) throws IOException, ServletException { QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); String httpSessionID = qaAuthoringForm.getHttpSessionID(); SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); qaAuthoringForm.setContentFolderID(contentFolderID); String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + Long toolContentID = new Long(strToolContentID); List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); @@ -120,7 +133,7 @@ QaAction.logger.debug("errors saved: " + errors); } - QaContent qaContent = qaService.getQaContent(new Long(strToolContentID).longValue()); + QaContent qaContent = qaService.getQaContent(toolContentID); if (errors.isEmpty()) { ToolAccessMode mode = getAccessMode(request); request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); @@ -145,14 +158,17 @@ qaService.removeQuestion(removeableQuestion); } } + + // ************************* Handle rating criterias ******************* + List oldCriterias = (List) sessionMap + .get(AttributeNames.ATTR_RATING_CRITERIAS); + qaService.saveRatingCriterias(request, oldCriterias, toolContentID); + // store content SortedSet conditionSet = (SortedSet) sessionMap .get(QaAppConstants.ATTR_CONDITION_SET); + qaContent = saveOrUpdateQaContent(questionDTOs, request, qaContent, toolContentID, conditionSet); - // store content - qaContent = AuthoringUtil.saveOrUpdateQaContent(questionDTOs, qaService, request, qaContent, - strToolContentID, conditionSet); - //reOrganizeDisplayOrder List sortedQuestions = qaService.getAllQuestionEntriesSorted(qaContent.getUid().longValue()); Iterator iter = sortedQuestions.iterator(); @@ -197,6 +213,170 @@ return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); } + private QaContent saveOrUpdateQaContent(List questionDTOs, HttpServletRequest request, + QaContent qaContent, Long toolContentId, Set conditions) { + UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + String usernameVisible = request.getParameter(QaAppConstants.USERNAME_VISIBLE); + String allowRateQuestions = request.getParameter(QaAppConstants.ALLOW_RATE_ANSWERS); + String notifyTeachersOnResponseSubmit = request.getParameter(QaAppConstants.NOTIFY_TEACHERS_ON_RESPONSE_SUBMIT); + String showOtherAnswers = request.getParameter("showOtherAnswers"); + String questionsSequenced = request.getParameter(QaAppConstants.QUESTIONS_SEQUENCED); + String lockWhenFinished = request.getParameter("lockWhenFinished"); + String allowRichEditor = request.getParameter("allowRichEditor"); + String useSelectLeaderToolOuput = request.getParameter("useSelectLeaderToolOuput"); + String reflect = request.getParameter(QaAppConstants.REFLECT); + String reflectionSubject = request.getParameter(QaAppConstants.REFLECTION_SUBJECT); + int minimumRates = WebUtil.readIntParam(request, "minimumRates"); + int maximumRates = WebUtil.readIntParam(request, "maximumRates"); + + boolean questionsSequencedBoolean = false; + boolean lockWhenFinishedBoolean = false; + boolean usernameVisibleBoolean = false; + boolean allowRateQuestionsBoolean = false; + boolean notifyTeachersOnResponseSubmitBoolean = false; + boolean showOtherAnswersBoolean = false; + boolean reflectBoolean = false; + boolean allowRichEditorBoolean = false; + boolean useSelectLeaderToolOuputBoolean = false; + + if (questionsSequenced != null && questionsSequenced.equalsIgnoreCase("1")) { + questionsSequencedBoolean = true; + } + + if (lockWhenFinished != null && lockWhenFinished.equalsIgnoreCase("1")) { + lockWhenFinishedBoolean = true; + } + + if (usernameVisible != null && usernameVisible.equalsIgnoreCase("1")) { + usernameVisibleBoolean = true; + } + + if (showOtherAnswers != null && showOtherAnswers.equalsIgnoreCase("1")) { + showOtherAnswersBoolean = true; + } + + if (allowRateQuestions != null && allowRateQuestions.equalsIgnoreCase("1") && showOtherAnswersBoolean) { + allowRateQuestionsBoolean = true; + } + + if (notifyTeachersOnResponseSubmit != null && notifyTeachersOnResponseSubmit.equalsIgnoreCase("1")) { + notifyTeachersOnResponseSubmitBoolean = true; + } + + if (allowRichEditor != null && allowRichEditor.equalsIgnoreCase("1")) { + allowRichEditorBoolean = true; + } + + if (useSelectLeaderToolOuput != null && useSelectLeaderToolOuput.equalsIgnoreCase("1")) { + useSelectLeaderToolOuputBoolean = true; + } + + if (reflect != null && reflect.equalsIgnoreCase("1")) { + reflectBoolean = true; + } + long userId = 0; + if (toolUser != null) { + userId = toolUser.getUserID().longValue(); + } else { + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (user != null) { + userId = user.getUserID().longValue(); + } else { + userId = 0; + } + } + + boolean newContent = false; + if (qaContent == null) { + qaContent = new QaContent(); + newContent = true; + } + + qaContent.setQaContentId(toolContentId); + qaContent.setTitle(richTextTitle); + qaContent.setInstructions(richTextInstructions); + qaContent.setUpdateDate(new Date(System.currentTimeMillis())); + /** keep updating this one */ + qaContent.setCreatedBy(userId); + /** make sure we are setting the userId from the User object above */ + + qaContent.setUsernameVisible(usernameVisibleBoolean); + qaContent.setAllowRateAnswers(allowRateQuestionsBoolean); + qaContent.setNotifyTeachersOnResponseSubmit(notifyTeachersOnResponseSubmitBoolean); + qaContent.setShowOtherAnswers(showOtherAnswersBoolean); + qaContent.setQuestionsSequenced(questionsSequencedBoolean); + qaContent.setLockWhenFinished(lockWhenFinishedBoolean); + qaContent.setReflect(reflectBoolean); + qaContent.setReflectionSubject(reflectionSubject); + qaContent.setAllowRichEditor(allowRichEditorBoolean); + qaContent.setUseSelectLeaderToolOuput(useSelectLeaderToolOuputBoolean); + qaContent.setMinimumRates(minimumRates); + qaContent.setMaximumRates(maximumRates); + + qaContent.setConditions(new TreeSet(new TextSearchConditionComparator())); + if (newContent) { + qaService.createQaContent(qaContent); + } else { + qaService.updateQaContent(qaContent); + } + + qaContent = qaService.getQaContent(toolContentId); + + for (QaCondition condition : conditions) { + condition.setQuestions(new TreeSet(new QaQueContentComparator())); + for (QaQuestionDTO dto : condition.temporaryQuestionDTOSet) { + for (QaQueContent queContent : (Set) qaContent.getQaQueContents()) { + if (dto.getDisplayOrder().equals(String.valueOf(queContent.getDisplayOrder()))) { + condition.getQuestions().add(queContent); + } + } + } + } + qaContent.setConditions(conditions); + qaService.updateQaContent(qaContent); + + // persist questions + int displayOrder = 0; + for (QaQuestionDTO questionDTO : questionDTOs) { + + String questionText = questionDTO.getQuestion(); + + // skip empty questions + if (questionText.isEmpty()) { + continue; + } + + ++displayOrder; + + QaQueContent question = qaService.getQuestionByUid(questionDTO.getUid()); + + // in case question doesn't exist + if (question == null) { + question = new QaQueContent(questionText, displayOrder, questionDTO.getFeedback(), + questionDTO.isRequired(), questionDTO.getMinWordsLimit(), qaContent); + qaContent.getQaQueContents().add(question); + question.setQaContent(qaContent); + + // in case question exists already + } else { + + question.setQuestion(questionText); + question.setFeedback(questionDTO.getFeedback()); + question.setDisplayOrder(displayOrder); + question.setRequired(questionDTO.isRequired()); + question.setMinWordsLimit(questionDTO.getMinWordsLimit()); + } + + qaService.saveOrUpdateQuestion(question); + } + + return qaContent; + } + /** * saveSingleQuestion */ @@ -233,6 +413,7 @@ if (required != null && required.equalsIgnoreCase("1")) { requiredBoolean = true; } + int minWordsLimit = WebUtil.readIntParam(request, "minWordsLimit"); if (newQuestion != null && newQuestion.length() > 0) { if (editQuestionBoxRequest != null && editQuestionBoxRequest.equals("false")) { @@ -258,6 +439,7 @@ qaQuestionDTO.setFeedback(feedback); qaQuestionDTO.setDisplayOrder(editableQuestionIndex); qaQuestionDTO.setRequired(requiredBoolean); + qaQuestionDTO.setMinWordsLimit(minWordsLimit); questionDTOs = AuthoringUtil.reorderUpdateQuestionDTOs(questionDTOs, qaQuestionDTO, editableQuestionIndex); @@ -285,6 +467,7 @@ qaQuestionDTO.setFeedback(feedback); qaQuestionDTO.setDisplayOrder(editableQuestionIndex); qaQuestionDTO.setRequired(requiredBoolean); + qaQuestionDTO.setMinWordsLimit(minWordsLimit); questionDTOs = AuthoringUtil.reorderUpdateQuestionDTOs(questionDTOs, qaQuestionDTO, editableQuestionIndex); @@ -471,21 +654,23 @@ qaAuthoringForm.setEditableQuestionIndex(questionIndex); - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); + List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); String editableQuestion = ""; String editableFeedback = ""; boolean requiredBoolean = false; - Iterator iter = questionDTOs.iterator(); + int minWordsLimit = 0; + Iterator iter = questionDTOs.iterator(); while (iter.hasNext()) { - QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) iter.next(); + QaQuestionDTO qaQuestionDTO = iter.next(); String displayOrder = qaQuestionDTO.getDisplayOrder(); if (displayOrder != null && !displayOrder.equals("")) { if (displayOrder.equals(questionIndex)) { editableFeedback = qaQuestionDTO.getFeedback(); editableQuestion = qaQuestionDTO.getQuestion(); requiredBoolean = qaQuestionDTO.isRequired(); + minWordsLimit = qaQuestionDTO.getMinWordsLimit(); break; } @@ -514,7 +699,7 @@ qaGeneralAuthoringDTO.setEditableQuestionText(editableQuestion); qaGeneralAuthoringDTO.setEditableQuestionFeedback(editableFeedback); qaAuthoringForm.setRequired(requiredBoolean); - qaAuthoringForm.setFeedback(editableFeedback); + qaAuthoringForm.setMinWordsLimit(minWordsLimit); request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); @@ -811,6 +996,7 @@ String question = qaQuestionDTO.getQuestion(); String feedback = qaQuestionDTO.getFeedback(); boolean required = qaQuestionDTO.isRequired(); + int minWordsLimit = qaQuestionDTO.getMinWordsLimit(); if (question != null && !question.equals("")) { ++queIndex; @@ -819,6 +1005,7 @@ qaQuestionDTO.setDisplayOrder(new Integer(queIndex).toString()); qaQuestionDTO.setFeedback(feedback); qaQuestionDTO.setRequired(required); + qaQuestionDTO.setMinWordsLimit(minWordsLimit); listFinalQuestionDTO.add(qaQuestionDTO); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java =================================================================== diff -u -r8c6cfff65f5e35a218d2cf03652560f665f84ecb -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision 8c6cfff65f5e35a218d2cf03652560f665f84ecb) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -28,6 +28,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -53,14 +54,16 @@ import org.apache.tomcat.util.json.JSONObject; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.rating.dto.ItemRatingCriteriaDTO; +import org.lamsfoundation.lams.rating.dto.ItemRatingDTO; +import org.lamsfoundation.lams.rating.dto.RatingCommentDTO; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaSession; import org.lamsfoundation.lams.tool.qa.QaUsrResp; -import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO; import org.lamsfoundation.lams.tool.qa.dto.GeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.service.IQaService; @@ -332,6 +335,7 @@ String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); String userID = request.getParameter("userID"); + QaQueUsr user = qaService.getUserByIdAndSession(new Long(userID), new Long(toolSessionID)); QaSession qaSession = QaLearningAction.qaService.getSessionById(new Long(toolSessionID).longValue()); QaContent qaContent = qaSession.getQaContent(); @@ -348,73 +352,62 @@ GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); String httpSessionID = qaLearningForm.getHttpSessionID(); generalLearnerFlowDTO.setHttpSessionID(httpSessionID); - String isUserNamesVisibleBoolean = generalLearnerFlowDTO.getUserNameVisible(); - boolean isUserNamesVisible = new Boolean(isUserNamesVisibleBoolean).booleanValue(); + + /** Set up the data for the view all answers screen */ + QaLearningAction.refreshSummaryData(request, qaContent, QaLearningAction.qaService, httpSessionID, user, + generalLearnerFlowDTO); - return prepareViewAllAnswers(mapping, request, qaLearningForm, toolSessionID, userID, qaSession, qaContent, - generalLearnerFlowDTO, isUserNamesVisible); + generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); + generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(false).toString()); - } else if (qaContent.isReflect()) { - return forwardtoReflection(mapping, request, qaContent, toolSessionID, userID, qaLearningForm); + generalLearnerFlowDTO.setReflection(new Boolean(qaContent.isReflect()).toString()); - } else { - return endLearning(mapping, qaLearningForm, request, response); - } - } + qaLearningForm.resetAll(); - /** Set up the data for the view all answers screen */ - private ActionForward prepareViewAllAnswers(ActionMapping mapping, HttpServletRequest request, - QaLearningForm qaLearningForm, String toolSessionID, String userID, QaSession qaSession, - QaContent qaContent, GeneralLearnerFlowDTO generalLearnerFlowDTO, boolean isUserNamesVisible) { + boolean lockWhenFinished = qaContent.isLockWhenFinished(); + generalLearnerFlowDTO.setLockWhenFinished(new Boolean(lockWhenFinished).toString()); - QaLearningAction.refreshSummaryData(request, qaContent, QaLearningAction.qaService, isUserNamesVisible, - toolSessionID, userID, generalLearnerFlowDTO); + boolean useSelectLeaderToolOuput = qaContent.isUseSelectLeaderToolOuput(); + generalLearnerFlowDTO.setUseSelectLeaderToolOuput(new Boolean(useSelectLeaderToolOuput).toString()); - generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); - generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(false).toString()); + boolean allowRichEditor = qaContent.isAllowRichEditor(); + generalLearnerFlowDTO.setAllowRichEditor(new Boolean(allowRichEditor).toString()); - generalLearnerFlowDTO.setReflection(new Boolean(qaContent.isReflect()).toString()); + generalLearnerFlowDTO.setAllowRateAnswers(new Boolean(qaContent.isAllowRateAnswers()).toString()); - qaLearningForm.resetAll(); + generalLearnerFlowDTO.setUserUid(qaQueUsr.getQueUsrId().toString()); - boolean lockWhenFinished = qaContent.isLockWhenFinished(); - generalLearnerFlowDTO.setLockWhenFinished(new Boolean(lockWhenFinished).toString()); + int sessionUserCount = 0; + if (qaSession.getQaQueUsers() != null) { + sessionUserCount = qaSession.getQaQueUsers().size(); + } - boolean useSelectLeaderToolOuput = qaContent.isUseSelectLeaderToolOuput(); - generalLearnerFlowDTO.setUseSelectLeaderToolOuput(new Boolean(useSelectLeaderToolOuput).toString()); - - boolean allowRichEditor = qaContent.isAllowRichEditor(); - generalLearnerFlowDTO.setAllowRichEditor(new Boolean(allowRichEditor).toString()); + if (sessionUserCount > 1) { + // there are multiple user responses + generalLearnerFlowDTO.setExistMultipleUserResponses(new Boolean(true).toString()); + } - generalLearnerFlowDTO.setAllowRateAnswers(new Boolean(qaContent.isAllowRateAnswers()).toString()); + boolean usernameVisible = qaContent.isUsernameVisible(); + generalLearnerFlowDTO.setUserNameVisible(new Boolean(usernameVisible).toString()); - QaQueUsr qaQueUsr = getCurrentUser(toolSessionID); - generalLearnerFlowDTO.setUserUid(qaQueUsr.getQueUsrId().toString()); + NotebookEntry notebookEntry = QaLearningAction.qaService.getEntry(new Long(toolSessionID), + CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(userID)); - int sessionUserCount = 0; - if (qaSession.getQaQueUsers() != null) { - sessionUserCount = qaSession.getQaQueUsers().size(); - } + if (notebookEntry != null) { + // String notebookEntryPresentable=QaUtils.replaceNewLines(notebookEntry.getEntry()); + String notebookEntryPresentable = notebookEntry.getEntry(); + qaLearningForm.setEntryText(notebookEntryPresentable); + } - if (sessionUserCount > 1) { - // there are multiple user responses - generalLearnerFlowDTO.setExistMultipleUserResponses(new Boolean(true).toString()); - } + request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + return (mapping.findForward(QaAppConstants.INDIVIDUAL_LEARNER_REPORT)); - boolean usernameVisible = qaContent.isUsernameVisible(); - generalLearnerFlowDTO.setUserNameVisible(new Boolean(usernameVisible).toString()); + } else if (qaContent.isReflect()) { + return forwardtoReflection(mapping, request, qaContent, toolSessionID, userID, qaLearningForm); - NotebookEntry notebookEntry = QaLearningAction.qaService.getEntry(new Long(toolSessionID), - CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(userID)); - - if (notebookEntry != null) { - // String notebookEntryPresentable=QaUtils.replaceNewLines(notebookEntry.getEntry()); - String notebookEntryPresentable = notebookEntry.getEntry(); - qaLearningForm.setEntryText(notebookEntryPresentable); + } else { + return endLearning(mapping, qaLearningForm, request, response); } - - request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - return (mapping.findForward(QaAppConstants.INDIVIDUAL_LEARNER_REPORT)); } /** @@ -437,16 +430,14 @@ qaLearningForm.setToolSessionID(toolSessionID); String userID = request.getParameter("userID"); + QaQueUsr user = qaService.getUserByIdAndSession(new Long(userID), new Long(toolSessionID)); QaSession qaSession = QaLearningAction.qaService.getSessionById(new Long(toolSessionID).longValue()); QaContent qaContent = qaSession.getQaContent(); GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - String isUserNamesVisibleBoolean = generalLearnerFlowDTO.getUserNameVisible(); - boolean isUserNamesVisible = new Boolean(isUserNamesVisibleBoolean).booleanValue(); - String httpSessionID = qaLearningForm.getHttpSessionID(); qaLearningForm.setHttpSessionID(httpSessionID); @@ -456,8 +447,8 @@ qaLearningForm.resetUserActions(); qaLearningForm.setSubmitAnswersContent(null); - QaLearningAction.refreshSummaryData(request, qaContent, QaLearningAction.qaService, isUserNamesVisible, - toolSessionID, userID, generalLearnerFlowDTO); + QaLearningAction.refreshSummaryData(request, qaContent, QaLearningAction.qaService, httpSessionID, user, + generalLearnerFlowDTO); generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(false).toString()); @@ -672,40 +663,6 @@ } /** - * Rates answers submitted by other learners. - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws JSONException - * @throws IOException - * @throws ServletException - * @throws ToolException - */ - public ActionForward rateResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws JSONException, IOException { - - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - - float rating = Float.parseFloat(request.getParameter("rate")); - Long responseId = WebUtil.readLongParam(request, "idBox"); - Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); - UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - Long userId = new Long(user.getUserID().intValue()); - - AverageRatingDTO averageRatingDTO = qaService.rateResponse(responseId, userId, toolSessionID, rating); - - JSONObject JSONObject = new JSONObject(); - JSONObject.put("averageRating", averageRatingDTO.getRating()); - JSONObject.put("numberOfVotes", averageRatingDTO.getNumberOfVotes()); - response.setContentType("application/json;charset=utf-8"); - response.getWriter().print(JSONObject); - return null; - } - - /** * finishes the user's tool activity * * @param request @@ -798,11 +755,9 @@ generalLearnerFlowDTO.setNotebookEntry(entryText); generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); - Boolean isUserNamesVisibleBoolean = new Boolean(qaContent.isUsernameVisible()); - boolean isUserNamesVisible = isUserNamesVisibleBoolean.booleanValue(); - QaLearningAction.refreshSummaryData(request, qaContent, QaLearningAction.qaService, isUserNamesVisible, - toolSessionID, userID, generalLearnerFlowDTO); + QaLearningAction.refreshSummaryData(request, qaContent, QaLearningAction.qaService, httpSessionID, qaQueUsr, + generalLearnerFlowDTO); int sessionUserCount = 0; if (qaSession.getQaQueUsers() != null) { @@ -944,46 +899,58 @@ * User id is needed if isUserNamesVisible is false && learnerRequest is * true, as it is required to work out if the data being analysed is the * current user. - * - * @param request - * @param qaContent - * @param qaService - * @param isUserNamesVisible - * @param isLearnerRequest - * @param userId */ public static void refreshSummaryData(HttpServletRequest request, QaContent qaContent, IQaService qaService, - boolean isUserNamesVisible, String sessionId, String userId, - GeneralLearnerFlowDTO generalLearnerFlowDTO) { + String httpSessionID, QaQueUsr user, GeneralLearnerFlowDTO generalLearnerFlowDTO) { -// List listMonitoredAnswersContainerDTO = MonitoringUtil.buildGroupsQuestionData(request, qaContent, qaService, -// isUserNamesVisible, true, sessionId, userId); -// generalLearnerFlowDTO.setListMonitoredAnswersContainerDTO(listMonitoredAnswersContainerDTO); - + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + Long userId = user.getQueUsrId(); Set questions = qaContent.getQaQueContents(); generalLearnerFlowDTO.setQuestions(questions); generalLearnerFlowDTO.setUserNameVisible(new Boolean(qaContent.isUsernameVisible()).toString()); - - QaQueUsr user = qaService.getUserByIdAndSession(new Long(userId), new Long(sessionId)); + List userResponses = qaService.getResponsesByUserUid(user.getUid()); - Map mapResponseIdToAverageRating = qaService.getAverageRatingDTOByUserAndContentId(user.getUid(), qaContent.getQaContentId()); - for (QaUsrResp userResponse : userResponses) { + //handle rating criterias + int commentsMinWordsLimit = 0; + boolean isCommentsEnabled = false; + if (qaContent.isAllowRateAnswers()) { + + // create itemIds list + List itemIds = new LinkedList(); + for (QaUsrResp responseIter : userResponses) { + itemIds.add(responseIter.getResponseId()); + } + List itemRatingDtos = qaService.getRatingCriteriaDtos(qaContent.getQaContentId(), itemIds, true, userId); + sessionMap.put(AttributeNames.ATTR_ITEM_RATING_DTOS, itemRatingDtos); - AverageRatingDTO averageRating = mapResponseIdToAverageRating.get(userResponse.getResponseId()); - if (averageRating == null) { - userResponse.setAverageRating("0"); - userResponse.setNumberOfVotes("0"); - } else { - userResponse.setAverageRating(averageRating.getRating()); - userResponse.setNumberOfVotes(averageRating.getNumberOfVotes()); + if (itemRatingDtos.size() > 0) { + commentsMinWordsLimit = itemRatingDtos.get(0).getCommentsMinWordsLimit(); + isCommentsEnabled = itemRatingDtos.get(0).isCommentsEnabled(); } - } - - for (QaQueContent question : questions) { - //TODO may be add questions that were not answered + //map itemRatingDto to corresponding response + for (QaUsrResp response : userResponses) { + + //find corresponding itemRatingDto + ItemRatingDTO itemRatingDto = null; + for (ItemRatingDTO itemRatingDtoIter : itemRatingDtos) { + if (itemRatingDtoIter.getItemId().equals(response.getResponseId())) { + itemRatingDto = itemRatingDtoIter; + break; + } + } + + response.setItemRatingDto(itemRatingDto); + } + + // store how many items are rated + int countRatedQuestions = qaService.getCountItemsRatedByUser(qaContent.getQaContentId(), userId.intValue()); + sessionMap.put(AttributeNames.ATTR_COUNT_RATED_ITEMS, countRatedQuestions); } + sessionMap.put("commentsMinWordsLimit", commentsMinWordsLimit); + sessionMap.put("isCommentsEnabled", isCommentsEnabled); + generalLearnerFlowDTO.setUserResponses(userResponses); generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); } @@ -1000,46 +967,60 @@ UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); TimeZone userTimeZone = userDto.getTimeZone(); + boolean isAllowRateAnswers = WebUtil.readBooleanParam(request, "isAllowRateAnswers"); + Long qaContentId = WebUtil.readLongParam(request, "qaContentId"); + Long questionUid = WebUtil.readLongParam(request, "questionUid"); Long qaSessionId = WebUtil.readLongParam(request, "qaSessionId"); //in case of monitoring we show all results. in case of learning - don't show results from the current user boolean isMonitoring = WebUtil.readBooleanParam(request, "isMonitoring", false); - Long excludeUserId = isMonitoring ? -1 : WebUtil.readLongParam(request, "userId"); + Long userId = isMonitoring ? -1 : WebUtil.readLongParam(request, "userId"); //paging parameters of tablesorter int size = WebUtil.readIntParam(request, "size"); int page = WebUtil.readIntParam(request, "page"); Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true); - Integer isSort2 = WebUtil.readIntParam(request, "column[1]", true); int sorting = QaAppConstants.SORT_BY_NO; if (isSort1 != null && isSort1.equals(0)) { sorting = QaAppConstants.SORT_BY_ANSWER_ASC; } else if (isSort1 != null && isSort1.equals(1)) { sorting = QaAppConstants.SORT_BY_ANSWER_DESC; - } else if (isSort2 != null && isSort2.equals(0)) { - sorting = QaAppConstants.SORT_BY_AVG_RATING_ASC; - } else if (isSort2 != null && isSort2.equals(1)) { - sorting = QaAppConstants.SORT_BY_AVG_RATING_DESC; } - List responses = qaService.getResponsesForTablesorter(qaSessionId, questionUid, excludeUserId, page, size, - sorting); + List responses = qaService.getResponsesForTablesorter(qaSessionId, questionUid, userId, page, size, + sorting); + JSONObject responcedata = new JSONObject(); JSONArray rows = new JSONArray(); - JSONObject responcedata = new JSONObject(); - responcedata.put("total_rows", qaService.getCountResponsesBySessionAndQuestion(qaSessionId, questionUid, excludeUserId)); + responcedata.put("total_rows", qaService.getCountResponsesBySessionAndQuestion(qaSessionId, questionUid, userId)); + //handle rating criterias + List itemRatingDtos = null; + if (isAllowRateAnswers) { + //create itemIds list + List itemIds = new LinkedList(); + for (QaUsrResp response : responses) { + itemIds.add(response.getResponseId()); + } + + itemRatingDtos = qaService.getRatingCriteriaDtos(qaContentId, itemIds, false, userId); + + // store how many items are rated + int countRatedQuestions = qaService.getCountItemsRatedByUser(qaContentId, userId.intValue()); + responcedata.put(AttributeNames.ATTR_COUNT_RATED_ITEMS, countRatedQuestions); + } + for (QaUsrResp response : responses) { QaQueUsr user = response.getQaQueUser(); //JSONArray cell=new JSONArray(); //cell.put(StringEscapeUtils.escapeHtml(user.getFirstName()) + " " + StringEscapeUtils.escapeHtml(user.getLastName()) + " [" + StringEscapeUtils.escapeHtml(user.getLogin()) + "]"); JSONObject responseRow = new JSONObject(); responseRow.put("responseUid", response.getResponseId().toString()); - responseRow.put("answer", response.getAnswer()); + responseRow.put("answer", StringEscapeUtils.escapeCsv(response.getAnswer())); responseRow.put("userName", StringEscapeUtils.escapeCsv(user.getFullname())); responseRow.put("visible", new Boolean(response.isVisible()).toString()); @@ -1049,15 +1030,50 @@ DateFormat dateFormatter = new SimpleDateFormat("d MMMM yyyy h:mm:ss a"); responseRow.put("attemptTime", dateFormatter.format(attemptTime)); - AverageRatingDTO averageRatingDto = qaService.getAverageRatingDTOByResponse(response.getResponseId()); - String averageRating = (averageRatingDto == null) ? "0" : averageRatingDto.getRating(); - responseRow.put("averageRating", averageRating); - String numberOfVotes = (averageRatingDto == null) ? "0" : averageRatingDto.getNumberOfVotes(); - responseRow.put("numberOfVotes", numberOfVotes); + if (isAllowRateAnswers) { + + //find corresponding itemRatingDto + ItemRatingDTO itemRatingDto = null; + for (ItemRatingDTO itemRatingDtoIter: itemRatingDtos) { + if (response.getResponseId().equals(itemRatingDtoIter.getItemId())) { + itemRatingDto = itemRatingDtoIter; + break; + } + } + + boolean isItemAuthoredByUser = response.getQaQueUser().getUid().equals(userId); + responseRow.put("isItemAuthoredByUser", isItemAuthoredByUser); + + JSONArray criteriasRows = new JSONArray(); + for (ItemRatingCriteriaDTO criteriaDto: itemRatingDto.getCriteriaDtos()) { + JSONObject criteriasRow = new JSONObject(); + criteriasRow.put("ratingCriteriaId", criteriaDto.getRatingCriteria().getRatingCriteriaId()); + criteriasRow.put("title", criteriaDto.getRatingCriteria().getTitle()); + criteriasRow.put("averageRating", criteriaDto.getAverageRating()); + criteriasRow.put("numberOfVotes", criteriaDto.getNumberOfVotes()); + criteriasRow.put("userRating", criteriaDto.getUserRating()); + + criteriasRows.put(criteriasRow); + } + responseRow.put("criteriaDtos", criteriasRows); + + //handle comments + responseRow.put("commentsCriteriaId", itemRatingDto.getCommentsCriteriaId()); + String commentPostedByUser = itemRatingDto.getCommentPostedByUser() == null ? "" : itemRatingDto.getCommentPostedByUser().getComment(); + responseRow.put("commentPostedByUser", commentPostedByUser); + if (itemRatingDto.getCommentDtos() != null) { + JSONArray comments = new JSONArray(); + for (RatingCommentDTO commentDto : itemRatingDto.getCommentDtos()) { + comments.put(StringEscapeUtils.escapeCsv(commentDto.getComment())); + } + responseRow.put("comments", comments); + } + } rows.put(responseRow); } responcedata.put("rows", rows); + res.setContentType("application/json;charset=utf-8"); res.getWriter().print(new String(responcedata.toString())); return null; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java =================================================================== diff -u -r890f666ec88ba3ffd1679ac0d19243a947f9d940 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision 890f666ec88ba3ffd1679ac0d19243a947f9d940) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -28,6 +28,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TimeZone; @@ -50,12 +51,15 @@ import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.rating.dto.ItemRatingCriteriaDTO; +import org.lamsfoundation.lams.rating.dto.ItemRatingDTO; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaSession; +import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.dto.GeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.service.IQaService; @@ -115,21 +119,21 @@ throw new ServletException("No QA content found"); } - QaQueUsr qaUser = null; + QaQueUsr user = null; if ((mode != null) && mode.equals(ToolAccessMode.TEACHER.toString())) { // monitoring mode - user is specified in URL // assessmentUser may be null if the user was force completed. - qaUser = getSpecifiedUser(toolSessionID, + user = getSpecifiedUser(toolSessionID, WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false)); } else { - qaUser = getCurrentUser(toolSessionID); + user = getCurrentUser(toolSessionID); } - Long userId = qaUser.getQueUsrId(); - qaLearningForm.setUserID(qaUser.getQueUsrId().toString()); + Long userId = user.getQueUsrId(); + qaLearningForm.setUserID(user.getQueUsrId().toString()); QaQueUsr groupLeader = null; if (qaContent.isUseSelectLeaderToolOuput()) { - groupLeader = qaService.checkLeaderSelectToolForSessionLeader(qaUser, new Long(toolSessionID).longValue()); + groupLeader = qaService.checkLeaderSelectToolForSessionLeader(user, new Long(toolSessionID).longValue()); // forwards to the leaderSelection page if (groupLeader == null && !mode.equals(ToolAccessMode.TEACHER.toString())) { @@ -147,10 +151,10 @@ // in case user joins the lesson after leader has answers some answers already - we need to make sure // he has the same scratches as leader - qaService.copyAnswersFromLeader(qaUser, groupLeader); + qaService.copyAnswersFromLeader(user, groupLeader); - qaUser.setResponseFinalized(true); - qaService.updateUser(qaUser); + user.setResponseFinalized(true); + qaService.updateUser(user); } } @@ -168,18 +172,21 @@ qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); sessionMap.put(AttributeNames.ATTR_LEARNER_CONTENT_FOLDER, - qaService.getLearnerContentFolder(new Long(toolSessionID), qaUser.getQueUsrId())); + qaService.getLearnerContentFolder(new Long(toolSessionID), user.getQueUsrId())); } + String sessionMapId = sessionMap.getSessionID(); + sessionMap.put(IS_DISABLED, qaContent.isLockWhenFinished() && user.isLearnerFinished()); sessionMap.put(ATTR_GROUP_LEADER, groupLeader); - boolean isUserLeader = qaService.isUserGroupLeader(qaUser, new Long(toolSessionID)); + boolean isUserLeader = qaService.isUserGroupLeader(user, new Long(toolSessionID)); sessionMap.put(ATTR_IS_USER_LEADER, isUserLeader); sessionMap.put(AttributeNames.ATTR_MODE, mode); sessionMap.put(ATTR_CONTENT, qaContent); + sessionMap.put(AttributeNames.USER, user); GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - generalLearnerFlowDTO.setUserUid(qaUser.getQueUsrId().toString()); - generalLearnerFlowDTO.setHttpSessionID(sessionMap.getSessionID()); + generalLearnerFlowDTO.setUserUid(user.getQueUsrId().toString()); + generalLearnerFlowDTO.setHttpSessionID(sessionMapId); generalLearnerFlowDTO.setToolSessionID(toolSessionID); generalLearnerFlowDTO.setToolContentID(qaContent.getQaContentId().toString()); generalLearnerFlowDTO.setReportTitleLearner(qaContent.getReportTitle()); @@ -269,13 +276,13 @@ /* the report should have the all entries for the users in this tool session, * and display under the "my answers" section the answers for the user id in the url */ - Long learnerProgressUserId = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); +// Long learnerProgressUserId = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); generalLearnerFlowDTO.setTeacherViewOnly(new Boolean(true).toString()); - QaLearningAction.refreshSummaryData(request, qaContent, qaService, qaContent.isUsernameVisible(), - toolSessionID, userId.toString(), generalLearnerFlowDTO); + QaLearningAction.refreshSummaryData(request, qaContent, qaService, sessionMapId, user, + generalLearnerFlowDTO); request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); return (mapping.findForward(INDIVIDUAL_LEARNER_REPORT)); @@ -284,19 +291,19 @@ //check if there is submission deadline Date submissionDeadline = qaContent.getSubmissionDeadline(); if (submissionDeadline != null) { - //store submission deadline to sessionMap - sessionMap.put(QaAppConstants.ATTR_SUBMISSION_DEADLINE, submissionDeadline); - - HttpSession ss = SessionManager.getSession(); - UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER); - TimeZone learnerTimeZone = learnerDto.getTimeZone(); - Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); - Date currentLearnerDate = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, new Date()); - - //calculate whether submission deadline has passed, and if so forward to "submissionDeadline" - if (currentLearnerDate.after(tzSubmissionDeadline)) { - return mapping.findForward("submissionDeadline"); - } + // store submission deadline to sessionMap + sessionMap.put(QaAppConstants.ATTR_SUBMISSION_DEADLINE, submissionDeadline); + + HttpSession ss = SessionManager.getSession(); + UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone learnerTimeZone = learnerDto.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); + Date currentLearnerDate = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, new Date()); + + // calculate whether submission deadline has passed, and if so forward to "submissionDeadline" + if (currentLearnerDate.after(tzSubmissionDeadline)) { + return mapping.findForward("submissionDeadline"); + } } /* @@ -310,8 +317,8 @@ Long currentToolSessionID = new Long(qaLearningForm.getToolSessionID()); //if Response is Finalized - if (qaUser.isResponseFinalized()) { - QaSession checkSession = qaUser.getQaSession(); + if (user.isResponseFinalized()) { + QaSession checkSession = user.getQaSession(); if (checkSession != null) { Long checkQaSessionId = checkSession.getQaSessionId(); @@ -327,11 +334,10 @@ */ generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); - boolean isUserNamesVisible = qaContent.isUsernameVisible(); - QaLearningAction.refreshSummaryData(request, qaContent, qaService, isUserNamesVisible, - currentToolSessionID.toString(), userId.toString(), generalLearnerFlowDTO); + QaLearningAction.refreshSummaryData(request, qaContent, qaService, sessionMapId, user, + generalLearnerFlowDTO); - if (qaUser.isLearnerFinished()) { + if (user.isLearnerFinished()) { generalLearnerFlowDTO.setRequestLearningReportViewOnly(new Boolean(true).toString()); return (mapping.findForward(REVISITED_LEARNER_REP)); } else { @@ -343,7 +349,7 @@ } //**---- showing AnswersContent.jsp ----** - LearningUtil.populateAnswers(sessionMap, qaContent, qaUser, mapQuestions, generalLearnerFlowDTO, qaService); + LearningUtil.populateAnswers(sessionMap, qaContent, user, mapQuestions, generalLearnerFlowDTO, qaService); return (mapping.findForward(LOAD_LEARNER)); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java =================================================================== diff -u -r7d0d609b844ea5e9c41f46d209825ce5bd4fb83a -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (.../QaMonitoringStarterAction.java) (revision 7d0d609b844ea5e9c41f46d209825ce5bd4fb83a) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (.../QaMonitoringStarterAction.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -49,12 +49,14 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; +import org.lamsfoundation.lams.rating.dto.ItemRatingDTO; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaCondition; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaSession; +import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.dto.GroupDTO; import org.lamsfoundation.lams.tool.qa.dto.QaMonitoredAnswersDTO; import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; @@ -151,6 +153,10 @@ boolean isGroupedActivity = qaService.isGroupedActivity(qaContent.getQaContentId()); request.setAttribute("isGroupedActivity", isGroupedActivity); + + //rating stuff + boolean isCommentsEnabled = qaService.isCommentsEnabled(qaContent.getQaContentId()); + request.setAttribute("isCommentsEnabled", isCommentsEnabled); //buildQaStatsDTO QaStatsDTO qaStatsDTO = new QaStatsDTO(); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java =================================================================== diff -u -r4d139bddc3cdd41d32d9f3033f2100c711d8c0c5 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java (.../QaStarterAction.java) (revision 4d139bddc3cdd41d32d9f3033f2100c711d8c0c5) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java (.../QaStarterAction.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -46,6 +46,7 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; +import org.lamsfoundation.lams.rating.model.RatingCriteria; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaCondition; @@ -148,6 +149,10 @@ sessionMap.put(QaAppConstants.ATTR_QA_AUTHORING_FORM, qaAuthoringForm); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + + // get rating criterias from DB + List ratingCriterias = qaService.getRatingCriterias(qaContent.getQaContentId()); + sessionMap.put(AttributeNames.ATTR_RATING_CRITERIAS, ratingCriterias); request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); @@ -174,6 +179,8 @@ qaAuthoringForm.setShowOtherAnswers(qaContent.isShowOtherAnswers() ? "1" : "0"); qaAuthoringForm.setQuestionsSequenced(qaContent.isQuestionsSequenced() ? "1" : "0"); qaAuthoringForm.setLockWhenFinished(qaContent.isLockWhenFinished() ? "1" : "0"); + qaAuthoringForm.setMaximumRates(qaContent.getMaximumRates()); + qaAuthoringForm.setMinimumRates(qaContent.getMinimumRates()); qaGeneralAuthoringDTO.setReflect(qaContent.isReflect() ? "1" : "0"); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaAuthoringForm.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaAuthoringForm.java (.../QaAuthoringForm.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaAuthoringForm.java (.../QaAuthoringForm.java) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -62,7 +62,9 @@ protected String questionsSequenced; protected String lockWhenFinished; protected String reflect; - protected String reflectionSubject; + protected String reflectionSubject; + protected int maximumRates; + protected int minimumRates; /* proxy controllers for Monitoring tabs */ protected String summaryMonitoring; @@ -76,6 +78,7 @@ private String editableQuestionIndex; private String feedback; private boolean required; + private int minWordsLimit; private String editQuestionBoxRequest; protected IQaService qaService; @@ -415,8 +418,30 @@ public void setQuestionsSequenced(String questionsSequenced) { this.questionsSequenced = questionsSequenced; } + + /** + * @return + */ + public int getMaximumRates() { + return maximumRates; + } + public void setMaximumRates(int maximumRates) { + this.maximumRates = maximumRates; + } + /** + * @return + */ + public int getMinimumRates() { + return minimumRates; + } + + public void setMinimumRates(int minimumRates) { + this.minimumRates = minimumRates; + } + + /** * @return Returns the endLearningMessage. */ public String getEndLearningMessage() { @@ -739,4 +764,12 @@ public void setRequired(boolean required) { this.required = required; } + + public void setMinWordsLimit(int minWordsLimit) { + this.minWordsLimit = minWordsLimit; + } + + public int getMinWordsLimit() { + return minWordsLimit; + } } Index: lams_tool_laqa/web/WEB-INF/tags/AuthoringRatingCriteria.tag =================================================================== diff -u --- lams_tool_laqa/web/WEB-INF/tags/AuthoringRatingCriteria.tag (revision 0) +++ lams_tool_laqa/web/WEB-INF/tags/AuthoringRatingCriteria.tag (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -0,0 +1,352 @@ +<% + /** + * AuthoringRatingCriteria.tag + * Author: Andrey Balan + * Description: Creates list of rating criterias for authoring page + */ + %> +<%@ tag body-content="scriptless" %> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-fmt" prefix="fmt" %> +<%@ taglib uri="tags-html" prefix="html" %> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-function" prefix="fn" %> + + +<%@ attribute name="criterias" required="true" rtexprvalue="true" type="java.util.Collection" %> + +<%-- Optional attribute --%> +<%@ attribute name="hasRatingLimits" required="false" rtexprvalue="true" %> +<%@ attribute name="formContentPrefix" required="false" rtexprvalue="true" %> +<%@ attribute name="headerLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="addLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="deleteLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="upLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="downLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="minimumLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="maximumLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="noMinimumLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="noMaximumLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="jsWarningLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="allowCommentsLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="minNumberWordsLabel" required="false" rtexprvalue="true" %> + +<%-- Default value for message key --%> + + + + + ${formContentPrefix}. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ +

+ + + + + + + + + + + + + + + + +
+ + + + +
">
+ +
">
+
+
+ + + +
">
+
+ +
">
+
+
+
" >
+
+ +
+ + + +
+ + +
+ + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + +
+
+ +
+ checked="checked" + /> + + +
+ + +
+ +
+ +
+ \ No newline at end of file Index: lams_tool_laqa/web/WEB-INF/tags/Rating.tag =================================================================== diff -u --- lams_tool_laqa/web/WEB-INF/tags/Rating.tag (revision 0) +++ lams_tool_laqa/web/WEB-INF/tags/Rating.tag (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -0,0 +1,206 @@ +<% + /** + * Rating.tag + * Author: Andrey Balan + * Description: Shows rating stars widget + */ + %> +<%@ tag body-content="scriptless" %> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-fmt" prefix="fmt" %> +<%@ taglib uri="tags-html" prefix="html" %> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-function" prefix="fn" %> + + +<%@ attribute name="itemRatingDto" required="true" rtexprvalue="true" type="org.lamsfoundation.lams.rating.dto.ItemRatingDTO" %> + +<%-- Optional attribute --%> +<%@ attribute name="disabled" required="false" rtexprvalue="true" %> +<%@ attribute name="isItemAuthoredByUser" required="false" rtexprvalue="true" %> +<%@ attribute name="maxRates" required="false" rtexprvalue="true" %> +<%@ attribute name="minRates" required="false" rtexprvalue="true" %> +<%@ attribute name="countRatedItems" required="false" rtexprvalue="true" %> +<%@ attribute name="yourRatingLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="averageRatingLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="warnCommentIsBlankLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="minNumberWordsLabel" required="false" rtexprvalue="true" %> +<%@ attribute name="warnMinNumberWordsLabel" required="false" rtexprvalue="true" %> + +<%-- Default value for message key --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%--Rating stars area---------------------------------------%> + +
+
+ + + + + + + + + + + + + +

+ ${criteriaDto.ratingCriteria.title} +

+ + + + + + + + + + +
+
+ + + +
+ + + + + + ${criteriaDto.numberOfVotes} + + +
+
+ + +
style="visibility: hidden;" + > + + + + + + + + + + + + + ${criteriaDto.numberOfVotes} + + +
+ +
+
+ +
+ +
+ +
+ +<%--Comments area---------------------------------------%> + +
+ + + + + + + + + + + +
+ +
+
+
+ + +
+ +
+
+ + +
+ + + + +
+ + : + +
+
+ + + +
+
+
+
+
+ +
+
\ No newline at end of file Index: lams_tool_laqa/web/WEB-INF/tlds/lams/lams.tld =================================================================== diff -u -r606581007abbdaee5483777096f32ffac1c3e3eb -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 606581007abbdaee5483777096f32ffac1c3e3eb) +++ lams_tool_laqa/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -426,6 +426,14 @@ AuthoringButton /WEB-INF/tags/AuthoringButton.tag + + + AuthoringRatingCriteria + /WEB-INF/tags/AuthoringRatingCriteria.tag + + + Rating + /WEB-INF/tags/Rating.tag headItems Index: lams_tool_laqa/web/authoring/AdvancedContent.jsp =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/web/authoring/AdvancedContent.jsp (.../AdvancedContent.jsp) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/web/authoring/AdvancedContent.jsp (.../AdvancedContent.jsp) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -1,74 +1,87 @@ <%@ include file="/common/taglibs.jsp"%> + - -

-

-

-

-        - - -

+
-

-        - - -

+

+ + +

+

+ + +

+ +
+
+
style="display:none;"> + +
+
+
+ +
+

@@ -90,7 +91,6 @@ - Index: lams_tool_laqa/web/authoring/conditions.jsp =================================================================== diff -u -r0af4ed13b963a588f3499b080801863d57f8ad95 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/web/authoring/conditions.jsp (.../conditions.jsp) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) +++ lams_tool_laqa/web/authoring/conditions.jsp (.../conditions.jsp) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -40,49 +40,41 @@ showConditionMessage(url); } //The panel of taskList list panel - var conditionListTargetDiv = "conditionsArea"; + var conditionListTargetDiv = "#conditionsArea"; function deleteCondition(orderId,sessionMapID){ var url = ""; var reqIDVar = new Date(); - var param = "orderId=" + orderId +"&sessionMapID="+sessionMapID;; - var myAjax = new Ajax.Updater( - conditionListTargetDiv, - url, - { - method:'get', - parameters:param, - evalScripts:true - } - ); + $(conditionListTargetDiv).load( + url, + { + orderId: orderId, + sessionMapID: sessionMapID + } + ); } function upCondition(orderId,sessionMapID){ var url = ""; var reqIDVar = new Date(); - var param = "orderId=" + orderId + "&sessionMapID="+sessionMapID;; - var myAjax = new Ajax.Updater( - conditionListTargetDiv, - url, - { - method:'get', - parameters:param, - evalScripts:true - } - ); + $(conditionListTargetDiv).load( + url, + { + orderId: orderId, + sessionMapID: sessionMapID + } + ); } function downCondition(orderId,sessionMapID){ var url = ""; var reqIDVar = new Date(); var param = "orderId=" + orderId + "&sessionMapID="+sessionMapID;; - var myAjax = new Ajax.Updater( - conditionListTargetDiv, - url, - { - method:'get', - parameters:param, - evalScripts:true - } - ); + $(conditionListTargetDiv).load( + url, + { + orderId: orderId, + sessionMapID: sessionMapID + } + ); } Index: lams_tool_laqa/web/authoring/editQuestionBox.jsp =================================================================== diff -u -r7705619f9846910e009c396d8f157f9cfe07c68e -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 7705619f9846910e009c396d8f157f9cfe07c68e) +++ lams_tool_laqa/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -5,8 +5,10 @@ <%@ include file="/common/header.jsp"%> + + @@ -50,7 +57,8 @@ + contentFolderID="${qaGeneralAuthoringDTO.contentFolderID}" width="99%"> +
@@ -59,6 +67,15 @@
+ +
+ + +
Index: lams_tool_laqa/web/authoring/newQuestionBox.jsp =================================================================== diff -u -r7f72623672348cea4cc023ca787c70374ffe1892 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 7f72623672348cea4cc023ca787c70374ffe1892) +++ lams_tool_laqa/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -7,8 +7,11 @@ <%@ include file="/common/header.jsp"%> <%@ include file="/includes/jsp/qaWizardCommon.jsp"%> - - + + + + + - - @@ -98,7 +85,6 @@ - @@ -176,7 +162,6 @@ - Index: lams_tool_laqa/web/includes/javascript/common.js =================================================================== diff -u --- lams_tool_laqa/web/includes/javascript/common.js (revision 0) +++ lams_tool_laqa/web/includes/javascript/common.js (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -0,0 +1,25 @@ +function validateForm() { + //in case main characters restriction is ON check it's been fullfilled + var isMinCharactersEnabled = $("#min-characters-enabled").val() == "true"; + var charsMissing = $("#char-required-div").html(); + + var isValid = !isMinCharactersEnabled || isMinCharactersEnabled && (charsMissing == "0"); + if (!isValid) { + var warningMsg = warning.replace("{0}", charsMissing); + alert(warningMsg); + } + + return isValid; +} + +function getNumberOfCharacters(value, isRemoveHtmlTags) { + + //HTML tags stripping + if (isRemoveHtmlTags) { + value = value.replace(/ /g, ' ').replace(/\n/gi, '').replace(/<\/?[a-z][^>]*>/gi, ''); + } + + var wordCount = value ? (value).length : 0; + return wordCount; +} + Index: lams_tool_laqa/web/includes/qalearning.css =================================================================== diff -u --- lams_tool_laqa/web/includes/qalearning.css (revision 0) +++ lams_tool_laqa/web/includes/qalearning.css (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -0,0 +1,22 @@ + .rating-stars-div {margin-top: 8px;} + .user-answer {padding: 0 2px;} + tr.odd:hover .jStar {background-image: url(/lams/images/css/jquery.jRating-stars-grey.png)!important;} + tr.even:hover .jStar {background-image: url(/lams/images/css/jquery.jRating-stars-light-grey.png)!important;} + tr.odd .jStar {background-image: url(/lams/images/css/jquery.jRating-stars-light-blue.png)!important;} + .tablesorter-blue {margin-bottom: 5px;} + .pager {padding-bottom: 20px;} + .extra-controls-inner:after { + margin-top: -10px; + } + .rating-comment{ + background-image: none; + background-color: rgba(205, 205, 205, 0.1); + border: 1px solid rgba(205, 205, 205, 0.2); + } + textarea { + margin: 10px 0px; + width: 88%; + } + .add-comment { + margin-top: 60px; + } \ No newline at end of file Index: lams_tool_laqa/web/learning/AnswersContent.jsp =================================================================== diff -u -r65a83a957c6c1160566e3e9d11a9c9a4d6e704f6 -rdd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0 --- lams_tool_laqa/web/learning/AnswersContent.jsp (.../AnswersContent.jsp) (revision 65a83a957c6c1160566e3e9d11a9c9a4d6e704f6) +++ lams_tool_laqa/web/learning/AnswersContent.jsp (.../AnswersContent.jsp) (revision dd4087c8c38ddcf2e97af7fc2dda25a8c948bcf0) @@ -32,22 +32,59 @@ + + + + + + - > + + + @@ -115,6 +138,7 @@ +