Index: lams_tool_scribe/db/sql/create_lams_tool_scribe.sql =================================================================== diff -u -r35bfb4b7a575561579fd11613b5baf0debfde7b7 -rc4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53 --- lams_tool_scribe/db/sql/create_lams_tool_scribe.sql (.../create_lams_tool_scribe.sql) (revision 35bfb4b7a575561579fd11613b5baf0debfde7b7) +++ lams_tool_scribe/db/sql/create_lams_tool_scribe.sql (.../create_lams_tool_scribe.sql) (revision c4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53) @@ -11,7 +11,7 @@ create table tl_lascrb11_heading (uid bigint not null auto_increment, heading text, scribe_uid bigint, display_order integer, primary key (uid)); create table tl_lascrb11_report_entry (uid bigint not null auto_increment, entry_text text, scribe_heading_uid bigint, scribe_session_uid bigint, primary key (uid)); create table tl_lascrb11_scribe (uid bigint not null auto_increment, create_date datetime, update_date datetime, create_by bigint, title varchar(255), instructions text, run_offline bit, lock_on_finished bit, auto_select_scribe bit, reflect_on_activity bit, reflect_instructions text, online_instructions text, offline_instructions text, content_in_use bit, define_later bit, tool_content_id bigint, primary key (uid)); -create table tl_lascrb11_session (uid bigint not null auto_increment, version integer not null, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), scribe_uid bigint, appointed_scribe_uid bigint, force_complete bit, primary key (uid)); +create table tl_lascrb11_session (uid bigint not null auto_increment, version integer not null, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), scribe_uid bigint, appointed_scribe_uid bigint, force_complete bit, report_submitted bit, primary key (uid)); create table tl_lascrb11_user (uid bigint not null auto_increment, user_id bigint, last_name varchar(255), login_name varchar(255), first_name varchar(255), finishedActivity bit, scribe_session_uid bigint, report_approved bit, started_activity bit, primary key (uid)); alter table tl_lascrb11_attachment add index FK57953706B3FA1495 (scribe_uid), add constraint FK57953706B3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); alter table tl_lascrb11_heading add index FK428A22FFB3FA1495 (scribe_uid), add constraint FK428A22FFB3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); Index: lams_tool_scribe/db/sql/table-schema.sql =================================================================== diff -u -r35bfb4b7a575561579fd11613b5baf0debfde7b7 -rc4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53 --- lams_tool_scribe/db/sql/table-schema.sql (.../table-schema.sql) (revision 35bfb4b7a575561579fd11613b5baf0debfde7b7) +++ lams_tool_scribe/db/sql/table-schema.sql (.../table-schema.sql) (revision c4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53) @@ -15,7 +15,7 @@ create table tl_lascrb11_heading (uid bigint not null auto_increment, heading text, scribe_uid bigint, display_order integer, primary key (uid)); create table tl_lascrb11_report_entry (uid bigint not null auto_increment, entry_text text, scribe_heading_uid bigint, scribe_session_uid bigint, primary key (uid)); create table tl_lascrb11_scribe (uid bigint not null auto_increment, create_date datetime, update_date datetime, create_by bigint, title varchar(255), instructions text, run_offline bit, lock_on_finished bit, auto_select_scribe bit, reflect_on_activity bit, reflect_instructions text, online_instructions text, offline_instructions text, content_in_use bit, define_later bit, tool_content_id bigint, primary key (uid)); -create table tl_lascrb11_session (uid bigint not null auto_increment, version integer not null, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), scribe_uid bigint, appointed_scribe_uid bigint, force_complete bit, primary key (uid)); +create table tl_lascrb11_session (uid bigint not null auto_increment, version integer not null, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), scribe_uid bigint, appointed_scribe_uid bigint, force_complete bit, report_submitted bit, primary key (uid)); create table tl_lascrb11_user (uid bigint not null auto_increment, user_id bigint, last_name varchar(255), login_name varchar(255), first_name varchar(255), finishedActivity bit, scribe_session_uid bigint, report_approved bit, started_activity bit, primary key (uid)); alter table tl_lascrb11_attachment add index FK57953706B3FA1495 (scribe_uid), add constraint FK57953706B3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); alter table tl_lascrb11_heading add index FK428A22FFB3FA1495 (scribe_uid), add constraint FK428A22FFB3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dto/ScribeSessionDTO.java =================================================================== diff -u -r4b4b0d35dcce611d0cb85cab458f2e9687858ef0 -rc4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dto/ScribeSessionDTO.java (.../ScribeSessionDTO.java) (revision 4b4b0d35dcce611d0cb85cab458f2e9687858ef0) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dto/ScribeSessionDTO.java (.../ScribeSessionDTO.java) (revision c4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53) @@ -53,10 +53,13 @@ boolean forceComplete; + boolean reportSubmitted; + public ScribeSessionDTO(ScribeSession session) { this.sessionID = session.getSessionId(); this.sessionName = session.getSessionName(); this.forceComplete = session.isForceComplete(); + this.reportSubmitted = session.isReportSubmitted(); ScribeUser appointedScribe = session.getAppointedScribe(); if (appointedScribe == null) { @@ -160,4 +163,12 @@ public void setForceComplete(boolean forceComplete) { this.forceComplete = forceComplete; } + + public boolean isReportSubmitted() { + return reportSubmitted; + } + + public void setReportSubmitted(boolean reportSubmitted) { + this.reportSubmitted = reportSubmitted; + } } Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/ScribeSession.java =================================================================== diff -u -r35bfb4b7a575561579fd11613b5baf0debfde7b7 -rc4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/ScribeSession.java (.../ScribeSession.java) (revision 35bfb4b7a575561579fd11613b5baf0debfde7b7) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/ScribeSession.java (.../ScribeSession.java) (revision c4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53) @@ -69,7 +69,8 @@ private ScribeUser appointedScribe; private boolean forceComplete; - + + private boolean reportSubmitted; // Constructors /** default constructor */ @@ -236,6 +237,17 @@ } /** + * @hibernate.property column="report_submitted" + */ + public boolean isReportSubmitted() { + return reportSubmitted; + } + + public void setReportSubmitted(boolean reportSubmitted) { + this.reportSubmitted = reportSubmitted; + } + + /** * toString * * @return String Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/LearningAction.java =================================================================== diff -u -r99d1be19e7e771c45bbb8faf61e6c0331efd1af5 -rc4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/LearningAction.java (.../LearningAction.java) (revision 99d1be19e7e771c45bbb8faf61e6c0331efd1af5) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/LearningAction.java (.../LearningAction.java) (revision c4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53) @@ -25,7 +25,9 @@ package org.lamsfoundation.lams.tool.scribe.web.actions; import java.io.IOException; +import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -74,13 +76,15 @@ * @struts.action-forward name="notebook" path="tiles:/learning/notebook" * @struts.action-forward name="voteDisplay" path="/pages/parts/voteDisplay.jsp" * @struts.action-forward name="report" path="tiles:/learning/report" - * @struts.action-forward name="instructions" path="tiles:/learning/instructions" + * @struts.action-forward name="instructions" + * path="tiles:/learning/instructions" */ public class LearningAction extends LamsDispatchAction { private static Logger log = Logger.getLogger(LearningAction.class); private static final boolean MODE_OPTIONAL = false; + private IScribeService scribeService; public ActionForward unspecified(ActionMapping mapping, ActionForm form, @@ -108,12 +112,12 @@ + toolSessionID); } Scribe scribe = scribeSession.getScribe(); - + // check defineLater if (scribe.isDefineLater()) { return mapping.findForward("defineLater"); } - + // Ensure that the content in use flag is set. if (!scribe.isContentInUse()) { scribe.setContentInUse(new Boolean(true)); @@ -122,54 +126,58 @@ // Retrieve the current user ScribeUser scribeUser = getCurrentUser(toolSessionID); - + // check whether scribe has been appointed while (scribeSession.getAppointedScribe() == null) { // check autoSelectScribe if (scribe.isAutoSelectScribe() == false) { - // learner needs to wait until a scribe has been appointed by teacher. + // learner needs to wait until a scribe has been appointed by + // teacher. return mapping.findForward("defineLater"); - + } else { // appoint the currentUser as the scribe scribeSession.setAppointedScribe(scribeUser); - - // attempt to update the scribeSession. + + // attempt to update the scribeSession. try { scribeService.saveOrUpdateScribeSession(scribeSession); - } catch (ObjectOptimisticLockingFailureException le){ - // scribeSession has been modified. Reload scribeSession and check again. - scribeSession = scribeService.getSessionBySessionId(toolSessionID); + } catch (ObjectOptimisticLockingFailureException le) { + // scribeSession has been modified. Reload scribeSession and + // check again. + scribeSession = scribeService + .getSessionBySessionId(toolSessionID); } } } - + // setup dto's forms and attributes. - ((LearningForm)form).setToolSessionID(scribeSession.getSessionId()); + ((LearningForm) form).setToolSessionID(scribeSession.getSessionId()); request.setAttribute("MODE", mode.toString()); setupDTOs(request, scribeSession, scribeUser); // check runOffline if (scribe.isRunOffline()) { return mapping.findForward("runOffline"); } - + // check force complete if (scribeSession.isForceComplete()) { // go to report page return mapping.findForward("report"); } - + // check if user has started activity - if (!scribeUser.isStartedActivity()) { - if (scribeSession.getAppointedScribe().getUid() == scribeUser.getUid()) { + if (!scribeUser.isStartedActivity()) { + if (scribeSession.getAppointedScribe().getUid() == scribeUser + .getUid()) { request.setAttribute("role", "scribe"); } else { request.setAttribute("role", "learner"); - } + } return mapping.findForward("instructions"); } - + // check if current user is the scribe. if (scribeSession.getAppointedScribe().getUid() == scribeUser.getUid()) { return mapping.findForward("scribe"); @@ -196,31 +204,33 @@ return scribeUser; } - public ActionForward startActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - - LearningForm lrnForm = (LearningForm)form; + public ActionForward startActivity(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) { + + LearningForm lrnForm = (LearningForm) form; Long toolSessionID = lrnForm.getToolSessionID(); - - ScribeSession scribeSession = scribeService.getSessionBySessionId(toolSessionID); + + ScribeSession scribeSession = scribeService + .getSessionBySessionId(toolSessionID); ScribeUser scribeUser = getCurrentUser(toolSessionID); - + // setup dto's, forms and attributes. lrnForm.setToolSessionID(scribeSession.getSessionId()); request.setAttribute("MODE", lrnForm.getMode()); setupDTOs(request, scribeSession, scribeUser); - + // update scribe user and go to instructions page scribeUser.setStartedActivity(true); scribeService.saveOrUpdateScribeUser(scribeUser); - + // check if current user is the scribe. if (scribeSession.getAppointedScribe().getUid() == scribeUser.getUid()) { return mapping.findForward("scribe"); } - + return mapping.findForward("learning"); } - + public ActionForward finishActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { @@ -305,26 +315,44 @@ .getSessionBySessionId(toolSessionID); ScribeUser scribeUser = getCurrentUser(toolSessionID); - - // update scribeReports + + boolean reportValid = false; + for (Iterator iter = session.getScribeReportEntries().iterator(); iter .hasNext();) { ScribeReportEntry report = (ScribeReportEntry) iter.next(); String entryText = (String) lrnForm.getReport(report.getUid() .toString()); - report.setEntryText(entryText); + + if (entryText.length() != 0) { + reportValid = true; + } } - - for (Iterator iter = session.getScribeUsers().iterator(); iter.hasNext();) { - ScribeUser user = (ScribeUser) iter.next(); - user.setReportApproved(false); - scribeService.saveOrUpdateScribeUser(scribeUser); + + if (reportValid) { + // update scribeReports + for (Iterator iter = session.getScribeReportEntries().iterator(); iter + .hasNext();) { + ScribeReportEntry report = (ScribeReportEntry) iter.next(); + + String entryText = (String) lrnForm.getReport(report.getUid() + .toString()); + report.setEntryText(entryText); + } + + // persist changes + for (Iterator iter = session.getScribeUsers().iterator(); iter + .hasNext();) { + ScribeUser user = (ScribeUser) iter.next(); + user.setReportApproved(false); + scribeService.saveOrUpdateScribeUser(scribeUser); + } + + session.setReportSubmitted(true); + scribeService.saveOrUpdateScribeSession(session); } - - // persist changes - scribeService.saveOrUpdateScribeSession(session); - + request.setAttribute("MODE", lrnForm.getMode()); setupDTOs(request, session, scribeUser); @@ -335,19 +363,19 @@ HttpServletRequest request, HttpServletResponse response) { LearningForm lrnForm = (LearningForm) form; - + // get session and user ScribeSession session = scribeService.getSessionBySessionId(lrnForm .getToolSessionID()); ScribeUser scribeUser = getCurrentUser(session.getSessionId()); - + scribeUser.setReportApproved(true); - + request.setAttribute("MODE", lrnForm.getMode()); setupDTOs(request, session, scribeUser); - + scribeService.saveOrUpdateScribeUser(scribeUser); - + if (session.getAppointedScribe().equals(scribeUser)) { // send updated voteDisplay return getVoteDisplay(mapping, form, request, response); @@ -356,96 +384,106 @@ return mapping.findForward("learning"); } } - + public ActionForward getVoteDisplay(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - + Long toolSessionID = WebUtil.readLongParam(request, "toolSessionID"); - - ScribeSession session = scribeService.getSessionBySessionId(toolSessionID); - + + ScribeSession session = scribeService + .getSessionBySessionId(toolSessionID); + int numberOfVotes = 0; - - for (Iterator iter = session.getScribeUsers().iterator(); iter.hasNext();) { + + for (Iterator iter = session.getScribeUsers().iterator(); iter + .hasNext();) { ScribeUser user = (ScribeUser) iter.next(); - + if (user.isReportApproved()) { - numberOfVotes++; + numberOfVotes++; } } - + int numberOfLearners = session.getScribeUsers().size(); - int votePercentage = ScribeUtils.calculateVotePercentage(numberOfVotes, numberOfLearners); - + int votePercentage = ScribeUtils.calculateVotePercentage(numberOfVotes, + numberOfLearners); + ScribeSessionDTO sessionDTO = new ScribeSessionDTO(); sessionDTO.setNumberOfVotes(numberOfVotes); sessionDTO.setNumberOfLearners(numberOfLearners); sessionDTO.setVotePercentage(votePercentage); - + request.setAttribute("scribeSessionDTO", sessionDTO); - + return mapping.findForward("voteDisplay"); } - - public ActionForward forceCompleteActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - + + public ActionForward forceCompleteActivity(ActionMapping mapping, + ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + LearningForm lrnForm = (LearningForm) form; - - ScribeUser scribeUser = scribeService.getUserByUID(lrnForm.getScribeUserUID()); - + + ScribeUser scribeUser = scribeService.getUserByUID(lrnForm + .getScribeUserUID()); + ScribeSession session = scribeUser.getScribeSession(); - + if (session.getAppointedScribe().getUid() == scribeUser.getUid()) { session.setForceComplete(true); } else { // TODO need to implement this. - log.error("ScribeUserUID: " + scribeUser.getUid() + " is not allowed to forceComplete this session"); + log.error("ScribeUserUID: " + scribeUser.getUid() + + " is not allowed to forceComplete this session"); } - + request.setAttribute("MODE", lrnForm.getMode()); setupDTOs(request, session, scribeUser); - + scribeService.saveOrUpdateScribeUser(scribeUser); - + return mapping.findForward("report"); } - + // Private methods. - - private void setupDTOs(HttpServletRequest request, ScribeSession scribeSession, ScribeUser scribeUser) { - + + private void setupDTOs(HttpServletRequest request, + ScribeSession scribeSession, ScribeUser scribeUser) { + ScribeDTO scribeDTO = new ScribeDTO(scribeSession.getScribe()); request.setAttribute("scribeDTO", scribeDTO); ScribeSessionDTO sessionDTO = new ScribeSessionDTO(scribeSession); - + int numberOfVotes = 0; - for (Iterator iter = scribeSession.getScribeUsers().iterator(); iter.hasNext();) { + for (Iterator iter = scribeSession.getScribeUsers().iterator(); iter + .hasNext();) { ScribeUser user = (ScribeUser) iter.next(); if (user.isReportApproved()) { numberOfVotes++; } } - + int numberOfLearners = scribeSession.getScribeUsers().size(); - + sessionDTO.setNumberOfVotes(numberOfVotes); sessionDTO.setNumberOfLearners(numberOfLearners); - sessionDTO.setVotePercentage(ScribeUtils.calculateVotePercentage(numberOfVotes, numberOfLearners)); - + sessionDTO.setVotePercentage(ScribeUtils.calculateVotePercentage( + numberOfVotes, numberOfLearners)); + request.setAttribute("scribeSessionDTO", sessionDTO); - + ScribeUserDTO scribeUserDTO = new ScribeUserDTO(scribeUser); if (scribeUser.isFinishedActivity()) { // get the notebook entry. - NotebookEntry notebookEntry = scribeService.getEntry(scribeSession.getSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, + NotebookEntry notebookEntry = scribeService.getEntry(scribeSession + .getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, ScribeConstants.TOOL_SIGNATURE, scribeUser.getUserId() .intValue()); if (notebookEntry != null) { scribeUserDTO.notebookEntry = notebookEntry.getEntry(); } - } + } request.setAttribute("scribeUserDTO", scribeUserDTO); } } Index: lams_tool_scribe/web/pages/learning/learning.jsp =================================================================== diff -u -r6f9a82945ad22a613ebdf36b17d6b1294d81eac0 -rc4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53 --- lams_tool_scribe/web/pages/learning/learning.jsp (.../learning.jsp) (revision 6f9a82945ad22a613ebdf36b17d6b1294d81eac0) +++ lams_tool_scribe/web/pages/learning/learning.jsp (.../learning.jsp) (revision c4e396e4c1ef24c04d7f25d8c2a8be2b62e35d53) @@ -44,7 +44,7 @@
-