Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -r287e1d4f1242a8d584f71cab96bfd0365b6855c8 -rbd4fa408454e7389b4e60bc68f2488de88eff663
--- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 287e1d4f1242a8d584f71cab96bfd0365b6855c8)
+++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision bd4fa408454e7389b4e60bc68f2488de88eff663)
@@ -2,7 +2,7 @@
#language code: en
#locale code: AU
- # Exported from the LAMS Community by Ernie Ghiglione on Tue May 22 00:47:14 CST 2018
+ # Exported from the LAMS Community by Ernie Ghiglione on Fri Dec 28 00:41:13 CST 2018
#=================== labels for LAMS Central =================#
@@ -85,6 +85,7 @@
title.import.result =Import tool content result
title.import =Import tool content
title.import.instruction =Please choose LAMS sequence to import.
+title.import.instruction.antivirus =An antivirus scan will be performed. It can take a while.
title.export.loading =Export tool content loading
label.ld.zip.file =Learning design import file
msg.import.success =Learning design and activities imported successfully.
@@ -176,11 +177,8 @@
label.no =No
label.ok =OK
title.forgot.password =LAMS :: Forgot password
-label.forgot.password.confirm =Password request
forgot.password.email.subject =LAMS server - Forgot password response
forgot.password.email.body =Click the link below and it will take you to a page where you can change your password.
-forgot.password.email.sent =An email has been sent to your email address.
-error.user.not.found =Unable to find the username in LAMS. Please check your username and try again.
error.support.email.not.set =Email could not be sent. The LAMS server has not been configured to handle emails. Please contact your system administrator.
error.password.request.expired =This request for a new password has expired. Please click the "Forgot your Password" link again to make a new request.
label.forgot.password.instructions.1 =Please enter your user name or email below. An email will be sent to you shortly with a link that will allow you to change your password. You only need to enter one value.
@@ -189,13 +187,12 @@
label.forgot.password.username =By username
error.forgot.password.fields =Both fields are required. Please try again.
error.email.not.sent =Server failed to send email to recipient. Please contact your system administrator.
-error.email.not.found =Unable to find a user that matches the given email. Please check your email address and try again.
error.forgot.password.email =Please enter an email address.
error.forgot.password.username =Please enter a username.
button.select.another.importfile =Select another file to import
error.forgot.password.incorrect.key =The request key is incorrect or has already been used. Please click the "Forgot your Password" link again to make a new request.
lessonsearch.title =Search learners in lesson
-lessonsearch.instuctions =Please enter the login, first or last name of the learner. As you type the name of the matching learners will appear.
+lessonsearch.instuctions =Please enter the login, first or last name of the learner.
lessonsearch.results =Lessons in which ''''{0}'''' has been found
index.searchlesson =Learner Search
index.searchlesson.tooltip =Search learners across lessons
@@ -228,10 +225,7 @@
message.profile.partially.edited =Profile has only been partially updated due to server configuration.
message.partial.edit.only =Only contact fields are editable due to server configuration.
error.password.empty =New password cannot be empty.
-label.tutorial.enabled =Automatically open help assistants
label.portrait.create.new.portrait =Select an image to upload or use your computer's webcam to create your portrait.
-label.tutorial.disable.single =You have chosen not to show this video again. You can always play it using the video icon in the right upper corner of the page.
-label.tutorial.disable.all =Welcome to LAMS! As a new user, you might want to spend a few minutes looking at the new online assistant animations and videos to help you get the most out of LAMS. You can turn this option off if you are an experience LAMS user. If you are new to LAMS, we recommend that you leave this on to get contextual help. Do you want to to leave this option on?
message.preceding.lessons.not.finished.cannot.participate =Preceding lessons have not been finished. You cannot participate in the lesson until this condition is met.
index.conditions =Conditions
index.conditions.tooltip =Conditions to participate in this lesson
@@ -280,9 +274,6 @@
register.if.you.want.to.signup =If you want to sign up to LAMS as a new user, please select "Sign up" tab. If you already have an account, please select "Login" one.
register.signup.to.lams =Sign up
register.login =Login
-kaltura.select.upload =Select Upload tab to upload videos or Webcam to start webcam recording. After you have done with this press Next button. Assign a title to your video and follow the instructions to add your video(s).
-kaltura.error =Sorry, there was an error
-kaltura.upload.error =An error occurred processing this video. Please, reupload it.
index.remove.lesson =Remove
index.remove.lesson.tooltip =Permanently remove this lesson
label.edit =Edit
@@ -335,7 +326,7 @@
label.tab.conditions.dependencies =Dependencies
label.tab.conditions.dependencies.desc =Select a lesson that learners will need to complete before they can see the lesson you are about to create.
label.tab.conditions.timelimit =Time limitations
-label.tab.conditions.timelimit.desc =Set the number of days the lesson will be available to learners. After this period the lesson will no longer be shown. If the time should count from the moment the learner starts the lesson, select the option for individual time limit.
+label.tab.conditions.timelimit.desc =Set the number of days the lesson will be available to learners. After this period the lesson will no longer be shown. If the time should count from the moment the learner starts the lesson, select the option for individual time limit. If you are scheduling the lesson end on the Advanced tab then you can only set an individual time limit.
label.tab.conditions.timelimit.days =Number days:
label.tab.conditions.timelimit.individual =Is this time limit for each individual?
label.tab.conditions.enable =Enable
@@ -756,60 +747,139 @@
label.post.anonomously =Post anonymously
label.anonymous =Anonymous
label.anonymous.tooltip =Turn on "Post anonymously" to hide your name from other learners. Teachers will still be able to see your name.
-authoring.fla.page.ld.title.desc=Click to display sequence details
+authoring.fla.page.ld.title.desc =Click to display sequence details
+label.start =Start:
+label.end =End:
+error.lesson.with.scheduled.end.only.have.individual.limits =Lessons with a scheduled end date can only have individual time limits, not a lesson time limit.
+error.lesson.end.date.must.be.after.start.date =Scheduled end date must be after the start date.
+label.policies.title =Policies
+label.agree.to.policies.before.proceeding =Please agree to all the policies before proceeding
+label.consent.required =Consent is required
+label.agree.to.policy =I agree to the policy
+label.policy.name =Policy name
+label.policy.type =Policy type
+label.policy.type.site =Site policy
+label.policy.type.privacy =Privacy policy
+label.policy.type.third.party =Third party policy
+label.policy.type.other =Other policy
+label.summary =Summary
+label.full.policy =Full policy
+label.consent =Consent
+label.policies.consents =Policies and consents
+label.version =Version
+label.consented =Consented?
+label.consented.on =Consented on
+label.policy.details =Policy details
+authoring.fla.page.prop.gradebook.none =No score
+label.select.country =Select a country
+error.country.required =Country is required
+error.cannot.login.as.with.not.allow.direct.access =You cannot login as this user as they are an Integration Learner and 'Allow direct access to main LAMS page for Integration Learners' is turned off in the system configuration.
+signup.email.verify.body.1 =Hi there,
+signup.email.verify.body.2 =Please confirm your email address by clicking on the link below
+signup.email.verify.body.3 =Regards,
+signup.email.verify.body.4 =LAMS Signup System
+signup.email.welcome.body.1 =Hi there,
+signup.email.welcome.body.2 =You''ve successfully registered an account with username {0} on the LAMS server at {1}.
+signup.email.welcome.body.3 =If you ever forget your password, you can reset it via this URL
+signup.email.welcome.body.4 =Regards,
+signup.email.welcome.body.5 =LAMS Signup System
+authoring.fla.readonly.checkbox =read-only
+authoring.fla.readonly.forbidden =This sequence is read-only. If you want to modify it, you can create its copy.
+register.email.verify =A confirmation email will be sent before you are able to log in.
+signup.email.verify.sent =A confirmation email has been sent to {0}
Check your email and follow the instructions.
+authoring.enable.confidence.levels =Enable confidence levels
+authoring.fla.page.menu.apply.changes =Apply changes
+forgot.password.request.processed =If the email/username that you have provided exists, an email would be sent to the registered email address.
+label.view =View
+index.outcome.manage =Outcomes
+index.outcome.manage.tooltip =Manage learning outcomes and scales
+outcome.manage.title =Course outcomes
+outcome.manage.remove =Remove outcome
+outcome.manage.remove.confirm =Are you sure you want to remove this outcome?
+outcome.manage.add =Add outcome
+outcome.manage.edit =Edit outcome
+outcome.manage.view =View outcome
+outcome.manage.add.name =Name
+outcome.manage.add.code =Code
+outcome.manage.add.description =Description
+outcome.manage.add.global =Global
+outcome.manage.add.scale =Scale
+outcome.manage.add.save =Save
+outcome.manage.scope =Scope
+outcome.manage.scope.global =global
+outcome.manage.scope.course =course
+outcome.manage.add.error =Error while saving an outcome
+outcome.manage.add.error.name.blank =Name can not be blank
+outcome.manage.add.error.code.blank =Code can not be blank
+outcome.manage.add.error.scale.choose =You have to choose a scale
+scale.title =Scales
+scale.manage =Manage scales
+scale.manage.add =Add scale
+scale.manage.edit =Edit scale
+scale.manage.view =View scale
+scale.manage.title =Course scales
+scale.manage.remove =Remove scale
+scale.manage.remove.scale =Error while removing a scale. It is probably used in some outcomes.
+scale.manage.remove.confirm =Are you sure you want to remove this scale?
+scale.manage.add.value =Values
+scale.manage.add.value.info =Enter comma separated values in increasing order of value. For example, an A,B,C,D scale must be entered as D,C,B,A.
+scale.manage.add.value.error.blank =A value must not be blank
+scale.manage.add.error =Error while saving an outcome scale
+outcome.authoring.title =Learning outcomes
+outcome.authoring.input =Search and select by outcome name or code
+outcome.authoring.existing =Added outcomes
+outcome.authoring.existing.none =none
+outcome.export.date =Exported on:
+outcome.export =Export
+outcome.import =Import
+outcome.import.error =Error while importing outcomes or scales. Check logs.
+authoring.msg.close.cancel.save =Do you want to close this window without saving?
+authoring.msg.list.cancel.save =Do you want to return to the template list without saving?
+authoring.fla.page.menu.new.template =Use Template
+authoring.template.list.introduction =Select a template from the list to see more details about the design that will be created. You can the proceed to create the design or return back to this list.
+authoring.learning.design.templates =Learning Design Templates
+authoring.template.successful =Your design has been saved as {0}.
+authoring.label.sequence.title =Title of Sequence
+authoring.error.question.num =Question {0} may not be blank
+authoring.error.question.correct.num =One of the answers for Question {0} needs to be correct.
+authoring.description.application.exercise =Application Exercise (These question(s) will be shown during the analysis phase in the sequence.)
+authoring.label.grouping =Grouping
+authoring.label.grouping.learners.choice =Learner's Choice
+authoring.label.grouping.teachers.choice =Teacher's Choice
+authoring.label.grouping.random.allocation =Random Allocation
+authoring.label.numgroups =Number of groups:
+authoring.error.numgroups =Number of groups must be 1 to 99.
+authoring.label.numlearners =Number of learners:
+authoring.error.numlearners =Number of learners must be 1 to 99.
+authoring.error.group.data =Group settings are not correct.
+authoring.section.lessondetails =Lesson Details
+authoring.section.questions =Questions
+authoring.section.applicationexercise =Application Exercise
+authoring.section.introduction =Introduction
+authoring.create.question =Create Question
+authoring.create.essay.question =Create Essay Question
+authoring.create.mc.question =Create Multiple Choice Question
+authoring.label.application.exercise.num =Application Exercise {0}
+authoring.error.application.exercise.num =Application Exercise {0} may not be blank.
+authoring.label.question.num =Question {0}
+authoring.label.option.num =Option {0}
+authoring.error.option =Option may not be blank
+authoring.label.correct.question =Correct?
+authoring.create.option =Create Option
+button.next =Next
+button.previous =Previous
+button.return.to.template.list =Go back to Template list
+authoring.error.content.id =Content ID is missing
+authoring.error.question.must.have.answer.num =Question {0} must have at least one answer.
+authoring.error.application.exercise.must.have.answer.num =Application Exercise {0} must have at least one answer.
+authoring.error.application.exercise.must.have.100.percent =Application Exercise {0} must have at least one answer worth 100%.
+authoring.error.application.exercise.not.blank.and.grade =Application Exercise {0} may not be blank and must have a grade.
+authoring.label.grade =Grade
+authoring.label.none =None
+authoring.tbl.template.title =Team Based Learning
+authoring.tbl.template.description =Individual and Team Readiness Assessments followed by Application Exercises.
+authoring.tbl.desc.question =These questions are for iRA and tRA. Click "Create Question" to add more questions. Turn on "Enable confidence levels" to have the learners' confidence levels from the iRA shown on the tRA screen.
+authoring.tbl.desc.ae =State the questions for AE. Click "Create Question" to add more questions.
-#====== Templates
-authoring.msg.close.cancel.save=Do you want to close this window without saving?
-authoring.msg.list.cancel.save=Do you want to return to the template list without saving?
-authoring.fla.page.menu.new.template=Use Template
-authoring.template.list.introduction=Select a template from the list to see more details about the design that will be created. You can the proceed to create the design or return back to this list.
-authoring.learning.design.templates=Learning Design Templates
-authoring.template.successful=Your design has been saved as {0}.
-
-authoring.label.sequence.title=Title of Sequence
-authoring.error.sequence.title=Title of Sequence may not be blank
-authoring.error.question.num=Question {0} may not be blank
-authoring.error.question.correct.num=One of the answers for Question {0} needs to be correct.
-authoring.description.application.exercise=Application Exercise (These question(s) will be shown during the analysis phase in the sequence.)
-authoring.label.grouping=Grouping
-authoring.label.grouping.learners.choice=Learner's Choice
-authoring.label.grouping.teachers.choice=Teacher's Choice
-authoring.label.grouping.random.allocation=Random Allocation
-authoring.label.numgroups=Number of groups:
-authoring.error.numgroups=Number of groups must be 1 to 99.
-authoring.label.numlearners=Number of learners:
-authoring.error.numlearners=Number of learners must be 1 to 99.
-authoring.error.group.data=Group settings are not correct.
-authoring.section.lessondetails=Lesson Details
-authoring.section.questions=Questions
-authoring.section.applicationexercise=Application Exercise
-authoring.section.introduction=Introduction
-authoring.create.question=Create Question
-authoring.create.essay.question=Create Essay Question
-authoring.create.mc.question=Create Multiple Choice Question
-authoring.label.application.exercise.num=Application Exercise {0}
-authoring.error.application.exercise.num=Application Exercise {0} may not be blank.
-authoring.label.question.num=Question {0}
-authoring.label.option.num=Option {0}
-authoring.error.option=Option may not be blank
-authoring.label.correct.question=Correct?
-authoring.create.option=Create Option
-button.next=Next
-button.previous=Previous
-button.return.to.template.list=Go back to Template list
-authoring.error.content.id=Content ID is missing
-authoring.error.question.correct.num=One of the answers for Question {0} needs to be correct.
-authoring.error.question.must.have.answer.num=Question {0} must have at least one answer.
-authoring.error.application.exercise.must.have.answer.num=Application Exercise {0} must have at least one answer.
-authoring.error.application.exercise.must.have.100.percent=Application Exercise {0} must have at least one answer worth 100%.
-authoring.error.application.exercise.not.blank.and.grade=Application Exercise {0} may not be blank and must have a grade.
-authoring.label.grade=Grade
-authoring.label.none=None
-
-#=================== Specific to Team Based Learning (TBL) =========================#
-authoring.tbl.template.title=Team Based Learning
-authoring.tbl.template.description=Individual and Team Readiness Assessments followed by Application Exercises.
-authoring.tbl.desc.question=These questions are for iRA and tRA. Click "Create Question" to add more questions.
-authoring.tbl.desc.ae=State the questions for AE. Click "Create Question" to add more questions.
-#======= End labels: Exported 749 labels for en AU =====
+#======= End labels: Exported 872 labels for en AU =====
Index: lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java
===================================================================
diff -u -r287e1d4f1242a8d584f71cab96bfd0365b6855c8 -rbd4fa408454e7389b4e60bc68f2488de88eff663
--- lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision 287e1d4f1242a8d584f71cab96bfd0365b6855c8)
+++ lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision bd4fa408454e7389b4e60bc68f2488de88eff663)
@@ -34,9 +34,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.apache.tomcat.util.json.JSONArray;
-import org.apache.tomcat.util.json.JSONException;
-import org.apache.tomcat.util.json.JSONObject;
import org.lamsfoundation.lams.dao.IBaseDAO;
import org.lamsfoundation.lams.learningdesign.Activity;
import org.lamsfoundation.lams.learningdesign.ActivityEvaluation;
@@ -92,12 +89,17 @@
import org.lamsfoundation.lams.usermanagement.User;
import org.lamsfoundation.lams.usermanagement.WorkspaceFolder;
import org.lamsfoundation.lams.util.AuthoringJsonTags;
+import org.lamsfoundation.lams.util.CommonConstants;
import org.lamsfoundation.lams.util.Configuration;
import org.lamsfoundation.lams.util.ConfigurationKeys;
import org.lamsfoundation.lams.util.DateUtil;
import org.lamsfoundation.lams.util.FileUtil;
import org.lamsfoundation.lams.util.JsonUtil;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
/**
* @author Manpreet Minhas
* @author Mailing Truong
@@ -114,9 +116,6 @@
*/
public class ObjectExtractor implements IObjectExtractor {
- public static final Integer DEFAULT_COORD = new Integer(10); // default coordinate used if the entry came from Flash
- // is 0 or less.
-
protected IBaseDAO baseDAO = null;
protected ILearningDesignDAO learningDesignDAO = null;
protected IActivityDAO activityDAO = null;
@@ -315,16 +314,16 @@
}
@Override
- public LearningDesign extractSaveLearningDesign(JSONObject ldJSON, LearningDesign existingLearningDesign,
- WorkspaceFolder workspaceFolder, User user) throws ObjectExtractorException, ParseException, JSONException {
+ public LearningDesign extractSaveLearningDesign(ObjectNode ldJSON, LearningDesign existingLearningDesign,
+ WorkspaceFolder workspaceFolder, User user) throws ObjectExtractorException, ParseException {
// if the learningDesign already exists, update it, otherwise create a
// new one.
learningDesign = existingLearningDesign != null ? existingLearningDesign : new LearningDesign();
// Check the copy type. Can only update it if it is COPY_TYPE_NONE (ie
// authoring copy)
- Integer copyTypeID = (Integer) JsonUtil.opt(ldJSON, AuthoringJsonTags.COPY_TYPE);
+ Integer copyTypeID = JsonUtil.optInt(ldJSON, AuthoringJsonTags.COPY_TYPE);
if (copyTypeID == null) {
copyTypeID = LearningDesign.COPY_TYPE_NONE;
}
@@ -340,15 +339,15 @@
learningDesign.setWorkspaceFolder(workspaceFolder);
learningDesign.setUser(user);
- String contentFolderID = (String) JsonUtil.opt(ldJSON, AuthoringJsonTags.CONTENT_FOLDER_ID);
+ String contentFolderID = JsonUtil.optString(ldJSON, AuthoringJsonTags.CONTENT_FOLDER_ID);
if (contentFolderID == null) {
contentFolderID = FileUtil.generateUniqueContentFolderID();
ldJSON.put(AuthoringJsonTags.CONTENT_FOLDER_ID, contentFolderID);
}
learningDesign.setContentFolderID(contentFolderID);
if (existingLearningDesign == null) {
- Integer originalUserID = (Integer) JsonUtil.opt(ldJSON, AuthoringJsonTags.ORIGINAL_USER_ID);
+ Integer originalUserID = JsonUtil.optInt(ldJSON, AuthoringJsonTags.ORIGINAL_USER_ID);
if (originalUserID == null) {
learningDesign.setOriginalUser(user);
} else {
@@ -376,24 +375,24 @@
initialiseToolSessionMap(learningDesign);
// get the core learning design stuff - default to invalid
- learningDesign.setValidDesign(JsonUtil.opt(ldJSON, AuthoringJsonTags.VALID_DESIGN, false));
- learningDesign.setLearningDesignUIID((Integer) JsonUtil.opt(ldJSON, AuthoringJsonTags.LEARNING_DESIGN_UIID));
- learningDesign.setDescription((String) JsonUtil.opt(ldJSON, AuthoringJsonTags.DESCRIPTION));
- learningDesign.setTitle((String) JsonUtil.opt(ldJSON, AuthoringJsonTags.TITLE));
- learningDesign.setMaxID((Integer) JsonUtil.opt(ldJSON, AuthoringJsonTags.MAX_ID));
- learningDesign.setReadOnly((Boolean) JsonUtil.opt(ldJSON, AuthoringJsonTags.READ_ONLY));
+ learningDesign.setValidDesign(JsonUtil.optBoolean(ldJSON, AuthoringJsonTags.VALID_DESIGN, false));
+ learningDesign.setLearningDesignUIID(JsonUtil.optInt(ldJSON, AuthoringJsonTags.LEARNING_DESIGN_UIID));
+ learningDesign.setDescription(JsonUtil.optString(ldJSON, AuthoringJsonTags.DESCRIPTION));
+ learningDesign.setTitle(JsonUtil.optString(ldJSON, AuthoringJsonTags.TITLE));
+ learningDesign.setMaxID(JsonUtil.optInt(ldJSON, AuthoringJsonTags.MAX_ID));
+ learningDesign.setReadOnly(JsonUtil.optBoolean(ldJSON, AuthoringJsonTags.READ_ONLY));
learningDesign.setDateReadOnly(
- DateUtil.convertFromString((String) JsonUtil.opt(ldJSON, AuthoringJsonTags.DATE_READ_ONLY)));
- learningDesign.setHelpText((String) JsonUtil.opt(ldJSON, AuthoringJsonTags.HELP_TEXT));
- String version = (String) JsonUtil.opt(ldJSON, AuthoringJsonTags.VERSION);
+ DateUtil.convertFromString(JsonUtil.optString(ldJSON, AuthoringJsonTags.DATE_READ_ONLY)));
+ learningDesign.setHelpText(JsonUtil.optString(ldJSON, AuthoringJsonTags.HELP_TEXT));
+ String version = JsonUtil.optString(ldJSON, AuthoringJsonTags.VERSION);
if (version == null) {
version = Configuration.get(ConfigurationKeys.SERVER_VERSION_NUMBER);
}
- learningDesign.setDesignType((String) JsonUtil.opt(ldJSON, AuthoringJsonTags.DESIGN_TYPE));
+ learningDesign.setDesignType(JsonUtil.optString(ldJSON, AuthoringJsonTags.DESIGN_TYPE));
learningDesign.setVersion(version);
learningDesign.setDuration(JsonUtil.optLong(ldJSON, AuthoringJsonTags.DURATION));
- mode = (Integer) JsonUtil.opt(ldJSON, AuthoringJsonTags.SAVE_MODE);
+ mode = JsonUtil.optInt(ldJSON, AuthoringJsonTags.SAVE_MODE);
// Set creation date and modification date based on the server timezone,
// not the client.
@@ -407,7 +406,7 @@
License license = licenseDAO.getLicenseByID(licenseID);
learningDesign.setLicense(license);
}
- learningDesign.setLicenseText((String) JsonUtil.opt(ldJSON, AuthoringJsonTags.LICENSE_TEXT));
+ learningDesign.setLicenseText(JsonUtil.optString(ldJSON, AuthoringJsonTags.LICENSE_TEXT));
Long originalLearningDesignID = JsonUtil.optLong(ldJSON, AuthoringJsonTags.ORIGINAL_DESIGN_ID);
if (originalLearningDesignID != null) {
@@ -418,13 +417,12 @@
learningDesignDAO.insertOrUpdate(learningDesign);
// now process the "parts" of the learning design
- parseGroupings((JSONArray) JsonUtil.opt(ldJSON, AuthoringJsonTags.GROUPINGS));
- parseActivities((JSONArray) JsonUtil.opt(ldJSON, AuthoringJsonTags.ACTIVITIES));
- parseActivitiesToMatchUpParentandInputActivities(
- (JSONArray) JsonUtil.opt(ldJSON, AuthoringJsonTags.ACTIVITIES));
- parseTransitions((JSONArray) JsonUtil.opt(ldJSON, AuthoringJsonTags.TRANSITIONS));
- parseBranchMappings((JSONArray) JsonUtil.opt(ldJSON, AuthoringJsonTags.BRANCH_MAPPINGS));
- parseAnnotations((JSONArray) JsonUtil.opt(ldJSON, AuthoringJsonTags.ANNOTATIONS));
+ parseGroupings(JsonUtil.optArray(ldJSON, AuthoringJsonTags.GROUPINGS));
+ parseActivities(JsonUtil.optArray(ldJSON, AuthoringJsonTags.ACTIVITIES));
+ parseActivitiesToMatchUpParentandInputActivities(JsonUtil.optArray(ldJSON, AuthoringJsonTags.ACTIVITIES));
+ parseTransitions(JsonUtil.optArray(ldJSON, AuthoringJsonTags.TRANSITIONS));
+ parseBranchMappings(JsonUtil.optArray(ldJSON, AuthoringJsonTags.BRANCH_MAPPINGS));
+ parseAnnotations(JsonUtil.optArray(ldJSON, AuthoringJsonTags.ANNOTATIONS));
progressDefaultChildActivities();
@@ -587,25 +585,24 @@
}
}
- private void parseGroupings(JSONArray groupingsList) throws JSONException {
+ private void parseGroupings(ArrayNode groupingsList) {
// iterate through the list of groupings objects
// each object should contain information groupingUUID, groupingID,
// groupingTypeID
if (groupingsList != null) {
- for (int groupingIndex = 0; groupingIndex < groupingsList.length(); groupingIndex++) {
- JSONObject groupingDetails = groupingsList.getJSONObject(groupingIndex);
+ for (JsonNode groupingDetails : groupingsList) {
if (groupingDetails != null) {
- Grouping grouping = extractGroupingObject(groupingDetails);
+ Grouping grouping = extractGroupingObject((ObjectNode) groupingDetails);
groupingDAO.insertOrUpdate(grouping);
groupings.put(grouping.getGroupingUIID(), grouping);
}
}
}
}
- public Grouping extractGroupingObject(JSONObject groupingDetails) throws JSONException {
- Integer groupingUIID = (Integer) JsonUtil.opt(groupingDetails, "groupingUIID");
- Integer groupingTypeID = (Integer) JsonUtil.opt(groupingDetails, "groupingTypeID");
+ public Grouping extractGroupingObject(ObjectNode groupingDetails) {
+ Integer groupingUIID = JsonUtil.optInt(groupingDetails, "groupingUIID");
+ Integer groupingTypeID = JsonUtil.optInt(groupingDetails, "groupingTypeID");
Grouping grouping = groupings.get(groupingUIID);
// check that the grouping type is still okay - if it is we keep the
@@ -638,15 +635,14 @@
createLessonClass((LessonClass) grouping, groupingDetails);
}
- grouping.setMaxNumberOfGroups((Integer) JsonUtil.opt(groupingDetails, "maxNumberOfGroups"));
+ grouping.setMaxNumberOfGroups(JsonUtil.optInt(groupingDetails, "maxNumberOfGroups"));
Set groupsToDelete = new HashSet<>(grouping.getGroups());
- JSONArray groupsList = (JSONArray) JsonUtil.opt(groupingDetails, "groups");
+ ArrayNode groupsList = JsonUtil.optArray(groupingDetails, "groups");
if (groupsList != null) {
- for (int groupIndex = 0; groupIndex < groupsList.length(); groupIndex++) {
- JSONObject groupDetails = groupsList.getJSONObject(groupIndex);
- Group group = extractGroupObject(groupDetails, grouping);
+ for (JsonNode groupDetails : groupsList) {
+ Group group = extractGroupObject((ObjectNode) groupDetails, grouping);
groups.put(group.getGroupUIID(), group);
groupsToDelete.remove(group);
}
@@ -670,10 +666,10 @@
return grouping;
}
- private Group extractGroupObject(JSONObject groupDetails, Grouping grouping) throws JSONException {
+ private Group extractGroupObject(ObjectNode groupDetails, Grouping grouping) {
Group group = null;
- Integer groupUIID = (Integer) JsonUtil.opt(groupDetails, AuthoringJsonTags.GROUP_UIID);
+ Integer groupUIID = JsonUtil.optInt(groupDetails, AuthoringJsonTags.GROUP_UIID);
Long groupID = JsonUtil.optLong(groupDetails, AuthoringJsonTags.GROUP_ID);
// Does it exist already? If the group was created at runtime, there
@@ -705,23 +701,23 @@
grouping.getGroups().add(group);
}
- group.setGroupName((String) JsonUtil.opt(groupDetails, AuthoringJsonTags.GROUP_NAME));
+ group.setGroupName(JsonUtil.optString(groupDetails, AuthoringJsonTags.GROUP_NAME));
group.setGrouping(grouping);
group.setGroupUIID(groupUIID);
- group.setOrderId(JsonUtil.opt(groupDetails, AuthoringJsonTags.ORDER_ID, 0));
+ group.setOrderId(JsonUtil.optInt(groupDetails, AuthoringJsonTags.ORDER_ID, 0));
return group;
}
- private void createRandomGrouping(RandomGrouping randomGrouping, JSONObject groupingDetails) throws JSONException {
+ private void createRandomGrouping(RandomGrouping randomGrouping, ObjectNode groupingDetails) {
// the two settings are mutually exclusive. Authoring takes care of this,
// but we'll code it here too just to make sure.
- Integer numLearnersPerGroup = (Integer) JsonUtil.opt(groupingDetails, AuthoringJsonTags.LEARNERS_PER_GROUP);
+ Integer numLearnersPerGroup = JsonUtil.optInt(groupingDetails, AuthoringJsonTags.LEARNERS_PER_GROUP);
if ((numLearnersPerGroup != null) && (numLearnersPerGroup.intValue() > 0)) {
randomGrouping.setLearnersPerGroup(numLearnersPerGroup);
randomGrouping.setNumberOfGroups(null);
} else {
- Integer numGroups = (Integer) JsonUtil.opt(groupingDetails, AuthoringJsonTags.NUMBER_OF_GROUPS);
+ Integer numGroups = JsonUtil.optInt(groupingDetails, AuthoringJsonTags.NUMBER_OF_GROUPS);
if ((numGroups != null) && (numGroups.intValue() > 0)) {
randomGrouping.setNumberOfGroups(numGroups);
} else {
@@ -731,21 +727,19 @@
}
}
- private void createChosenGrouping(ChosenGrouping chosenGrouping, JSONObject groupingDetails) {
+ private void createChosenGrouping(ChosenGrouping chosenGrouping, ObjectNode groupingDetails) {
// no extra properties as yet
}
- private void parseActivities(JSONArray activitiesList) throws ObjectExtractorException, JSONException {
-
+ private void parseActivities(ArrayNode activitiesList) throws ObjectExtractorException {
if (activitiesList != null) {
- for (int activityIndex = 0; activityIndex < activitiesList.length(); activityIndex++) {
- JSONObject activityDetails = activitiesList.getJSONObject(activityIndex);
- Activity activity = extractActivityObject(activityDetails);
+ for (JsonNode activityDetails : activitiesList) {
+ Activity activity = extractActivityObject((ObjectNode) activityDetails);
activityDAO.insertOrUpdate(activity);
// if its a tool activity, extract evaluation details
if (activity.isToolActivity()) {
- extractEvaluationObject(activityDetails, (ToolActivity) activity);
+ extractEvaluationObject((ObjectNode) activityDetails, (ToolActivity) activity);
}
newActivityMap.put(activity.getActivityUIID(), activity);
@@ -768,9 +762,9 @@
learningDesignDAO.insertOrUpdate(learningDesign);
}
- private void extractEvaluationObject(JSONObject activityDetails, ToolActivity toolActivity)
- throws ObjectExtractorException, JSONException {
- String toolOutputDefinition = (String) JsonUtil.opt(activityDetails, AuthoringJsonTags.TOOL_OUTPUT_DEFINITION);
+ private void extractEvaluationObject(ObjectNode activityDetails, ToolActivity toolActivity)
+ throws ObjectExtractorException {
+ String toolOutputDefinition = JsonUtil.optString(activityDetails, AuthoringJsonTags.TOOL_OUTPUT_DEFINITION);
if (StringUtils.isNotBlank(toolOutputDefinition)) {
ActivityEvaluation evaluation = toolActivity.getEvaluation();
if (evaluation == null) {
@@ -779,7 +773,7 @@
}
evaluation.setToolOutputDefinition(toolOutputDefinition);
- String weight = (String) JsonUtil.opt(activityDetails, AuthoringJsonTags.TOOL_OUTPUT_WEIGHT);
+ String weight = JsonUtil.optString(activityDetails, AuthoringJsonTags.TOOL_OUTPUT_WEIGHT);
if (StringUtils.isBlank(weight)) {
evaluation.setWeight(null);
} else {
@@ -793,13 +787,12 @@
activityDAO.update(toolActivity);
}
- private void parseCompetences(JSONArray competenceList) throws ObjectExtractorException, JSONException {
+ private void parseCompetences(ArrayNode competenceList) throws ObjectExtractorException {
Set existingCompetences = learningDesign.getCompetences();
if (competenceList != null) {
- for (int competenceIndex = 0; competenceIndex < competenceList.length(); competenceIndex++) {
- JSONObject competeneJSON = competenceList.getJSONObject(competenceIndex);
- String title = competeneJSON.getString(AuthoringJsonTags.TITLE);
- String description = competeneJSON.getString(AuthoringJsonTags.DESCRIPTION);
+ for (JsonNode competenceJSON : competenceList) {
+ String title = JsonUtil.optString(competenceJSON, AuthoringJsonTags.TITLE);
+ String description = JsonUtil.optString(competenceJSON, AuthoringJsonTags.DESCRIPTION);
if (getComptenceFromSet(existingCompetences, title) != null) {
Competence updateCompetence = getComptenceFromSet(existingCompetences, title);
@@ -818,12 +811,12 @@
// that dont exist in the new list.
Set removeCompetences = new HashSet<>();
if (existingCompetences != null) {
- if ((competenceList != null) && (competenceList.length() > 0)) {
+ if ((competenceList != null) && (competenceList.size() > 0)) {
for (Competence existingCompetence : existingCompetences) {
boolean remove = true;
- for (int competenceIndex = 0; competenceIndex < competenceList.length(); competenceIndex++) {
- if (existingCompetence.getTitle().equals(
- competenceList.getJSONObject(competenceIndex).getString(AuthoringJsonTags.TITLE))) {
+ for (JsonNode competenceJSON : competenceList) {
+ if (existingCompetence.getTitle()
+ .equals(JsonUtil.optString(competenceJSON, AuthoringJsonTags.TITLE))) {
remove = false;
break;
}
@@ -842,7 +835,7 @@
}
}
- private void parseAnnotations(JSONArray annotationList) throws ObjectExtractorException, JSONException {
+ private void parseAnnotations(ArrayNode annotationList) throws ObjectExtractorException {
if (annotationList == null) {
return;
}
@@ -854,14 +847,13 @@
}
Set updatedAnnotations = new HashSet<>();
- for (int annotationIndex = 0; annotationIndex < annotationList.length(); annotationIndex++) {
- JSONObject annotationJSON = annotationList.getJSONObject(annotationIndex);
+ for (JsonNode annotationJSON : annotationList) {
boolean found = false;
LearningDesignAnnotation annotation = null;
for (LearningDesignAnnotation existingAnnotation : existingAnnotations) {
if (existingAnnotation.getAnnotationUIID()
- .equals(annotationJSON.getInt(AuthoringJsonTags.ANNOTATION_UIID))) {
+ .equals(JsonUtil.optInt(annotationJSON, AuthoringJsonTags.ANNOTATION_UIID))) {
annotation = existingAnnotation;
found = true;
break;
@@ -872,14 +864,14 @@
annotation = new LearningDesignAnnotation();
}
annotation.setLearningDesignId(learningDesign.getLearningDesignId());
- annotation.setAnnotationUIID(annotationJSON.getInt(AuthoringJsonTags.ANNOTATION_UIID));
- annotation.setTitle((String) JsonUtil.opt(annotationJSON, AuthoringJsonTags.TITLE));
- annotation.setXcoord((Integer) JsonUtil.opt(annotationJSON, AuthoringJsonTags.XCOORD));
- annotation.setYcoord((Integer) JsonUtil.opt(annotationJSON, AuthoringJsonTags.YCOORD));
- annotation.setEndXcoord((Integer) JsonUtil.opt(annotationJSON, AuthoringJsonTags.END_XCOORD));
- annotation.setEndYcoord((Integer) JsonUtil.opt(annotationJSON, AuthoringJsonTags.END_YCOORD));
- annotation.setColor((String) JsonUtil.opt(annotationJSON, AuthoringJsonTags.COLOR));
- String size = (String) JsonUtil.opt(annotationJSON, AuthoringJsonTags.SIZE);
+ annotation.setAnnotationUIID(JsonUtil.optInt(annotationJSON, AuthoringJsonTags.ANNOTATION_UIID));
+ annotation.setTitle(JsonUtil.optString(annotationJSON, AuthoringJsonTags.TITLE));
+ annotation.setXcoord(JsonUtil.optInt(annotationJSON, AuthoringJsonTags.XCOORD));
+ annotation.setYcoord(JsonUtil.optInt(annotationJSON, AuthoringJsonTags.YCOORD));
+ annotation.setEndXcoord(JsonUtil.optInt(annotationJSON, AuthoringJsonTags.END_XCOORD));
+ annotation.setEndYcoord(JsonUtil.optInt(annotationJSON, AuthoringJsonTags.END_YCOORD));
+ annotation.setColor(JsonUtil.optString(annotationJSON, AuthoringJsonTags.COLOR));
+ String size = JsonUtil.optString(annotationJSON, AuthoringJsonTags.SIZE);
if (size != null) {
annotation.setSize(Short.valueOf(size));
}
@@ -909,17 +901,15 @@
return null;
}
- private void parseActivitiesToMatchUpParentandInputActivities(JSONArray activitiesList)
- throws ObjectExtractorException, JSONException {
+ private void parseActivitiesToMatchUpParentandInputActivities(ArrayNode activitiesList)
+ throws ObjectExtractorException {
if (activitiesList != null) {
- for (int activityIndex = 0; activityIndex < activitiesList.length(); activityIndex++) {
- JSONObject activityDetails = activitiesList.getJSONObject(activityIndex);
-
- Integer activityUUID = activityDetails.getInt(AuthoringJsonTags.ACTIVITY_UIID);
+ for (JsonNode activityDetails : activitiesList) {
+ Integer activityUUID = JsonUtil.optInt(activityDetails, AuthoringJsonTags.ACTIVITY_UIID);
Activity existingActivity = newActivityMap.get(activityUUID);
// match up activity to parent based on UIID
- Integer parentUIID = (Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.PARENT_UIID);
+ Integer parentUIID = JsonUtil.optInt(activityDetails, AuthoringJsonTags.PARENT_UIID);
if (parentUIID != null) {
Activity parentActivity = newActivityMap.get(parentUIID);
@@ -945,7 +935,7 @@
// match up activity to input activities based on UIID. At
// present there will be only one input activity
existingActivity.getInputActivities().clear();
- Integer inputActivityUIID = (Integer) JsonUtil.opt(activityDetails,
+ Integer inputActivityUIID = JsonUtil.optInt(activityDetails,
AuthoringJsonTags.INPUT_TOOL_ACTIVITY_UIID);
if (inputActivityUIID != null) {
Activity inputActivity = newActivityMap.get(inputActivityUIID);
@@ -962,14 +952,13 @@
}
}
- private void parseTransitions(JSONArray transitionsList) throws JSONException {
+ private void parseTransitions(ArrayNode transitionsList) {
HashMap newMap = new HashMap<>();
if (transitionsList != null) {
- for (int transitionIndex = 0; transitionIndex < transitionsList.length(); transitionIndex++) {
- JSONObject transitionDetails = transitionsList.getJSONObject(transitionIndex);
- Transition transition = extractTransitionObject(transitionDetails);
+ for (JsonNode transitionDetails : transitionsList) {
+ Transition transition = extractTransitionObject((ObjectNode) transitionDetails);
// Check if transition actually exists. extractTransitionObject
// returns null
// if neither the to/from activity exists.
@@ -1004,11 +993,11 @@
}
- public Activity extractActivityObject(JSONObject activityDetails) throws ObjectExtractorException, JSONException {
+ public Activity extractActivityObject(ObjectNode activityDetails) throws ObjectExtractorException {
// it is assumed that the activityUUID will always be sent by Authoring
- Integer activityUIID = (Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.ACTIVITY_UIID);
- Integer activityTypeID = (Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.ACTIVITY_TYPE_ID);
+ Integer activityUIID = JsonUtil.optInt(activityDetails, AuthoringJsonTags.ACTIVITY_UIID);
+ Integer activityTypeID = JsonUtil.optInt(activityDetails, AuthoringJsonTags.ACTIVITY_TYPE_ID);
Activity activity = null;
// get the activity with the particular activity uuid, if null, then new
@@ -1027,13 +1016,13 @@
activity.setActivityTypeId(activityTypeID);
activity.setActivityUIID(activityUIID);
- activity.setDescription((String) JsonUtil.opt(activityDetails, AuthoringJsonTags.DESCRIPTION));
- activity.setTitle((String) JsonUtil.opt(activityDetails, AuthoringJsonTags.ACTIVITY_TITLE));
+ activity.setDescription(JsonUtil.optString(activityDetails, AuthoringJsonTags.DESCRIPTION));
+ activity.setTitle(JsonUtil.optString(activityDetails, AuthoringJsonTags.ACTIVITY_TITLE));
activity.setXcoord(getCoord(activityDetails, AuthoringJsonTags.XCOORD));
activity.setYcoord(getCoord(activityDetails, AuthoringJsonTags.YCOORD));
- Integer groupingUIID = (Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.GROUPING_UIID);
+ Integer groupingUIID = JsonUtil.optInt(activityDetails, AuthoringJsonTags.GROUPING_UIID);
if (groupingUIID == null) {
clearGrouping(activity);
@@ -1049,7 +1038,7 @@
}
- activity.setOrderId((Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.ORDER_ID));
+ activity.setOrderId(JsonUtil.optInt(activityDetails, AuthoringJsonTags.ORDER_ID));
activity.setLearningDesign(learningDesign);
@@ -1065,20 +1054,20 @@
activity.setCreateDateTime(modificationDate);
}
- activity.setActivityCategoryID((Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.ACTIVITY_CATEGORY_ID));
- activity.setLibraryActivityUiImage((String) JsonUtil.opt(activityDetails, AuthoringJsonTags.LIBRARY_IMAGE));
- activity.setGroupingSupportType(
- (Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.GROUPING_SUPPORT_TYPE));
- activity.setStopAfterActivity(JsonUtil.opt(activityDetails, AuthoringJsonTags.STOP_AFTER_ACTIVITY, false));
+ activity.setActivityCategoryID(JsonUtil.optInt(activityDetails, AuthoringJsonTags.ACTIVITY_CATEGORY_ID));
+ activity.setLibraryActivityUiImage(JsonUtil.optString(activityDetails, AuthoringJsonTags.LIBRARY_IMAGE));
+ activity.setGroupingSupportType(JsonUtil.optInt(activityDetails, AuthoringJsonTags.GROUPING_SUPPORT_TYPE));
+ activity.setStopAfterActivity(
+ JsonUtil.optBoolean(activityDetails, AuthoringJsonTags.STOP_AFTER_ACTIVITY, false));
return activity;
}
- private Integer getCoord(JSONObject details, String tag) throws JSONException {
+ private Integer getCoord(ObjectNode details, String tag) {
// the coordinate can be Integer or Double in JSON, need to be ready for any
- Number number = (Number) JsonUtil.opt(details, tag);
+ Number number = JsonUtil.optDouble(details, tag);
Integer coord = number == null ? null : number.intValue();
- return (coord == null) || (coord >= 0) ? coord : ObjectExtractor.DEFAULT_COORD;
+ return (coord == null) || (coord >= 0) ? coord : CommonConstants.DEFAULT_COORD;
}
private void clearGrouping(Activity activity) {
@@ -1093,8 +1082,7 @@
activity.setApplyGrouping(true);
}
- private void processActivityType(Activity activity, JSONObject activityDetails)
- throws ObjectExtractorException, JSONException {
+ private void processActivityType(Activity activity, ObjectNode activityDetails) throws ObjectExtractorException {
if (activity.isGroupingActivity()) {
buildGroupingActivity((GroupingActivity) activity, activityDetails);
} else if (activity.isToolActivity()) {
@@ -1106,17 +1094,16 @@
}
}
- private void buildComplexActivity(ComplexActivity activity, JSONObject activityDetails)
- throws ObjectExtractorException, JSONException {
+ private void buildComplexActivity(ComplexActivity activity, ObjectNode activityDetails)
+ throws ObjectExtractorException {
// clear all the children - will be built up again by
// parseActivitiesToMatchUpParentActivityByParentUIID
// we don't use all-delete-orphan on the activities relationship so we
// can do this clear.
activity.getActivities().clear();
activity.setDefaultActivity(null);
- Integer defaultActivityMapUIID = (Integer) JsonUtil.opt(activityDetails,
- AuthoringJsonTags.DEFAULT_ACTIVITY_UIID);
+ Integer defaultActivityMapUIID = JsonUtil.optInt(activityDetails, AuthoringJsonTags.DEFAULT_ACTIVITY_UIID);
if (defaultActivityMapUIID != null) {
defaultActivityMap.put(defaultActivityMapUIID, activity);
}
@@ -1135,25 +1122,24 @@
}
}
- private void buildFloatingActivity(FloatingActivity floatingActivity, JSONObject activityDetails)
- throws ObjectExtractorException, JSONException {
- floatingActivity
- .setMaxNumberOfActivities((Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.MAX_ACTIVITIES));
+ private void buildFloatingActivity(FloatingActivity floatingActivity, ObjectNode activityDetails)
+ throws ObjectExtractorException {
+ floatingActivity.setMaxNumberOfActivities(JsonUtil.optInt(activityDetails, AuthoringJsonTags.MAX_ACTIVITIES));
SystemTool systemTool = getSystemTool(SystemTool.FLOATING_ACTIVITIES);
floatingActivity.setSystemTool(systemTool);
}
- private void buildBranchingActivity(BranchingActivity branchingActivity, JSONObject activityDetails)
- throws ObjectExtractorException, JSONException {
+ private void buildBranchingActivity(BranchingActivity branchingActivity, ObjectNode activityDetails)
+ throws ObjectExtractorException {
if (branchingActivity.isChosenBranchingActivity()) {
branchingActivity.setSystemTool(getSystemTool(SystemTool.TEACHER_CHOSEN_BRANCHING));
} else if (branchingActivity.isGroupBranchingActivity()) {
branchingActivity.setSystemTool(getSystemTool(SystemTool.GROUP_BASED_BRANCHING));
} else if (branchingActivity.isToolBranchingActivity()) {
branchingActivity.setSystemTool(getSystemTool(SystemTool.TOOL_BASED_BRANCHING));
((ToolBranchingActivity) branchingActivity).setBranchingOrderedAsc(
- (Boolean) JsonUtil.opt(activityDetails, AuthoringJsonTags.BRANCHING_ORDERED_ASC));
+ JsonUtil.optBoolean(activityDetails, AuthoringJsonTags.BRANCHING_ORDERED_ASC));
}
branchingActivity.setStartXcoord(getCoord(activityDetails, AuthoringJsonTags.START_XCOORD));
@@ -1162,12 +1148,12 @@
branchingActivity.setEndYcoord(getCoord(activityDetails, AuthoringJsonTags.END_YCOORD));
}
- private void buildGroupingActivity(GroupingActivity groupingActivity, JSONObject activityDetails)
- throws ObjectExtractorException, JSONException {
+ private void buildGroupingActivity(GroupingActivity groupingActivity, ObjectNode activityDetails)
+ throws ObjectExtractorException {
/**
* read the createGroupingUUID, get the Grouping Object, and set CreateGrouping to that object
*/
- Integer createGroupingUIID = (Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.CREATE_GROUPING_UIID);
+ Integer createGroupingUIID = JsonUtil.optInt(activityDetails, AuthoringJsonTags.CREATE_GROUPING_UIID);
Grouping grouping = groupings.get(createGroupingUIID);
if (grouping != null) {
groupingActivity.setCreateGrouping(grouping);
@@ -1178,16 +1164,15 @@
groupingActivity.setSystemTool(systemTool);
}
- private void buildOptionsActivity(OptionsActivity optionsActivity, JSONObject activityDetails)
- throws JSONException {
- optionsActivity.setMaxNumberOfOptions((Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.MAX_OPTIONS));
- optionsActivity.setMinNumberOfOptions((Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.MIN_OPTIONS));
+ private void buildOptionsActivity(OptionsActivity optionsActivity, ObjectNode activityDetails) {
+ optionsActivity.setMaxNumberOfOptions(JsonUtil.optInt(activityDetails, AuthoringJsonTags.MAX_OPTIONS));
+ optionsActivity.setMinNumberOfOptions(JsonUtil.optInt(activityDetails, AuthoringJsonTags.MIN_OPTIONS));
optionsActivity
- .setOptionsInstructions((String) JsonUtil.opt(activityDetails, AuthoringJsonTags.OPTIONS_INSTRUCTIONS));
+ .setOptionsInstructions(JsonUtil.optString(activityDetails, AuthoringJsonTags.OPTIONS_INSTRUCTIONS));
}
private void buildOptionsWithSequencesActivity(OptionsWithSequencesActivity optionsActivity,
- JSONObject activityDetails) throws JSONException {
+ ObjectNode activityDetails) {
buildOptionsActivity(optionsActivity, activityDetails);
optionsActivity.setStartXcoord(getCoord(activityDetails, AuthoringJsonTags.START_XCOORD));
@@ -1203,7 +1188,7 @@
activity.setSystemTool(getSystemTool(SystemTool.SEQUENCE));
}
- private void buildToolActivity(ToolActivity toolActivity, JSONObject activityDetails) throws JSONException {
+ private void buildToolActivity(ToolActivity toolActivity, ObjectNode activityDetails) {
Tool tool = toolDAO.getToolByID(JsonUtil.optLong(activityDetails, AuthoringJsonTags.TOOL_ID));
toolActivity.setTool(tool);
@@ -1220,7 +1205,7 @@
toolActivity.setToolContentId(toolContentId);
}
- private void buildGateActivity(Object activity, JSONObject activityDetails) throws JSONException {
+ private void buildGateActivity(Object activity, ObjectNode activityDetails) {
if (activity instanceof SynchGateActivity) {
buildSynchGateActivity((SynchGateActivity) activity);
} else if (activity instanceof PermissionGateActivity) {
@@ -1233,9 +1218,7 @@
buildScheduleGateActivity((ScheduleGateActivity) activity, activityDetails);
}
GateActivity gateActivity = (GateActivity) activity;
- gateActivity.setGateActivityLevelId(
- (Integer) JsonUtil.opt(activityDetails, AuthoringJsonTags.GATE_ACTIVITY_LEVEL_ID));
-
+ gateActivity.setGateActivityLevelId(JsonUtil.optInt(activityDetails, AuthoringJsonTags.GATE_ACTIVITY_LEVEL_ID));
}
private void buildSynchGateActivity(SynchGateActivity activity) {
@@ -1250,17 +1233,16 @@
activity.setSystemTool(getSystemTool(SystemTool.SYSTEM_GATE));
}
- private void buildScheduleGateActivity(ScheduleGateActivity activity, JSONObject activityDetails)
- throws JSONException {
+ private void buildScheduleGateActivity(ScheduleGateActivity activity, ObjectNode activityDetails) {
activity.setGateStartTimeOffset(JsonUtil.optLong(activityDetails, AuthoringJsonTags.GATE_START_OFFSET));
activity.setGateEndTimeOffset(JsonUtil.optLong(activityDetails, AuthoringJsonTags.GATE_END_OFFSET));
activity.setGateActivityCompletionBased(
- (Boolean) JsonUtil.opt(activityDetails, AuthoringJsonTags.GATE_ACTIVITY_COMPLETION_BASED));
+ JsonUtil.optBoolean(activityDetails, AuthoringJsonTags.GATE_ACTIVITY_COMPLETION_BASED));
SystemTool systemTool = getSystemTool(SystemTool.SCHEDULE_GATE);
activity.setSystemTool(systemTool);
}
- private void createLessonClass(LessonClass lessonClass, JSONObject groupingDetails) throws JSONException {
+ private void createLessonClass(LessonClass lessonClass, ObjectNode groupingDetails) {
Long groupId = JsonUtil.optLong(groupingDetails, AuthoringJsonTags.STAFF_GROUP_ID);
if (groupId != null) {
Group group = groupDAO.getGroupById(groupId);
@@ -1270,13 +1252,12 @@
}
}
- private Transition extractTransitionObject(JSONObject transitionDetails) throws JSONException {
+ private Transition extractTransitionObject(ObjectNode transitionDetails) {
+ Integer transitionUUID = JsonUtil.optInt(transitionDetails, AuthoringJsonTags.TRANSITION_UIID);
+ Integer toUIID = JsonUtil.optInt(transitionDetails, AuthoringJsonTags.TO_ACTIVITY_UIID);
+ Integer fromUIID = JsonUtil.optInt(transitionDetails, AuthoringJsonTags.FROM_ACTIVITY_UIID);
+ Integer transitionType = JsonUtil.optInt(transitionDetails, AuthoringJsonTags.TRANSITION_TYPE);
- Integer transitionUUID = transitionDetails.getInt(AuthoringJsonTags.TRANSITION_UIID);
- Integer toUIID = transitionDetails.getInt(AuthoringJsonTags.TO_ACTIVITY_UIID);
- Integer fromUIID = transitionDetails.getInt(AuthoringJsonTags.FROM_ACTIVITY_UIID);
- Integer transitionType = transitionDetails.getInt(AuthoringJsonTags.TRANSITION_TYPE);
-
Transition transition = null;
Transition existingTransition = findTransition(transitionUUID, toUIID, fromUIID, transitionType);
@@ -1322,8 +1303,8 @@
transition.setFromUIID(null);
}
- transition.setDescription((String) JsonUtil.opt(transitionDetails, AuthoringJsonTags.DESCRIPTION));
- transition.setTitle((String) JsonUtil.opt(transitionDetails, AuthoringJsonTags.TITLE));
+ transition.setDescription(JsonUtil.optString(transitionDetails, AuthoringJsonTags.DESCRIPTION));
+ transition.setTitle(JsonUtil.optString(transitionDetails, AuthoringJsonTags.TITLE));
// Set creation date based on the server timezone, not the client.
if (transition.getCreateDateTime() == null) {
@@ -1337,7 +1318,6 @@
// One of the to/from is missing, can't store this transition. Make
// sure we clean up the related activities
cleanupTransition(transition);
- transition.setLearningDesign(null);
return null;
}
}
@@ -1354,6 +1334,7 @@
if ((transition.getToActivity() != null) && transition.equals(transition.getToActivity().getTransitionTo())) {
transition.getToActivity().setTransitionTo(null);
}
+ transitionDAO.delete(transition);
}
/**
@@ -1393,10 +1374,10 @@
return mode;
}
- private void parseBranchMappings(JSONArray branchMappingsList) throws JSONException, ObjectExtractorException {
+ private void parseBranchMappings(ArrayNode branchMappingsList) throws ObjectExtractorException {
if (branchMappingsList != null) {
- for (int branchMappingIndex = 0; branchMappingIndex < branchMappingsList.length(); branchMappingIndex++) {
- extractBranchActivityEntry(branchMappingsList.getJSONObject(branchMappingIndex));
+ for (JsonNode branchMappingJSON : branchMappingsList) {
+ extractBranchActivityEntry((ObjectNode) branchMappingJSON);
}
}
@@ -1424,20 +1405,19 @@
}
}
- private BranchActivityEntry extractBranchActivityEntry(JSONObject details)
- throws JSONException, ObjectExtractorException {
+ private BranchActivityEntry extractBranchActivityEntry(ObjectNode details) throws ObjectExtractorException {
Long entryId = JsonUtil.optLong(details, AuthoringJsonTags.BRANCH_ACTIVITY_ENTRY_ID);
- Integer entryUIID = details.getInt(AuthoringJsonTags.BRANCH_ACTIVITY_ENTRY_UIID);
+ Integer entryUIID = JsonUtil.optInt(details, AuthoringJsonTags.BRANCH_ACTIVITY_ENTRY_UIID);
- Integer sequenceActivityUIID = (Integer) JsonUtil.opt(details, AuthoringJsonTags.BRANCH_SEQUENCE_ACTIVITY_UIID);
- Boolean gateOpenWhenConditionMet = (Boolean) JsonUtil.opt(details,
+ Integer sequenceActivityUIID = JsonUtil.optInt(details, AuthoringJsonTags.BRANCH_SEQUENCE_ACTIVITY_UIID);
+ Boolean gateOpenWhenConditionMet = JsonUtil.optBoolean(details,
AuthoringJsonTags.BRANCH_GATE_OPENS_WHEN_CONDITION_MET);
Integer branchingActivityUIID = null;
if (gateOpenWhenConditionMet != null) {
- branchingActivityUIID = details.getInt(AuthoringJsonTags.BRANCH_GATE_ACTIVITY_UIID);
+ branchingActivityUIID = JsonUtil.optInt(details, AuthoringJsonTags.BRANCH_GATE_ACTIVITY_UIID);
} else {
- branchingActivityUIID = details.getInt(AuthoringJsonTags.BRANCH_ACTIVITY_UIID);
+ branchingActivityUIID = JsonUtil.optInt(details, AuthoringJsonTags.BRANCH_ACTIVITY_UIID);
}
Activity branchingActivity = newActivityMap.get(branchingActivityUIID);
@@ -1508,9 +1488,10 @@
// (which is used for doing deletions later).
oldbranchActivityEntryList.remove(entry);
- BranchCondition condition = extractCondition(details.optJSONObject(AuthoringJsonTags.BRANCH_CONDITION), entry);
+ BranchCondition condition = extractCondition(JsonUtil.optObject(details, AuthoringJsonTags.BRANCH_CONDITION),
+ entry);
- Integer groupUIID = (Integer) JsonUtil.opt(details, AuthoringJsonTags.GROUP_UIID);
+ Integer groupUIID = JsonUtil.optInt(details, AuthoringJsonTags.GROUP_UIID);
Group group = null;
if (groupUIID != null) {
group = groups.get(groupUIID);
@@ -1575,8 +1556,7 @@
return entry;
}
- private BranchCondition extractCondition(JSONObject conditionDetails, BranchActivityEntry entry)
- throws JSONException {
+ private BranchCondition extractCondition(ObjectNode conditionDetails, BranchActivityEntry entry) {
BranchCondition condition = null;
@@ -1594,13 +1574,14 @@
// automatically via the cascade
}
- Integer conditionUIID = conditionDetails.getInt(AuthoringJsonTags.CONDITION_UIID);
- String conditionType = conditionDetails.getString(AuthoringJsonTags.CONDITION_TYPE);
+ Integer conditionUIID = JsonUtil.optInt(conditionDetails, AuthoringJsonTags.CONDITION_UIID);
+ String conditionType = JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_TYPE);
if (BranchCondition.OUTPUT_TYPE_COMPLEX.equals(conditionType)
|| BranchCondition.OUTPUT_TYPE_STRING.equals(conditionType)) {
// This is different than "conditionID" !!!
- Long newConditionID = condition == null ? conditionDetails.getLong(AuthoringJsonTags.CONDITION_ID)
+ Long newConditionID = condition == null
+ ? JsonUtil.optLong(conditionDetails, AuthoringJsonTags.CONDITION_ID)
: condition.getConditionId();
// we need to get the proper subclass, since the one provided by branch entry is not valid
BranchCondition originalCondition = branchActivityEntryDAO.getConditionByID(newConditionID);
@@ -1616,24 +1597,24 @@
}
} else if (condition == null) {
condition = new BranchCondition(null, conditionUIID,
- conditionDetails.getInt(AuthoringJsonTags.ORDER_ID),
- conditionDetails.getString(AuthoringJsonTags.CONDITION_NAME),
- conditionDetails.getString(AuthoringJsonTags.CONDITION_DISPLAY_NAME),
- conditionDetails.getString(AuthoringJsonTags.CONDITION_TYPE),
- (String) JsonUtil.opt(conditionDetails, AuthoringJsonTags.CONDITION_START_VALUE),
- (String) JsonUtil.opt(conditionDetails, AuthoringJsonTags.CONDITION_END_VALUE),
- (String) JsonUtil.opt(conditionDetails, AuthoringJsonTags.CONDITION_EXACT_MATCH_VALUE));
+ JsonUtil.optInt(conditionDetails, AuthoringJsonTags.ORDER_ID),
+ JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_NAME),
+ JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_DISPLAY_NAME),
+ JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_TYPE),
+ JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_START_VALUE),
+ JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_END_VALUE),
+ JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_EXACT_MATCH_VALUE));
} else {
condition.setConditionUIID(conditionUIID);
- condition.setDisplayName(conditionDetails.getString(AuthoringJsonTags.CONDITION_DISPLAY_NAME));
- condition.setEndValue((String) JsonUtil.opt(conditionDetails, AuthoringJsonTags.CONDITION_END_VALUE));
+ condition
+ .setDisplayName(JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_DISPLAY_NAME));
+ condition.setEndValue(JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_END_VALUE));
condition.setExactMatchValue(
- (String) JsonUtil.opt(conditionDetails, AuthoringJsonTags.CONDITION_EXACT_MATCH_VALUE));
- condition.setName(conditionDetails.getString(AuthoringJsonTags.CONDITION_NAME));
- condition.setOrderId(conditionDetails.getInt(AuthoringJsonTags.ORDER_ID));
- condition.setStartValue(
- (String) JsonUtil.opt(conditionDetails, AuthoringJsonTags.CONDITION_START_VALUE));
- condition.setType(conditionDetails.getString(AuthoringJsonTags.CONDITION_TYPE));
+ JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_EXACT_MATCH_VALUE));
+ condition.setName(JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_NAME));
+ condition.setOrderId(JsonUtil.optInt(conditionDetails, AuthoringJsonTags.ORDER_ID));
+ condition.setStartValue(JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_START_VALUE));
+ condition.setType(JsonUtil.optString(conditionDetails, AuthoringJsonTags.CONDITION_TYPE));
}
}
return condition;
@@ -1652,16 +1633,15 @@
return tool;
}
- private void createLearnerChoiceGrouping(LearnerChoiceGrouping learnerChoiceGrouping, JSONObject groupingDetails)
- throws JSONException {
- Integer numLearnersPerGroup = (Integer) JsonUtil.opt(groupingDetails, AuthoringJsonTags.LEARNERS_PER_GROUP);
+ private void createLearnerChoiceGrouping(LearnerChoiceGrouping learnerChoiceGrouping, ObjectNode groupingDetails) {
+ Integer numLearnersPerGroup = JsonUtil.optInt(groupingDetails, AuthoringJsonTags.LEARNERS_PER_GROUP);
if ((numLearnersPerGroup != null) && (numLearnersPerGroup.intValue() > 0)) {
learnerChoiceGrouping.setLearnersPerGroup(numLearnersPerGroup);
learnerChoiceGrouping.setNumberOfGroups(null);
learnerChoiceGrouping.setEqualNumberOfLearnersPerGroup(null);
} else {
- Integer numGroups = (Integer) JsonUtil.opt(groupingDetails, AuthoringJsonTags.NUMBER_OF_GROUPS);
+ Integer numGroups = JsonUtil.optInt(groupingDetails, AuthoringJsonTags.NUMBER_OF_GROUPS);
if ((numGroups != null) && (numGroups.intValue() > 0)) {
learnerChoiceGrouping.setNumberOfGroups(numGroups);
@@ -1670,14 +1650,14 @@
}
learnerChoiceGrouping.setLearnersPerGroup(null);
- Boolean equalNumberOfLearnersPerGroup = (Boolean) JsonUtil.opt(groupingDetails,
+ Boolean equalNumberOfLearnersPerGroup = JsonUtil.optBoolean(groupingDetails,
AuthoringJsonTags.EQUAL_NUMBER_OF_LEARNERS_PER_GROUP);
if (equalNumberOfLearnersPerGroup != null) {
learnerChoiceGrouping.setEqualNumberOfLearnersPerGroup(equalNumberOfLearnersPerGroup);
}
}
learnerChoiceGrouping.setViewStudentsBeforeSelection(
- (Boolean) JsonUtil.opt(groupingDetails, AuthoringJsonTags.VIEW_STUDENTS_BEFORE_SELECTION));
+ JsonUtil.optBoolean(groupingDetails, AuthoringJsonTags.VIEW_STUDENTS_BEFORE_SELECTION));
}
private void buildConditionGateActivity(ConditionGateActivity activity) {
Index: lams_central/web/authoring/authoring.jsp
===================================================================
diff -u -r287e1d4f1242a8d584f71cab96bfd0365b6855c8 -rbd4fa408454e7389b4e60bc68f2488de88eff663
--- lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision 287e1d4f1242a8d584f71cab96bfd0365b6855c8)
+++ lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision bd4fa408454e7389b4e60bc68f2488de88eff663)
@@ -34,7 +34,7 @@