Index: lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java =================================================================== diff -u -r42d1e3fc39b9b5421eb2b65620f6856dd5afebc4 -r9352c0f9470d3fd142e688234b7946d025ec0afb --- lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java (.../CentralConstants.java) (revision 42d1e3fc39b9b5421eb2b65620f6856dd5afebc4) +++ lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java (.../CentralConstants.java) (revision 9352c0f9470d3fd142e688234b7946d025ec0afb) @@ -104,6 +104,8 @@ public static final String METHOD_VERIFY_EXT_SERVER = "verify"; public static final String METHOD_LIST_MONITOR = "listMonitor"; + + public static final String METHOD_CHECK_LESSON_FOR_NUMERIC_TOOL_OUTPUTS = "checkLessonForNumericToolOutputs"; public static final String ATTR_COURSE_ID = "courseId"; Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java =================================================================== diff -u -r11b64f81e406ff277c7c35988304b0064300de57 -r9352c0f9470d3fd142e688234b7946d025ec0afb --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision 11b64f81e406ff277c7c35988304b0064300de57) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision 9352c0f9470d3fd142e688234b7946d025ec0afb) @@ -75,6 +75,12 @@ import org.w3c.dom.ls.LSSerializer; public class LessonManagerServlet extends HttpServlet { + + private static final String TOOL_SIGNATURE_ASSESSMENT = "laasse10"; + + public static final String TOOL_SIGNATURE_SCRATCHIE = "lascrt11"; + + public static final String TOOL_SIGNATURE_MCQ = "lamc11"; private static Logger log = Logger.getLogger(LessonManagerServlet.class); @@ -283,6 +289,10 @@ element = getToolOutputs(document, serverId, datetime, hashValue, username, lsId, courseId, true, outputsUser); + } else if (method.equals(CentralConstants.METHOD_CHECK_LESSON_FOR_NUMERIC_TOOL_OUTPUTS)) { + lsId = new Long(lsIdStr); + element = checkLessonForNumericToolOutputs(document, serverId, datetime, hashValue, username, lsId); + } else if (method.equals(CentralConstants.METHOD_VERIFY_EXT_SERVER)) { verify(serverId, datetime, hashValue); response.setContentType("text/html"); @@ -1150,7 +1160,7 @@ * @throws Exception */ @SuppressWarnings("unchecked") - public Element getToolOutputs(Document document, String serverId, String datetime, String hashValue, + private Element getToolOutputs(Document document, String serverId, String datetime, String hashValue, String username, Long lessonId, String courseID, boolean isAuthoredToolOutputs, String outputsUser) throws Exception { @@ -1252,7 +1262,41 @@ return toolOutputsElement; } + + /** + * Returns whether specified lesson has numeric tool outputs (i.e. contains Scratchie, Assessment or MCQ). + */ + @SuppressWarnings("unchecked") + private Element checkLessonForNumericToolOutputs(Document document, String serverId, String datetime, + String hashValue, String username, Long lessonId) + throws Exception { + ExtServer extServer = LessonManagerServlet.integrationService.getExtServer(serverId); + Authenticator.authenticate(extServer, datetime, username, hashValue); + + Lesson lesson = LessonManagerServlet.lessonService.getLesson(lessonId); + if (lesson == null) { + throw new Exception("No lesson exists for: " + lessonId); + } + + Set activities = getLessonActivities(lesson); + + //Scratchie, Assessment and MCQ are the tools that produce numeric tool outputs + boolean hasNumericToolOutput = false; + for (ToolActivity activity : activities) { + String toolSignature = activity.getTool().getToolSignature(); + hasNumericToolOutput |= TOOL_SIGNATURE_ASSESSMENT.equals(toolSignature) + || TOOL_SIGNATURE_ASSESSMENT.equals(toolSignature) + || TOOL_SIGNATURE_ASSESSMENT.equals(toolSignature); + } + + // Create the root node of the xml document + Element lessonElement = document.createElement("Lesson"); + lessonElement.setAttribute(CentralConstants.ATTR_LESSON_ID, "" + lessonId); + lessonElement.setAttribute("hasNumericToolOutput", Boolean.toString(hasNumericToolOutput)); + return lessonElement; + } + /** * Returns lesson tool activities. It works almost the same as lesson.getLearningDesign().getActivities() except it * solves problem with first activity unable to cast to ToolActivity.