uuid
and
- * versionID
from the content repository
+ * This method deletes the content with the given uuid
and versionID
from the content
+ * repository
*
* @param uuid
* The uuid
of the node to be deleted
@@ -554,7 +554,7 @@
}
}
- ListTicket
to login and access the Content Repository.
+ * This method verifies the credentials of the SubmitFiles Tool and gives it the Ticket
to login and
+ * access the Content Repository.
*
- * A valid ticket is needed in order to access the content from the
- * repository. This method would be called evertime the tool needs to
- * upload/download files from the content repository.
+ * A valid ticket is needed in order to access the content from the repository. This method would be called evertime
+ * the tool needs to upload/download files from the content repository.
*
* @return ITicket The ticket for repostory access
* @throws SubmitFilesException
@@ -759,8 +758,7 @@
}
/**
- * Export the XML fragment for the tool's content, along with any files
- * needed for the content.
+ * Export the XML fragment for the tool's content, along with any files needed for the content.
*
* @throws DataMissingException
* if no tool content matches the toolSessionId
@@ -807,8 +805,7 @@
}
/**
- * Import the XML fragment for the tool's content, along with any files
- * needed for the content.
+ * Import the XML fragment for the tool's content, along with any files needed for the content.
*
* @throws ToolException
* if any other error occurs
@@ -860,14 +857,12 @@
}
/**
- * Get the definitions for possible output for an activity, based on the
- * toolContentId. These may be definitions that are always available for the
- * tool (e.g. number of marks for Multiple Choice) or a custom definition
- * created for a particular activity such as the answer to the third
- * question contains the word Koala and hence the need for the toolContentId
+ * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions
+ * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created
+ * for a particular activity such as the answer to the third question contains the word Koala and hence the need for
+ * the toolContentId
*
- * @return SortedMap of ToolOutputDefinitions with the key being the name of
- * each definition
+ * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition
*/
public SortedMapupdateTopic
method. So topic can keep this attachment if user choose "Cancel" edit
- * topic.
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- */
- private ActionForward deleteAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
+ /**
+ * Display a editable form for a special topic in order to update it.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws PersistenceException
+ */
+ public ActionForward editTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws PersistenceException {
+ Long topicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID);
- //only reset not attachment flag.
- MessageDTO dto = new MessageDTO();
- dto.setHasAttachment(false);
- request.setAttribute(ForumConstants.AUTHORING_TOPIC, dto);
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(
- WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID));
- request.setAttribute(ForumConstants.ATTR_ALLOW_UPLOAD, sessionMap.get(ForumConstants.ATTR_ALLOW_UPLOAD));
+ MessageDTO topic = getTopic(topicId);
- return mapping.findForward("success");
+ // echo current topic content to web page
+ MessageForm msgForm = (MessageForm) form;
+ if (topic != null) {
+ msgForm.setMessage(topic.getMessage());
+ request.setAttribute(ForumConstants.AUTHORING_TOPIC, topic);
}
- /**
- * Update a topic.
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws PersistenceException
- */
- public ActionForward updateTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws PersistenceException {
+ // cache this topicID, using in Update topic
+ SessionMap sessionMap = getSessionMap(request, msgForm);
+ sessionMap.put(ForumConstants.ATTR_TOPIC_ID, topicId);
- forumService = getForumManager();
+ // Should we show the reflection or not? We shouldn't show it when the View Forum screen is accessed
+ // from the Monitoring Summary screen, but we should when accessed from the Learner Progress screen.
+ // Need to constantly past this value on, rather than hiding just the once, as the View Forum
+ // screen has a refresh button. Need to pass it through the view topic screen and dependent screens
+ // as it has a link from the view topic screen back to View Forum screen.
+ boolean hideReflection = WebUtil.readBooleanParam(request, ForumConstants.ATTR_HIDE_REFLECTION, false);
+ sessionMap.put(ForumConstants.ATTR_HIDE_REFLECTION, hideReflection);
- MessageForm messageForm = (MessageForm) form;
- SessionMap sessionMap = getSessionMap(request, messageForm);
- Long topicId = (Long) sessionMap.get(ForumConstants.ATTR_TOPIC_ID);
- Message message = messageForm.getMessage();
+ return mapping.findForward("success");
+ }
- boolean makeAuditEntry = ToolAccessMode.TEACHER.equals(sessionMap.get(AttributeNames.ATTR_MODE));
- String oldMessageString = null;
+ /**
+ * Delete attachment from topic. This method only reset attachment information in memory. The finally update will
+ * happen in updateTopic
method. So topic can keep this attachment if user choose "Cancel" edit
+ * topic.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward deleteAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
- // get PO from database and sync with Form
- Message messagePO = forumService.getMessage(topicId);
- if (makeAuditEntry) {
- oldMessageString = messagePO.toString();
- }
- messagePO.setSubject(message.getSubject());
- messagePO.setBody(message.getBody());
- messagePO.setUpdated(new Date());
- messagePO.setModifiedBy(getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)));
- setAttachment(messageForm, messagePO);
+ // only reset not attachment flag.
+ MessageDTO dto = new MessageDTO();
+ dto.setHasAttachment(false);
+ request.setAttribute(ForumConstants.AUTHORING_TOPIC, dto);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(
+ WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID));
+ request.setAttribute(ForumConstants.ATTR_ALLOW_UPLOAD, sessionMap.get(ForumConstants.ATTR_ALLOW_UPLOAD));
- if (makeAuditEntry) {
- Long userId = 0L;
- String loginName = "Default";
- if (message.getCreatedBy() != null) {
- userId = message.getCreatedBy().getUserId();
- loginName = message.getCreatedBy().getLoginName();
- }
- forumService.getAuditService().logChange(ForumConstants.TOOL_SIGNATURE, userId, loginName, oldMessageString,
- messagePO.toString());
- }
+ return mapping.findForward("success");
+ }
- // save message into database
- // if we are in monitoring then we are probably editing some else's entry so log the change.
- forumService.updateTopic(messagePO);
+ /**
+ * Update a topic.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws PersistenceException
+ */
+ public ActionForward updateTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws PersistenceException {
- // echo back this topic thread into page
- Long rootTopicId = forumService.getRootTopicId(topicId);
- List msgDtoList = forumService.getTopicThread(rootTopicId);
- updateMesssageFlag(msgDtoList);
+ forumService = getForumManager();
- // check if we can still make posts in this topic
- ForumUser forumUser = getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID));
- Forum forum = forumUser.getSession().getForum();
- int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), ((MessageDTO) msgDtoList.get(0)).getMessage()
- .getUid());
- boolean noMorePosts = forum.getMaximumReply() != 0 && numOfPosts >= forum.getMaximumReply() && !forum.isAllowNewTopic() ? Boolean.TRUE
- : Boolean.FALSE;
- request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts);
- request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts);
+ MessageForm messageForm = (MessageForm) form;
+ SessionMap sessionMap = getSessionMap(request, messageForm);
+ Long topicId = (Long) sessionMap.get(ForumConstants.ATTR_TOPIC_ID);
+ Message message = messageForm.getMessage();
- request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList);
- request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID());
-
- // Saving or updating user timestamp
- saveUserTimestamp(rootTopicId, forumUser);
-
- return mapping.findForward("success");
+ boolean makeAuditEntry = ToolAccessMode.TEACHER.equals(sessionMap.get(AttributeNames.ATTR_MODE));
+ String oldMessageString = null;
+
+ // get PO from database and sync with Form
+ Message messagePO = forumService.getMessage(topicId);
+ if (makeAuditEntry) {
+ oldMessageString = messagePO.toString();
}
+ messagePO.setSubject(message.getSubject());
+ messagePO.setBody(message.getBody());
+ messagePO.setUpdated(new Date());
+ messagePO.setModifiedBy(getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)));
+ setAttachment(messageForm, messagePO);
- /**
- * Sets the visibility of a message by updating the hide flag for a message
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- */
- public ActionForward updateMessageHideFlag(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
+ if (makeAuditEntry) {
+ Long userId = 0L;
+ String loginName = "Default";
+ if (message.getCreatedBy() != null) {
+ userId = message.getCreatedBy().getUserId();
+ loginName = message.getCreatedBy().getLoginName();
+ }
+ forumService.getAuditService().logChange(ForumConstants.TOOL_SIGNATURE, userId, loginName,
+ oldMessageString, messagePO.toString());
+ }
- Long msgId = new Long(WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID));
- Boolean hideFlag = new Boolean(WebUtil.readBooleanParam(request, "hideFlag"));
- forumService = getForumManager();
+ // save message into database
+ // if we are in monitoring then we are probably editing some else's entry so log the change.
+ forumService.updateTopic(messagePO);
- // TODO Skipping permissions for now, currently having issues with default learning designs not having an create_by field
- // Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
- // check if the user has permission to hide posts.
- // ForumToolSession toolSession = forumService
- // .getSessionBySessionId(sessionId);
- //
- // Forum forum = toolSession.getForum();
- // ForumUser currentUser = getCurrentUser(request,sessionId);
- // ForumUser forumCreatedBy = forum.getCreatedBy();
+ // echo back this topic thread into page
+ Long rootTopicId = forumService.getRootTopicId(topicId);
+ List msgDtoList = forumService.getTopicThread(rootTopicId);
+ updateMesssageFlag(msgDtoList);
- // we should be looking at whether a user is a teacher and more specifically staff
- // if (currentUser.getUserId().equals(forumCreatedBy.getUserId())) {
- forumService.updateMessageHideFlag(msgId, hideFlag.booleanValue());
- // } else {
- // log.info(currentUser + "does not have permission to hide/show postings in forum: " + forum.getUid());
- // log.info("Forum created by :" + forumCreatedBy.getUid() + ", Current User is: " + currentUser.getUid());
- // }
+ // check if we can still make posts in this topic
+ ForumUser forumUser = getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID));
+ Forum forum = forumUser.getSession().getForum();
+ int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), ((MessageDTO) msgDtoList.get(0))
+ .getMessage().getUid());
+ boolean noMorePosts = forum.getMaximumReply() != 0 && numOfPosts >= forum.getMaximumReply()
+ && !forum.isAllowNewTopic() ? Boolean.TRUE : Boolean.FALSE;
+ request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts);
+ request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts);
- // echo back this topic thread into page
- Long rootTopicId = forumService.getRootTopicId(msgId);
- List msgDtoList = forumService.getTopicThread(rootTopicId);
- updateMesssageFlag(msgDtoList);
- request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList);
- request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, WebUtil
- .readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID));
-
- return mapping.findForward("success");
- }
+ request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList);
+ request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID());
- // ==========================================================================================
- // Utility methods
- // ==========================================================================================
- /**
- * Validation method to check whether user posts meet minimum number.
- */
- private boolean validateBeforeFinish(HttpServletRequest request, String sessionMapID) {
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
- Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
+ // Saving or updating user timestamp
+ saveUserTimestamp(rootTopicId, forumUser);
- ForumToolSession session = forumService.getSessionBySessionId(sessionId);
- Forum forum = session.getForum();
- // get session from shared session.
- HttpSession ss = SessionManager.getSession();
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- Long userID = new Long(user.getUserID().longValue());
- if (!forum.getRunOffline() && !forum.isAllowNewTopic()) {
+ return mapping.findForward("success");
+ }
- List- * Hibernate implementation for database access to VoteUsrAttemptDAO for - * the voting tool. + * Hibernate implementation for database access to VoteUsrAttemptDAO for the voting tool. *
*/ public class VoteUsrAttemptDAO extends HibernateDaoSupport implements IVoteUsrAttemptDAO { @@ -70,20 +69,19 @@ // lfoxton about below: // No! Very Bad programmer!!! Go to your room and think about what you did! - //private static final String LOAD_ALL_ENTRIES = "from voteUsrAttempt in class VoteUsrAttempt"; + // private static final String LOAD_ALL_ENTRIES = "from voteUsrAttempt in class VoteUsrAttempt"; private static final String LOAD_DISTINCT_USER_ENTRIES = "select distinct voteUsrAttempt.queUsrId from VoteUsrAttempt voteUsrAttempt"; private static final String COUNT_ATTEMPTS_BY_CONTENT_ID = "select count(*) from VoteUsrAttempt att, VoteQueUsr user, VoteSession ses where " + "att.voteQueUsr=user and user.voteSession=ses and " + "ses.voteContentId=:voteContentId"; - + private static final String LOAD_ENTRIES_BY_SESSION_ID = "select att from VoteUsrAttempt att, VoteQueUsr user, VoteSession ses where " + "att.voteQueUsr=user and user.voteSession=ses and ses.uid=:voteSessionUid"; - + private static final String COUNT_ENTRIES_BY_SESSION_ID = "select count(*) from VoteUsrAttempt att, VoteQueUsr user, VoteSession ses where " + "att.voteQueUsr=user and user.voteSession=ses and ses.uid=:voteSessionUid"; - public VoteUsrAttempt getVoteUserAttemptByUID(Long uid) { return (VoteUsrAttempt) this.getHibernateTemplate().get(VoteUsrAttempt.class, uid); } @@ -107,20 +105,21 @@ public List getAttemptsForUser(final Long queUsrId) { HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ATTEMPT_FOR_USER).setLong("queUsrId", queUsrId.longValue()).list(); + List list = getSession().createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER).setLong("queUsrId", + queUsrId.longValue()).list(); return list; } public int getUserEnteredVotesCountForContent(final Long voteContentUid) { - List result = getSession().createQuery(COUNT_ATTEMPTS_BY_CONTENT_ID).setLong("voteContentId", voteContentUid) - .list(); - Integer resultInt = (result.get(0) != null) ? (Integer) result.get(0) : new Integer(0); - return resultInt.intValue(); + List result = getSession().createQuery(VoteUsrAttemptDAO.COUNT_ATTEMPTS_BY_CONTENT_ID).setLong("voteContentId", + voteContentUid).list(); + Long resultLong = result.get(0) != null ? (Long) result.get(0) : new Long(0); + return resultLong.intValue(); } public Set getUserEntries() { HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_USER_ENTRIES).list(); + List list = getSession().createQuery(VoteUsrAttemptDAO.LOAD_USER_ENTRIES).list(); Set set = new HashSet(); @@ -129,32 +128,34 @@ Iterator listIterator = list.iterator(); while (listIterator.hasNext()) { String entry = (String) listIterator.next(); - logger.debug("entry: " + entry); - if ((entry != null) && (entry.length() > 0)) + VoteUsrAttemptDAO.logger.debug("entry: " + entry); + if (entry != null && entry.length() > 0) { userEntries.add(entry); + } } } return userEntries; } public List getSessionUserEntries(final Long voteSessionUid) { - - return getSession().createQuery(LOAD_ENTRIES_BY_SESSION_ID).setLong("voteSessionUid", voteSessionUid).list(); + + return getSession().createQuery(VoteUsrAttemptDAO.LOAD_ENTRIES_BY_SESSION_ID).setLong("voteSessionUid", + voteSessionUid).list(); } public Set getSessionUserEntriesSet(final Long voteSessionUid) { - List