Index: lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java,v diff -u -r1.37.2.9 -r1.37.2.10 --- lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java 5 Aug 2016 11:40:18 -0000 1.37.2.9 +++ lams_central/src/java/org/lamsfoundation/lams/util/CentralConstants.java 20 Dec 2016 15:45:56 -0000 1.37.2.10 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java,v diff -u -r1.48.2.21 -r1.48.2.22 --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java 28 Sep 2016 15:13:38 -0000 1.48.2.21 +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java 20 Dec 2016 15:45:56 -0000 1.48.2.22 @@ -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.