Index: lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java =================================================================== diff -u -r6950295e2d5e90ffae268faeae946718654ddc7b -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java (.../HomeAction.java) (revision 6950295e2d5e90ffae268faeae946718654ddc7b) +++ lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java (.../HomeAction.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -37,19 +37,20 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.DispatchAction; -import org.lamsfoundation.lams.learning.service.LearnerServiceException; import org.lamsfoundation.lams.learningdesign.GroupUser; import org.lamsfoundation.lams.learningdesign.dao.IGroupUserDAO; +import org.lamsfoundation.lams.learningdesign.service.ILearningDesignService; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.lesson.service.ILessonService; +import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.User; -import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.util.svg.SVGGenerator; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.web.context.WebApplicationContext; @@ -62,6 +63,7 @@ * @struts:action path="/home" validate="false" parameter="method" * @struts:action-forward name="sysadmin" path="/sysadmin.jsp" * @struts:action-forward name="learner" path="/learner.jsp" + * @struts:action-forward name="lessonIntro" path="/lessonIntro.jsp" * @struts:action-forward name="author" path="/author.jsp" * @struts:action-forward name="monitorLesson" path="/monitorLesson.jsp" * @struts:action-forward name="addLesson" path="/addLesson.jsp" @@ -77,44 +79,9 @@ private static IUserManagementService service; private static ILessonService lessonService; + private static ILearningDesignService learningDesignService; private static IGroupUserDAO groupUserDAO; - private IUserManagementService getService() { - if (service == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); - service = (IUserManagementService) ctx.getBean("userManagementService"); - } - return service; - } - - private ILessonService getLessonService() { - if (lessonService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); - lessonService = (ILessonService) ctx.getBean("lessonService"); - } - return lessonService; - } - - private IGroupUserDAO getGroupUserDAO() { - if (groupUserDAO == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); - groupUserDAO = (IGroupUserDAO) ctx.getBean("groupUserDAO"); - } - return groupUserDAO; - } - - private UserDTO getUser() { - HttpSession ss = SessionManager.getSession(); - return (UserDTO) ss.getAttribute(AttributeNames.USER); - } - - private User getRealUser(UserDTO dto) { - return getService().getUserByLogin(dto.getLogin()); - } - /** * request for sysadmin environment */ @@ -201,7 +168,31 @@ String presenceUrl = Configuration.get(ConfigurationKeys.XMPP_DOMAIN); req.setAttribute("presenceUrl", presenceUrl); req.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId); - return mapping.findForward("learner"); + + //show lesson intro page if required + if (lesson.isEnableLessonIntro()) { + req.setAttribute("lessonName", lesson.getLessonName()); + req.setAttribute("lessonDescription", lesson.getLessonDescription()); + req.setAttribute("displayDesignImage", lesson.isDisplayDesignImage()); + + //check if we need to create learning design SVG + if (lesson.isDisplayDesignImage()) { + Long learningDesignId = lesson.getLearningDesign().getLearningDesignId(); + req.setAttribute(AttributeNames.PARAM_LEARNINGDESIGN_ID, learningDesignId); + + if (lesson.getLearnerProgresses().isEmpty()) { + // create svg, png files on the server + getLearningDesignService().createLearningDesignSVG(learningDesignId, + SVGGenerator.OUTPUT_FORMAT_SVG); + getLearningDesignService().createLearningDesignSVG(learningDesignId, + SVGGenerator.OUTPUT_FORMAT_PNG); + } + } + return mapping.findForward("lessonIntro"); + } else { + return mapping.findForward("learner"); + } + } } catch (Exception e) { @@ -372,4 +363,49 @@ req.setAttribute("messageKey", messageKey); return mapping.findForward("message"); } + + private IUserManagementService getService() { + if (service == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + service = (IUserManagementService) ctx.getBean("userManagementService"); + } + return service; + } + + private ILessonService getLessonService() { + if (lessonService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + lessonService = (ILessonService) ctx.getBean("lessonService"); + } + return lessonService; + } + + private ILearningDesignService getLearningDesignService() { + if (learningDesignService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService"); + } + return learningDesignService; + } + + private IGroupUserDAO getGroupUserDAO() { + if (groupUserDAO == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + groupUserDAO = (IGroupUserDAO) ctx.getBean("groupUserDAO"); + } + return groupUserDAO; + } + + private UserDTO getUser() { + HttpSession ss = SessionManager.getSession(); + return (UserDTO) ss.getAttribute(AttributeNames.USER); + } + + private User getRealUser(UserDTO dto) { + return getService().getUserByLogin(dto.getLogin()); + } } \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/webservice/LearningDesignSVGServlet.java =================================================================== diff -u -r192e8bed06df5a995b34c4e94023cbc699b341e5 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_central/src/java/org/lamsfoundation/lams/webservice/LearningDesignSVGServlet.java (.../LearningDesignSVGServlet.java) (revision 192e8bed06df5a995b34c4e94023cbc699b341e5) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/LearningDesignSVGServlet.java (.../LearningDesignSVGServlet.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -23,6 +23,8 @@ /* $Id$ */ package org.lamsfoundation.lams.webservice; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; @@ -31,6 +33,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; import org.lamsfoundation.lams.integration.ExtServerOrgMap; import org.lamsfoundation.lams.integration.security.Authenticator; @@ -110,9 +113,15 @@ contentType = "image/png"; } response.setContentType(contentType); - OutputStream out = response.getOutputStream(); - learningDesignService.getLearningDesignSVG(learningDesignId, imageFormat, out); + + String imagePath = learningDesignService.createLearningDesignSVG(learningDesignId, imageFormat); + OutputStream output = response.getOutputStream(); + FileInputStream input = new FileInputStream(imagePath); + IOUtils.copy(input, output); + IOUtils.closeQuietly(input); + IOUtils.closeQuietly(output); + } catch (Exception e) { log.error("Problem with LearningDesignRepositoryServlet request", e); response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Problem with LearningDesignRepositoryServlet request"); Index: lams_central/web/includes/javascript/css.browser.selector.js =================================================================== diff -u --- lams_central/web/includes/javascript/css.browser.selector.js (revision 0) +++ lams_central/web/includes/javascript/css.browser.selector.js (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -0,0 +1,8 @@ +/* +CSS Browser Selector v0.4.0 (Nov 02, 2010) +Rafael Lima (http://rafael.adm.br) +http://rafael.adm.br/css_browser_selector +License: http://creativecommons.org/licenses/by/2.5/ +Contributors: http://rafael.adm.br/css_browser_selector#contributors +*/ +function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent); \ No newline at end of file Index: lams_central/web/learner.jsp =================================================================== diff -u -r5593d5b6d117372be17dacc3523ee0dfda5ed435 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_central/web/learner.jsp (.../learner.jsp) (revision 5593d5b6d117372be17dacc3523ee0dfda5ed435) +++ lams_central/web/learner.jsp (.../learner.jsp) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -13,10 +13,10 @@ - &portfolioEnabled=&presenceEnabledPatch=&presenceImEnabled=&presenceUrl=&createDateTime=&title=&mode=¬ifyCloseURL="> + &portfolioEnabled=&presenceEnabledPatch=&presenceImEnabled=&presenceUrl=&createDateTime=&title=&mode=¬ifyCloseURL="> - &portfolioEnabled=&presenceEnabledPatch=&presenceImEnabled=&presenceUrl=&createDateTime=&title=&mode=¬ifyCloseURL="> + &portfolioEnabled=&presenceEnabledPatch=&presenceImEnabled=&presenceUrl=&createDateTime=&title=&mode=¬ifyCloseURL="> Index: lams_central/web/lessonIntro.jsp =================================================================== diff -u --- lams_central/web/lessonIntro.jsp (revision 0) +++ lams_central/web/lessonIntro.jsp (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -0,0 +1,64 @@ + + +<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %> +<%@ taglib uri="tags-lams" prefix="lams" %> +<%@ taglib uri="tags-fmt" prefix="fmt" %> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-html" prefix="html" %> + + + + +learner.jsp?mode=${mode}&portfolioEnabled=${portfolioEnabled}&presenceEnabledPatch=${presenceEnabledPatch}&presenceImEnabled=${presenceImEnabled}&title=${title}&createDateTime=${createDateTime}&serverUrl=${serverUrl}&presenceUrl=${presenceUrl}&lessonID=${lessonID} + + + + + + <fmt:message key="title.learner.window"/> + + + + + + + + + +
+ +

${lessonName}

+ +

${lessonDescription}

+ + +
+ Sequence Preview +
+ + Sequence Preview + +
+
+
+ +
+ + + +
+ +
+ + + + + +
Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml =================================================================== diff -u -rde3706d9ff6d4d4768a805e5f40bd8851634174f -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml (.../Lesson.hbm.xml) (revision de3706d9ff6d4d4768a805e5f40bd8851634174f) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml (.../Lesson.hbm.xml) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -45,10 +45,16 @@ + + + + - + column="learner_exportport_avail" length="1"> + Index: lams_common/db/sql/create_lams_11_tables.sql =================================================================== diff -u -rf6a03ee21a18654d54498cd94d9f68fbea3b996a -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision f6a03ee21a18654d54498cd94d9f68fbea3b996a) +++ lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -648,6 +648,8 @@ , end_date_time DATETIME , schedule_end_date_time DATETIME , previous_state_id INT(3) + , enable_lesson_intro TINYINT(1) DEFAULT 0 + , display_design_image TINYINT(1) DEFAULT 0 , learner_exportport_avail TINYINT(1) DEFAULT 1 , learner_presence_avail TINYINT(1) DEFAULT 0 , learner_im_avail TINYINT(1) DEFAULT 0 Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040010.sql =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040010.sql (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040010.sql (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -0,0 +1,10 @@ +-- Turn off autocommit, so nothing is committed if there is an error +SET AUTOCOMMIT = 0; + +-- LDEV-2829 Lesson intro page +ALTER TABLE lams_lesson ADD COLUMN enable_lesson_intro TINYINT(1) DEFAULT 0; +ALTER TABLE lams_lesson ADD COLUMN display_design_image TINYINT(1) DEFAULT 0; + +-- If there were no errors, commit and restore autocommit to on +COMMIT; +SET AUTOCOMMIT = 1; \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java =================================================================== diff -u -r097c7143c4edf7a649e785d0f58a1bbf640edd3b -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 097c7143c4edf7a649e785d0f58a1bbf640edd3b) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -62,6 +62,7 @@ import org.apache.batik.transcoder.TranscoderException; import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.apache.log4j.Logger; @@ -667,13 +668,13 @@ //generate SVG image if (format != ExportToolContentService.PACKAGE_FORMAT_IMS) { - String svgFileName = FileUtil.getFullPath(contentDir, ExportToolContentService.SVG_IMAGE_FILE_NAME); - FileOutputStream svgOutputStream = new FileOutputStream(svgFileName); - service.getLearningDesignSVG(learningDesignId, SVGGenerator.OUTPUT_FORMAT_SVG, svgOutputStream); + String destinationPath = FileUtil.getFullPath(contentDir, ExportToolContentService.SVG_IMAGE_FILE_NAME); + String svgPath = service.createLearningDesignSVG(learningDesignId, SVGGenerator.OUTPUT_FORMAT_SVG); + FileUtils.copyFile(new File(svgPath), new File(destinationPath)); - String pngFileName = FileUtil.getFullPath(contentDir, ExportToolContentService.PNG_IMAGE_FILE_NAME); - FileOutputStream pngOutputStream = new FileOutputStream(pngFileName); - service.getLearningDesignSVG(learningDesignId, SVGGenerator.OUTPUT_FORMAT_PNG, pngOutputStream); + destinationPath = FileUtil.getFullPath(contentDir, ExportToolContentService.PNG_IMAGE_FILE_NAME); + String pngPath = service.createLearningDesignSVG(learningDesignId, SVGGenerator.OUTPUT_FORMAT_PNG); + FileUtils.copyFile(new File(pngPath), new File(destinationPath)); } log.debug("Learning design xml export success"); Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ILearningDesignService.java =================================================================== diff -u -r87e2cccf93ac20d2b8e953cea2cf36c8a8fb5b14 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ILearningDesignService.java (.../ILearningDesignService.java) (revision 87e2cccf93ac20d2b8e953cea2cf36c8a8fb5b14) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ILearningDesignService.java (.../ILearningDesignService.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -24,7 +24,6 @@ package org.lamsfoundation.lams.learningdesign.service; import java.io.IOException; -import java.io.OutputStream; import java.util.ArrayList; import java.util.Vector; @@ -80,16 +79,14 @@ public void setValid(Long learningLibraryId, boolean valid); /** - * Streams out learning design SVG into specified OutputStream. Additionally, stores resulted SVG into file system for caching. + * Creates learning design SVG/PNG file. Also stores it into the file system for caching. * - * @param learningDesignId - * @param imageFormat either SVGGenerator.OUTPUT_FORMAT_SVG or SVGGenerator.OUTPUT_FORMAT_PNG - * @param out - * @return whether operation was successful or not + * @param learningDesignId source learning design for the outcome image + * @param imageFormat it can be either SVGGenerator.OUTPUT_FORMAT_SVG or SVGGenerator.OUTPUT_FORMAT_PNG + * @return * @throws JDOMException * @throws IOException * @throws TranscoderException - * @throws ExportToolContentException */ - boolean getLearningDesignSVG(Long learningDesignId, int imageFormat, OutputStream out) throws JDOMException, IOException, TranscoderException, ExportToolContentException; + String createLearningDesignSVG(Long learningDesignId, int imageFormat) throws JDOMException, IOException, TranscoderException; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LearningDesignService.java =================================================================== diff -u -r95dadc981fa9e8e7e64022ae61f569219c9d20f5 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LearningDesignService.java (.../LearningDesignService.java) (revision 95dadc981fa9e8e7e64022ae61f569219c9d20f5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LearningDesignService.java (.../LearningDesignService.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -57,6 +57,7 @@ import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.FileUtil; +import org.lamsfoundation.lams.util.FileUtilException; import org.lamsfoundation.lams.util.ILoadedMessageSourceService; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.svg.SVGGenerator; @@ -198,12 +199,12 @@ return libraries; } - public boolean getLearningDesignSVG(Long learningDesignId, int imageFormat, OutputStream out) throws JDOMException, IOException, TranscoderException, ExportToolContentException { + public String createLearningDesignSVG(Long learningDesignId, int imageFormat) throws JDOMException, IOException, TranscoderException { //construct absolute filePath to SVG String earFolder = Configuration.get(ConfigurationKeys.LAMS_EAR_DIR); if (StringUtils.isBlank(earFolder)) { log.error("Unable to get path to the LAMS Server URL from the configuration table. SVG image creation failed"); - return false; + return null; } String directoryToStoreFile = FileUtil.getFullPath(earFolder, "lams-www.war\\secure\\learning-design-images"); @@ -234,36 +235,7 @@ svgGenerator.streamOutDocument(fileOutputStream, imageFormat); } - //stream out SVG to the specified by user OutputStream - InputStream in = null; - try { - in = new BufferedInputStream(new FileInputStream(file)); - int count = 0; - - int ch; - while ((ch = in.read()) != -1) { - out.write((char) ch); - count++; - } - out.flush(); - } catch (Exception e) { - log.error("Exception occured writing out file:" + e.getMessage()); - throw new ExportToolContentException(e); - } finally { - try { - if (in != null) { - in.close(); // very important - } - if (out != null) { - out.close(); - } - } catch (Exception e) { - log.error("Error Closing file. File already written out - no exception being thrown.", e); - return false; - } - } - - return true; + return absoluteFilePath; } private void internationaliseActivities(Collection activities) { Index: lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java =================================================================== diff -u -r192608ebab727b612fcc5bff809846856509a2df -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java (.../Lesson.java) (revision 192608ebab727b612fcc5bff809846856509a2df) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java (.../Lesson.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.Set; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; @@ -36,56 +37,58 @@ import org.lamsfoundation.lams.lesson.dto.LessonDetailsDTO; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.User; -/** - * A Lesson is a learning sequence that is assocated with - * a number of users for use in learning. A lesson needs a run time copy of - * learning design to interact with. + +/** + * A Lesson is a learning sequence that is assocated with a number of users for use in learning. A lesson needs a run + * time copy of learning design to interact with. */ public class Lesson implements Serializable { - private static final long serialVersionUID = 5733920851084229175L; - - //--------------------------------------------------------------------- + private static final long serialVersionUID = 5733920851084229175L; + + // --------------------------------------------------------------------- // Class level constants - //--------------------------------------------------------------------- - /** The state for newly created lesson. The learning design has been copied. - * The lesson class may or may not have been configured. It is - * seen on the staff interface but not on the learning interface. */ + // --------------------------------------------------------------------- + /** + * The state for newly created lesson. The learning design has been copied. The lesson class may or may not have + * been configured. It is seen on the staff interface but not on the learning interface. + */ public static final Integer CREATED = new Integer(1); - /** The state for lessons that have been scheduled. */ + /** The state for lessons that have been scheduled. */ public static final Integer NOT_STARTED_STATE = new Integer(2); /** The state for started lesson */ public static final Integer STARTED_STATE = new Integer(3); - /** The state for lessons that have been suspended by the teacher. - * The lesson can be seen on the staff interface but not on the learning interface */ + /** + * The state for lessons that have been suspended by the teacher. The lesson can be seen on the staff interface but + * not on the learning interface + */ public static final Integer SUSPENDED_STATE = new Integer(4); - /** The state for lessons that have been finished. A finished lesson - * is shown as inactive on the staff interface, and is shown on the learner interface - * but the learner is to only see the overall progress and be able to export - * data - they should not be able to iteract with the tools */ + /** + * The state for lessons that have been finished. A finished lesson is shown as inactive on the staff interface, and + * is shown on the learner interface but the learner is to only see the overall progress and be able to export data + * - they should not be able to iteract with the tools + */ public static final Integer FINISHED_STATE = new Integer(5); - /** The state for lesssons that are shown as inactive on the staff interface - * but no longer visible to the learners. */ + /** + * The state for lesssons that are shown as inactive on the staff interface but no longer visible to the learners. + */ public static final Integer ARCHIVED_STATE = new Integer(6); /** The state for lesssons that are removed and never can be accessed again */ - public static final Integer REMOVED_STATE = new Integer(7); + public static final Integer REMOVED_STATE = new Integer(7); //--------------------------------------------------------------------- // attributes //--------------------------------------------------------------------- /** identifier field */ private Long lessonId; - - /** Hibernate managed version field */ - private Integer version; + /** Hibernate managed version field */ + private Integer version; + /** persistent field */ private String lessonName; /** persistent field */ - private String lessonDescription; - - /** persistent field */ private Date createDateTime; /** nullable persistent field */ @@ -126,25 +129,34 @@ /** persistent field */ private Set gradebookUserLessons; + + /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ + private Boolean enableLessonIntro; + + /** persistent field */ + private String lessonDescription; + + /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ + private Boolean displayDesignImage; /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ private Boolean learnerExportAvailable; - + /** Persistent field. Defaults to FALSE - is not included in the constructor anywhere. */ private Boolean lockedForEdit; - + /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ - private Boolean learnerPresenceAvailable; + private Boolean learnerPresenceAvailable; /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ private Boolean learnerImAvailable; - + /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ private Boolean liveEditEnabled; - + /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ private Boolean enableLessonNotifications; - + /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ private Boolean marksReleased; @@ -162,38 +174,27 @@ } /** - * Minimum constructor that initialize the lesson data. It doesn't include organization and class information. Cain + * Minimum constructor that initialize the lesson data. It doesn't include organization and class information. Chain * constructor pattern implementation. */ public Lesson(String name, String description, Date createDateTime, User user, Integer lessonStateId, - Integer previousLessonStateId, Boolean learnerExportAvailable, LearningDesign learningDesign, - Set learnerProgresses, Boolean learnerPresenceAvailable, Boolean learnerImAvailable, - Boolean liveEditEnabled, Boolean enableLessonNotifications, Integer scheduledNumberDaysTolessonFinish) { + Integer previousLessonStateId, LearningDesign learningDesign, Set learnerProgresses, + Boolean enableLessonIntro, Boolean displayDesignImage, Boolean learnerExportAvailable, + Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled, + Boolean enableLessonNotifications, Integer scheduledNumberDaysTolessonFinish) { this(null, name, description, createDateTime, null, null, user, lessonStateId, previousLessonStateId, - learnerExportAvailable, false, learningDesign, null, null, learnerProgresses, learnerPresenceAvailable, - learnerImAvailable, liveEditEnabled, enableLessonNotifications, scheduledNumberDaysTolessonFinish); + enableLessonIntro, displayDesignImage, learnerExportAvailable, false, learningDesign, null, null, + learnerProgresses, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, + enableLessonNotifications, scheduledNumberDaysTolessonFinish); } - /** - * Constructor that creates a new lesson with organization and class information. Chain construtor pattern - * implementation. - */ - public Lesson(String name, String description, Date createDateTime, User user, Integer lessonStateId, - Integer previousLessonStateId, Boolean learnerExportAvailable, LearningDesign learningDesign, - LessonClass lessonClass, Organisation organisation, Set learnerProgresses, - Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled) { - this(null, name, description, createDateTime, null, null, user, lessonStateId, previousLessonStateId, - learnerExportAvailable, false, learningDesign, lessonClass, organisation, learnerProgresses, - learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, false, null); - } - /** full constructor */ public Lesson(Long lessonId, String name, String description, Date createDateTime, Date startDateTime, Date endDateTime, User user, Integer lessonStateId, Integer previousLessonStateId, - Boolean learnerExportAvailable, Boolean lockedForEdit, LearningDesign learningDesign, - LessonClass lessonClass, Organisation organisation, Set learnerProgresses, - Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled, - Boolean enableLessonNotifications, Integer scheduledNumberDaysToLessonFinish) { + Boolean enableLessonIntro, Boolean displayDesignImage, Boolean learnerExportAvailable, + Boolean lockedForEdit, LearningDesign learningDesign, LessonClass lessonClass, Organisation organisation, + Set learnerProgresses, Boolean learnerPresenceAvailable, Boolean learnerImAvailable, + Boolean liveEditEnabled, Boolean enableLessonNotifications, Integer scheduledNumberDaysToLessonFinish) { this.lessonId = lessonId; this.lessonName = name; this.lessonDescription = description; @@ -203,6 +204,8 @@ this.user = user; this.lessonStateId = lessonStateId; this.previousLessonStateId = previousLessonStateId; + this.enableLessonIntro = enableLessonIntro != null ? enableLessonIntro : Boolean.FALSE; + this.displayDesignImage = displayDesignImage != null ? displayDesignImage : Boolean.FALSE; this.learnerExportAvailable = learnerExportAvailable != null ? learnerExportAvailable : Boolean.FALSE; this.learnerPresenceAvailable = learnerPresenceAvailable != null ? learnerPresenceAvailable : Boolean.FALSE; this.learnerImAvailable = learnerImAvailable != null ? learnerImAvailable : Boolean.FALSE; @@ -217,65 +220,26 @@ this.marksReleased = false; this.scheduledNumberDaysToLessonFinish = scheduledNumberDaysToLessonFinish; } - + /** - * Factory method that create a new lesson. It initialized all necessary data for a new lesson with organization and - * lesson class information. It is designed for monitor side to create a lesson by teacher. + * Factory method that create a new lesson with lesson class and organization. It is design to allow user create a + * lesson first and modify organization and lesson class data later. * * @param user - * the teacher who created this lesson - * @pram learnerExportAvailable should the export portfolio option be made available to the learner? - * @param organisation - * the organisation associated with this lesson. + * the user who want to create a lesson. + * @param learnerExportAvailable + * should the export portfolio option be made available to the learner? * @param ld - * the learning design associated with this lesson. - * @param newLessonClass - * the lesson class that will run this lesson. - * @return the new lesson object. - */ - public static Lesson createNewLesson(String lessonName, - String lessonDescription, - User user, - Organisation organisation, - Boolean learnerExportAvailable, - LearningDesign ld, - LessonClass newLessonClass, - Boolean learnerPresenceAvailable, - Boolean learnerImAvailable, - Boolean liveEditEnabled) - { - //setup new lesson - return new Lesson(lessonName, - lessonDescription, - new Date(System.currentTimeMillis()), - user, - Lesson.CREATED, - null, - learnerExportAvailable, - ld, - newLessonClass,//lesson class - organisation, - new HashSet(), //learner progress - false, - false, - false); - } - - /** - * Factory method that create a new lesson with lesson class and organization. - * It is design to allow user create a lesson first and modify organization - * and lesson class data later. - * - * @param user the user who want to create a lesson. - * @param learnerExportAvailable should the export portfolio option be made available to the learner? - * @param ld the learning design that this lesson is based on. + * the learning design that this lesson is based on. * @return the lesson created. */ public static Lesson createNewLessonWithoutClass(String lessonName, String lessonDescription, User user, - Boolean learnerExportAvailable, LearningDesign ld, + Boolean enableLessonIntro, + Boolean displayDesignImage, + Boolean learnerExportAvailable, Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled, @@ -288,129 +252,127 @@ user, Lesson.CREATED, null, - learnerExportAvailable, ld, new HashSet(), + enableLessonIntro, + displayDesignImage, + learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, enableLessonNotifications, scheduledNumberDaysToLessonFinish); } - //--------------------------------------------------------------------- + + // --------------------------------------------------------------------- // Getters and Setters - //--------------------------------------------------------------------- - /** - * @hibernate.id generator-class="native" type="java.lang.Long" - * column="lesson_id" + // --------------------------------------------------------------------- + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="lesson_id" */ public Long getLessonId() { - return this.lessonId; + return this.lessonId; } public void setLessonId(Long lessonId) { - this.lessonId = lessonId; + this.lessonId = lessonId; } - /** + /** * Hibernate version column - updated automatically * - * @hibernate.version type="java.lang.Integer" - * column="version" + * @hibernate.version type="java.lang.Integer" column="version" */ - public Integer getVersion() { - return this.version; - } + public Integer getVersion() { + return this.version; + } - public void setVersion(Integer version) { - this.version = version; - } - /** - * @hibernate.property column="name" length="255" not-null="true" + public void setVersion(Integer version) { + this.version = version; + } + + /** + * @hibernate.property column="name" length="255" not-null="true" * @return Returns the lessonName. */ - public String getLessonName() - { - return lessonName; + public String getLessonName() { + return lessonName; } + /** - * @param lessonName The lessonName to set. + * @param lessonName + * The lessonName to set. */ - public void setLessonName(String lessonName) - { - this.lessonName = lessonName; + public void setLessonName(String lessonName) { + this.lessonName = lessonName; } - + /** - * @hibernate.property column="description" length="65535" + * @hibernate.property column="description" length="65535" * @return Returns the lessonDescription. */ - public String getLessonDescription() - { - return lessonDescription; + public String getLessonDescription() { + return lessonDescription; } + /** - * @param lessonDescription The lessonDescription to set. + * @param lessonDescription + * The lessonDescription to set. */ - public void setLessonDescription(String lessonDescription) - { - this.lessonDescription = lessonDescription; + public void setLessonDescription(String lessonDescription) { + this.lessonDescription = lessonDescription; } - /** - * @hibernate.property type="java.sql.Timestamp" column="create_date_time" - * length="19" + /** + * @hibernate.property type="java.sql.Timestamp" column="create_date_time" length="19" */ public Date getCreateDateTime() { - return this.createDateTime; + return this.createDateTime; } public void setCreateDateTime(Date createDateTime) { - this.createDateTime = createDateTime; + this.createDateTime = createDateTime; } - /** - * @hibernate.property type="java.sql.Timestamp" column="start_date_time" - * length="19" + /** + * @hibernate.property type="java.sql.Timestamp" column="start_date_time" length="19" */ public Date getStartDateTime() { - return this.startDateTime; + return this.startDateTime; } public void setStartDateTime(Date startDateTime) { - this.startDateTime = startDateTime; + this.startDateTime = startDateTime; } - /** - * @hibernate.property type="java.sql.Timestamp" column="end_date_time" - * length="19" + /** + * @hibernate.property type="java.sql.Timestamp" column="end_date_time" length="19" */ public Date getEndDateTime() { - return this.endDateTime; + return this.endDateTime; } public void setEndDateTime(Date endDateTime) { - this.endDateTime = endDateTime; + this.endDateTime = endDateTime; } /** - * @hibernate.property type="java.sql.Timestamp" column="schedule_end_date_time" - * length="19" + * @hibernate.property type="java.sql.Timestamp" column="schedule_end_date_time" length="19" * * @return Returns the scheduleEndDate. */ - public Date getScheduleEndDate() - { - return scheduleEndDate; + public Date getScheduleEndDate() { + return scheduleEndDate; } + /** - * @param scheduleEndDate The scheduleEndDate to set. + * @param scheduleEndDate + * The scheduleEndDate to set. */ - public void setScheduleEndDate(Date scheduleEndDate) - { - this.scheduleEndDate = scheduleEndDate; + public void setScheduleEndDate(Date scheduleEndDate) { + this.scheduleEndDate = scheduleEndDate; } - + /** * @return Returns whether there is an end date for individual user. */ @@ -430,114 +392,130 @@ /** * @param scheduledNumberDaysToLessonFinish - * the number of days the lesson will be available to user since he starts it. (It's ON only if the lesson - * was scheduled to be finished and individual option was selected) + * the number of days the lesson will be available to user since he starts it. (It's ON only if the + * lesson was scheduled to be finished and individual option was selected) */ public void setScheduledNumberDaysToLessonFinish(Integer scheduledNumberDaysToLessonFinish) { this.scheduledNumberDaysToLessonFinish = scheduledNumberDaysToLessonFinish; } - + /** - * @hibernate.property type="java.sql.Timestamp" column="schedule_start_date_time" - * length="19" + * @hibernate.property type="java.sql.Timestamp" column="schedule_start_date_time" length="19" * @return Returns the scheduleStartDate. */ - public Date getScheduleStartDate() - { - return scheduleStartDate; + public Date getScheduleStartDate() { + return scheduleStartDate; } + /** - * @param scheduleStartDate The scheduleStartDate to set. + * @param scheduleStartDate + * The scheduleStartDate to set. */ - public void setScheduleStartDate(Date scheduleStartDate) - { - this.scheduleStartDate = scheduleStartDate; + public void setScheduleStartDate(Date scheduleStartDate) { + this.scheduleStartDate = scheduleStartDate; } - /** + + /** * @hibernate.many-to-one not-null="true" - * @hibernate.column name="user_id" + * @hibernate.column name="user_id" */ public User getUser() { - return this.user; + return this.user; } public void setUser(User user) { - this.user = user; + this.user = user; } - /** - * @hibernate.property type="java.lang.Integer" column="lesson_state_id" - * length="3" + /** + * @hibernate.property type="java.lang.Integer" column="lesson_state_id" length="3" */ public Integer getLessonStateId() { - return this.lessonStateId; + return this.lessonStateId; } public void setLessonStateId(Integer lessonStateId) { - this.lessonStateId = lessonStateId; + this.lessonStateId = lessonStateId; } - /** - * @hibernate.property type="java.lang.Integer" column="previous_state_id" - * length="3" + /** + * @hibernate.property type="java.lang.Integer" column="previous_state_id" length="3" */ public Integer getPreviousLessonStateId() { - return this.previousLessonStateId; + return this.previousLessonStateId; } public void setPreviousLessonStateId(Integer previousLessonStateId) { - this.previousLessonStateId = previousLessonStateId; + this.previousLessonStateId = previousLessonStateId; } + + /** + * @hibernate.property type="java.lang.Boolean" column="enable_lesson_intro" length="1" + */ + public Boolean isEnableLessonIntro() { + return enableLessonIntro; + } - /** - * @hibernate.property type="java.lang.Boolean" column="learner_exportport_avail" - * length="1" + public void setEnableLessonIntro(Boolean enableLessonIntro) { + this.enableLessonIntro = enableLessonIntro; + } + + /** + * @hibernate.property type="java.lang.Boolean" column="display_design_image" length="1" */ - public Boolean getLearnerExportAvailable() { - return learnerExportAvailable; - } + public Boolean isDisplayDesignImage() { + return displayDesignImage; + } - public void setLearnerExportAvailable(Boolean learnerExportAvailable) { - this.learnerExportAvailable = learnerExportAvailable; - } - - /** - * @hibernate.property type="java.lang.Boolean" column="learner_presence_avail" - * length="1" + public void setDisplayDesignImage(Boolean displayDesignImage) { + this.displayDesignImage = displayDesignImage; + } + + /** + * @hibernate.property type="java.lang.Boolean" column="learner_exportport_avail" length="1" */ - public Boolean getLearnerPresenceAvailable() { - return learnerPresenceAvailable; - } + public Boolean getLearnerExportAvailable() { + return learnerExportAvailable; + } - public void setLearnerPresenceAvailable(Boolean learnerPresenceAvailable) { - this.learnerPresenceAvailable = learnerPresenceAvailable; - } - + public void setLearnerExportAvailable(Boolean learnerExportAvailable) { + this.learnerExportAvailable = learnerExportAvailable; + } + /** - * @hibernate.property type="java.lang.Boolean" column="learner_exportport_avail" - * length="1" + * @hibernate.property type="java.lang.Boolean" column="learner_presence_avail" length="1" */ - public Boolean getLearnerImAvailable() { - return learnerImAvailable; - } + public Boolean getLearnerPresenceAvailable() { + return learnerPresenceAvailable; + } - public void setLearnerImAvailable(Boolean learnerImAvailable) { - this.learnerImAvailable = learnerImAvailable; - } + public void setLearnerPresenceAvailable(Boolean learnerPresenceAvailable) { + this.learnerPresenceAvailable = learnerPresenceAvailable; + } /** - * @hibernate.property type="java.lang.Boolean" column="live_edit_enabled" - * length="1" + * @hibernate.property type="java.lang.Boolean" column="learner_exportport_avail" length="1" */ - public Boolean getLiveEditEnabled() { - return liveEditEnabled; - } + public Boolean getLearnerImAvailable() { + return learnerImAvailable; + } - public void setLiveEditEnabled(Boolean liveEditEnabled) { - this.liveEditEnabled = liveEditEnabled; - } - + public void setLearnerImAvailable(Boolean learnerImAvailable) { + this.learnerImAvailable = learnerImAvailable; + } + /** + * @hibernate.property type="java.lang.Boolean" column="live_edit_enabled" length="1" + */ + public Boolean getLiveEditEnabled() { + return liveEditEnabled; + } + + public void setLiveEditEnabled(Boolean liveEditEnabled) { + this.liveEditEnabled = liveEditEnabled; + } + + /** * @hibernate.property type="java.lang.Boolean" column="enable_lesson_notifications" length="1" */ public Boolean getEnableLessonNotifications() { @@ -547,35 +525,33 @@ public void setEnableLessonNotifications(Boolean enableLessonNotifications) { this.enableLessonNotifications = enableLessonNotifications; } - - /** - * @hibernate.property type="java.lang.Boolean" column="locked_for_edit" - * length="1" + + /** + * @hibernate.property type="java.lang.Boolean" column="locked_for_edit" length="1" */ - public Boolean getLockedForEdit() { - return lockedForEdit; - } + public Boolean getLockedForEdit() { + return lockedForEdit; + } - public void setLockedForEdit(Boolean lockedForEdit) { - this.lockedForEdit = lockedForEdit; - } + public void setLockedForEdit(Boolean lockedForEdit) { + this.lockedForEdit = lockedForEdit; + } - /** + /** * @hibernate.many-to-one not-null="true" cascade="none" - * @hibernate.column name="learning_design_id" + * @hibernate.column name="learning_design_id" */ public LearningDesign getLearningDesign() { - return this.learningDesign; + return this.learningDesign; } public void setLearningDesign(LearningDesign learningDesign) { - this.learningDesign = learningDesign; + this.learningDesign = learningDesign; } - /** - * @hibernate.many-to-one not-null="false" unique="true" - * cascade = "save-update" - * @hibernate.column name="learning_design_id" + /** + * @hibernate.many-to-one not-null="false" unique="true" cascade = "save-update" + * @hibernate.column name="learning_design_id" */ public LessonClass getLessonClass() { return this.lessonClass; @@ -585,23 +561,22 @@ this.lessonClass = lessonClass; } - /** + /** * @hibernate.many-to-one not-null="false" cascade="none" - * @hibernate.column name="organisation_id" + * @hibernate.column name="organisation_id" */ public Organisation getOrganisation() { - return this.organisation; + return this.organisation; } public void setOrganisation(Organisation organisation) { - this.organisation = organisation; + this.organisation = organisation; } - - /** + + /** * @hibernate.set lazy="false" inverse="true" cascade="none" * @hibernate.collection-key column="lesson_id" - * @@hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.lesson.LearnerProgress" + * @@hibernate.collection-one-to-many class="org.lamsfoundation.lams.lesson.LearnerProgress" */ public Set getLearnerProgresses() { return this.learnerProgresses; @@ -619,98 +594,95 @@ } public boolean equals(Object other) { - if ( (this == other ) ) return true; - if ( !(other instanceof Lesson) ) return false; - Lesson castOther = (Lesson) other; - return new EqualsBuilder() - .append(this.getLessonId(), castOther.getLessonId()) - .isEquals(); + if ((this == other)) + return true; + if (!(other instanceof Lesson)) + return false; + Lesson castOther = (Lesson) other; + return new EqualsBuilder().append(this.getLessonId(), castOther.getLessonId()).isEquals(); } public int hashCode() { - return new HashCodeBuilder() - .append(getLessonId()) - .toHashCode(); + return new HashCodeBuilder().append(getLessonId()).toHashCode(); } - public Set getAllLearners() - { - return lessonClass.getLearners(); + public Set getAllLearners() { + return lessonClass.getLearners(); } - //--------------------------------------------------------------------- + + // --------------------------------------------------------------------- // Domain service methods - //--------------------------------------------------------------------- + // --------------------------------------------------------------------- /** - * Create lesson data transfer object for flash and java learner interaction. - * Does not include the counts of the users. + * Create lesson data transfer object for flash and java learner interaction. Does not include the counts of the + * users. * * @return the lesson data transfer object. */ - public LessonDTO getLessonData() - { - return new LessonDTO(this); + public LessonDTO getLessonData() { + return new LessonDTO(this); } + /** - * Create lesson data transfer object for flash and java monitoring interaction. - * Includes counts of the learners. + * Create lesson data transfer object for flash and java monitoring interaction. Includes counts of the learners. * * @return the monitoring lesson data transfer object. */ - public LessonDetailsDTO getLessonDetails(){ - return new LessonDetailsDTO(this); + public LessonDetailsDTO getLessonDetails() { + return new LessonDetailsDTO(this); } - + /** Is this lesson a preview lesson? ie is it attached to a preview learning design? */ public boolean isPreviewLesson() { - Integer copyTypeID = getLearningDesign().getCopyTypeID(); - return ( copyTypeID != null && LearningDesign.COPY_TYPE_PREVIEW == copyTypeID.intValue() ); + Integer copyTypeID = getLearningDesign().getCopyTypeID(); + return (copyTypeID != null && LearningDesign.COPY_TYPE_PREVIEW == copyTypeID.intValue()); } - - /** Has this lesson ever been started? Considered started if it is started, finished, archived or removed - * or if the previousLessonStateId is one of these states (to pick up suspended started)*/ + + /** + * Has this lesson ever been started? Considered started if it is started, finished, archived or removed or if the + * previousLessonStateId is one of these states (to pick up suspended started) + */ public boolean isLessonStarted() { - return isStarted(lessonStateId) || isStarted(previousLessonStateId) ; + return isStarted(lessonStateId) || isStarted(previousLessonStateId); } private boolean isStarted(Integer stateId) { - return ( stateId != null && - ( stateId.equals(STARTED_STATE) || stateId.equals(FINISHED_STATE) - || stateId.equals(ARCHIVED_STATE) || stateId.equals(REMOVED_STATE) ) ) ; + return (stateId != null && (stateId.equals(STARTED_STATE) || stateId.equals(FINISHED_STATE) + || stateId.equals(ARCHIVED_STATE) || stateId.equals(REMOVED_STATE))); } public Set getGradebookUserLessons() { - return gradebookUserLessons; + return gradebookUserLessons; } public void setGradebookUserLessons(Set gradebookUserLessons) { - this.gradebookUserLessons = gradebookUserLessons; + this.gradebookUserLessons = gradebookUserLessons; } - /** - * @hibernate.property type="java.lang.Boolean" column="marks_released" - * length="1" + /** + * @hibernate.property type="java.lang.Boolean" column="marks_released" length="1" */ public Boolean getMarksReleased() { - return marksReleased; + return marksReleased; } public void setMarksReleased(Boolean marksReleased) { - this.marksReleased = marksReleased; + this.marksReleased = marksReleased; } public Set getPrecedingLessons() { - return precedingLessons; + return precedingLessons; } public void setPrecedingLessons(Set precedingLessons) { - this.precedingLessons = precedingLessons; + this.precedingLessons = precedingLessons; } public Set getSucceedingLessons() { - return succeedingLessons; + return succeedingLessons; } public void setSucceedingLessons(Set succeedingLessons) { - this.succeedingLessons = succeedingLessons; + this.succeedingLessons = succeedingLessons; } } Index: lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java =================================================================== diff -u -r68d2988cca350af15ba4087814f74e1527a71997 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java (.../LessonDataAccessTestCase.java) (revision 68d2988cca350af15ba4087814f74e1527a71997) +++ lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java (.../LessonDataAccessTestCase.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -236,22 +236,12 @@ /** * Create lesson based on the information we initialized. */ - protected void initLessonData() - { - testLesson = new Lesson("Test Lesson", - "Test lesson description", - new Date(System.currentTimeMillis()), - testUser, - Lesson.CREATED, - null, - true, - testLearningDesign, - testLessonClass,//lesson class - testOrg, - new HashSet(), - false, - false, - false); + protected void initLessonData() { + testLesson = new Lesson("Test Lesson", "Test lesson description", new Date(System.currentTimeMillis()), + testUser, Lesson.CREATED, null, testLearningDesign, new HashSet(), false, false, true, false, false, + false, false, null); + testLesson.setLessonClass(testLessonClass); + testLesson.setOrganisation(testOrg); } Index: lams_common/test/java/org/lamsfoundation/lams/lesson/dao/TestLessonDAO.java =================================================================== diff -u -rcb6d628cd53fe3d51e4f67cbaff7390651a048da -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/test/java/org/lamsfoundation/lams/lesson/dao/TestLessonDAO.java (.../TestLessonDAO.java) (revision cb6d628cd53fe3d51e4f67cbaff7390651a048da) +++ lams_common/test/java/org/lamsfoundation/lams/lesson/dao/TestLessonDAO.java (.../TestLessonDAO.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -119,12 +119,14 @@ Lesson lessonWithoutName = Lesson.createNewLessonWithoutClass(null, null, testUser, - true, testLearningDesign, false, false, + true, false, false, + false, + false, null); try Index: lams_common/test/java/org/lamsfoundation/lams/lesson/service/TestLessonService.java =================================================================== diff -u -rcb6d628cd53fe3d51e4f67cbaff7390651a048da -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_common/test/java/org/lamsfoundation/lams/lesson/service/TestLessonService.java (.../TestLessonService.java) (revision cb6d628cd53fe3d51e4f67cbaff7390651a048da) +++ lams_common/test/java/org/lamsfoundation/lams/lesson/service/TestLessonService.java (.../TestLessonService.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -79,7 +79,7 @@ User test1 = userManagementService.getUserByLogin(TEST1_USER_LOGIN); // this lesson isn't valid as it doesn't have a learning design - Lesson newLesson = Lesson.createNewLessonWithoutClass("test lesson", "test lesson", mmm, true, null, false, false, false, false, null); + Lesson newLesson = Lesson.createNewLessonWithoutClass("test lesson", "test lesson", mmm, null, false, false, true, false, false, false, false, null); lessonDAO.saveLesson(newLesson); Organisation organisation = (Organisation) baseDAO.find(Organisation.class, TEST_ORG_ID); Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java =================================================================== diff -u -r6a1464e83458721fec7237d3dccfdf5e6214cc69 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 6a1464e83458721fec7237d3dccfdf5e6214cc69) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -65,8 +65,6 @@ * the name of the lesson * @param lessonDescription * the description of the lesson. - * @param learnerExportAvailable - * should the export portfolio option be made available to the learner? * @param learningDesignId * the selected learning design * @param organisationId @@ -76,17 +74,24 @@ * the user who want to create this lesson. * @param customCSV * the custom comma separated values to be used by toolAdapters + * @param enableLessonIntro + * display an intro page to the lesson + * @param displayDesignImage + * display the design image or not + * @param learnerExportAvailable + * should the export portfolio option be made available to the learner? * @param enableNotifications * enable "email notifications" link for the current lesson * @param numberDaysToLessonFinish * number of days the lesson will be available to user since he starts it. (lesson finish scheduling * feature) * @return the lesson initialized. */ - public Lesson initializeLesson(String lessonName, String lessonDescription, Boolean learnerExportAvailable, - long learningDesignId, Integer organisationId, Integer userID, String customCSV, - Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled, - Boolean enableNotifications, Integer numberDaysToLessonFinish, Long precedingLessonId); + public Lesson initializeLesson(String lessonName, String lessonDescription, long learningDesignId, + Integer organisationId, Integer userID, String customCSV, Boolean enableLessonIntro, + Boolean displayDesignImage, Boolean learnerExportAvailable, Boolean learnerPresenceAvailable, + Boolean learnerImAvailable, Boolean liveEditEnabled, Boolean enableNotifications, + Integer numberDaysToLessonFinish, Long precedingLessonId); /** * Initialize a new lesson so as to start the learning process for a normal Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -r6a1464e83458721fec7237d3dccfdf5e6214cc69 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 6a1464e83458721fec7237d3dccfdf5e6214cc69) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -413,10 +413,11 @@ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#initializeLesson(String, String, long, * Integer) */ - public Lesson initializeLesson(String lessonName, String lessonDescription, Boolean learnerExportAvailable, - long learningDesignId, Integer organisationId, Integer userID, String customCSV, - Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled, - Boolean enableLessonNotifications, Integer scheduledNumberDaysToLessonFinish, Long precedingLessonId) { + public Lesson initializeLesson(String lessonName, String lessonDescription, long learningDesignId, + Integer organisationId, Integer userID, String customCSV, Boolean enableLessonIntro, + Boolean displayDesignImage, Boolean learnerExportAvailable, Boolean learnerPresenceAvailable, + Boolean learnerImAvailable, Boolean liveEditEnabled, Boolean enableLessonNotifications, + Integer scheduledNumberDaysToLessonFinish, Long precedingLessonId) { LearningDesign originalLearningDesign = authoringService.getLearningDesign(new Long(learningDesignId)); if (originalLearningDesign == null) { @@ -452,9 +453,10 @@ } User user = userID != null ? (User) baseDAO.find(User.class, userID) : null; - Lesson initializedLesson = initializeLesson(lessonName, lessonDescription, learnerExportAvailable, - originalLearningDesign, user, runSeqFolder, LearningDesign.COPY_TYPE_LESSON, customCSV, - learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, enableLessonNotifications, scheduledNumberDaysToLessonFinish, precedingLesson); + Lesson initializedLesson = initializeLesson(lessonName, lessonDescription, originalLearningDesign, user, + runSeqFolder, LearningDesign.COPY_TYPE_LESSON, customCSV, enableLessonIntro, displayDesignImage, + learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, + enableLessonNotifications, scheduledNumberDaysToLessonFinish, precedingLesson); Long initializedLearningDesignId = initializedLesson.getLearningDesign().getLearningDesignId(); logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_CREATE, userID, initializedLearningDesignId, initializedLesson.getLessonId(), null); @@ -477,15 +479,16 @@ } User user = userID != null ? (User) baseDAO.find(User.class, userID) : null; - return initializeLesson(lessonName, lessonDescription, Boolean.TRUE, originalLearningDesign, user, null, - LearningDesign.COPY_TYPE_PREVIEW, customCSV, learnerPresenceAvailable, learnerImAvailable, + return initializeLesson(lessonName, lessonDescription, originalLearningDesign, user, null, + LearningDesign.COPY_TYPE_PREVIEW, customCSV, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, null, null, null); } - public Lesson initializeLesson(String lessonName, String lessonDescription, Boolean learnerExportAvailable, - LearningDesign originalLearningDesign, User user, WorkspaceFolder workspaceFolder, int copyType, - String customCSV, Boolean learnerPresenceAvailable, Boolean learnerImAvailable, Boolean liveEditEnabled, - Boolean enableLessonNotifications, Integer scheduledNumberDaysToLessonFinish, Lesson precedingLesson) { + public Lesson initializeLesson(String lessonName, String lessonDescription, LearningDesign originalLearningDesign, + User user, WorkspaceFolder workspaceFolder, int copyType, String customCSV, Boolean enableLessonIntro, + Boolean displayDesignImage, Boolean learnerExportAvailable, Boolean learnerPresenceAvailable, + Boolean learnerImAvailable, Boolean liveEditEnabled, Boolean enableLessonNotifications, + Integer scheduledNumberDaysToLessonFinish, Lesson precedingLesson) { // copy the current learning design LearningDesign copiedLearningDesign = authoringService.copyLearningDesign(originalLearningDesign, new Integer( @@ -500,9 +503,9 @@ title = title.substring(0, 254); } - Lesson lesson = createNewLesson(title, lessonDescription, user, learnerExportAvailable, copiedLearningDesign, - learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, enableLessonNotifications, - scheduledNumberDaysToLessonFinish, precedingLesson); + Lesson lesson = createNewLesson(title, lessonDescription, user, copiedLearningDesign, enableLessonIntro, + displayDesignImage, learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, + liveEditEnabled, enableLessonNotifications, scheduledNumberDaysToLessonFinish, precedingLesson); auditAction(MonitoringService.AUDIT_LESSON_CREATED_KEY, new Object[] { lessonName, copiedLearningDesign.getTitle(), learnerExportAvailable }); return lesson; @@ -526,14 +529,18 @@ Integer organisationId = WDDXProcessor.convertToInteger("organisationID", table.get("organisationID")); long ldId = WDDXProcessor.convertToLong(AttributeNames.PARAM_LEARNINGDESIGN_ID, table .get(AttributeNames.PARAM_LEARNINGDESIGN_ID)); + String customCSV = WDDXProcessor.convertToString(WDDXTAGS.CUSTOM_CSV, table.get(WDDXTAGS.CUSTOM_CSV)); + boolean enableLessonIntro = WDDXProcessor.convertToBoolean("enableLessonIntro", + table.get("enableLessonIntro")); + boolean displayDesignImage = WDDXProcessor.convertToBoolean("displayDesignImage", + table.get("displayDesignImage")); boolean learnerExportAvailable = WDDXProcessor.convertToBoolean("learnerExportPortfolio", table .get("learnerExportPortfolio")); boolean learnerPresenceAvailable = WDDXProcessor.convertToBoolean("enablePresence", table .get("enablePresence")); boolean learnerImAvailable = WDDXProcessor.convertToBoolean("enableIm", table.get("enableIm")); boolean liveEditEnabled = WDDXProcessor.convertToBoolean("enableLiveEdit", table.get("enableLiveEdit")); Boolean enableLessonNotifications = WDDXProcessor.convertToBoolean("enableLessonNotifications", table.get("enableLessonNotifications")); - String customCSV = WDDXProcessor.convertToString(WDDXTAGS.CUSTOM_CSV, table.get(WDDXTAGS.CUSTOM_CSV)); Integer scheduledNumberDaysToLessonFinish = WDDXProcessor.convertToInteger("scheduledNumberDaysToLessonFinish", table.get("scheduledNumberDaysToLessonFinish")); Long precedingLessonId = WDDXProcessor.convertToLong("organisationID", table.get("precedingLessonID")); @@ -545,8 +552,9 @@ newLesson = initializeLessonForPreview(title, desc, ldId, creatorUserId, customCSV, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled); } else { - newLesson = initializeLesson(title, desc, learnerExportAvailable, ldId, organisationId, creatorUserId, - customCSV, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, enableLessonNotifications, + newLesson = initializeLesson(title, desc, ldId, organisationId, creatorUserId, customCSV, + enableLessonIntro, displayDesignImage, learnerExportAvailable, learnerPresenceAvailable, + learnerImAvailable, liveEditEnabled, enableLessonNotifications, scheduledNumberDaysToLessonFinish, precedingLessonId); } @@ -2231,17 +2239,18 @@ * */ private Lesson createNewLesson(String lessonName, String lessonDescription, User user, - Boolean learnerExportAvailable, LearningDesign copiedLearningDesign, Boolean learnerPresenceAvailable, - Boolean learnerImAvailable, Boolean liveEditEnabled, Boolean enableLessonNotifications, - Integer scheduledNumberDaysToLessonFinish, Lesson precedingLesson) { + LearningDesign copiedLearningDesign, Boolean enableLessonIntro, Boolean displayDesignImage, + Boolean learnerExportAvailable, Boolean learnerPresenceAvailable, Boolean learnerImAvailable, + Boolean liveEditEnabled, Boolean enableLessonNotifications, Integer scheduledNumberDaysToLessonFinish, + Lesson precedingLesson) { Lesson newLesson = Lesson.createNewLessonWithoutClass(lessonName, lessonDescription, user, - learnerExportAvailable, copiedLearningDesign, learnerPresenceAvailable, learnerImAvailable, - liveEditEnabled, enableLessonNotifications, scheduledNumberDaysToLessonFinish); + copiedLearningDesign, enableLessonIntro, displayDesignImage, learnerExportAvailable, + learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, enableLessonNotifications, + scheduledNumberDaysToLessonFinish); if (precedingLesson != null) { HashSet precedingLessons = new HashSet(); precedingLessons.add(precedingLesson); newLesson.setPrecedingLessons(precedingLessons); -// newLesson.getPrecedingLessons().add(precedingLesson); } lessonDAO.saveLesson(newLesson); @@ -2990,12 +2999,16 @@ Integer organisationId = WDDXProcessor.convertToInteger("organisationID", table.get("organisationID")); long ldId = WDDXProcessor.convertToLong(AttributeNames.PARAM_LEARNINGDESIGN_ID, table .get(AttributeNames.PARAM_LEARNINGDESIGN_ID)); - boolean learnerExportAvailable = WDDXProcessor.convertToBoolean("learnerExportPortfolio", table - .get("learnerExportPortfolio")); - boolean learnerPresenceAvailable = WDDXProcessor.convertToBoolean("enablePresence", table - .get("enablePresence")); - boolean learnerImAvailable = WDDXProcessor.convertToBoolean("enableIm", table.get("enableIm")); String customCSV = WDDXProcessor.convertToString(WDDXTAGS.CUSTOM_CSV, table.get(WDDXTAGS.CUSTOM_CSV)); + boolean enableLessonIntro = WDDXProcessor.convertToBoolean("enableLessonIntro", + table.get("enableLessonIntro")); + boolean displayDesignImage = WDDXProcessor.convertToBoolean("displayDesignImage", + table.get("displayDesignImage")); + boolean learnerExportAvailable = WDDXProcessor.convertToBoolean("learnerExportPortfolio", + table.get("learnerExportPortfolio")); + boolean learnerPresenceAvailable = WDDXProcessor.convertToBoolean("enablePresence", + table.get("enablePresence")); + boolean learnerImAvailable = WDDXProcessor.convertToBoolean("enableIm", table.get("enableIm")); boolean liveEditEnabled = WDDXProcessor.convertToBoolean("enableLiveEdit", table.get("enableLiveEdit")); Boolean enableLessonNotifications = WDDXProcessor.convertToBoolean("enableLessonNotifications", table.get("enableLessonNotifications")); int numLessons = WDDXProcessor.convertToInt("numberLessonsSplit", table.get("numberLessonsSplit")); @@ -3005,9 +3018,10 @@ // initialize multiple lessons if (numLessons > 0) { for (int i = 1; i <= numLessons; i++) { - Lesson newLesson = initializeLesson(title + " " + i, desc, learnerExportAvailable, ldId, - organisationId, creatorUserId, customCSV, learnerPresenceAvailable, learnerImAvailable, - liveEditEnabled, enableLessonNotifications, scheduledNumberDaysToLessonFinish, precedingLessonId); + Lesson newLesson = initializeLesson(title + " " + i, desc, ldId, organisationId, creatorUserId, + customCSV, enableLessonIntro, displayDesignImage, learnerExportAvailable, + learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, enableLessonNotifications, + scheduledNumberDaysToLessonFinish, precedingLessonId); lessonIds.add(newLesson.getLessonId()); } } @@ -3168,12 +3182,13 @@ learnerIds); // init Lesson with user as creator - Lesson newLesson = this.initializeLesson(lesson.getLessonName(), lesson - .getLessonDescription(), lesson.getLearnerExportAvailable(), lesson - .getLearningDesign().getLearningDesignId(), group.getOrganisationId(), userDto - .getUserID(), null, lesson.getLearnerPresenceAvailable(), lesson - .getLearnerImAvailable(), lesson.getLiveEditEnabled(), lesson - .getEnableLessonNotifications(), null, null); + Lesson newLesson = this.initializeLesson(lesson.getLessonName(), + lesson.getLessonDescription(), + lesson.getLearningDesign().getLearningDesignId(), group.getOrganisationId(), + userDto.getUserID(), null, lesson.isEnableLessonIntro(), + lesson.isDisplayDesignImage(), lesson.getLearnerExportAvailable(), + lesson.getLearnerPresenceAvailable(), lesson.getLearnerImAvailable(), + lesson.getLiveEditEnabled(), lesson.getEnableLessonNotifications(), null, null); // save LessonClasses newLesson = this Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== diff -u -r943d43d5e2afea12f2fdcb9e6ef24bc1a524b4a9 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 943d43d5e2afea12f2fdcb9e6ef24bc1a524b4a9) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -189,7 +189,9 @@ Boolean learnerPresenceAvailable = WebUtil.readBooleanParam(request, "learnerPresenceAvailable", false); Boolean learnerImAvailable = WebUtil.readBooleanParam(request, "learnerImAvailable", false); Boolean liveEditEnabled = WebUtil.readBooleanParam(request, "liveEditEnabled", false); - Lesson newLesson = monitoringService.initializeLesson(title,desc,learnerExportAvailable,ldId,organisationId,getUserId(), null, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, Boolean.FALSE, null, null); + Lesson newLesson = monitoringService.initializeLesson(title, desc, ldId, organisationId, getUserId(), null, + Boolean.FALSE, Boolean.FALSE, learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, + liveEditEnabled, Boolean.FALSE, null, null); flashMessage = new FlashMessage("initializeLesson",newLesson.getLessonId()); } catch (Exception e) { @@ -761,6 +763,8 @@ languageCollection.add(new String("label.completed")); languageCollection.add(new String("advanced.tab.form.validation.schedule.date.error")); languageCollection.add(new String("alert.no.learner.data")); + languageCollection.add(new String("advanced.tab.enable.lesson.intro")); + languageCollection.add(new String("advanced.tab.display.design.image")); } String languageOutput = ""; Index: lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java =================================================================== diff -u -r6a1464e83458721fec7237d3dccfdf5e6214cc69 -r27a9e58b46446d891cf6b081e8fb6fb6f6294e2e --- lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java (.../TestMonitoringService.java) (revision 6a1464e83458721fec7237d3dccfdf5e6214cc69) +++ lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java (.../TestMonitoringService.java) (revision 27a9e58b46446d891cf6b081e8fb6fb6f6294e2e) @@ -156,8 +156,9 @@ String idName = "learning_design_id"; long previousLDId = getMaxId(lamsLearningDesignTableName, idName); - Lesson testLesson = monitoringService.initializeLesson("Test_Lesson", "Test_Description", Boolean.TRUE, - TEST_LEARNING_DESIGN_ID, null, testUser.getUserId(), null, false, false, false, false, null, null); + Lesson testLesson = monitoringService.initializeLesson("Test_Lesson", "Test_Description", + TEST_LEARNING_DESIGN_ID, null, testUser.getUserId(), null, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, + false, false, false, false, null, null); TestMonitoringService.TEST_LESSON_ID = testLesson.getLessonId(); Lesson createdLesson = lessonDao.getLesson(TestMonitoringService.TEST_LESSON_ID); assertNotNull(createdLesson);