Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -ra9f95a26e562a58b55c99f2c18e253c151ef457a -r33aeeae9d9764b3411e04a48ee165e526c240f44
--- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision a9f95a26e562a58b55c99f2c18e253c151ef457a)
+++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 33aeeae9d9764b3411e04a48ee165e526c240f44)
@@ -988,4 +988,5 @@
label.multiple.lessons =Multiple lessons
label.add.lessons.to.subgroups =Add lesson to all selected subcourses
label.marks =Marks
+label.question.not.added =This question has already been added
#======= End labels: Exported 872 labels for en AU =====
Index: lams_central/web/qb/search.jsp
===================================================================
diff -u -re8a7110708b15579af2c6b31ac52a6da427fef6d -r33aeeae9d9764b3411e04a48ee165e526c240f44
--- lams_central/web/qb/search.jsp (.../search.jsp) (revision e8a7110708b15579af2c6b31ac52a6da427fef6d)
+++ lams_central/web/qb/search.jsp (.../search.jsp) (revision 33aeeae9d9764b3411e04a48ee165e526c240f44)
@@ -173,22 +173,31 @@
}
//disabling the button
$(this).attr("disabled", "disabled");
-
- $("#itemArea").load(
- "${param.returnUrl}",
- {
+
+ $.ajax({
+ url: "${param.returnUrl}",
+ data: {
qbQuestionUid: $("#selected-question-uid").val()
},
- function() {
- //invoke refreshThickbox() only in case parent page has this method
- if (typeof refreshThickbox === "function") {
- refreshThickbox();
- }
+ type: "POST",
+ success: function(response, status, xhr) {
+ if (response.isDuplicated) {
+ //show not successfull notification
+ $.growlUI(' ');
+
+ } else {
+ $("#itemArea").html(response);
- //show successfull notification
- $.growlUI(' ');
+ //invoke refreshThickbox() only in case parent page has this method
+ if (typeof refreshThickbox === "function") {
+ refreshThickbox();
+ }
+
+ //show successfull notification
+ $.growlUI(' ');
+ }
}
- );
+ });
});
//handler for "Advanced search" button
Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/AuthoringController.java
===================================================================
diff -u -r06d090eefddaafa108bcd8614d47d3d92f946210 -r33aeeae9d9764b3411e04a48ee165e526c240f44
--- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 06d090eefddaafa108bcd8614d47d3d92f946210)
+++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 33aeeae9d9764b3411e04a48ee165e526c240f44)
@@ -31,7 +31,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -55,7 +54,6 @@
import org.lamsfoundation.lams.qb.QbConstants;
import org.lamsfoundation.lams.qb.form.QbQuestionForm;
import org.lamsfoundation.lams.qb.model.QbCollection;
-import org.lamsfoundation.lams.qb.model.QbOption;
import org.lamsfoundation.lams.qb.model.QbQuestion;
import org.lamsfoundation.lams.qb.service.IQbService;
import org.lamsfoundation.lams.tool.ToolAccessMode;
@@ -585,10 +583,20 @@
@RequestParam Long qbQuestionUid) {
SessionMap sessionMap = (SessionMap) request.getSession()
.getAttribute(sessionMapID);
- QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid);
+ SortedSet references = getQuestionReferences(sessionMap);
+ //check whether this question is a duplicate
+ for (QuestionReference reference : references) {
+ if (!reference.isRandomQuestion()
+ && qbQuestionUid.equals(reference.getQuestion().getQbQuestion().getUid())) {
+ //let jsp know it's a duplicate
+ return "forward:/authoring/showDuplicateQuestionError.do";
+ }
+ }
+
//create new ScratchieItem and assign imported qbQuestion to it
AssessmentQuestion assessmentQuestion = new AssessmentQuestion();
+ QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid);
assessmentQuestion.setQbQuestion(qbQuestion);
assessmentQuestion.setDisplayOrder(getNextDisplayOrder(sessionMap));
@@ -598,8 +606,7 @@
// set SequenceId
int maxSeq = 1;
- SortedSet references = getQuestionReferences(sessionMap);
- if ((references != null) && (references.size() > 0)) {
+ if (!references.isEmpty()) {
QuestionReference last = references.last();
maxSeq = last.getSequenceId() + 1;
}
@@ -615,6 +622,18 @@
request.setAttribute(AssessmentConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return "pages/authoring/parts/questionlist";
}
+
+ /**
+ * Shows "This question has already been added" error message in a browser.
+ */
+ @RequestMapping("/showDuplicateQuestionError")
+ @ResponseBody
+ public String showDuplicateQuestionError(HttpServletResponse response) throws IOException {
+ ObjectNode responseJSON = JsonNodeFactory.instance.objectNode();
+ responseJSON.put("isDuplicated", true);
+ response.setContentType("application/json;charset=utf-8");
+ return responseJSON.toString();
+ }
/**
* Remove assessment question from HttpSession list and update page display. As authoring rule, all persist only
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McController.java
===================================================================
diff -u -rb436dbb8397cdcbacaab50eec68b6427a5c6e1e9 -r33aeeae9d9764b3411e04a48ee165e526c240f44
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McController.java (.../McController.java) (revision b436dbb8397cdcbacaab50eec68b6427a5c6e1e9)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McController.java (.../McController.java) (revision 33aeeae9d9764b3411e04a48ee165e526c240f44)
@@ -62,7 +62,11 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
/**
* Action class that controls the logic of tool behavior.
*
@@ -447,6 +451,14 @@
.getAttribute(sessionMapId);
request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId);
List questionDtos = (List) sessionMap.get(McAppConstants.QUESTION_DTOS);
+
+ //check whether this QB question is a duplicate
+ for (McQuestionDTO questionDto : questionDtos) {
+ if (qbQuestionUid.equals(questionDto.getQbQuestionUid())) {
+ //let jsp know it's a duplicate
+ return "forward:/authoring/showDuplicateQuestionError.do";
+ }
+ }
//get QbQuestion from DB
QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid);
@@ -481,6 +493,18 @@
return "authoring/itemlist";
}
+
+ /**
+ * Shows "This question has already been added" error message in a browser.
+ */
+ @RequestMapping("/showDuplicateQuestionError")
+ @ResponseBody
+ public String showDuplicateQuestionError(HttpServletResponse response) throws IOException {
+ ObjectNode responseJSON = JsonNodeFactory.instance.objectNode();
+ responseJSON.put("isDuplicated", true);
+ response.setContentType("application/json;charset=utf-8");
+ return responseJSON.toString();
+ }
@SuppressWarnings("unchecked")
@RequestMapping("/saveQuestion")
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringController.java
===================================================================
diff -u -r8a5ba0f4e4ced295600d75bca2fef2ef727d7eb0 -r33aeeae9d9764b3411e04a48ee165e526c240f44
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringController.java (.../QaAuthoringController.java) (revision 8a5ba0f4e4ced295600d75bca2fef2ef727d7eb0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringController.java (.../QaAuthoringController.java) (revision 33aeeae9d9764b3411e04a48ee165e526c240f44)
@@ -37,6 +37,7 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.beanutils.PropertyUtils;
@@ -71,7 +72,11 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
/**
* Q&A Tool's authoring methods. Additionally, there is one more method that initializes authoring and it's located in
* QaStarterAction.java.
@@ -296,6 +301,14 @@
@RequestParam String sessionMapID, @RequestParam Long qbQuestionUid) {
SessionMap sessionMap = getSessionMap(form, request);
SortedSet qaQuestions = getQuestions(sessionMap);
+
+ //check whether this QB question is a duplicate
+ for (QaQueContent qaQuestion : qaQuestions) {
+ if (qbQuestionUid.equals(qaQuestion.getQbQuestion().getUid())) {
+ //let jsp know it's a duplicate
+ return "forward:/authoring/showDuplicateQuestionError.do";
+ }
+ }
//get QbQuestion from DB
QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid);
@@ -313,6 +326,18 @@
return "authoring/itemlist";
}
+
+ /**
+ * Shows "This question has already been added" error message in a browser.
+ */
+ @RequestMapping("/showDuplicateQuestionError")
+ @ResponseBody
+ public String showDuplicateQuestionError(HttpServletResponse response) throws IOException {
+ ObjectNode responseJSON = JsonNodeFactory.instance.objectNode();
+ responseJSON.put("isDuplicated", true);
+ response.setContentType("application/json;charset=utf-8");
+ return responseJSON.toString();
+ }
/**
* saveQuestion
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java
===================================================================
diff -u -ra9f95a26e562a58b55c99f2c18e253c151ef457a -r33aeeae9d9764b3411e04a48ee165e526c240f44
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java (.../AuthoringController.java) (revision a9f95a26e562a58b55c99f2c18e253c151ef457a)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 33aeeae9d9764b3411e04a48ee165e526c240f44)
@@ -41,6 +41,7 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;
@@ -71,13 +72,19 @@
import org.lamsfoundation.lams.web.util.SessionMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
/**
* @author Andrey Balan
*/
@@ -383,6 +390,14 @@
SessionMap sessionMap = (SessionMap) request.getSession()
.getAttribute(sessionMapID);
SortedSet itemList = getItemList(sessionMap);
+
+ //check whether this QB question is a duplicate
+ for (ScratchieItem item : itemList) {
+ if (qbQuestionUid.equals(item.getQbQuestion().getUid())) {
+ //let jsp know it's a duplicate
+ return "forward:/authoring/showDuplicateQuestionError.do";
+ }
+ }
QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid);
@@ -396,11 +411,24 @@
}
item.setDisplayOrder(maxSeq);
itemList.add(item);
+ ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
// set session map ID so that itemlist.jsp can get sessionMAP
request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return "pages/authoring/parts/itemlist";
}
+
+ /**
+ * Shows "This question has already been added" error message in a browser.
+ */
+ @RequestMapping("/showDuplicateQuestionError")
+ @ResponseBody
+ public String showDuplicateQuestionError(HttpServletResponse response) throws IOException {
+ ObjectNode responseJSON = JsonNodeFactory.instance.objectNode();
+ responseJSON.put("isDuplicated", true);
+ response.setContentType("application/json;charset=utf-8");
+ return responseJSON.toString();
+ }
/**
* This method will get necessary information from assessment question form and save or update into