Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McApplicationException.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McApplicationException.java (.../McApplicationException.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McApplicationException.java (.../McApplicationException.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -24,7 +24,7 @@ /** - *
This exception wraps all basic exception occured in the qa tool. It is + *
This exception wraps all basic exception occured in the mcq tool. It is * not suppose to be try and catched in any level. The struts should be taking * care of handling this exception.
* Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McComparator.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McComparator.java (.../McComparator.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McComparator.java (.../McComparator.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -27,12 +27,6 @@ /** * @author Ozgur Demirtas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ - -/** * A comparator implementation that can be used as a constructor to collections. * The TreeMap in the web layer makes use of it. * Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McContent.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McContent.java (.../McContent.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McContent.java (.../McContent.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -31,7 +31,14 @@ import org.apache.commons.lang.builder.ToStringBuilder; -/** @author Ozgur Demirtas */ +/** + *Persistent object/bean that defines the content for the MCQ tool. + * Provides accessors and mutators to get/set attributes + * It maps to database table: tl_lamc11_content + *
+ * + * @author Ozgur Demirtas + */ public class McContent implements Serializable { /** identifier field */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McOptsContent.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McOptsContent.java (.../McOptsContent.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McOptsContent.java (.../McOptsContent.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -29,7 +29,14 @@ import org.apache.commons.lang.builder.ToStringBuilder; -/** @author Ozgur Demirtas */ +/** + *Persistent object/bean that defines the content for the MCQ tool. + * Provides accessors and mutators to get/set attributes + * It maps to database table: tl_lamc11_options_content + *
+ * + * @author Ozgur Demirtas + */ public class McOptsContent implements Serializable { /** identifier field */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueContent.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueContent.java (.../McQueContent.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueContent.java (.../McQueContent.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -30,7 +30,14 @@ import org.apache.commons.lang.builder.ToStringBuilder; -/** @author Ozgur Demirtas */ +/** + *Persistent object/bean that defines the question content for the MCQ tool. + * Provides accessors and mutators to get/set attributes + * It maps to database table: tl_lamc11_que_content + *
+ * + * @author Ozgur Demirtas + */ public class McQueContent implements Serializable { /** identifier field */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueUsr.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueUsr.java (.../McQueUsr.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueUsr.java (.../McQueUsr.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -29,7 +29,14 @@ import org.apache.commons.lang.builder.ToStringBuilder; -/** @author Ozgur Demirtas */ +/** + *Persistent object/bean that defines the user for the MCQ tool. + * Provides accessors and mutators to get/set attributes + * It maps to database table: tl_lamc11_que_usr + *
+ * + * @author Ozgur Demirtas + */ public class McQueUsr implements Serializable { /** identifier field */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McSession.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McSession.java (.../McSession.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McSession.java (.../McSession.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -30,7 +30,14 @@ import org.apache.commons.lang.builder.ToStringBuilder; -/** @author Ozgur Demirtas */ +/** + *Persistent object/bean that defines the content for the MCQ tool. + * Provides accessors and mutators to get/set attributes + * It maps to database table: tl_lamc11_session + *
+ * + * @author Ozgur Demirtas + */ public class McSession implements Serializable { public final static String INCOMPLETE = "INCOMPLETE"; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McStringComparator.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McStringComparator.java (.../McStringComparator.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McStringComparator.java (.../McStringComparator.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -30,13 +30,7 @@ /** * @author Ozgur Demirtas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ - -/** - * A comparator implementation that can be used as a constructor to collections. + * * A comparator implementation that can be used as a constructor to collections. * The TreeMap in the web layer makes use of it. * */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUploadedFile.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUploadedFile.java (.../McUploadedFile.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUploadedFile.java (.../McUploadedFile.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -25,10 +25,13 @@ import org.apache.commons.lang.builder.ToStringBuilder; /** + *Persistent object/bean that defines the uploaded file for the MCQ tool. + * Provides accessors and mutators to get/set attributes + * It maps to database table: tl_lamc11_uploadedFile + *
* * @author Ozgur Demirtas */ - public class McUploadedFile implements Serializable { /** identifier field */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUsrAttempt.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUsrAttempt.java (.../McUsrAttempt.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUsrAttempt.java (.../McUsrAttempt.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -27,7 +27,14 @@ import org.apache.commons.lang.builder.ToStringBuilder; -/** @author Ozgur Demirtas */ +/** + *Persistent object/bean that defines the user attempt for the MCQ tool. + * Provides accessors and mutators to get/set attributes + * It maps to database table: tl_lamc11_usr_attempt + *
+ * + * @author Ozgur Demirtas + */ public class McUsrAttempt implements Serializable { /** identifier field */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java =================================================================== diff -u -re69d075821d086db03316c2f15e6e1d74aba165f -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision e69d075821d086db03316c2f15e6e1d74aba165f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -1,8 +1,6 @@ /* * Created on 21/04/2005 * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates */ package org.lamsfoundation.lams.tool.mc; @@ -35,18 +33,19 @@ /** * @author Ozgur Demirtas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * Common MCQ utility functions live here. */ - -/** - * Common utility functions live here. - */ public abstract class McUtils implements McAppConstants { static Logger logger = Logger.getLogger(McUtils.class.getName()); - + + /** + * returns the service object from the session cache + * IMcService getToolService(HttpServletRequest request) + * + * @param request + * @return + */ public static IMcService getToolService(HttpServletRequest request) { IMcService mcService=(IMcService)request.getSession().getAttribute(TOOL_SERVICE); @@ -55,87 +54,6 @@ /** - * generateId() - * return long - * IMPORTANT: The way we obtain either content id or tool session id must be modified - * so that we only use lams common to get these ids. This functionality is not - * available yet in the lams common as of 21/04/2005. - */ - public static long generateId() - { - Random generator = new Random(); - long longId=generator.nextLong(); - if (longId < 0) longId=longId * (-1) ; - return longId; - } - - /** - * helps create a mock user object in development time. - * static long generateIntegerId() - * @return long - */ - public static int generateIntegerId() - { - Random generator = new Random(); - int intId=generator.nextInt(); - if (intId < 0) intId=intId * (-1) ; - return intId; - } - - - public static int getCurrentUserId(HttpServletRequest request) throws McApplicationException - { - HttpSession ss = SessionManager.getSession(); - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - logger.debug(logger + " " + "McUtils" + " Current user is: " + user + " with id: " + user.getUserID()); - return user.getUserID().intValue(); - } - - - /** - * This method exists temporarily until we have the user data is passed properly from teh container to the tool - * createMockUser() - * @return User - */ - public static User createMockUser() - { - logger.debug(logger + " " + "McUtils" + " request for new new mock user"); - int randomUserId=generateIntegerId(); - User mockUser=new User(); - mockUser.setUserId(new Integer(randomUserId)); - mockUser.setFirstName(MOCK_USER_NAME + randomUserId); - mockUser.setLastName(MOCK_USER_LASTNAME + randomUserId); - mockUser.setLogin(MOCK_LOGIN_NAME + randomUserId); //we assume login and username refers to the same property - logger.debug(logger + " " + "McUtils" + " created mockuser: " + mockUser); - return mockUser; - } - - public static User createSimpleUser(Integer userId) - { - User user=new User(); - user.setUserId(userId); - return user; - } - - public static User createUser(Integer userId) - { - User user=new User(); - user.setUserId(userId); - - int randomUserId=generateIntegerId(); - user.setFirstName(MOCK_USER_NAME + randomUserId); - user.setLastName(MOCK_USER_LASTNAME + randomUserId); - user.setLogin(MOCK_LOGIN_NAME + randomUserId); - return user; - } - - public static boolean getDefineLaterStatus() - { - return false; - } - - - /** * existsContent(long toolContentId) * @param long toolContentId * @return boolean @@ -716,5 +634,97 @@ } } + + + /** + * temporary function + * @return + */ + public static long generateId() + { + Random generator = new Random(); + long longId=generator.nextLong(); + if (longId < 0) longId=longId * (-1) ; + return longId; + } + + /** + * temporary function + * @return + */ + public static int generateIntegerId() + { + Random generator = new Random(); + int intId=generator.nextInt(); + if (intId < 0) intId=intId * (-1) ; + return intId; + } + + + /** + * temporary function + * @return + */ + public static int getCurrentUserId(HttpServletRequest request) throws McApplicationException + { + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + logger.debug(logger + " " + "McUtils" + " Current user is: " + user + " with id: " + user.getUserID()); + return user.getUserID().intValue(); + } + + + /** + * temporary function + * @return + */ + public static User createMockUser() + { + logger.debug(logger + " " + "McUtils" + " request for new new mock user"); + int randomUserId=generateIntegerId(); + User mockUser=new User(); + mockUser.setUserId(new Integer(randomUserId)); + mockUser.setFirstName(MOCK_USER_NAME + randomUserId); + mockUser.setLastName(MOCK_USER_LASTNAME + randomUserId); + mockUser.setLogin(MOCK_LOGIN_NAME + randomUserId); //we assume login and username refers to the same property + logger.debug(logger + " " + "McUtils" + " created mockuser: " + mockUser); + return mockUser; + } + + /** + * temporary function + * @return + */ + public static User createSimpleUser(Integer userId) + { + User user=new User(); + user.setUserId(userId); + return user; + } + + /** + * temporary function + * @return + */ + public static User createUser(Integer userId) + { + User user=new User(); + user.setUserId(userId); + int randomUserId=generateIntegerId(); + user.setFirstName(MOCK_USER_NAME + randomUserId); + user.setLastName(MOCK_USER_LASTNAME + randomUserId); + user.setLogin(MOCK_LOGIN_NAME + randomUserId); + return user; + } + + /** + * temporary function + * @return + */ + public static boolean getDefineLaterStatus() + { + return false; + } + } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcContentDAO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcContentDAO.java (.../IMcContentDAO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcContentDAO.java (.../IMcContentDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -28,13 +28,11 @@ import org.lamsfoundation.lams.tool.mc.McSession; /** - *Interface for the McContent DAO, defines methods needed to access/modify - * mc content
- * @author ozgurd + * @author Ozgur Demirtas + *Interface for the McContent DAO, defines methods needed to access/modify mc content
+ * */ public interface IMcContentDAO { - - /** *Return the persistent instance of a McContent
* with the given identifier uid
, returns null if not found.
Interface for the McOptionsContent DAO, defines methods needed to access/modify mc options content
* - * @author ozgurd - * */ public interface IMcOptionsContentDAO { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java (.../IMcQueContentDAO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java (.../IMcQueContentDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -29,7 +29,8 @@ /** * - * @author ozgurd + * @author Ozgur Demirtas + *Interface for the McQueContent DAO, defines methods needed to access/modify mc question content
* */ public interface IMcQueContentDAO Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java (.../IMcSessionDAO.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java (.../IMcSessionDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -30,9 +30,9 @@ /** - *Interface for the McSession DAO, defines methods needed to access/modify - * mc session
- * @author ozgurd + * @author Ozgur Demirtas + *Interface for the McSession DAO, defines methods needed to access/modify mc session
+ * */ public interface IMcSessionDAO { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUploadedFileDAO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUploadedFileDAO.java (.../IMcUploadedFileDAO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUploadedFileDAO.java (.../IMcUploadedFileDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -27,6 +27,7 @@ /** * * @author Ozgur Demirtas + *Interface for the McUploadedFile DAO, defines methods needed to access/modify mc uploadedFile content
* */ public interface IMcUploadedFileDAO Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java (.../IMcUserDAO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java (.../IMcUserDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -27,10 +27,8 @@ import org.lamsfoundation.lams.tool.mc.McSession; /** - * @author ozgurd - * - *Interface for the McSession DAO, defines methods needed to access/modify - * mc users (learners of the mc activity)
+ * @author Ozgur Demirtas + *Interface for the McUser DAO, defines methods needed to access/modify user data
*/ public interface IMcUserDAO { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -27,7 +27,8 @@ /** * - * @author ozgurd + * @author Ozgur Demirtas + * *Interface for the McUsrAttempt DAO, defines methods needed to access/modify user attempt data
* */ public interface IMcUsrAttemptDAO Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McContentDAO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McContentDAO.java (.../McContentDAO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McContentDAO.java (.../McContentDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -35,7 +35,7 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport; /** - * @author ozgurd + * @author Ozgur Demirtas *Hibernate implementation for database access to McContent for the mc tool.
*/ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -33,11 +33,9 @@ /** - * @author ozgurd - * + * @author Ozgur Demirtas *Hibernate implementation for database access to McOptionsContent for the mc tool.
*/ - public class McOptionsContentDAO extends HibernateDaoSupport implements IMcOptionsContentDAO { static Logger logger = Logger.getLogger(McOptionsContentDAO.class.getName()); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -44,10 +44,9 @@ /** - * This interface define the contract that all MCQ service provider must - * follow. + * @author Ozgur Demirtas * - * @author ozgurd + * Interface that defines the contract that all MCQ service provider must follow. */ public interface IMcService { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -71,22 +71,15 @@ import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.springframework.dao.DataAccessException; - - /** - * The POJO implementation of Mc service. All business logics of survey tool - * are implemented in this class. It translate the request from presentation - * layer and perform approporiate database operation. * + * @author Ozgur Demirtas * - * Every method is implemented as a Hibernate session transaction. It open an - * new persistent session or connect to existing persistent session in the - * begining and it close or disconnect to the persistent session in the end. + * The POJO implementation of Mc service. All business logics of MCQ tool + * are implemented in this class. It translate the request from presentation + * layer and perform appropriate database operation. * - * @author ozgurd - * */ - public class McServicePOJO implements IMcService, ToolContentManager, ToolSessionManager, McAppConstants Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServiceProxy.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServiceProxy.java (.../McServiceProxy.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServiceProxy.java (.../McServiceProxy.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -33,22 +33,21 @@ /** + * @author Ozgur Demirtas + * *This class act as the proxy between web layer and service layer. It is * designed to decouple the presentation logic and business logic completely. * In this way, the presentation tier will no longer be aware of the changes in * service layer. Therefore we can feel free to switch the business logic * implementation.
- * - * @author ozgurd - * */ public class McServiceProxy { /** - * Return the qa domain service object. It will delegate to the Spring + * Return the mc domain service object. It will delegate to the Spring * helper method to retrieve the proper bean from Spring bean factory. * @param servletContext the servletContext for current application - * @return survey service object. + * @return mcq service object. */ public static final IMcService getMcService(ServletContext servletContext) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java =================================================================== diff -u -r735c5db341aaba22874662bf7e44ec91a24424c7 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 735c5db341aaba22874662bf7e44ec91a24424c7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -1,8 +1,5 @@ /* * Created on 16/05/2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates */ package org.lamsfoundation.lams.tool.mc.web; @@ -31,6 +28,269 @@ public class AuthoringUtil implements McAppConstants { static Logger logger = Logger.getLogger(AuthoringUtil.class.getName()); + public static Map repopulateCurrentCheckBoxStatesMap(HttpServletRequest request) + { + Map mapTempContent= new TreeMap(new McComparator()); + + long mapCounter=0; + for (long i=1; i <= MAX_OPTION_COUNT ; i++) + { + String candidateEntry =request.getParameter("checkBoxSelected" + i); + String optionText =request.getParameter("optionContent" + i); + + if ( + (candidateEntry != null) && + (candidateEntry.length() > 0) + ) + { + if (candidateEntry.equals("Correct")) + { + mapCounter++; + mapTempContent.put(new Long(mapCounter).toString(), optionText); + } + } + } + logger.debug("return repopulated currentCheckBoxStatesMap: " + mapTempContent); + return mapTempContent; + } + + + public static boolean verifyDuplicatesOptionsMap(Map mapOptionsContent) + { + Map originalMapOptionsContent=mapOptionsContent; + Map backupMapOptionsContent=mapOptionsContent; + + int optionCount=0; + for (long i=1; i <= MAX_OPTION_COUNT ; i++) + { + String currentOption=(String)originalMapOptionsContent.get(new Long(i).toString()); + logger.debug("verified currentOption " + currentOption); + + optionCount=0; + for (long j=1; j <= MAX_OPTION_COUNT ; j++) + { + String backedOption=(String)backupMapOptionsContent.get(new Long(j).toString()); + + if ((currentOption != null) && (backedOption !=null)) + { + if (currentOption.equals(backedOption)) + { + optionCount++; + logger.debug("optionCount for " + currentOption + " is: " + optionCount); + } + + if (optionCount > 1) + return false; + } + } + } + return true; + } + + + public static boolean validateQuestionsNotEmpty(Map mapQuestionsContent) + { + Iterator itMap = mapQuestionsContent.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry)itMap.next(); + logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if ((pairs.getValue() != null) && (pairs.getValue().toString().length() == 0)) + return false; + + } + return true; + } + + public static Map repopulateCurrentWeightsMap(HttpServletRequest request, String parameterType) + { + Map mapTempQuestionsContent= new TreeMap(new McComparator()); + logger.debug("parameterType: " + parameterType); + + long mapCounter=0; + for (long i=1; i <= MAX_QUESTION_COUNT ; i++) + { + String candidateEntry =request.getParameter(parameterType + i); + String questionText =request.getParameter("questionContent" + i); + if ((questionText != null) && (questionText.length() > 0)) + { + logger.debug("questionText: " + questionText); + if (candidateEntry != null) + { + mapCounter++; + mapTempQuestionsContent.put(new Long(mapCounter).toString(), candidateEntry); + } + } + + } + logger.debug("return repopulated Map: " + mapTempQuestionsContent); + return mapTempQuestionsContent; + } + + + /** + * shrinks the size of the Map to only used entries + * + * @param mapQuestionContent + * @param request + * @return + */ + public static Map repopulateMap(HttpServletRequest request, String parameterType) + { + Map mapTempQuestionsContent= new TreeMap(new McComparator()); + logger.debug("parameterType: " + parameterType); + + long mapCounter=0; + for (long i=1; i <= MAX_QUESTION_COUNT ; i++) + { + String candidateEntry =request.getParameter(parameterType + i); + if ( + (candidateEntry != null) && + (candidateEntry.length() > 0) + ) + { + mapCounter++; + mapTempQuestionsContent.put(new Long(mapCounter).toString(), candidateEntry); + } + } + logger.debug("return repopulated Map: " + mapTempQuestionsContent); + return mapTempQuestionsContent; + } + + + public static Map shiftMap(Map mapQuestionsContent, String questionIndex , String movableQuestionEntry, String direction) + { + logger.debug("movableQuestionEntry: " + movableQuestionEntry); + /* map to be returned */ + Map mapTempQuestionsContent= new TreeMap(new McComparator()); + + Iterator itMap = mapQuestionsContent.entrySet().iterator(); + String shiftableEntry=null; + + int shiftableIndex=0; + if (direction.equals("down")) + { + logger.debug("moving map down"); + shiftableIndex=new Integer(questionIndex).intValue() + 1; + } + else + { + logger.debug("moving map up"); + shiftableIndex=new Integer(questionIndex).intValue() - 1; + + } + + logger.debug("shiftableIndex: " + shiftableIndex); + shiftableEntry=(String)mapQuestionsContent.get(new Integer(shiftableIndex).toString()); + logger.debug("shiftable entry: " + shiftableEntry); + + if (shiftableEntry != null) + { + Iterator itQuestionsMap = mapQuestionsContent.entrySet().iterator(); + long mapCounter=0; + while (itQuestionsMap.hasNext()) { + Map.Entry pairs = (Map.Entry)itQuestionsMap.next(); + logger.debug("comparing the pair: " + pairs.getKey() + " = " + pairs.getValue()); + mapCounter++; + logger.debug("mapCounter: " + mapCounter); + + if (!pairs.getKey().equals(questionIndex) && !pairs.getKey().equals(new Integer(shiftableIndex).toString())) + { + logger.debug("normal copy " + questionIndex); + mapTempQuestionsContent.put(new Long(mapCounter).toString(), pairs.getValue()); + } + else if (pairs.getKey().equals(questionIndex)) + { + logger.debug("move type 1 " + questionIndex); + mapTempQuestionsContent.put(new Long(mapCounter).toString(), shiftableEntry); + } + else if (pairs.getKey().equals(new Integer(shiftableIndex).toString())) + { + logger.debug("move type 2 " + shiftableIndex); + mapTempQuestionsContent.put(new Long(mapCounter).toString(), movableQuestionEntry); + } + } + } + else + { + logger.debug("no change to map"); + mapTempQuestionsContent=mapQuestionsContent; + } + return mapTempQuestionsContent; + } + + + public static boolean validateTotalWeight(HttpServletRequest request) + { + Map mapWeights= repopulateCurrentWeightsMap(request, "questionWeight"); + logger.debug("mapWeights: " + mapWeights); + + Iterator itMap = mapWeights.entrySet().iterator(); + int totalWeight=0; + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry)itMap.next(); + logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if ((pairs.getValue() != null) || (pairs.getValue().toString().length() > 0)) + { + totalWeight=totalWeight+ new Integer(pairs.getValue().toString()).intValue(); + } + } + + logger.debug("totalWeight: " + totalWeight); + + if (totalWeight != 100) + { + return false; + } + + return true; + } + + + public static boolean validateSubTotalWeights(HttpServletRequest request, McAuthoringForm mcAuthoringForm) + { + Map mapWeights= repopulateCurrentWeightsMap(request, "questionWeight"); + logger.debug("mapWeights: " + mapWeights); + + int totalWeight=0; + Iterator itMap = mapWeights.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry)itMap.next(); + logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + int currentWeight=new Integer(pairs.getValue().toString()).intValue(); + totalWeight= totalWeight + currentWeight; + logger.debug("sub totalWeight: " + totalWeight); + } + logger.debug("final totalWeight: " + totalWeight); + + if (totalWeight > 100) + return false; + else + return true; + } + + + public static boolean validateOptions(HttpServletRequest request) + { + logger.debug("will validateOptions"); + String parameterType="checkBoxSelected"; + for (int i=1; i <= MAX_OPTION_COUNT ; i++) + { + String isCorrect=request.getParameter(parameterType + i); + logger.debug("isCorrect: " + isCorrect); + + if (isCorrect != null) + { + if (isCorrect.equals("Correct")) + return true; + } + } + return false; + } + + public Map rebuildQuestionMapfromDB(HttpServletRequest request, Long toolContentId) { Map mapQuestionsContent= new TreeMap(new McComparator()); @@ -136,5 +396,4 @@ } logger.debug("end of simulating setAsDefineLater on content id: " + toolContentId); } - } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -r66e72872d1d3cdb236fce53f721ede405249ab50 -r25a3cd766f44f20c25042ad630f87b5b79a53671 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 66e72872d1d3cdb236fce53f721ede405249ab50) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) @@ -55,114 +55,9 @@ import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; - /** + * * @author Ozgur Demirtas * - * change the logic about completion status - * - */ - -/** - * - * once lams_learning is ready and appContext file is src/ then FINISH toool session will work. - * - */ - -/** - * - * done: removed styling, except error messages and table centering - * - */ - -/** - * The tool's Spring configuration file: qaCompactApplicationContext.xml - * Main service bean of the tool is: org.lamsfoundation.lams.tool.qa.service.McServicePOJO - * - * done: config file is read from classpath - */ - - -/** - * - * the tool's web.xml will be modified to have classpath to learning service. - * This is how the tool gets the definition of "learnerService" - */ - -/** - * - * when to reset define later and synchin monitor etc.. - * - */ - -/** make sure the tool gets called on: - * setAsForceComplete(Long userId) throws McApplicationException - */ - - -/** - * - * User Issue: - * Right now: - * 1- the tool gets the request object from the container. - * 2- Principal principal = req.getUserPrincipal(); - * 3- String username = principal.getName(); - * 4- User userCompleteData = qaService.getCurrentUserData(userName); - * 5- write back userCompleteData.getUserId() - */ - - -/** - * - * JBoss Issue: - * Currently getUserPrincipal() returns null and ServletRequest.isUserInRole() always returns false on unsecured pages, - * even after the user has been authenticated. - * http://jira.jboss.com/jira/browse/JBWEB-19 - */ - - -/** - * eliminate calls: - * authoringUtil.simulatePropertyInspector_RunOffline(request); - * authoringUtil.simulatePropertyInspector_setAsDefineLater(request); - */ - - -/** - * - * @author ozgurd - * - * TOOL PARAMETERS: ?? (toolAccessMode) ?? - * Authoring environment: toolContentId - * Learning environment: toolSessionId + toolContentId - * Monitoring environment: toolContentId / Contribute tab:toolSessionId(s) - * - * - */ - -/** - * Note: the tool must support deletion of an existing content from within the authoring environment. - * The current support for this is by implementing the tool contract : removeToolContent(Long toolContentId) - */ - - -/** - * - * We have had to simulate container bahaviour in development stage by calling - * createToolSession and leaveToolSession from the web layer. These will go once the tool is - * in deployment environment. - * - * - * CHECK: leaveToolSession and relavent LearnerService may need to be defined in the spring config file. - * - */ - -/** - * - * GROUPING SUPPORT: Find out what to do. - */ - - -/** *Action class that controls the logic of tool behavior.
* *Note that Struts action class only has the responsibility to navigate
@@ -176,10 +71,57 @@
* Struts action class as all of them are handled in
* CustomStrutsExceptionHandler
.
*
- * @author Ozgur Demirtas
- */
+
+
-
Index: lams_tool_lamc/web/OptionsContent.jsp
===================================================================
diff -u -r48ae5d808d7eb36ec52e696a646b035cfa70e60b -r25a3cd766f44f20c25042ad630f87b5b79a53671
--- lams_tool_lamc/web/OptionsContent.jsp (.../OptionsContent.jsp) (revision 48ae5d808d7eb36ec52e696a646b035cfa70e60b)
+++ lams_tool_lamc/web/OptionsContent.jsp (.../OptionsContent.jsp) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671)
@@ -47,7 +47,7 @@
+
-
Index: lams_tool_lamc/web/WEB-INF/struts-config.xml
===================================================================
diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r25a3cd766f44f20c25042ad630f87b5b79a53671
--- lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7)
+++ lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671)
@@ -62,7 +62,6 @@
path=".errorList"
redirect="true"
/>
-
+