Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java =================================================================== diff -u -r109a71a895d44a4bb8294b9b4c127e741cb2f772 -re283e2d817ad22103fdb65a11a5e68f4f61016f9 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision 109a71a895d44a4bb8294b9b4c127e741cb2f772) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision e283e2d817ad22103fdb65a11a5e68f4f61016f9) @@ -28,6 +28,7 @@ import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.lesson.dto.LessonDetailsDTO; import org.lamsfoundation.lams.usermanagement.User; /** @@ -201,4 +202,12 @@ * @return list of teachers that monitor the lesson which contains the tool with given session ID */ public List getMonitorsByToolSessionId(Long sessionId); + + /** + * Gets lesson for tools based on toolSessionID + * + * @param sessionID + * @return + */ + public Lesson getLessonFromSessionID(Long toolSessionID); } Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java =================================================================== diff -u -r109a71a895d44a4bb8294b9b4c127e741cb2f772 -re283e2d817ad22103fdb65a11a5e68f4f61016f9 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision 109a71a895d44a4bb8294b9b4c127e741cb2f772) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision e283e2d817ad22103fdb65a11a5e68f4f61016f9) @@ -64,6 +64,8 @@ + Lesson.STARTED_STATE + " " + "and l.organisation.organisationId = ? " + " order by l.lessonName"; private final static String LESSONS_BY_GROUP = "from " + Lesson.class.getName() + " where organisation.organisationId=? and lessonStateId <= 6"; + private final static String LESSON_BY_SESSION_ID = "select lesson from Lesson lesson, ToolSession session where " + + "session.lesson=lesson and session.toolSessionId=:toolSessionID"; /** * Retrieves the Lesson. Used in instances where it cannot be lazy loaded so it forces an initialize. @@ -343,5 +345,18 @@ return this.getHibernateTemplate().findByNamedQueryAndNamedParam("monitorsByToolSessionId", "sessionId", sessionId); } - + + /** + * @see org.lamsfoundation.lams.lesson.dao.ILessonDAO#getLessonDetailsFromSessionID(java.lang.Long) + */ + public Lesson getLessonFromSessionID(final Long toolSessionID) { + HibernateTemplate hibernateTemplate = new HibernateTemplate(this.getSessionFactory()); + return (Lesson) hibernateTemplate.execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + Query query = session.createQuery(LessonDAO.LESSON_BY_SESSION_ID); + query.setLong("toolSessionID", toolSessionID); + return query.uniqueResult(); + } + }); + } } Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dto/LessonDetailsDTO.java =================================================================== diff -u -r68d2988cca350af15ba4087814f74e1527a71997 -re283e2d817ad22103fdb65a11a5e68f4f61016f9 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dto/LessonDetailsDTO.java (.../LessonDetailsDTO.java) (revision 68d2988cca350af15ba4087814f74e1527a71997) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dto/LessonDetailsDTO.java (.../LessonDetailsDTO.java) (revision e283e2d817ad22103fdb65a11a5e68f4f61016f9) @@ -33,227 +33,353 @@ * @author Manpreet Minhas */ public class LessonDetailsDTO { - - private Long lessonID; - private String lessonName; - private String lessonDescription; - private Integer lessonStateID; - private Date createDateTime; - private Date startDateTime; - private String startDateTimeStr; + + private Long lessonID; + private String lessonName; + private String lessonDescription; + private Integer lessonStateID; + private Date createDateTime; + private Date startDateTime; + private String startDateTimeStr; private Date scheduleStartDate; private String scheduleStartDateStr; private Date scheduleEndDate; - private Long duration; - private Integer organisationID; - private String organisationName; - private String organisationDescription; - private Integer workspaceFolderID; - private String contentFolderID; - private Long licenseID; - private String licenseText; - private Long learningDesignID; - private Integer numberPossibleLearners; - private Integer numberStartedLearners; - private Boolean learnerExportAvailable; - private Boolean locked_for_edit; - private Boolean learnerPresenceAvailable; - private Boolean learnerImAvailable; - private Boolean liveEditEnabled; - - /** Create the DTO based on the lesson. Sets up all the fields except numberStartedLearners */ - public LessonDetailsDTO(Lesson lesson){ - this.lessonID = lesson.getLessonId(); - this.lessonName = lesson.getLessonName(); - this.lessonDescription = lesson.getLessonDescription(); + private Long duration; + private Integer organisationID; + private String organisationName; + private String organisationDescription; + private Integer workspaceFolderID; + private String contentFolderID; + private Long licenseID; + private String licenseText; + private Long learningDesignID; + private Integer numberPossibleLearners; + private Integer numberStartedLearners; + private Boolean learnerExportAvailable; + private Boolean locked_for_edit; + private Boolean learnerPresenceAvailable; + private Boolean learnerImAvailable; + private Boolean liveEditEnabled; + private Boolean isPreview; - this.lessonStateID = lesson.getLessonStateId(); - this.createDateTime = lesson.getCreateDateTime(); - this.startDateTime = lesson.getStartDateTime(); - this.startDateTimeStr = null; - this.scheduleStartDate = lesson.getScheduleStartDate(); - //if(this.scheduleStartDate != null) { - // this.scheduleStartDateStr = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(this.scheduleStartDate); - - //} else { - this.scheduleStartDateStr = null; - //} - this.scheduleEndDate = lesson.getScheduleEndDate(); - - this.duration = lesson.getLearningDesign().getDuration(); - - this.organisationID = lesson.getOrganisation()!=null? - lesson.getOrganisation().getOrganisationId(): - WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; - - this.organisationName = lesson.getOrganisation()!=null? - lesson.getOrganisation().getName(): - WDDXTAGS.STRING_NULL_VALUE; - - this.organisationDescription = lesson.getOrganisation()!=null? - lesson.getOrganisation().getDescription(): - WDDXTAGS.STRING_NULL_VALUE; - - this.workspaceFolderID = lesson.getLearningDesign().getWorkspaceFolder()!=null? - lesson.getLearningDesign().getWorkspaceFolder().getWorkspaceFolderId(): - WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; - - this.contentFolderID = lesson.getLearningDesign().getContentFolderID()!=null? - lesson.getLearningDesign().getContentFolderID(): - WDDXTAGS.STRING_NULL_VALUE; - - this.licenseID = lesson.getLearningDesign().getLicense()!=null? - lesson.getLearningDesign().getLicense().getLicenseID(): - WDDXTAGS.NUMERIC_NULL_VALUE_LONG; - - this.licenseText = lesson.getLearningDesign().getLicenseText()!=null? - lesson.getLearningDesign().getLicenseText(): - WDDXTAGS.STRING_NULL_VALUE; - - this.learningDesignID = lesson.getLearningDesign().getLearningDesignId(); + /** + * Create the DTO based on the lesson. Sets up all the fields except + * numberStartedLearners + */ + public LessonDetailsDTO(Lesson lesson) { + this.lessonID = lesson.getLessonId(); + this.lessonName = lesson.getLessonName(); + this.lessonDescription = lesson.getLessonDescription(); - Set allLearners = lesson.getAllLearners(); - this.numberPossibleLearners = new Integer(allLearners !=null ? allLearners.size() : 0); - this.numberStartedLearners = new Integer(0); + this.lessonStateID = lesson.getLessonStateId(); + this.createDateTime = lesson.getCreateDateTime(); + this.startDateTime = lesson.getStartDateTime(); + this.startDateTimeStr = null; + this.scheduleStartDate = lesson.getScheduleStartDate(); + // if(this.scheduleStartDate != null) { + // this.scheduleStartDateStr = + // DateFormat.getDateTimeInstance(DateFormat.FULL, + // DateFormat.FULL).format(this.scheduleStartDate); + + // } else { + this.scheduleStartDateStr = null; + // } + this.scheduleEndDate = lesson.getScheduleEndDate(); + + this.duration = lesson.getLearningDesign().getDuration(); + + this.organisationID = lesson.getOrganisation() != null ? lesson.getOrganisation().getOrganisationId() : WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; + + this.organisationName = lesson.getOrganisation() != null ? lesson.getOrganisation().getName() : WDDXTAGS.STRING_NULL_VALUE; + + this.organisationDescription = lesson.getOrganisation() != null ? lesson.getOrganisation().getDescription() : WDDXTAGS.STRING_NULL_VALUE; + + this.workspaceFolderID = lesson.getLearningDesign().getWorkspaceFolder() != null ? lesson.getLearningDesign().getWorkspaceFolder() + .getWorkspaceFolderId() : WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; + + this.contentFolderID = lesson.getLearningDesign().getContentFolderID() != null ? lesson.getLearningDesign().getContentFolderID() + : WDDXTAGS.STRING_NULL_VALUE; + + this.licenseID = lesson.getLearningDesign().getLicense() != null ? lesson.getLearningDesign().getLicense().getLicenseID() + : WDDXTAGS.NUMERIC_NULL_VALUE_LONG; + + this.licenseText = lesson.getLearningDesign().getLicenseText() != null ? lesson.getLearningDesign().getLicenseText() : WDDXTAGS.STRING_NULL_VALUE; + + this.learningDesignID = lesson.getLearningDesign().getLearningDesignId(); + + Set allLearners = lesson.getAllLearners(); + this.numberPossibleLearners = new Integer(allLearners != null ? allLearners.size() : 0); + this.numberStartedLearners = new Integer(0); + + this.learnerExportAvailable = lesson.getLearnerExportAvailable(); + + this.learnerPresenceAvailable = lesson.getLearnerPresenceAvailable(); + this.learnerImAvailable = lesson.getLearnerImAvailable(); + + this.liveEditEnabled = lesson.getLiveEditEnabled(); + + this.locked_for_edit = lesson.getLockedForEdit(); - this.learnerExportAvailable = lesson.getLearnerExportAvailable(); - - this.learnerPresenceAvailable = lesson.getLearnerPresenceAvailable(); - this.learnerImAvailable = lesson.getLearnerImAvailable(); - - this.liveEditEnabled = lesson.getLiveEditEnabled(); - - this.locked_for_edit = lesson.getLockedForEdit(); - } - public Date getScheduleEndDate() { - return scheduleEndDate; - } - public Date getScheduleStartDate() { - return scheduleStartDate; - } - public String getScheduleStartDateStr() { - return scheduleStartDateStr; - } - public void setScheduleStartDateStr(String scheduleStartDateStr) { - this.scheduleStartDateStr = scheduleStartDateStr; - } - - /** - * @return Returns the createDateTime. - */ - public Date getCreateDateTime() { - return createDateTime!=null?createDateTime:WDDXTAGS.DATE_NULL_VALUE; - } - /** - * @return Returns the duration. - */ - public Long getDuration() { - return duration!=null?duration:WDDXTAGS.NUMERIC_NULL_VALUE_LONG; - } - /** - * @return Returns the learningDesignID. - */ - public Long getLearningDesignID() { - return learningDesignID!=null?learningDesignID:WDDXTAGS.NUMERIC_NULL_VALUE_LONG; - } - /** - * @return Returns the lessonID. - */ - public Long getLessonID() { - return lessonID!=null?lessonID:WDDXTAGS.NUMERIC_NULL_VALUE_LONG; - } - /** - * @return Returns the lessonStateID. - */ - public Integer getLessonStateID() { - return lessonStateID!=null?lessonStateID:WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; - } - /** - * @return Returns the licenseID. - */ - public Long getLicenseID() { - return licenseID!=null?licenseID:WDDXTAGS.NUMERIC_NULL_VALUE_LONG; - } - /** - * @return Returns the licenseText. - */ - public String getLicenseText() { - return licenseText!=null?licenseText:WDDXTAGS.STRING_NULL_VALUE; - } - /** - * @return Returns the organisationDescription. - */ - public String getOrganisationDescription() { - return organisationDescription!=null?organisationDescription:WDDXTAGS.STRING_NULL_VALUE; - } - /** - * @return Returns the organisationID. - */ - public Integer getOrganisationID() { - return organisationID!=null?organisationID:WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; - } - /** - * @return Returns the organisationName. - */ - public String getOrganisationName() { - return organisationName!=null?organisationName:WDDXTAGS.STRING_NULL_VALUE; - } - /** - * @return Returns the startDateTime. - */ - public Date getStartDateTime() { - return startDateTime!=null?startDateTime:WDDXTAGS.DATE_NULL_VALUE; - } - - public String getStartDateTimeStr() { - return startDateTimeStr!=null?startDateTimeStr:WDDXTAGS.STRING_NULL_VALUE; - } - - public void setStartDateTimeStr(String startDateTimeStr) { - this.startDateTimeStr = startDateTimeStr; - } - - /** - * @return Returns the workspaceFolderID. - */ - public Integer getWorkspaceFolderID() { - return workspaceFolderID!=null?workspaceFolderID:WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; - } - /** - * - * @return Returns the contentFolderID. - */ - public String getContentFolderID() { - return contentFolderID!=null?contentFolderID:WDDXTAGS.STRING_NULL_VALUE; - } - public Integer getNumberStartedLearners() { - return numberStartedLearners; - } - public void setNumberStartedLearners(Integer numberStartedLearners) { - this.numberStartedLearners = numberStartedLearners; - } - public String getLessonDescription() { - return lessonDescription; - } - public String getLessonName() { - return lessonName; - } - public Integer getNumberPossibleLearners() { - return numberPossibleLearners; - } - public Boolean getLearnerExportAvailable() { - return learnerExportAvailable; - } - public Boolean getLearnerPresenceAvailable() { - return learnerPresenceAvailable; - } - public Boolean getLearnerImAvailable() { - return learnerImAvailable; - } - public Boolean getLockedForEdit() { - return locked_for_edit; - } - public Boolean getLiveEditEnabled() { - return liveEditEnabled; - } + this.isPreview = lesson.isPreviewLesson(); + } + + public Date getScheduleEndDate() { + return scheduleEndDate; + } + + public Date getScheduleStartDate() { + return scheduleStartDate; + } + + public String getScheduleStartDateStr() { + return scheduleStartDateStr; + } + + public void setScheduleStartDateStr(String scheduleStartDateStr) { + this.scheduleStartDateStr = scheduleStartDateStr; + } + + /** + * @return Returns the createDateTime. + */ + public Date getCreateDateTime() { + return createDateTime != null ? createDateTime : WDDXTAGS.DATE_NULL_VALUE; + } + + /** + * @return Returns the duration. + */ + public Long getDuration() { + return duration != null ? duration : WDDXTAGS.NUMERIC_NULL_VALUE_LONG; + } + + /** + * @return Returns the learningDesignID. + */ + public Long getLearningDesignID() { + return learningDesignID != null ? learningDesignID : WDDXTAGS.NUMERIC_NULL_VALUE_LONG; + } + + /** + * @return Returns the lessonID. + */ + public Long getLessonID() { + return lessonID != null ? lessonID : WDDXTAGS.NUMERIC_NULL_VALUE_LONG; + } + + /** + * @return Returns the lessonStateID. + */ + public Integer getLessonStateID() { + return lessonStateID != null ? lessonStateID : WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; + } + + /** + * @return Returns the licenseID. + */ + public Long getLicenseID() { + return licenseID != null ? licenseID : WDDXTAGS.NUMERIC_NULL_VALUE_LONG; + } + + /** + * @return Returns the licenseText. + */ + public String getLicenseText() { + return licenseText != null ? licenseText : WDDXTAGS.STRING_NULL_VALUE; + } + + /** + * @return Returns the organisationDescription. + */ + public String getOrganisationDescription() { + return organisationDescription != null ? organisationDescription : WDDXTAGS.STRING_NULL_VALUE; + } + + /** + * @return Returns the organisationID. + */ + public Integer getOrganisationID() { + return organisationID != null ? organisationID : WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; + } + + /** + * @return Returns the organisationName. + */ + public String getOrganisationName() { + return organisationName != null ? organisationName : WDDXTAGS.STRING_NULL_VALUE; + } + + /** + * @return Returns the startDateTime. + */ + public Date getStartDateTime() { + return startDateTime != null ? startDateTime : WDDXTAGS.DATE_NULL_VALUE; + } + + public String getStartDateTimeStr() { + return startDateTimeStr != null ? startDateTimeStr : WDDXTAGS.STRING_NULL_VALUE; + } + + public void setStartDateTimeStr(String startDateTimeStr) { + this.startDateTimeStr = startDateTimeStr; + } + + /** + * @return Returns the workspaceFolderID. + */ + public Integer getWorkspaceFolderID() { + return workspaceFolderID != null ? workspaceFolderID : WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; + } + + /** + * + * @return Returns the contentFolderID. + */ + public String getContentFolderID() { + return contentFolderID != null ? contentFolderID : WDDXTAGS.STRING_NULL_VALUE; + } + + public Integer getNumberStartedLearners() { + return numberStartedLearners; + } + + public void setNumberStartedLearners(Integer numberStartedLearners) { + this.numberStartedLearners = numberStartedLearners; + } + + public String getLessonDescription() { + return lessonDescription; + } + + public String getLessonName() { + return lessonName; + } + + public Integer getNumberPossibleLearners() { + return numberPossibleLearners; + } + + public Boolean getLearnerExportAvailable() { + return learnerExportAvailable; + } + + public Boolean getLearnerPresenceAvailable() { + return learnerPresenceAvailable; + } + + public Boolean getLearnerImAvailable() { + return learnerImAvailable; + } + + public Boolean getLockedForEdit() { + return locked_for_edit; + } + + public Boolean getLiveEditEnabled() { + return liveEditEnabled; + } + + public Boolean getLocked_for_edit() { + return locked_for_edit; + } + + public void setLocked_for_edit(Boolean locked_for_edit) { + this.locked_for_edit = locked_for_edit; + } + + public Boolean getIsPreview() { + return isPreview; + } + + public void setIsPreview(Boolean isPreview) { + this.isPreview = isPreview; + } + + public void setLessonID(Long lessonID) { + this.lessonID = lessonID; + } + + public void setLessonName(String lessonName) { + this.lessonName = lessonName; + } + + public void setLessonDescription(String lessonDescription) { + this.lessonDescription = lessonDescription; + } + + public void setLessonStateID(Integer lessonStateID) { + this.lessonStateID = lessonStateID; + } + + public void setCreateDateTime(Date createDateTime) { + this.createDateTime = createDateTime; + } + + public void setStartDateTime(Date startDateTime) { + this.startDateTime = startDateTime; + } + + public void setScheduleStartDate(Date scheduleStartDate) { + this.scheduleStartDate = scheduleStartDate; + } + + public void setScheduleEndDate(Date scheduleEndDate) { + this.scheduleEndDate = scheduleEndDate; + } + + public void setDuration(Long duration) { + this.duration = duration; + } + + public void setOrganisationID(Integer organisationID) { + this.organisationID = organisationID; + } + + public void setOrganisationName(String organisationName) { + this.organisationName = organisationName; + } + + public void setOrganisationDescription(String organisationDescription) { + this.organisationDescription = organisationDescription; + } + + public void setWorkspaceFolderID(Integer workspaceFolderID) { + this.workspaceFolderID = workspaceFolderID; + } + + public void setContentFolderID(String contentFolderID) { + this.contentFolderID = contentFolderID; + } + + public void setLicenseID(Long licenseID) { + this.licenseID = licenseID; + } + + public void setLicenseText(String licenseText) { + this.licenseText = licenseText; + } + + public void setLearningDesignID(Long learningDesignID) { + this.learningDesignID = learningDesignID; + } + + public void setNumberPossibleLearners(Integer numberPossibleLearners) { + this.numberPossibleLearners = numberPossibleLearners; + } + + public void setLearnerExportAvailable(Boolean learnerExportAvailable) { + this.learnerExportAvailable = learnerExportAvailable; + } + + public void setLearnerPresenceAvailable(Boolean learnerPresenceAvailable) { + this.learnerPresenceAvailable = learnerPresenceAvailable; + } + + public void setLearnerImAvailable(Boolean learnerImAvailable) { + this.learnerImAvailable = learnerImAvailable; + } + + public void setLiveEditEnabled(Boolean liveEditEnabled) { + this.liveEditEnabled = liveEditEnabled; + } } Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java =================================================================== diff -u -r109a71a895d44a4bb8294b9b4c127e741cb2f772 -re283e2d817ad22103fdb65a11a5e68f4f61016f9 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision 109a71a895d44a4bb8294b9b4c127e741cb2f772) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision e283e2d817ad22103fdb65a11a5e68f4f61016f9) @@ -55,6 +55,10 @@ * and will need to purge users who haven't done anything for a while - otherwise a user whose PC has crashed and then * never returns to a lesson will staying in the cache forever. */ +/** + * @author lfoxton + * + */ public interface ILessonService { /** Get all the learners who have started the lesson. They may not be currently online. */ @@ -403,4 +407,13 @@ * @return a List with all active lessons in it. */ public List getActiveLessonsForLearner(final Integer learnerId, final Integer organisationId); + + + /** + * Gets lesson details for tools based on toolSessionID + * + * @param sessionID + * @return + */ + public LessonDetailsDTO getLessonDetailsFromSessionID(Long toolSessionID); } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java =================================================================== diff -u -r109a71a895d44a4bb8294b9b4c127e741cb2f772 -re283e2d817ad22103fdb65a11a5e68f4f61016f9 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision 109a71a895d44a4bb8294b9b4c127e741cb2f772) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision e283e2d817ad22103fdb65a11a5e68f4f61016f9) @@ -820,4 +820,15 @@ public List getActiveLessonsForLearner(Integer learnerId, Integer organisationId) { return lessonDAO.getActiveLessonsForLearner(learnerId, organisationId); } + + /** + * @see org.lamsfoundation.lams.lesson.service.ILessonService#getLessonDetailsFromSessionID(java.lang.Long) + */ + public LessonDetailsDTO getLessonDetailsFromSessionID(Long toolSessionID) { + Lesson lesson = this.lessonDAO.getLessonFromSessionID(toolSessionID); + if (lesson != null) { + return lesson.getLessonDetails(); + } + return null; + } }