Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r953f62a7fc515e2dc5c4ad983df233070cf7a82c -r463716d6023591c9c35eeb5057a16c903289029e Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java =================================================================== diff -u -r6c3fd8f37aa129672b89086bdc84cf2cc2ee79c7 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision 6c3fd8f37aa129672b89086bdc84cf2cc2ee79c7) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -469,7 +469,8 @@ int nextOrderId = 2; Activity nextActivity = defaultActivity.getTransitionFrom() != null - ? defaultActivity.getTransitionFrom().getToActivity() : null; + ? defaultActivity.getTransitionFrom().getToActivity() + : null; while (nextActivity != null) { boolean removed = unprocessedChildren.remove(nextActivity); if (!removed) { @@ -480,7 +481,8 @@ } nextActivity.setOrderId(nextOrderId++); nextActivity = nextActivity.getTransitionFrom() != null - ? nextActivity.getTransitionFrom().getToActivity() : null; + ? nextActivity.getTransitionFrom().getToActivity() + : null; } if (unprocessedChildren.size() > 0) { @@ -768,36 +770,25 @@ private void extractEvaluationObject(JSONObject activityDetails, ToolActivity toolActivity) throws ObjectExtractorException, JSONException { - - Set activityEvaluations = toolActivity.getActivityEvaluations(); - ActivityEvaluation activityEvaluation; - - // Get the first (only) ActivityEvaluation if it exists - if ((activityEvaluations != null) && (activityEvaluations.size() >= 1)) { - activityEvaluation = activityEvaluations.iterator().next(); - } else { - activityEvaluation = new ActivityEvaluation(); - } - String toolOutputDefinition = (String) JsonUtil.opt(activityDetails, AuthoringJsonTags.TOOL_OUTPUT_DEFINITION); - if (!StringUtils.isBlank(toolOutputDefinition)) { - activityEvaluations = new HashSet<>(); - activityEvaluation.setActivity(toolActivity); - activityEvaluation.setToolOutputDefinition(toolOutputDefinition); - activityEvaluations.add(activityEvaluation); - toolActivity.setActivityEvaluations(activityEvaluations); - baseDAO.insertOrUpdate(activityEvaluation); + if (StringUtils.isNotBlank(toolOutputDefinition)) { + ActivityEvaluation evaluation = toolActivity.getEvaluation(); + if (evaluation == null) { + evaluation = new ActivityEvaluation(); + evaluation.setActivity(toolActivity); + } + evaluation.setToolOutputDefinition(toolOutputDefinition); + String weight = (String) JsonUtil.opt(activityDetails, AuthoringJsonTags.TOOL_OUTPUT_WEIGHT); + if (StringUtils.isNotBlank(weight)) { + evaluation.setWeight(Float.valueOf(weight)); + } + toolActivity.setEvaluation(evaluation); + } else { // update the parent toolActivity - toolActivity.setActivityEvaluations(activityEvaluations); - activityDAO.insertOrUpdate(toolActivity); - - } else if (activityEvaluation.getUid() != null) { - // update the parent toolActivity - toolActivity.setActivityEvaluations(new HashSet()); - activityDAO.insertOrUpdate(toolActivity); - baseDAO.delete(activityEvaluation); + toolActivity.setEvaluation(null); } + activityDAO.update(toolActivity); } private void parseCompetences(JSONArray competenceList) throws ObjectExtractorException, JSONException { Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== diff -u -r144d391c51436459564a6346c241174506eca988 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 144d391c51436459564a6346c241174506eca988) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -403,8 +403,7 @@ SortedMap defns = lamsCoreToolService.getOutputDefinitionsFromTool(toolContentID, definitionType); - ArrayList defnDTOList = new ArrayList( - defns != null ? defns.size() : 0); + ArrayList defnDTOList = new ArrayList<>(defns != null ? defns.size() : 0); if (defns != null) { for (ToolOutputDefinition defn : defns.values()) { defnDTOList.add(new ToolOutputDefinitionDTO(defn)); @@ -857,8 +856,6 @@ updateCompetenceMappings(newLearningDesign.getCompetences(), newActivities); - updateEvaluations(newActivities); - try { AuthoringService.copyLearningDesignImages(originalLearningDesign.getLearningDesignId(), newLearningDesign.getLearningDesignId()); @@ -944,19 +941,6 @@ insertCompetenceMappings(mainDesign.getCompetences(), designToImport.getCompetences(), newActivities); - // For some reason, the evaluations will not save on insert when the - // learning design is saved, so doing it manually here - - this.updateEvaluations(newActivities); - - // for (Integer activityKey : newActivities.keySet()) { - // Activity activity = newActivities.get(activityKey); - // if (activity.isToolActivity()) { - // ToolActivity toolAct = (ToolActivity) activity; - // baseDAO.insertOrUpdateAll(toolAct.getActivityEvaluations()); - // } - // } - return mainDesign; } @@ -1027,16 +1011,16 @@ */ private HashMap updateDesignActivities(LearningDesign originalLearningDesign, LearningDesign newLearningDesign, int uiidOffset, String customCSV) { - HashMap newActivities = new HashMap(); // key + HashMap newActivities = new HashMap<>(); // key // is // UIID - HashMap newGroupings = new HashMap(); // key + HashMap newGroupings = new HashMap<>(); // key // is // UIID // as we create the activities, we need to record any "first child" // UIID's for the sequence activity to process later - Map firstChildUIIDToSequence = new HashMap(); + Map firstChildUIIDToSequence = new HashMap<>(); Set oldParentActivities = originalLearningDesign.getParentActivities(); if (oldParentActivities != null) { @@ -1115,7 +1099,7 @@ } if ((activity.getInputActivities() != null) && (activity.getInputActivities().size() > 0)) { - Set newInputActivities = new HashSet(); + Set newInputActivities = new HashSet<>(); Iterator inputIter = activity.getInputActivities().iterator(); while (inputIter.hasNext()) { Activity elem = (Activity) inputIter.next(); @@ -1293,7 +1277,7 @@ */ public void updateDesignCompetences(LearningDesign originalLearningDesign, LearningDesign newLearningDesign, boolean insert) { - HashSet newCompeteces = new HashSet(); + HashSet newCompeteces = new HashSet<>(); Set oldCompetences = originalLearningDesign.getCompetences(); if (oldCompetences != null) { @@ -1340,7 +1324,7 @@ for (Integer activityKey : newActivities.keySet()) { Activity activity = newActivities.get(activityKey); if (activity.isToolActivity()) { - Set newCompetenceMappings = new HashSet(); + Set newCompetenceMappings = new HashSet<>(); ToolActivity newToolActivity = (ToolActivity) activity; if (newToolActivity.getCompetenceMappings() != null) { for (CompetenceMapping competenceMapping : newToolActivity.getCompetenceMappings()) { @@ -1398,7 +1382,7 @@ for (Integer activityKey : newActivities.keySet()) { Activity activity = newActivities.get(activityKey); if (activity.isToolActivity()) { - Set newCompetenceMappings = new HashSet(); + Set newCompetenceMappings = new HashSet<>(); ToolActivity newToolActivity = (ToolActivity) activity; if (newToolActivity.getCompetenceMappings() != null) { for (CompetenceMapping competenceMapping : newToolActivity.getCompetenceMappings()) { @@ -1421,20 +1405,6 @@ } } - private void updateEvaluations(HashMap newActivities) { - - for (Integer key : newActivities.keySet()) { - Activity activity = newActivities.get(key); - if (activity.isToolActivity()) { - Set newActivityEvaluations = ((ToolActivity) activity).getActivityEvaluations(); - - if (newActivityEvaluations != null) { - baseDAO.insertOrUpdateAll(newActivityEvaluations); - } - } - } - } - /** * Determines the type of activity and returns a deep-copy of the same * @@ -1551,7 +1521,7 @@ @Override public Vector getToolActivities(Long learningDesignId, String languageCode) { LearningDesign learningDesign = learningDesignDAO.getLearningDesignById(learningDesignId); - Vector listOfAuthoringActivityDTOs = new Vector(); + Vector listOfAuthoringActivityDTOs = new Vector<>(); for (Iterator i = learningDesign.getActivities().iterator(); i.hasNext();) { Activity currentActivity = (Activity) i.next(); @@ -1744,9 +1714,10 @@ } if (gradebookToolOutputDefinitionName != null) { ActivityEvaluation evaluation = new ActivityEvaluation(); - evaluation.setActivity(activity); evaluation.setToolOutputDefinition(gradebookToolOutputDefinitionName); - baseDAO.insert(evaluation); + evaluation.setActivity(activity); + activity.setEvaluation(evaluation); + activityDAO.update(activity); } learningDesign.getActivities().add(activity); @@ -1802,7 +1773,7 @@ @Override public List updateLearningDesignAccessByUser(Integer userId) { List accessList = learningDesignDAO.getAccessByUser(userId); - List result = new LinkedList(); + List result = new LinkedList<>(); for (LearningDesignAccess access : accessList) { LearningDesign learningDesign = learningDesignDAO.getLearningDesignById(access.getLearningDesignId()); if (learningDesign == null) { Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java =================================================================== diff -u -r98b130b2a9491b0b7ec6da05f224b8f99f0fdeac -r463716d6023591c9c35eeb5057a16c903289029e --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision 98b130b2a9491b0b7ec6da05f224b8f99f0fdeac) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -173,8 +173,8 @@ if (method.equals(CentralConstants.METHOD_START)) { ldId = new Long(ldIdStr); - Long lessonId = startLesson(serverId, datetime, hashValue, username, ldId, courseId, title, desc, - country, lang, customCSV, presenceEnable, imEnable, enableNotifications); + Long lessonId = LessonManagerServlet.startLesson(serverId, datetime, hashValue, username, ldId, + courseId, title, desc, country, lang, customCSV, presenceEnable, imEnable, enableNotifications); element = document.createElement(CentralConstants.ELEM_LESSON); element.setAttribute(CentralConstants.ATTR_LESSON_ID, lessonId.toString()); @@ -388,7 +388,7 @@ user.getUserId(), customCSV, false, false, presenceEnable, imEnable, true, enableNotifications, false, false, null, null); // 2. create lessonClass for lesson - createLessonClass(lesson, organisation, user); + LessonManagerServlet.createLessonClass(lesson, organisation, user); // 3. start lesson monitoringService.startLesson(lesson.getLessonId(), user.getUserId()); // store information which extServer has started the lesson @@ -415,7 +415,7 @@ orgMap.getOrganisation().getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, false, presenceEnable, imEnable, true, enableNotifications, false, false, null, null); // 2. create lessonClass for lesson - createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); + LessonManagerServlet.createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); // 3. schedule lesson Date date = DateUtil.convertFromString(startDate, DateUtil.SCHEDULE_LESSON_FORMAT); monitoringService.startLessonOnSchedule(lesson.getLessonId(), date, userMap.getUser().getUserId()); @@ -739,8 +739,8 @@ private Long importLearningDesign(HttpServletRequest request, HttpServletResponse response, String filePath, String username, String serverId, String customCSV) throws RemoteException { - List ldErrorMsgs = new ArrayList(); - List toolsErrorMsgs = new ArrayList(); + List ldErrorMsgs = new ArrayList<>(); + List toolsErrorMsgs = new ArrayList<>(); Long ldId = null; Integer workspaceFolderUid = null; ExtUserUseridMap userMap; @@ -783,9 +783,9 @@ @SuppressWarnings("unchecked") private static void createLessonClass(Lesson lesson, Organisation organisation, User creator) { - List staffList = new LinkedList(); + List staffList = new LinkedList<>(); staffList.add(creator); - List learnerList = new LinkedList(); + List learnerList = new LinkedList<>(); Vector learnerVector = userManagementService .getUsersFromOrganisationByRole(organisation.getOrganisationId(), Role.LEARNER, true); learnerList.addAll(learnerVector); @@ -896,7 +896,8 @@ String[] learnerIdArray = (learnerIds != null) ? learnerIds.split(",") : new String[0]; String[] monitorIdArray = (monitorIds != null) ? monitorIds.split(",") : new String[0]; String[] firstNameArray = (firstNames != null) - ? firstNames.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1) : new String[0]; + ? firstNames.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1) + : new String[0]; String[] lastNameArray = (lastNames != null) ? lastNames.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1) : new String[0]; String[] emailArray = (emails != null) ? emails.split(",") : new String[0]; @@ -1032,7 +1033,7 @@ ExtServer extServer = integrationService.getExtServer(serverId); Authenticator.authenticate(extServer, datetime, username, hashValue); - List lessons = new LinkedList(); + List lessons = new LinkedList<>(); if (courseId != null) { ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(extServer.getSid(), courseId); @@ -1073,7 +1074,7 @@ } } lessonElement.setAttribute("lessonMaxPossibleMark", lessonMaxPossibleMark.toString()); - + List allUsers = integrationService.getExtUserUseridMapByExtServer(extServer); // if outputsUser is null we build results for the whole lesson, otherwise - for the specified learner @@ -1098,14 +1099,14 @@ } else { log.debug("Getting tool ouputs report for: " + lessonId + ". With learning design: " + lesson.getLearningDesign().getLearningDesignId()); - + List usersCompletedLesson = monitoringService.getUsersCompletedLesson(lessonId, null, null, true); List gradebookUserLessons = gradebookService.getGradebookUserLesson(lessonId); - + // add all users who had finished the lesson for (User user : usersCompletedLesson) { Integer userId = user.getUserId(); - + // find user's gradebookLessonMark (it will be null in cases when lesson contains zero activities that // set to produce toolOutputs) Double gradebookUserLessonMark = null; @@ -1130,19 +1131,19 @@ /* * Creates learner element and appends it to the specified lessonElement. - * + * * @param extServer - * + * * @param lessonElement - * + * * @param allUsers all available users associated with extServer - * + * * @param userId userId of the learner to whom this learnerElement corresponds - * + * * @param gradebookUserLessonMark mark of the gradebookUserLesson - * + * * @return - * + * * @throws Exception */ private void createLearnerElement(ExtServer extServer, Element lessonElement, List allUsers, @@ -1203,7 +1204,7 @@ Set activities = getLessonActivities(lesson); - Set learners = new TreeSet(); + Set learners = new TreeSet<>(); // if outputsUser is null we build results for the whole lesson, otherwise - for the specified learner if (outputsUser != null) { @@ -1231,7 +1232,7 @@ List toolSessions = toolService.getToolSessionsByLesson(lesson); // map contains pairs toolContentId -> toolOutputDefinitions - Map> toolOutputDefinitionsMap = new TreeMap>(); + Map> toolOutputDefinitionsMap = new TreeMap<>(); for (ToolActivity activity : activities) { Long toolContentId = activity.getToolContentId(); if (toolOutputDefinitionsMap.get(toolContentId) == null) { @@ -1325,8 +1326,8 @@ */ @SuppressWarnings("unchecked") private Set getLessonActivities(Lesson lesson) { - Set activities = new TreeSet(); - Set toolActivities = new TreeSet(); + Set activities = new TreeSet<>(); + Set toolActivities = new TreeSet<>(); /* * Hibernate CGLIB is failing to load the first activity in the sequence as a ToolActivity for some mysterious @@ -1412,14 +1413,12 @@ ToolOutputDefinition definition = toolOutputDefinitions.get(outputName); if (isAuthoredToolOutputs) { - Set activityEvaluations = activity.getActivityEvaluations(); - if (activityEvaluations != null) { - for (ActivityEvaluation evaluation : activityEvaluations) { - if (outputName.equals(evaluation.getToolOutputDefinition())) { - ToolOutput toolOutput = toolService.getOutputFromTool(outputName, toolSession, - learner.getUserId()); - activityElement.appendChild(getOutputElement(document, toolOutput, definition)); - } + ActivityEvaluation evaluation = activity.getEvaluation(); + if (evaluation != null) { + if (outputName.equals(evaluation.getToolOutputDefinition())) { + ToolOutput toolOutput = toolService.getOutputFromTool(outputName, toolSession, + learner.getUserId()); + activityElement.appendChild(getOutputElement(document, toolOutput, definition)); } } } else { Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -re62c22a43f556f1d516359cd5449893d7c2ea2d3 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision e62c22a43f556f1d516359cd5449893d7c2ea2d3) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -248,7 +248,7 @@ * Constructor for a Tool Activity. */ ToolActivity : function(id, uiid, toolContentID, toolID, learningLibraryID, authorURL, x, y, title, - readOnly, gradebookToolOutputDefinitionName) { + readOnly, evaluation) { this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; this.toolContentID = toolContentID; @@ -257,7 +257,8 @@ this.authorURL = authorURL; this.title = title; this.readOnly = readOnly; - this.gradebookToolOutputDefinitionName = gradebookToolOutputDefinitionName; + this.gradebookToolOutputDefinitionName = evaluation ? evaluation[0] : ""; + this.gradebookToolOutputWeight = evaluation && evaluation.length > 1 ? evaluation[1] : null; this.transitions = { 'from' : [], 'to' : [] @@ -1688,4 +1689,4 @@ branchingActivity.longestBranchLength = longestBranchLength; } -}; +}; \ No newline at end of file Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== diff -u -rc0d686afa3050184393439464ec5f40c656ba7e3 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision c0d686afa3050184393439464ec5f40c656ba7e3) +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -1514,8 +1514,7 @@ activityData.yCoord ? activityData.yCoord : 1, activityData.activityTitle, activityData.readOnly, - activityData.activityEvaluations.length > 0 - ? activityData.activityEvaluations[0] : ""); + activityData.evaluation); // for later reference activityData.activity = activity; break; @@ -2329,7 +2328,8 @@ 'maxOptions' : activity.maxOptions || null, 'stopAfterActivity' : activity.stopAfterActivity ? true : false, 'toolActivityUIID' : activity.input ? activity.input.uiid : null, - 'gradebookToolOutputDefinitionName' : activity.gradebookToolOutputDefinitionName + 'gradebookToolOutputDefinitionName' : activity.gradebookToolOutputDefinitionName == '' ? + null : activity.gradebookToolOutputDefinitionName }); var activityTransitions = activity instanceof ActivityDefs.BranchingActivity ? Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml =================================================================== diff -u -r2c216dc6ff16c074af2d2db0e8c6f528b0ca4456 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml (.../Activity.hbm.xml) (revision 2c216dc6ff16c074af2d2db0e8c6f528b0ca4456) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml (.../Activity.hbm.xml) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -159,14 +159,11 @@ - - @hibernate.set lazy="false" inverse="true" cascade="none" - @hibernate.collection-key column="activity_evaluation_id" - @hibernate.collection-one-to-many class="org.lamsfoundation.lams.evaluation.model.ActivityEvaluation" - - - - + @hibernate.set lazy="false" inverse="true" cascade="none" Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/ActivityEvaluation.hbm.xml =================================================================== diff -u -r8620cb3f29c4710a0ddfd597fdc1b676d4b2b4b0 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/ActivityEvaluation.hbm.xml (.../ActivityEvaluation.hbm.xml) (revision 8620cb3f29c4710a0ddfd597fdc1b676d4b2b4b0) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/ActivityEvaluation.hbm.xml (.../ActivityEvaluation.hbm.xml) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -6,52 +6,39 @@ - - - - - + + activity + - - - + + + - - + - \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20170829.sql =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20170829.sql (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20170829.sql (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -0,0 +1,22 @@ +-- 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------------------------- + +-- Add column for weighted outputs + +ALTER TABLE lams_activity_evaluation ADD COLUMN weight FLOAT(4,1) DEFAULT NULL, + DROP PRIMARY KEY, + ADD PRIMARY KEY (activity_id), + DROP COLUMN activity_evaluation_id; + +DELETE FROM lams_configuration WHERE config_key LIKE '%ClientVersion'; + +UPDATE lams_configuration SET config_value = '3.0.1' WHERE config_key = 'ServerVersionNumber'; + +----------------------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; Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ActivityEvaluation.java =================================================================== diff -u -r51fb2a37254f24bb2a805d4ffd54482c779f43fa -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ActivityEvaluation.java (.../ActivityEvaluation.java) (revision 51fb2a37254f24bb2a805d4ffd54482c779f43fa) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ActivityEvaluation.java (.../ActivityEvaluation.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -20,7 +20,6 @@ * **************************************************************** */ - package org.lamsfoundation.lams.learningdesign; /** @@ -29,48 +28,29 @@ * copied and exported in author. * * @author lfoxton - * - * - * */ public class ActivityEvaluation { - - private Long uid; - private Activity activity; + private Long activityId; + private ToolActivity activity; private String toolOutputDefinition; + private Float weight; - public ActivityEvaluation() { - super(); - // TODO Auto-generated constructor stub + public Long getActivityId() { + return activityId; } - /** - * - */ - public Long getUid() { - return uid; + public void setActivityId(Long activityId) { + this.activityId = activityId; } - public void setUid(Long uid) { - this.uid = uid; - } - - /** - * - * - * - */ - public Activity getActivity() { + public ToolActivity getActivity() { return activity; } - public void setActivity(Activity activity) { + public void setActivity(ToolActivity activity) { this.activity = activity; } - /** - * - */ public String getToolOutputDefinition() { return toolOutputDefinition; } @@ -79,4 +59,11 @@ this.toolOutputDefinition = toolOutputDefinition; } -} + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + this.weight = weight; + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java =================================================================== diff -u -r0353a54de8fc2b242756332894ebcda259a35011 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java (.../ToolActivity.java) (revision 0353a54de8fc2b242756332894ebcda259a35011) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java (.../ToolActivity.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -50,6 +50,8 @@ */ public class ToolActivity extends SimpleActivity implements Serializable { + private static final long serialVersionUID = -7500867438126908849L; + private static Logger log = Logger.getLogger(ToolActivity.class); /** Holds value of property toolContentId. */ @@ -63,7 +65,7 @@ private Set competenceMappings; - private Set activityEvaluations; + private ActivityEvaluation evaluation; private Set gradebookUserActivities; @@ -74,16 +76,16 @@ Integer orderId, java.util.Date createDateTime, LearningLibrary learningLibrary, Activity parentActivity, Activity libraryActivity, Integer parentUIID, LearningDesign learningDesign, Grouping grouping, Integer activityTypeId, Transition transitionTo, Transition transitionFrom, String languageFile, - Boolean stopAfterActivity, Set inputActivities, Tool tool, Long toolContentId, Set branchActivityEntries, - Set competenceMappings, Set activityEvaluations, + Boolean stopAfterActivity, Set inputActivities, Tool tool, Long toolContentId, + Set branchActivityEntries, Set competenceMappings, ActivityEvaluation evaluation, Set gradebookUserActivities) { super(activityId, id, description, title, xcoord, ycoord, orderId, createDateTime, learningLibrary, parentActivity, libraryActivity, parentUIID, learningDesign, grouping, activityTypeId, transitionTo, transitionFrom, languageFile, stopAfterActivity, inputActivities, branchActivityEntries); this.tool = tool; this.toolContentId = toolContentId; this.competenceMappings = competenceMappings; - this.activityEvaluations = activityEvaluations; + this.evaluation = evaluation; super.simpleActivityStrategy = new ToolActivityStrategy(this); this.gradebookUserActivities = gradebookUserActivities; } @@ -120,7 +122,7 @@ newToolActivity.setTool(this.getTool()); newToolActivity.setToolContentId(this.getToolContentId()); - Set newCompetenceMappings = new HashSet(); + Set newCompetenceMappings = new HashSet<>(); if (this.competenceMappings != null) { for (CompetenceMapping compMap : this.competenceMappings) { CompetenceMapping newComp = new CompetenceMapping(); @@ -132,18 +134,15 @@ newToolActivity.setCompetenceMappings(newCompetenceMappings); - Set newEvaluations = new HashSet(); - if (this.activityEvaluations != null) { - for (ActivityEvaluation evaluation : this.activityEvaluations) { - ActivityEvaluation newEvaluation = new ActivityEvaluation(); - newEvaluation.setActivity(newToolActivity); - newEvaluation.setToolOutputDefinition(evaluation.getToolOutputDefinition()); - newEvaluations.add(newEvaluation); - } + if (this.evaluation != null) { + ActivityEvaluation newEvaluation = new ActivityEvaluation(); + newEvaluation.setToolOutputDefinition(evaluation.getToolOutputDefinition()); + newEvaluation.setWeight(evaluation.getWeight()); + newEvaluation.setActivity(newToolActivity); + newToolActivity.setEvaluation(newEvaluation); } - newToolActivity.setActivityEvaluations(newEvaluations); - Set newGradebookUserActivities = new HashSet(); + Set newGradebookUserActivities = new HashSet<>(); if (this.gradebookUserActivities != null) { for (GradebookUserActivity gradebookAct : this.gradebookUserActivities) { GradebookUserActivity newGradebookAct = new GradebookUserActivity(); @@ -336,12 +335,12 @@ toolActivities.add(this); } - public Set getActivityEvaluations() { - return activityEvaluations; + public ActivityEvaluation getEvaluation() { + return evaluation; } - public void setActivityEvaluations(Set activityEvaluations) { - this.activityEvaluations = activityEvaluations; + public void setEvaluation(ActivityEvaluation evaluation) { + this.evaluation = evaluation; } public Set getGradebookUserActivities() { Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java =================================================================== diff -u -r51fb2a37254f24bb2a805d4ffd54482c779f43fa -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java (.../AuthoringActivityDTO.java) (revision 51fb2a37254f24bb2a805d4ffd54482c779f43fa) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java (.../AuthoringActivityDTO.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.Iterator; +import java.util.List; import java.util.Set; import org.lamsfoundation.lams.learningdesign.Activity; @@ -244,7 +245,7 @@ /** List of the UIIDs of the activities that are input activities for this activity */ private Integer toolActivityUIID; - private ArrayList activityEvaluations; + private List evaluation; /** * Used by a sequence activity to determine the start of the transition based sequence and used by tool based @@ -412,7 +413,7 @@ extLmsId = toolActivity.getTool().getExtLmsId(); helpURL = HelpUtil.constructToolURL(toolActivity.getTool().getHelpUrl(), toolSignature, "", languageCode); - competenceMappingTitles = new ArrayList(); + competenceMappingTitles = new ArrayList<>(); if (toolActivity.getCompetenceMappings() != null) { Set competenceMappings = toolActivity.getCompetenceMappings(); @@ -424,15 +425,18 @@ } } - activityEvaluations = new ArrayList(); - if (toolActivity.getActivityEvaluations() != null) { - for (ActivityEvaluation eval : toolActivity.getActivityEvaluations()) { - activityEvaluations.add(eval.getToolOutputDefinition()); + if (toolActivity.getEvaluation() != null) { + evaluation = new ArrayList(); + ActivityEvaluation eval = toolActivity.getEvaluation(); + evaluation.add(eval.getToolOutputDefinition()); + if (eval.getWeight() != null) { + String.valueOf(eval.getWeight()); } } plannerMetadataDTO = toolActivity.getPlannerMetadata() == null ? null : new PlannerActivityMetadataDTO(toolActivity.getPlannerMetadata()); + } private void addGateActivityAttributes(Object activity, ArrayList branchMappings) { @@ -1248,12 +1252,12 @@ this.competenceMappingTitles = competenceMappingTitles; } - public ArrayList getActivityEvaluations() { - return activityEvaluations; + public List getEvaluation() { + return evaluation; } - public void setActivityEvaluations(ArrayList activityEvaluations) { - this.activityEvaluations = activityEvaluations; + public void setEvaluation(List evaluation) { + this.evaluation = evaluation; } public PlannerActivityMetadataDTO getPlannerMetadataDTO() { Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java =================================================================== diff -u -r2623eb7399f1ea9633c776630f379fa48a21b7e9 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 2623eb7399f1ea9633c776630f379fa48a21b7e9) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -58,10 +58,10 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.contentrepository.exception.ItemNotFoundException; import org.lamsfoundation.lams.contentrepository.NodeKey; -import org.lamsfoundation.lams.contentrepository.exception.RepositoryCheckedException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; +import org.lamsfoundation.lams.contentrepository.exception.ItemNotFoundException; +import org.lamsfoundation.lams.contentrepository.exception.RepositoryCheckedException; import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.ActivityEvaluation; @@ -821,7 +821,7 @@ String currentVersionString = Configuration.get(ConfigurationKeys.SERVER_VERSION_NUMBER); try { - boolean isLaterVersion = !VersionUtil.isSameOrLaterVersionAsServer(versionString, true); + boolean isLaterVersion = !VersionUtil.isSameOrLaterVersionAsServer(versionString); if (isLaterVersion) { log.warn( "Importing a design from a later version of LAMS. There may be parts of the design that will fail to import. Design name \'" @@ -853,13 +853,20 @@ // all exported files from server version prior to 2.4.2 will require deletion of defineLater and runOffline // flags - boolean isEarlierVersionThan242 = !VersionUtil.isSameOrLaterVersion("2.4.2", versionString, true); + boolean isEarlierVersionThan242 = !VersionUtil.isSameOrLaterVersion("2.4.2", versionString); if (isEarlierVersionThan242) { Class problemClass = Class.forName(AuthoringActivityDTO.class.getName()); contentFilter.removeField(problemClass, "defineLater"); contentFilter.removeField(problemClass, "runOffline"); contentFilter.transformXML(fullFilePath); } + + boolean isEarlierVersionThan301 = !VersionUtil.isSameOrLaterVersion("3.0.1", versionString); + if (isEarlierVersionThan301) { + Class problemClass = Class.forName(AuthoringActivityDTO.class.getName()); + contentFilter.renameField(problemClass, "activityEvaluations", "evaluation"); + contentFilter.transformXML(fullFilePath); + } } private WorkspaceFolder getWorkspaceFolderForDesign(User importer, Integer workspaceFolderUid) @@ -1213,14 +1220,17 @@ act.setActivityId(null); activityDAO.insert(act); + List eval = actDto.getEvaluation(); // Once the activity is saved, we can import the ActivityEvaluations - if (actDto.getActivityEvaluations() != null) { - for (String toolOutputDefinition : actDto.getActivityEvaluations()) { - ActivityEvaluation activityEvaluation = new ActivityEvaluation(); - activityEvaluation.setToolOutputDefinition(toolOutputDefinition); - activityEvaluation.setActivity(act); - baseDAO.insertOrUpdate(activityEvaluation); + if (eval != null && eval.size() > 0) { + ActivityEvaluation activityEvaluation = new ActivityEvaluation(); + activityEvaluation.setToolOutputDefinition(eval.get(0)); + if (eval.size() > 1) { + activityEvaluation.setWeight(Float.valueOf(eval.get(1))); } + activityEvaluation.setActivity((ToolActivity) act); + ((ToolActivity) act).setEvaluation(activityEvaluation); + activityDAO.update(act); } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ToolContentVersionFilter.java =================================================================== diff -u -r5773f84ed608838de3521ecde87c52f3c72d478c -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ToolContentVersionFilter.java (.../ToolContentVersionFilter.java) (revision 5773f84ed608838de3521ecde87c52f3c72d478c) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ToolContentVersionFilter.java (.../ToolContentVersionFilter.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -178,7 +178,14 @@ node = node.getNextSibling(); if (oldNode.getNodeName().equals(renamed.oldFieldname)) { Element newElement = root.getOwnerDocument().createElement(renamed.newFieldname); - newElement.setTextContent(oldNode.getTextContent()); + if (oldNode.hasChildNodes()) { + NodeList children = oldNode.getChildNodes(); + for (int childIndex = 0; childIndex < children.getLength(); childIndex++) { + newElement.appendChild(children.item(childIndex).cloneNode(true)); + } + } else { + newElement.setTextContent(oldNode.getTextContent()); + } root.replaceChild(newElement, oldNode); ToolContentVersionFilter.log.debug("Field " + renamed.oldFieldname + " in class " + renamed.ownerClass.getName() + " was renamed to " + renamed.newFieldname); Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java =================================================================== diff -u -rb7de687cc7c54815ea555bb7674ef5b104e1c619 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision b7de687cc7c54815ea555bb7674ef5b104e1c619) +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -606,24 +606,20 @@ @Override public Long getActivityMaxPossibleMark(ToolActivity activity) { - // if ActivityEvaluation is not set it means activity will produce no toolOutputs and thus max possible mark is null - if ((activity == null) || (activity.getActivityEvaluations() == null) - || activity.getActivityEvaluations().isEmpty()) { + if ((activity == null) || (activity.getEvaluation() == null)) { return null; } // the first available activity evaluation will be the only one that activity has - ActivityEvaluation activityEvaluation = activity.getActivityEvaluations().iterator().next(); + ActivityEvaluation evaluation = activity.getEvaluation(); // searching for the according toolOutputDefinition SortedMap toolOutputDefinitions = getOutputDefinitionsFromTool( activity.getToolContentId(), ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION); for (String key : toolOutputDefinitions.keySet()) { ToolOutputDefinition toolOutputDefinition = toolOutputDefinitions.get(key); - - if (activityEvaluation.getToolOutputDefinition().equals(key)) { - + if (evaluation.getToolOutputDefinition().equals(key)) { Object upperLimit = toolOutputDefinition.getEndValue(); if ((upperLimit != null) && (upperLimit instanceof Long)) { return (Long) upperLimit; @@ -875,10 +871,10 @@ } @Override - public ToolCompletionStatus getCompletionStatusFromTool(User learner, Activity activity) { + public ToolCompletionStatus getCompletionStatusFromTool(User learner, Activity activity) { if (activity.isToolActivity()) { ToolSession session = getToolSessionByLearner(learner, activity); - ToolSessionManager toolService = (ToolSessionManager) findToolService(((ToolActivity)activity).getTool()); + ToolSessionManager toolService = (ToolSessionManager) findToolService(((ToolActivity) activity).getTool()); return toolService.getCompletionStatus(learner.getUserId().longValue(), session.getToolSessionId()); } return null; Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsToolService.java =================================================================== diff -u -r2abc3485dc2d24ea02044a64271f3ee0d3b8c11b -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsToolService.java (.../LamsToolService.java) (revision 2abc3485dc2d24ea02044a64271f3ee0d3b8c11b) +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsToolService.java (.../LamsToolService.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -25,7 +25,6 @@ import java.io.IOException; import java.util.Date; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -52,7 +51,6 @@ import org.lamsfoundation.lams.tool.dao.IToolContentDAO; import org.lamsfoundation.lams.tool.dao.IToolDAO; import org.lamsfoundation.lams.tool.dao.IToolSessionDAO; -import org.lamsfoundation.lams.tool.exception.LamsToolServiceException; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.FileUtilException; @@ -138,61 +136,41 @@ public Boolean isGroupedActivity(long toolContentID) { ToolActivity toolActivity = activityDAO.getToolActivityByToolContentId(toolContentID); boolean isGroupedActivity = toolActivity == null ? null : toolActivity.getApplyGrouping(); - + return isGroupedActivity; } - + @Override public void auditLogStartEditingActivityInMonitor(long toolContentID) { auditService.logStartEditingActivityInMonitor(toolContentID); - } + } @Override public String getActivityEvaluation(Long toolContentId) { - ToolActivity toolActivity = activityDAO.getToolActivityByToolContentId(toolContentId); - Set activityEvaluations = toolActivity.getActivityEvaluations(); - if (activityEvaluations.isEmpty()) { - return null; - } else { - ActivityEvaluation activityEvaluation = activityEvaluations.iterator().next(); - return activityEvaluation.getToolOutputDefinition(); - } + ActivityEvaluation evaluation = toolActivity.getEvaluation(); + return evaluation == null ? null : evaluation.getToolOutputDefinition(); } @Override public void setActivityEvaluation(Long toolContentId, String toolOutputDefinition) { - if (StringUtils.isEmpty(toolOutputDefinition)) { return; } ToolActivity toolActivity = activityDAO.getToolActivityByToolContentId(toolContentId); - Set activityEvaluations = toolActivity.getActivityEvaluations(); - - // Get the first (only) ActivityEvaluation if it exists - ActivityEvaluation activityEvaluation; + ActivityEvaluation evaluation = toolActivity.getEvaluation(); boolean isToolOutputDefinitionChanged = true; - if (activityEvaluations.isEmpty()) { - activityEvaluation = new ActivityEvaluation(); - activityEvaluation.setActivity(toolActivity); - - activityEvaluations = new HashSet(); - activityEvaluations.add(activityEvaluation); - toolActivity.setActivityEvaluations(activityEvaluations); - + if (evaluation == null) { + evaluation = new ActivityEvaluation(); + evaluation.setActivity(toolActivity); + toolActivity.setEvaluation(evaluation); } else { - activityEvaluation = activityEvaluations.iterator().next(); - isToolOutputDefinitionChanged = !toolOutputDefinition.equals(activityEvaluation.getToolOutputDefinition()); + isToolOutputDefinitionChanged = !toolOutputDefinition.equals(evaluation.getToolOutputDefinition()); } + evaluation.setToolOutputDefinition(toolOutputDefinition); + activityDAO.update(toolActivity); - activityEvaluation.setToolOutputDefinition(toolOutputDefinition); - activityDAO.insertOrUpdate(activityEvaluation); - - // update the parent toolActivity - toolActivity.setActivityEvaluations(activityEvaluations); - activityDAO.insertOrUpdate(toolActivity); - //update gradebook marks if required if (isToolOutputDefinitionChanged) { gradebookService.recalculateGradebookMarksForActivity(toolActivity); @@ -227,7 +205,7 @@ return leaderUserId; } - + @Override public Set getAllLeaderUserIds(Long toolSessionId, Integer learnerId) { Set leaderUserIds = null; @@ -236,12 +214,12 @@ ToolActivity specifiedActivity = toolSession.getToolActivity(); Activity leaderSelectionActivity = getNearestLeaderSelectionActivity(specifiedActivity, learnerId, toolSession.getLesson().getLessonId()); - + // check if there is leaderSelectionTool available if (leaderSelectionActivity != null) { leaderUserIds = getLeaderUserId(leaderSelectionActivity.getActivityId()); } - + return leaderUserIds; } @@ -285,7 +263,7 @@ toolActivity = (ToolActivity) activity; } - if (LamsToolService.LEADER_SELECTION_TOOL_SIGNATURE.equals(toolActivity.getTool().getToolSignature())) { + if (ILamsToolService.LEADER_SELECTION_TOOL_SIGNATURE.equals(toolActivity.getTool().getToolSignature())) { return activity; } @@ -301,7 +279,7 @@ if (completedActivity instanceof ToolActivity) { ToolActivity completedToolActivity = (ToolActivity) completedActivity; - if (LamsToolService.LEADER_SELECTION_TOOL_SIGNATURE + if (ILamsToolService.LEADER_SELECTION_TOOL_SIGNATURE .equals(completedToolActivity.getTool().getToolSignature())) { Date finishDate = completedActivities.get(completedActivity).getFinishDate(); @@ -352,7 +330,7 @@ public void setActivityDAO(IActivityDAO activityDAO) { this.activityDAO = activityDAO; } - + public void setAuditService(IAuditService auditService) { this.auditService = auditService; } Index: lams_common/src/java/org/lamsfoundation/lams/util/AuthoringJsonTags.java =================================================================== diff -u -rbd8e4d7f256d453e579e8138182bf51898b2b256 -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/util/AuthoringJsonTags.java (.../AuthoringJsonTags.java) (revision bd8e4d7f256d453e579e8138182bf51898b2b256) +++ lams_common/src/java/org/lamsfoundation/lams/util/AuthoringJsonTags.java (.../AuthoringJsonTags.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -203,4 +203,5 @@ /** Evaluation tool output tag */ public static final String TOOL_OUTPUT_DEFINITION = "gradebookToolOutputDefinitionName"; + public static final String TOOL_OUTPUT_WEIGHT = "gradebookToolOutputWeight"; } Index: lams_common/src/java/org/lamsfoundation/lams/util/VersionUtil.java =================================================================== diff -u -r51fb2a37254f24bb2a805d4ffd54482c779f43fa -r463716d6023591c9c35eeb5057a16c903289029e --- lams_common/src/java/org/lamsfoundation/lams/util/VersionUtil.java (.../VersionUtil.java) (revision 51fb2a37254f24bb2a805d4ffd54482c779f43fa) +++ lams_common/src/java/org/lamsfoundation/lams/util/VersionUtil.java (.../VersionUtil.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -20,7 +20,6 @@ * **************************************************************** */ - package org.lamsfoundation.lams.util; /** @@ -31,7 +30,7 @@ /** * Extract the three possible parts of the ServerVersionNumber. - * + * * @return Long[4] */ public static Long[] extractSystemVersionParts() throws NumberFormatException { @@ -42,7 +41,7 @@ * Extract the three possible parts of a version number. Should only be applied to data in the format * nn.nn.nn.nnnnnn, * such as the ServerVersionNumber value. - * + * * @return Long[4] */ public static Long[] extractVersionParts(String versionString) throws NumberFormatException { @@ -55,18 +54,15 @@ versionParts[1] = Long.parseLong(split[1]); if (split.length > 2) { versionParts[2] = Long.parseLong(split[2]); - if (split.length > 3) { - versionParts[3] = Long.parseLong(split[3]); - } } } } } return versionParts; } - public static boolean isSameOrLaterVersion(String versionOneString, String versionTwoString, - boolean compareOnlyFirstPart) throws NumberFormatException { + public static boolean isSameOrLaterVersion(String versionOneString, String versionTwoString) + throws NumberFormatException { Long[] versionTwo = VersionUtil.extractVersionParts(versionTwoString); Long[] versionOne = VersionUtil.extractVersionParts(versionOneString); int compareRes = VersionUtil.checkVersionPart(versionTwo[0], versionOne[0]); @@ -89,28 +85,20 @@ if (compareRes < 0) { return false; } - if (compareRes > 0) { - return true; - } - - return (compareOnlyFirstPart || VersionUtil.checkVersionPart(versionTwo[3], versionOne[3]) >= 0); + return true; } /** * Is the supplied version string the same as the current version? The comparison is done to the internal * server version, not the version displayed on the login screen. Splits the version into its three component part * for comparison. - * + * * @param versionString * String to be compared to the current Server version. - * @param compareOnlyFirstPart - * Set to true to only compare the Major and Minor version numbers (e.g. 2.0.4), set to false to compare - * the date part. */ - public static boolean isSameOrLaterVersionAsServer(String versionString, boolean compareOnlyFirstPart) - throws NumberFormatException { + public static boolean isSameOrLaterVersionAsServer(String versionString) throws NumberFormatException { String serverVersion = Configuration.get(ConfigurationKeys.SERVER_VERSION_NUMBER); - return VersionUtil.isSameOrLaterVersion(versionString, serverVersion, compareOnlyFirstPart); + return VersionUtil.isSameOrLaterVersion(versionString, serverVersion); } private static int checkVersionPart(Long version1, Long version2) { @@ -122,5 +110,4 @@ } return version1.compareTo(version2); } - -} +} \ No newline at end of file Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java =================================================================== diff -u -r1bcc3c28b03ff0c6eea307f258afb4ddb9d547dd -r463716d6023591c9c35eeb5057a16c903289029e --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 1bcc3c28b03ff0c6eea307f258afb4ddb9d547dd) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 463716d6023591c9c35eeb5057a16c903289029e) @@ -22,7 +22,6 @@ package org.lamsfoundation.lams.gradebook.service; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -351,14 +350,16 @@ } if (startDate != null) { - if (userTimeZone != null) + if (userTimeZone != null) { startDate = DateUtil.convertToTimeZoneFromDefault(userTimeZone, startDate); + } gradebookUserDTO.setStartDate(startDate); } if (learnerProgress.getFinishDate() != null) { - if (userTimeZone != null) + if (userTimeZone != null) { finishDate = DateUtil.convertToTimeZoneFromDefault(userTimeZone, finishDate); + } gradebookUserDTO.setFinishDate(finishDate); } @@ -502,14 +503,13 @@ Lesson lesson = lessonDAO.getLessonForActivity(activityId); if ((lesson == null) || (activity == null) || !(activity instanceof ToolActivity) - || (((ToolActivity) activity).getActivityEvaluations() == null) - || ((ToolActivity) activity).getActivityEvaluations().isEmpty()) { + || (((ToolActivity) activity).getEvaluation() == null)) { return; } ToolActivity toolActivity = (ToolActivity) activity; // Getting the first activity evaluation - ActivityEvaluation eval = toolActivity.getActivityEvaluations().iterator().next(); + ActivityEvaluation eval = toolActivity.getEvaluation(); String toolOutputDefinition = eval.getToolOutputDefinition(); Map userToGradebookUserActivityMap = getUserToGradebookUserActivityMap(activity, @@ -549,14 +549,13 @@ if ((toolSession == null) || (toolSession == null) || (learner == null) || (lesson == null) || (activity == null) || !(activity instanceof ToolActivity) - || (((ToolActivity) activity).getActivityEvaluations() == null) - || ((ToolActivity) activity).getActivityEvaluations().isEmpty()) { + || (((ToolActivity) activity).getEvaluation() == null)) { return; } ToolActivity toolActivity = (ToolActivity) activity; // Getting the first activity evaluation - ActivityEvaluation eval = toolActivity.getActivityEvaluations().iterator().next(); + ActivityEvaluation eval = toolActivity.getEvaluation(); try { ToolOutput toolOutput = toolService.getOutputFromTool(eval.getToolOutputDefinition(), toolSession, @@ -619,7 +618,7 @@ gradebookDAO.insertOrUpdate(gradebookUserActivity); //flush the session in order to make updated mark be available at calculating lesson total mark gradebookDAO.flush(); - + // Now update the lesson mark if (gradebookUserLesson == null) { gradebookUserLesson = new GradebookUserLesson(); @@ -734,8 +733,9 @@ Date startDate = lesson.getStartDateTime(); if (startDate != null) { - if (userTimeZone != null) + if (userTimeZone != null) { startDate = DateUtil.convertToTimeZoneFromDefault(userTimeZone, startDate); + } lessonRow.setStartDate(startDate); } @@ -764,14 +764,16 @@ } if (startDate != null) { - if (userTimeZone != null) + if (userTimeZone != null) { startDate = DateUtil.convertToTimeZoneFromDefault(userTimeZone, startDate); + } lessonRow.setStartDate(startDate); } if (learnerProgress.getFinishDate() != null) { - if (userTimeZone != null) + if (userTimeZone != null) { finishDate = DateUtil.convertToTimeZoneFromDefault(userTimeZone, finishDate); + } lessonRow.setFinishDate(finishDate); } } @@ -838,7 +840,7 @@ } ComplexActivity sequence = (ComplexActivity) activity; - Set childActivities = (Set) sequence.getActivities(); + Set childActivities = sequence.getActivities(); for (Activity childActivity : childActivities) { getActivityDataForLessonGradebookExport(activityToUserDTOMap, complexLearners, userToLearnerProgressMap, activityDAO.getActivityByActivityId(childActivity.getActivityId())); @@ -1184,12 +1186,14 @@ // start date if ((learnerProgress != null) && (learnerProgress.getStartDate() != null)) { - startDate = FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(learnerProgress.getStartDate()); + startDate = FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT + .format(learnerProgress.getStartDate()); } // finish date if ((learnerProgress != null) && (learnerProgress.getFinishDate() != null)) { - finishDate = FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(learnerProgress.getFinishDate()); + finishDate = FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT + .format(learnerProgress.getFinishDate()); } // calculate time taken @@ -1328,10 +1332,11 @@ rowList.add(lessonsNames); // Headers row---------------------- - if (simplified) + if (simplified) { rowList.add(createSelectedLessonsHeaderSimplified(selectedLessons, numberCellsPerRow)); - else + } else { rowList.add(createSelectedLessonsHeaderFull(selectedLessons, lessonActivitiesMap, numberCellsPerRow)); + } // Actual data rows---------------------- for (User learner : allLearners) { @@ -1365,7 +1370,7 @@ // group name String groupName = ""; - for (Group group : (Set) lesson.getLessonClass().getGroups()) { + for (Group group : lesson.getLessonClass().getGroups()) { if (group.hasLearner(learner)) { groupName = group.getGroupName(); break; @@ -1382,10 +1387,12 @@ } } String startDate = (learnerProgress == null || learnerProgress.getStartDate() == null) ? "" - : FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(learnerProgress.getStartDate()); + : FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT + .format(learnerProgress.getStartDate()); userRow[i++] = new ExcelCell(startDate, false); String finishDate = (learnerProgress == null || learnerProgress.getFinishDate() == null) ? "" - : FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(learnerProgress.getFinishDate()); + : FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT + .format(learnerProgress.getFinishDate()); userRow[i++] = new ExcelCell(finishDate, false); } @@ -1397,17 +1404,21 @@ Double mark = 0d; if (gradebookUserActivity != null) { mark = gradebookUserActivity.getMark(); - if (!simplified) + if (!simplified) { userRow[i++] = new ExcelCell(mark, false); + } } else { - if (!simplified) + if (!simplified) { userRow[i++] = new ExcelCell("", false); + } } Long activityTotalMarks = (activityToTotalMarkMap.get(activity.getActivityId()) != null) - ? activityToTotalMarkMap.get(activity.getActivityId()) : 0l; - if (!simplified) + ? activityToTotalMarkMap.get(activity.getActivityId()) + : 0l; + if (!simplified) { userRow[i++] = new ExcelCell(activityTotalMarks, false); + } lessonTotal += mark; overallTotal += mark; @@ -1986,7 +1997,7 @@ return map; } - + @Override public List getMarksArray(Long lessonId) { return gradebookDAO.getAllMarksForLesson(lessonId);