Index: lams_tool_lamc/db/model/lams_tool_mc.clay =================================================================== diff -u -r19d6ab09baf339ddaf00248008f994d2a38f1079 -rd5c5282b3010b7ca8605cfa64012c5ecff95880e --- lams_tool_lamc/db/model/lams_tool_mc.clay (.../lams_tool_mc.clay) (revision 19d6ab09baf339ddaf00248008f994d2a38f1079) +++ lams_tool_lamc/db/model/lams_tool_mc.clay (.../lams_tool_mc.clay) (revision d5c5282b3010b7ca8605cfa64012c5ecff95880e) @@ -27,8 +27,8 @@ - + @@ -59,8 +59,8 @@ - + @@ -88,7 +88,7 @@ - + @@ -106,8 +106,8 @@ - + @@ -269,6 +269,19 @@ + + + + + + + + + + + + + @@ -357,8 +370,8 @@ - + @@ -411,8 +424,8 @@ - + @@ -444,8 +457,8 @@ - + @@ -517,8 +530,8 @@ - + @@ -530,8 +543,8 @@ - + @@ -604,8 +617,8 @@ - + @@ -630,8 +643,8 @@ - + Index: lams_tool_lamc/db/sql/create_lams_tool_lamc.sql =================================================================== diff -u -r19d6ab09baf339ddaf00248008f994d2a38f1079 -rd5c5282b3010b7ca8605cfa64012c5ecff95880e --- lams_tool_lamc/db/sql/create_lams_tool_lamc.sql (.../create_lams_tool_lamc.sql) (revision 19d6ab09baf339ddaf00248008f994d2a38f1079) +++ lams_tool_lamc/db/sql/create_lams_tool_lamc.sql (.../create_lams_tool_lamc.sql) (revision d5c5282b3010b7ca8605cfa64012c5ecff95880e) @@ -17,6 +17,7 @@ , online_instructions VARCHAR(250) NOT NULL DEFAULT 'online instructions' , end_learning_message VARCHAR(150) NOT NULL DEFAULT 'Thank you!' , content_in_use TINYINT(1) NOT NULL DEFAULT 0 + , retries TINYINT(1) NOT NULL DEFAULT 0 , pass_mark INTEGER , show_feedback TINYINT(1) NOT NULL DEFAULT 0 , show_top_users TINYINT(1) NOT NULL DEFAULT 0 Index: lams_tool_lamc/db/sql/delete_lams_tool_lamc.sql =================================================================== diff -u --- lams_tool_lamc/db/sql/delete_lams_tool_lamc.sql (revision 0) +++ lams_tool_lamc/db/sql/delete_lams_tool_lamc.sql (revision d5c5282b3010b7ca8605cfa64012c5ecff95880e) @@ -0,0 +1,14 @@ + +DELETE FROM lams.tl_lamc11_usr_attempt; +DELETE FROM lams.tl_lamc11_options_content; +DELETE FROM lams.tl_lamc11_que_content; +DELETE FROM lams.tl_lamc11_que_usr; +DELETE FROM lams.tl_lamc11_session; +DELETE FROM lams.tl_lamc11_content; + + + + + + + Index: lams_tool_lamc/db/sql/insert_lams_tool_lamc.sql =================================================================== diff -u --- lams_tool_lamc/db/sql/insert_lams_tool_lamc.sql (revision 0) +++ lams_tool_lamc/db/sql/insert_lams_tool_lamc.sql (revision d5c5282b3010b7ca8605cfa64012c5ecff95880e) @@ -0,0 +1,75 @@ + + + +INSERT INTO tl_lamc11_content (mc_content_id, + creation_date +) +VALUES (10, + NOW()); + + + + +INSERT INTO tl_lamc11_session (mc_session_id, + mc_content_id) VALUES (20,LAST_INSERT_ID()); + + + + + +INSERT INTO tl_lamc11_que_content (mc_que_content_id, + question, + display_order, + mc_content_id) VALUES (20,'What is the name of this activity?',1,1); + + + +INSERT INTO tl_lamc11_que_usr (que_usr_id, + username, + fullname, + mc_session_id) VALUES (40,'ozgurd','Ozgur Demirtas',1); + + + +INSERT INTO tl_lamc11_options_content (mc_que_option_id, + correct_option, + mc_que_content_id, + mc_que_option_text) VALUES (100,0,1,'survey'); + + +INSERT INTO tl_lamc11_options_content (mc_que_option_id, + correct_option, + mc_que_content_id, + mc_que_option_text) VALUES (101,0,1,'q/a'); + +INSERT INTO tl_lamc11_options_content (mc_que_option_id, + correct_option, + mc_que_content_id, + mc_que_option_text) VALUES (102,1,1,'mc'); + + + +INSERT INTO tl_lamc11_usr_attempt (attempt_id, + que_usr_id, + mc_que_content_id, + mc_que_option_id) + VALUES (200, 1, 1, 1); + + +INSERT INTO tl_lamc11_usr_attempt (attempt_id, + que_usr_id, + mc_que_content_id, + mc_que_option_id) + VALUES (200, 1, 1, 2); + + +INSERT INTO tl_lamc11_usr_attempt (attempt_id, + que_usr_id, + mc_que_content_id, + mc_que_option_id) + VALUES (200, 1, 1, 3); + + + + + Fisheye: Tag d5c5282b3010b7ca8605cfa64012c5ecff95880e refers to a dead (removed) revision in file `lams_tool_lamc/db/sql/insert_tool_lamc_data.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag d5c5282b3010b7ca8605cfa64012c5ecff95880e refers to a dead (removed) revision in file `lams_tool_lamc/db/sql/tl_lamc11_session.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag d5c5282b3010b7ca8605cfa64012c5ecff95880e refers to a dead (removed) revision in file `lams_tool_lamc/db/sql/tl_lamc11_usr_attempt.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag d5c5282b3010b7ca8605cfa64012c5ecff95880e refers to a dead (removed) revision in file `lams_tool_lamc/db/sql/tl_laqa11_uploadedFile.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag d5c5282b3010b7ca8605cfa64012c5ecff95880e refers to a dead (removed) revision in file `lams_tool_lamc/db/sql/tl_laqa11_uploadedFiles.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java (revision d5c5282b3010b7ca8605cfa64012c5ecff95880e) @@ -0,0 +1,130 @@ +/* + *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * + *This program is free software; you can redistribute it and/or modify + *it under the terms of the GNU General Public License as published by + *the Free Software Foundation; either version 2 of the License, or + *(at your option) any later version. + * + *This program is distributed in the hope that it will be useful, + *but WITHOUT ANY WARRANTY; without even the implied warranty of + *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *GNU General Public License for more details. + * + *You should have received a copy of the GNU General Public License + *along with this program; if not, write to the Free Software + *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + *USA + * + *http://www.gnu.org/licenses/gpl.txt + */ +package org.lamsfoundation.lams.tool.mc.dao; + +import java.util.List; + +import org.lamsfoundation.lams.tool.mc.McContent; +import org.lamsfoundation.lams.tool.mc.McSession; +import org.lamsfoundation.lams.tool.mc.McQueUsr; + + +/** + *

Interface for the NoticeboardSession DAO, defines methods needed to access/modify + * mc session

+ * @author ozgurd + */ +public interface IMcSessionDAO { + + + /** + *

Return the persistent instance of a NoticeboardSession + * with the given tool session id mcSessionId, + * returns null if not found.

+ * + * @param mcSessionId The tool session id + * @return the persistent instance of a NoticeboardSession or null if not found. + */ + public McSession findMcSessionById(Long mcSessionId); + + /** + *

Return the persistent instance of a McSession + * with the given identifier uid, returns null if not found.

+ * + * @param uid an identifier for the McSession object. + * @return the persistent instance of a McSession or null if not found + */ + public McSession getMcSessionByUID(Long uid); + + + /** + *

Persist the given persistent instance of McSession.

+ * + * @param mcSession The instance of McSession to persist. + */ + public void saveMcSession(McSession mcSession); + + /** + *

Update the given persistent instance of McSession.

+ * + * @param mcContent The instance of McSession to persist. + */ + public void updateMcSession(McSession mcSession); + + /** + *

Delete the given instance of McSession with the + * given identifier uid + * + * @param uid an identifier for the McSession instance. + */ + public void removeMcSessionByUID(Long uid); + + /** + *

Delete the given instance of McSession

+ * + * @param mcSession The instance of McSession to delete. + */ + public void removeMcSession(McSession mcSession); + + /** + *

Delete the given instance of McSession with the + * given tool session id mcSessionid + * + * @param mcSessionId The tool session Id. + */ + public void removeMcSession(Long mcSessionId); + + /** + *

Returns the persistent instance of McSession + * associated with the given mc user, with user id userId, + * returns null if not found. + * + * @param userId The mc user id + * @return a persistent instance of McSessions or null if not found. + */ + public McSession getMcSessionByUser(Long userId); + + /** + *

Deletes all instances of McQueUsr that are associated + * with the given instance of McSession

+ * + * @param mcSession The instance of McSession in which corresponding instances of McQueUsr should be deleted. + */ + public void removeMcUsers(McSession mcSession); + + /** + *

Creates and persists an instance of McQueUsr which is associated + * with the McSession with tool session id mcSessionId

+ * + * @param mcSessionId The tool session id + * @param user The instance of McQueUsr + */ + public void addMcUsers(Long mcSessionId, McQueUsr user); + + /** + * Returns a list of tool session ids which are associated with this + * instance of McContent. + + * @param nbContent The instance of McContent in which you want the list of toolSessionIds + * @return a list of tool session Ids + */ + public List getSessionsFromContent(McContent mcContent); +} \ No newline at end of file Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java (revision d5c5282b3010b7ca8605cfa64012c5ecff95880e) @@ -0,0 +1,153 @@ +/* +Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA + +http://www.gnu.org/licenses/gpl.txt +*/ + +package org.lamsfoundation.lams.tool.mc.dao.hibernate; + +import java.util.List; + +import net.sf.hibernate.HibernateException; +import net.sf.hibernate.Session; + +import org.lamsfoundation.lams.tool.mc.McContent; +import org.lamsfoundation.lams.tool.mc.McQueUsr; +import org.lamsfoundation.lams.tool.mc.McSession; +import org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO; +import org.springframework.orm.hibernate.HibernateCallback; +import org.springframework.orm.hibernate.support.HibernateDaoSupport; + +/** + * @author ozgurd + *

Hibernate implementation for database access to Mc sessions for the mc tool.

+ */ + +public class McSessionDAO extends HibernateDaoSupport implements IMcSessionDAO { + + private static final String LOAD_MCSESSION_BY_USER = "select ms from McSession ms left join fetch " + + "ms.mcQueUsers user where user.queUsrId=:userId"; + + private static final String GET_SESSIONS_FROM_CONTENT = "select ms.mcSessionId from McSession ms where ms.mcContent= :mcContent"; + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#getMcSessionByUID(java.lang.Long) */ + public McSession getMcSessionByUID(Long uid) + { + return (McSession) this.getHibernateTemplate() + .get(McSession.class, uid); + } + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#findMcSessionById(java.lang.Long) */ + public McSession findMcSessionById(Long mcSessionId) + { + String query = "from McSession mcS where mcS.mcSessionId=?"; + List session = getHibernateTemplate().find(query,mcSessionId); + + if(session!=null && session.size() == 0) + { + return null; + } + else + { + return (McSession)session.get(0); + } + } + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#saveMcSession(org.lamsfoundation.lams.tool.mc.McSession) */ + public void saveMcSession(McSession mcSession) + { + this.getHibernateTemplate().save(mcSession); + } + + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#updateMcSession(org.lamsfoundation.lams.tool.mc.McSession) */ + public void updateMcSession(McSession mcSession) + { + this.getHibernateTemplate().update(mcSession); + } + + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#removeMcSessionByUID(java.lang.Long) */ + public void removeMcSessionByUID(Long uid) + { + McSession ms = (McSession)getHibernateTemplate().get(McSession.class, uid); + this.getHibernateTemplate().delete(ms); + } + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#removeMcSession(java.lang.Long) */ + public void removeMcSession(Long mcSessionId) + { + String query = "from McSession as ms where ms.mcSessionId ="; + StringBuffer sb = new StringBuffer(query); + sb.append(mcSessionId.longValue()); + + String queryString = sb.toString(); + + this.getHibernateTemplate().delete(queryString); + + } + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#removeMcSession(org.lamsfoundation.lams.tool.mc.McSession) */ + public void removeMcSession(McSession mcSession) + { + this.getHibernateTemplate().delete(mcSession); + } + + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#getMcSessionByUser(java.lang.Long) */ + public McSession getMcSessionByUser(final Long userId) + { + return (McSession) getHibernateTemplate().execute(new HibernateCallback() + { + + public Object doInHibernate(Session session) throws HibernateException + { + return session.createQuery(LOAD_MCSESSION_BY_USER) + .setLong("userId", + userId.longValue()) + .uniqueResult(); + } + }); + } + + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#removeMcUsers(org.lamsfoundation.lams.tool.mc.McSession) */ + public void removeMcUsers(McSession mcSession) + { + this.getHibernateTemplate().deleteAll(mcSession.getMcQueUsers()); + } + + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#addMcUsers(java.lang.Long, org.lamsfoundation.lams.tool.mc.McSession) */ + public void addMcUsers(Long mcSessionId, McQueUsr user) + { + McSession session = findMcSessionById(mcSessionId); + user.setMcSession(session); + session.getMcQueUsers().add(user); + this.getHibernateTemplate().saveOrUpdate(user); + this.getHibernateTemplate().saveOrUpdateCopy(session); + } + + /** @see org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO#getSessionsFromContent(org.lamsfoundation.lams.tool.mc.McSession) */ + public List getSessionsFromContent(McContent mcContent) + { + return (getHibernateTemplate().findByNamedParam(GET_SESSIONS_FROM_CONTENT, + "mcContent", + mcContent)); + } + +}