Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -re0b158087e5f4e1e07e373051b8ff1935797b3d3 -rccd4ec9c17db772dd790b199a8d12f61bcc3595b Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LD102Importer.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -rccd4ec9c17db772dd790b199a8d12f61bcc3595b --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LD102Importer.java (.../LD102Importer.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LD102Importer.java (.../LD102Importer.java) (revision ccd4ec9c17db772dd790b199a8d12f61bcc3595b) @@ -129,8 +129,10 @@ /** store the content by content id field, ready for use when the matching activity is processed */ private Map contentMap = new HashMap(); - /** images to use for each tool, based on the library activities in the database. Key is tool id, value is url. */ - private Map libraryActivityUiImages; + /** basic library activity used for the image and activityCategoryID + * to use for each tool, based on the library activities in the database. + * Key is tool id, value is ToolActivity. */ + private Map libraryActivityForTool; /** Map of the 1.0.2 tool signature (key) to the tool which now supports it (value) */ private Map toolImportSupport; @@ -317,7 +319,7 @@ public Long storeLDDataWDDX(String ldWddxPacket, User importer, WorkspaceFolder folder, List toolsErrorMsgs) throws ImportToolContentException { - this.libraryActivityUiImages = getLibraryActivityUiImages(); + this.libraryActivityForTool = getLibraryActivityForTool(); this.toolImportSupport = getToolImportSupport(); this.toolsErrorMsgs = toolsErrorMsgs; @@ -758,7 +760,7 @@ activity = setupGroupingActivity(taskDetails, contentId, taskUIID, parentActivityId); } else { - activity = setupToolActivity(taskDetails, contentId, taskUIID); + activity = setupToolActivity(taskDetails, contentId, taskUIID, parentTitle, parentDescription); } if ( activity != null ) { @@ -772,12 +774,6 @@ } private void processCommonActivityFields(Hashtable taskDetails, Integer xCoOrd, Integer yCoOrd, Activity activity) throws WDDXProcessorConversionException { - // Don't overwrite title and description if they have already be set up from the content. - if ( activity.getDescription() == null && keyExists(taskDetails, WDDXTAGS102.DESCRIPTION)) - activity.setDescription(WDDXProcessor.convertToString(taskDetails,WDDXTAGS102.DESCRIPTION)); - if ( activity.getTitle() == null && keyExists(taskDetails, WDDXTAGS102.TITLE)) - activity.setTitle(WDDXProcessor.convertToString(taskDetails,WDDXTAGS102.TITLE)); - // define later will have already been set up for tool activities if ( activity.getDefineLater() == null ) { activity.setDefineLater(Boolean.FALSE); @@ -823,7 +819,7 @@ while ( iter.hasNext() ) { Hashtable subTask = (Hashtable) iter.next(); - Activity subActivity = createActivityFromTask(subTask, null, null, null, null, parentTitle, parentDescription); + Activity subActivity = createActivityFromTask(subTask, null, null, null, null, null, null); if ( subActivity != null ) { // won't be created if it can't find a matching tool. subActivity.setParentActivity(activity); @@ -888,23 +884,27 @@ return groupingActivity; } - private ToolActivity setupToolActivity(Hashtable taskDetails, Integer wddxContentId, Integer taskUIID) { + private ToolActivity setupToolActivity(Hashtable taskDetails, Integer wddxContentId, Integer taskUIID, String overrideTitle, String overrideDescription) { ToolActivity activity = new ToolActivity(); activity.setActivityUIID(taskUIID); activity.setActivityTypeId(Activity.TOOL_ACTIVITY_TYPE); - activity.setActivityCategoryID(Activity.CATEGORY_CONTENT); // first, find the matching new tool and set up the tool, tool content details. String toolType = (String) taskDetails.get(WDDXTAGS102.TASK_TOOLTYPE); - String title = (String) taskDetails.get(WDDXTAGS102.TITLE); + String toolTitle = (String) taskDetails.get(WDDXTAGS102.TITLE); + String toolDescription = (String) taskDetails.get(WDDXTAGS102.DESCRIPTION); Tool tool = toolType != null ? toolImportSupport.get(toolType) : null; if ( tool == null ) { - String message = "Unable to find a tool that supports the activity "+title+". This activity will be skipped. Activity is "+taskDetails; + String message = "Unable to find a tool that supports the activity "+toolTitle+". This activity will be skipped. Activity is "+taskDetails; log.warn(message); toolsErrorMsgs.add(message); return null; } + + + activity.setTitle( overrideTitle != null ? overrideTitle : toolTitle); + activity.setDescription( overrideDescription != null ? overrideDescription : toolDescription); ToolContent newContent = new ToolContent(tool); toolContentDAO.saveToolContent(newContent); @@ -924,19 +924,25 @@ ToolContentImport102Manager toolService = (ToolContentImport102Manager) context.getBean(tool.getServiceName()); toolService.import102ToolContent(toolContentId, importerDTO, content); } catch ( Exception e ) { - String message = "Tool content for activity "+title+" cannot be set up due to an error. Activity will be use the default content. Activity is "+taskDetails; + String message = "Tool content for activity "+toolTitle+" cannot be set up due to an error. Activity will be use the default content. Activity is "+taskDetails; log.warn(message,e); toolsErrorMsgs.add(message); } } else { - String message = "Tool content for activity "+title+" is missing. Activity will be set up with default content. Activity is "+taskDetails; + String message = "Tool content for activity "+toolTitle+" is missing. Activity will be set up with default content. Activity is "+taskDetails; log.warn(message); toolsErrorMsgs.add(message); } // Now find an icon for the activity. The icon is in the activity tables so look for a library activity that matches this tool. // It may not always find the right icon if there is more than one possible match but its a start! - activity.setLibraryActivityUiImage(libraryActivityUiImages.get(tool.getToolId())); + ToolActivity ta = libraryActivityForTool.get(tool.getToolId()); + if ( ta != null ) { + activity.setLibraryActivityUiImage(ta.getLibraryActivityUiImage()); + activity.setActivityCategoryID(ta.getActivityCategoryID()); + } else { + activity.setActivityCategoryID(Activity.CATEGORY_CONTENT); + } return activity; } @@ -1050,11 +1056,14 @@ optionsActivity.setMinNumberOfOptions(WDDXProcessor.convertToInteger(optionObj,WDDXTAGS102.OPTACT_MIN_NUMBER_COMPLETE)); optionsActivity.setMaxNumberOfOptions(null); // not supported in 1.0.2. optionsActivity.setOptionsInstructions(null); // not supported in 1.0.2. + optionsActivity.setDescription((String) optionObj.get(WDDXTAGS102.DESCRIPTION)); + optionsActivity.setTitle((String) optionObj.get(WDDXTAGS102.TITLE)); Integer xCoOrd = WDDXProcessor.convertToInteger(optionObj,WDDXTAGS102.ACT_X); Integer yCoOrd = WDDXProcessor.convertToInteger(optionObj,WDDXTAGS102.ACT_Y); + processCommonActivityFields(optionObj, xCoOrd, yCoOrd, optionsActivity); - + // work out the child activities and move them from the main activity set to the optional activity. Vector subActivityUIIDs = (Vector) optionObj.get(WDDXTAGS102.OPTACT_ACTIVITIES); int orderId = 1; @@ -1239,30 +1248,41 @@ return activity; } - /** Get all the tool icons based on the library activities + /** Get all the tool icons based on the library activities. Goes through all the library + * activities and pulls out the first occurance of each tool. Can't just go through the + * tool activities as not all tools have a standalone activity e.g. scribe * @return Map of tool icons - key is tool id, value is url. */ - private Map getLibraryActivityUiImages() { + private Map getLibraryActivityForTool() { - HashMap imageURLS = new HashMap(); + HashMap activityMap = new HashMap(); Iterator iterator = learningLibraryDAO.getAllLearningLibraries().iterator(); while(iterator.hasNext()){ LearningLibrary learningLibrary = (LearningLibrary)iterator.next(); List templateActivities = activityDAO.getActivitiesByLibraryID(learningLibrary.getLearningLibraryId()); Iterator actIterator = templateActivities.iterator(); while ( actIterator.hasNext() ) { - Activity activity = (Activity) actIterator.next(); - if ( activity.isToolActivity() ) { - ToolActivity toolActivity = (ToolActivity) activityDAO.getActivityByActivityId(activity.getActivityId(), ToolActivity.class); - Tool tool = toolActivity.getTool(); - if ( ! imageURLS.containsKey(tool.getToolId()) ) { - imageURLS.put(tool.getToolId(), activity.getLibraryActivityUiImage()); - } - } + getLibraryActivityFromActivity((Activity)actIterator.next(), activityMap); } } - return imageURLS; + return activityMap; } - + + private void getLibraryActivityFromActivity( Activity activity, HashMap activityMap ) { + if ( activity.isToolActivity() ) { + ToolActivity toolActivity = (ToolActivity) activityDAO.getActivityByActivityId(activity.getActivityId(), ToolActivity.class); + Tool tool = toolActivity.getTool(); + if ( ! activityMap.containsKey(tool.getToolId()) ) { + activityMap.put(tool.getToolId(), toolActivity); + } + } else if ( activity.isComplexActivity() ) { + ComplexActivity complex = (ComplexActivity) activity; + Iterator actIterator = complex.getActivities().iterator(); + while ( actIterator.hasNext() ) { + getLibraryActivityFromActivity((Activity)actIterator.next(), activityMap); + } + } + } + /** Get all Map of the current tools that support the 1.0.2 signatures. */ private Map getToolImportSupport() { Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentImport102Manager.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -rccd4ec9c17db772dd790b199a8d12f61bcc3595b --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentImport102Manager.java (.../ToolContentImport102Manager.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentImport102Manager.java (.../ToolContentImport102Manager.java) (revision ccd4ec9c17db772dd790b199a8d12f61bcc3595b) @@ -56,6 +56,7 @@ public static final String TAGS_SIMPLE_ASSESSMENT = "simpleassessment"; public static final String TAGS_URLCONTENT = "urlcontent"; public static final String TAGS_HTMLNOTICBOARD = "htmlnb"; + public static final String TAGS_SURVEY = "survey"; // the following tools haven't supported for a while or can't be supported by // import as they are tied to files which won't be in the import, @@ -72,6 +73,7 @@ public static final String CONTENT_DEFINE_LATER = "contentDefineLater"; // boolean // used public static final String CONTENT_TITLE = "title"; // used public static final String CONTENT_ID = "id"; // used + public static final String CONTENT_REUSABLE = "isReusable"; //type boolean // contentType is based on the content class used - doesn't persist public static final String CONTENT_TYPE = "contentType"; @@ -112,7 +114,6 @@ public static final String CONTENT_MB_POSTING_NOTIFIED = "isPostingNotified"; // type boolean public static final String CONTENT_MB_POSTING_MODERATED = "isPostingModerated"; // type boolean public static final String CONTENT_MB_NEW_TOPIC_ALLOWED = "isNewTopicAllowed"; //type boolean - public static final String CONTENT_MB_REUSABLE = "isReusable"; //type boolean public static final String CONTENT_MB_TOPICS = "topics"; // array public static final String CONTENT_MB_TOPIC_SUBJECT = "subject"; // string @@ -131,6 +132,21 @@ public static final String CONTENT_Q_CANDIDATES = "candidates"; // array of string public static final String CONTENT_Q_ANSWER = "answer"; // string + // Survey content + public static final String CONTENT_SURVEY_TEXTBOX_ENABLED = "isTextBoxEnabled"; // boolean + public static final String CONTENT_SURVEY_QUESTION_TYPE = "questionType"; // string + public static final String CONTENT_SURVEY_OPTIONAL = "isOptional"; // boolean + public static final String CONTENT_SURVEY_QUESTIONS = "questions"; // string + public static final String CONTENT_SURVEY_QUESTION = "question"; // string + public static final String CONTENT_SURVEY_CANDIDATES = "candidates"; // array of maps, each map contain order and answer + public static final String CONTENT_SURVEY_ORDER= "order"; // integer + public static final String CONTENT_SURVEY_ANSWER = "answer"; // string + public static final String CONTENT_SURVEY_COMPLETION_MESSAGE = "summary"; // string + + public static final String CONTENT_SURVEY_TYPE_SINGLE = "simpleChoice"; + public static final String CONTENT_SURVEY_TYPE_MULTIPLE = "choiceMultiple"; + public static final String CONTENT_SURVEY_TYPE_TEXTENTRY = "textEntry"; + // for file upload - SingleResource, HTMLNoticeboard, Image tools public static final String DIRECTORY_NAME = "directoryName";