You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(128) |
Jun
(97) |
Jul
(13) |
Aug
(40) |
Sep
(50) |
Oct
(27) |
Nov
(7) |
Dec
(15) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(18) |
Feb
(47) |
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
(32) |
Aug
|
Sep
(14) |
Oct
(22) |
Nov
|
Dec
|
From: <se...@us...> - 2008-05-29 11:41:42
|
Revision: 181 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=181&view=rev Author: sem62 Date: 2008-05-29 04:41:50 -0700 (Thu, 29 May 2008) Log Message: ----------- Fixed bug with summary page: after adding new item in course, it don't show properly in summary page. Now calling method resetModelForActivity for updating objectives list. Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/SummaryPageManager.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/Data/SummaryPageManager.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/SummaryPageManager.java 2008-05-29 11:39:23 UTC (rev 180) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Data/SummaryPageManager.java 2008-05-29 11:41:50 UTC (rev 181) @@ -8,6 +8,7 @@ import edu.lnu.FireFly.FFManifest.item.sequencing.objectives.Objective; import edu.lnu.FireFly.FFManifest.item.sequencing.objectives.Objectives; import edu.lnu.FireFly.FFManifest.parser.TestDocException; +import edu.lnu.FireFly.Rte.CmiManager; import edu.lnu.FireFly.WebEditor.GUI.Reorganizer; import edu.lnu.FireFly.WebEditor.ItemModels.ItemModel; import edu.lnu.FireFly.WebEditor.ItemModels.ItemModels; @@ -85,6 +86,8 @@ summaryPage.sequencing.objectives.objective.add(objective); } + + CmiManager.getInstance().resetModelForActivity(summaryPage); } private ArrayList<String> getShowingItemsIds(TreeItem root) { Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java 2008-05-29 11:39:23 UTC (rev 180) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java 2008-05-29 11:41:50 UTC (rev 181) @@ -10,7 +10,6 @@ import edu.lnu.FireFly.WebEditor.ItemModels.ResourcedItemModel; import edu.lnu.FireFly.WebEditor.ItemModels.SummaryPageModel.SummaryPageModel; import edu.lnu.FireFly.WebEditor.UserAnswerStatus.UserAnswerStatus; -import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; public class ChapterModel extends ResourcedItemModel { @@ -86,11 +85,6 @@ return 0; } - @Override - protected String getConfFileName(TreeItem anItem) { - return getIdentifier(anItem); - } - private ChapterItemData getData(TreeItem anItem) { return (ChapterItemData) getItemData(anItem); } @@ -156,8 +150,6 @@ TreeDataModel.getInstance().treeNodesDeleted(aChapter); aChapter.getParent().removeChild(aChapter); - WebEditorServiceClient.getInstance().deleteFile( - getConfFileName(aChapter)); SummaryPageManager.getInstance().updateSummaryPages(); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-29 11:39:23 UTC (rev 180) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-29 11:41:50 UTC (rev 181) @@ -216,8 +216,7 @@ sequencing.objectives = ManifestFactory.createObjectives(); } - sequencing.objectives.primaryObjective = ManifestFactory - .createObjective(); + sequencing.objectives.primaryObjective = ManifestFactory.createObjective(); sequencing.objectives.primaryObjective.objectiveID = getIdentifier(anItem); sequencing.objectives.primaryObjective.satisfiedByMeasure = true; @@ -226,8 +225,7 @@ mapInfo.writeSatisfiedStatus = true; mapInfo.targetObjectiveID = sequencing.objectives.primaryObjective.objectiveID; - sequencing.objectives.primaryObjective.mapInfo = ManifestFactory - .createMapInfos(); + sequencing.objectives.primaryObjective.mapInfo = ManifestFactory.createMapInfos(); sequencing.objectives.primaryObjective.mapInfo.add(mapInfo); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java 2008-05-29 11:39:23 UTC (rev 180) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java 2008-05-29 11:41:50 UTC (rev 181) @@ -7,7 +7,6 @@ import edu.lnu.FireFly.FFManifest.item.Item; import edu.lnu.FireFly.FFManifest.parser.TestDocException; import edu.lnu.FireFly.FFManifest.resource.Resource; -import edu.lnu.FireFly.WebEditor.WebEditor; import edu.lnu.FireFly.WebEditor.Data.SummaryPageManager; import edu.lnu.FireFly.WebEditor.GUI.TreeDataModel; import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; @@ -46,19 +45,6 @@ ConfigureItem(item); } - protected final String getConfFileContent(String location, TreeItem anItem) { - String res = ""; - - if (location.equalsIgnoreCase("course")) { - res = WebEditorServiceClient.getInstance().getFileContent( - getConfFileName(anItem), location); - } else { - res = WebEditorServiceClient.getInstance().getFileContent( - modelName + ".conf", location); - } - return res; - } - @Override public boolean isRemovable() { return true; @@ -82,8 +68,6 @@ WebEditorServiceClient.getInstance().deleteFile( resource.getFullHref()); - WebEditorServiceClient.getInstance().deleteFile( - getConfFileName(anItem)); manifest.resources.deleteResource(identifier); @@ -125,18 +109,13 @@ return !isSubTreeUsingResource(root, getIdentifier(anItem), anItem); } - protected String getConfFileName(TreeItem anItem) { - Resource resource = WebEditor.instance.getManifest().resources - .findResourceByIdentifier(getIdentifierRef(anItem)); - - return resource.identifier + ".conf"; - } - @Override protected final void initializeDataForItem(Item anItem) { ItemData itemData = createItemDataInstance(); //String res = getConfFileContent("template", anItem); +// res = WebEditorServiceClient.getInstance().getFileContent( +// modelName + ".conf", location); //itemData.unmarshal(new StringReader(res), anItem); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-29 11:39:16
|
Revision: 180 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=180&view=rev Author: sem62 Date: 2008-05-29 04:39:23 -0700 (Thu, 29 May 2008) Log Message: ----------- * Modified GlobalObjectives class as Siglethon. * Moved register method for registering global objective from Objectives to GlobalObjectives. * added resetModel method for reseting cmi model after modifying objectives list in item. Modified Paths: -------------- RTE/src/edu/lnu/FireFly/Rte/CmiManager.java RTE/src/edu/lnu/FireFly/Rte/objectives/GlobalObjectives.java RTE/src/edu/lnu/FireFly/Rte/objectives/Objectives.java Modified: RTE/src/edu/lnu/FireFly/Rte/CmiManager.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/CmiManager.java 2008-05-29 09:39:57 UTC (rev 179) +++ RTE/src/edu/lnu/FireFly/Rte/CmiManager.java 2008-05-29 11:39:23 UTC (rev 180) @@ -38,6 +38,10 @@ return activitiesVSModels.get(activity); } + public void resetModelForActivity(TreeItem activity){ + activitiesVSModels.put(activity, new Cmi(activity)); + } + private static CmiManager obj = null; private CmiManager(){ Modified: RTE/src/edu/lnu/FireFly/Rte/objectives/GlobalObjectives.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/objectives/GlobalObjectives.java 2008-05-29 09:39:57 UTC (rev 179) +++ RTE/src/edu/lnu/FireFly/Rte/objectives/GlobalObjectives.java 2008-05-29 11:39:23 UTC (rev 180) @@ -4,9 +4,31 @@ import edu.lnu.FireFly.Rte.ElementName; public class GlobalObjectives { - private static ArrayList<ObjectivesItem> list = new ArrayList<ObjectivesItem>(); + private ArrayList<ObjectivesItem> list = new ArrayList<ObjectivesItem>(); - public static boolean registered(String id){ + private GlobalObjectives(){ + + } + + private static GlobalObjectives obj = null; + + public static GlobalObjectives getInstance(){ + if (obj == null){ + obj = new GlobalObjectives(); + } + + return obj; + } + + public void register(String id){ + if (!registered(id)){ + ObjectivesItem item = new ObjectivesItem(); + item.setValue(new ElementName("id"), id); + put(item); + } + } + + public boolean registered(String id){ for (int i=0; i < list.size(); i++){ ObjectivesItem item = (ObjectivesItem) list.get(i); String globalId = item.getValue(new ElementName("globalId")); @@ -18,7 +40,7 @@ return false; } - public static void put(ObjectivesItem item){ + public void put(ObjectivesItem item){ String id = item.getValue(new ElementName("id")); if (!registered(id)){ @@ -27,7 +49,7 @@ } } - public static ObjectivesItem get(String id){ + public ObjectivesItem get(String id){ for (int i=0; i < list.size(); i++){ ObjectivesItem item = (ObjectivesItem) list.get(i); String globalId = item.getValue(new ElementName("globalId")); Modified: RTE/src/edu/lnu/FireFly/Rte/objectives/Objectives.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/objectives/Objectives.java 2008-05-29 09:39:57 UTC (rev 179) +++ RTE/src/edu/lnu/FireFly/Rte/objectives/Objectives.java 2008-05-29 11:39:23 UTC (rev 180) @@ -11,14 +11,6 @@ public class Objectives extends Collection { public static ArrayList<ObjectiveMap> objectiveMap = new ArrayList<ObjectiveMap>(); - public static void registerGlobalObjective(String id){ - if (!GlobalObjectives.registered(id)){ - ObjectivesItem item = new ObjectivesItem(); - item.setValue(new ElementName("id"), id); - GlobalObjectives.put(item); - } - } - public Objectives(Item current, boolean indexed){ super(indexed); _children = ObjectivesItem._children; @@ -32,7 +24,7 @@ for (int i = 0; i < current.sequencing.objectives.primaryObjective.mapInfo.size(); i++){ String globalId = ((MapInfo)current.sequencing.objectives.primaryObjective.mapInfo.get(i)).targetObjectiveID; - registerGlobalObjective(globalId); + GlobalObjectives.getInstance().register(globalId); objectiveMap.add(new ObjectiveMap(localId, globalId)); }; @@ -43,7 +35,7 @@ for (int j = 0; j < obj.mapInfo.size(); j++){ String globalId = ((MapInfo)obj.mapInfo.get(j)).targetObjectiveID.substring(0); - registerGlobalObjective(globalId); + GlobalObjectives.getInstance().register(globalId); objectiveMap.add(new ObjectiveMap(localId, globalId)); }; } @@ -69,8 +61,8 @@ if (((ObjectiveMap)objectiveMap.get(i)).activityObjectiveID.equals(id)){ String globalId = ((ObjectiveMap)objectiveMap.get(i)).targetObjectiveID; - if (GlobalObjectives.registered(globalId)){ - ObjectivesItem obj = GlobalObjectives.get(globalId); + if (GlobalObjectives.getInstance().registered(globalId)){ + ObjectivesItem obj = GlobalObjectives.getInstance().get(globalId); return obj.setValue(new ElementName(name, 1), value); } } @@ -90,8 +82,8 @@ if (((ObjectiveMap)objectiveMap.get(i)).activityObjectiveID.equals(id)){ String globalId = ((ObjectiveMap)objectiveMap.get(i)).targetObjectiveID; - if (GlobalObjectives.registered(globalId)){ - ObjectivesItem obj = GlobalObjectives.get(globalId); + if (GlobalObjectives.getInstance().registered(globalId)){ + ObjectivesItem obj = GlobalObjectives.getInstance().get(globalId); return obj.getValue(new ElementName(name, 1)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-29 09:39:55
|
Revision: 179 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=179&view=rev Author: sem62 Date: 2008-05-29 02:39:57 -0700 (Thu, 29 May 2008) Log Message: ----------- Fixed bugs with calculation min/max score when type of simple question is TYPE Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java Added Paths: ----------- WebEditor/.classpath WebEditor/.project WebEditor/.settings/ WebEditor/.settings/org.eclipse.jdt.core.prefs WebEditor/.settings/org.eclipse.jdt.ui.prefs Added: WebEditor/.classpath =================================================================== --- WebEditor/.classpath (rev 0) +++ WebEditor/.classpath 2008-05-29 09:39:57 UTC (rev 179) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="lib" path="S:/WebEditor/RTEValidators.jar"/> + <classpathentry kind="lib" path="C:/Documents and Settings/Yura/Мои документы/NetBeansProjects/WebEditor/web/WebEditor/dom4j.jar"/> + <classpathentry kind="lib" path="S:/WebEditor/FFManifest.jar" sourcepath="S:/WebEditor/FFManifest.jar"/> + <classpathentry kind="lib" path="C:/Program Files/Java/jre1.6.0_05/lib/plugin.jar"/> + <classpathentry kind="lib" path="S:/WebEditor/rte.jar" sourcepath="/RTE"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: WebEditor/.project =================================================================== --- WebEditor/.project (rev 0) +++ WebEditor/.project 2008-05-29 09:39:57 UTC (rev 179) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>webEditor</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: WebEditor/.settings/org.eclipse.jdt.core.prefs =================================================================== --- WebEditor/.settings/org.eclipse.jdt.core.prefs (rev 0) +++ WebEditor/.settings/org.eclipse.jdt.core.prefs 2008-05-29 09:39:57 UTC (rev 179) @@ -0,0 +1,256 @@ +#Sun May 18 12:00:25 EEST 2008 +eclipse.preferences.version=1 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=80 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=mixed +org.eclipse.jdt.core.formatter.tabulation.size=8 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true Added: WebEditor/.settings/org.eclipse.jdt.ui.prefs =================================================================== --- WebEditor/.settings/org.eclipse.jdt.ui.prefs (rev 0) +++ WebEditor/.settings/org.eclipse.jdt.ui.prefs 2008-05-29 09:39:57 UTC (rev 179) @@ -0,0 +1,4 @@ +#Sun May 18 12:00:25 EEST 2008 +eclipse.preferences.version=1 +formatter_profile=org.eclipse.jdt.ui.default.sun_profile +formatter_settings_version=11 Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-29 09:30:08 UTC (rev 178) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-29 09:39:57 UTC (rev 179) @@ -61,6 +61,13 @@ result = getMax(answers); } } + + if (data.getAnswers().getAnswerType() == SimpleQuestionAnswersDataModel.ANSWER_TYPE_TYPE) { + if (result < 0){ + result = 0; + } + } + return result; } @@ -79,6 +86,13 @@ result = getMin(answers); } } + + if (data.getAnswers().getAnswerType() == SimpleQuestionAnswersDataModel.ANSWER_TYPE_TYPE) { + if (result > 0){ + result = 0; + } + } + return result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-29 09:30:24
|
Revision: 178 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=178&view=rev Author: sem62 Date: 2008-05-29 02:30:08 -0700 (Thu, 29 May 2008) Log Message: ----------- * Added ItemConfigurationManager that must manage all item configurations. * Saving all item configurations in one file at saving course. It's some optimization. Modified Paths: -------------- WebEditor/src/deploy.jardesc WebEditor/src/edu/lnu/FireFly/WebEditor/Data/ManifestFactory.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterItemData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModels.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java Added Paths: ----------- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemDataFactory.java WebEditor/src/edu/lnu/FireFly/WebEditor/itemConfiguration/ WebEditor/src/edu/lnu/FireFly/WebEditor/itemConfiguration/ItemConfigurationManager.java Property Changed: ---------------- WebEditor/ Property changes on: WebEditor ___________________________________________________________________ Name: svn:ignore - *.classpath *.project .settings + Modified: WebEditor/src/deploy.jardesc =================================================================== --- WebEditor/src/deploy.jardesc 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/deploy.jardesc 2008-05-29 09:30:08 UTC (rev 178) @@ -11,9 +11,6 @@ </sealing> </manifest> <selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false"> - <file path="/webEditor/.classpath"/> <javaElement handleIdentifier="=webEditor/src"/> - <file path="/webEditor/webEditor.eap"/> - <file path="/webEditor/.project"/> </selectedElements> </jardesc> Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/Data/ManifestFactory.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/ManifestFactory.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Data/ManifestFactory.java 2008-05-29 09:30:08 UTC (rev 178) @@ -15,6 +15,7 @@ import edu.lnu.FireFly.FFManifest.resource.Resources; import edu.lnu.FireFly.WebEditor.ItemModels.OrganizationModel; import edu.lnu.FireFly.WebEditor.ItemModels.Chapter.ChapterItemData; +import edu.lnu.FireFly.WebEditor.itemConfiguration.ItemConfigurationManager; public class ManifestFactory { static public Manifest createManifest() { @@ -33,8 +34,9 @@ e.printStackTrace(); return null; } - - model.setItemData(root, new ChapterItemData()); + + ItemConfigurationManager.getInstance().clear(); + ItemConfigurationManager.getInstance().update(root, new ChapterItemData()); model.updateItemResource(root, false); return manifest; Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterItemData.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterItemData.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterItemData.java 2008-05-29 09:30:08 UTC (rev 178) @@ -1,22 +1,17 @@ package edu.lnu.FireFly.WebEditor.ItemModels.Chapter; -import java.io.Reader; - -import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; -import org.dom4j.io.SAXReader; -import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.WebEditor.ItemModels.ItemData; public class ChapterItemData extends ItemData { private boolean showSummaryPage = true; @Override - public String marshal(TreeItem anItem) { - Document doc = DocumentHelper.createDocument(); - Element root = doc.addElement("ChapterItemData"); + public Element marshal() { + Element root = DocumentHelper.createElement("ItemData"); + root.addElement("ShowSummaryPage").setText( String.valueOf(isShowSummaryPage())); @@ -26,7 +21,7 @@ root.addElement("Configuration").setText( String.valueOf(getConfiguration())); - return doc.asXML(); + return root; } private boolean flow; @@ -86,23 +81,9 @@ } @Override - public boolean unmarshal(Reader aXmlInputStream, TreeItem anItem) { - SAXReader reader = new SAXReader(); - - Document doc = null; - Element root = null; + public boolean unmarshal(Element root) { try { - doc = reader.read(aXmlInputStream); - - root = doc.getRootElement(); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - - try { - boolean showSP = Boolean.valueOf(root - .elementTextTrim("ShowSummaryPage")); + boolean showSP = Boolean.valueOf(root.elementTextTrim("ShowSummaryPage")); setShowSummaryPage(showSP); boolean showOnSP = Boolean.valueOf(root Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java 2008-05-29 09:30:08 UTC (rev 178) @@ -164,12 +164,6 @@ public void setShowSummaryPage(TreeItem anItem, boolean state) { ChapterItemData itemData = getData(anItem); - if (itemData == null) { - ItemData data = new ChapterItemData(); - setItemData(anItem, data); - itemData = (ChapterItemData) getItemData(anItem); - } - if (itemData.isShowSummaryPage() != state) { itemData.setShowSummaryPage(state); updateItemResource(anItem, true); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQData.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQData.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQData.java 2008-05-29 09:30:08 UTC (rev 178) @@ -1,21 +1,16 @@ package edu.lnu.FireFly.WebEditor.ItemModels.CompileQ; -import java.io.Reader; import java.util.Iterator; -import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; -import org.dom4j.io.SAXReader; -import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.WebEditor.ItemModels.ItemData; public class CompileQData extends ItemData { @Override - public String marshal(TreeItem anItem) { - Document doc = DocumentHelper.createDocument(); - Element root = doc.addElement("CompileQuestion"); + public Element marshal() { + Element root = DocumentHelper.createElement("ItemData"); root.addElement("caption").setText(getCaption()); root.addElement("ShowOnSummaryPage").setText( @@ -41,7 +36,7 @@ partElement.setText(part.getAnswerText()); } - return doc.asXML(); + return root; } private String caption = ""; @@ -59,14 +54,8 @@ @Override @SuppressWarnings("unchecked") - public boolean unmarshal(Reader res, TreeItem anItem) { - SAXReader reader = new SAXReader(); - - Document doc = null; + public boolean unmarshal(Element root) { try { - doc = reader.read(res); - - Element root = doc.getRootElement(); Element answers = root.element("parts"); setCaption(root.elementTextTrim("caption")); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemData.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemData.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemData.java 2008-05-29 09:30:08 UTC (rev 178) @@ -1,9 +1,7 @@ package edu.lnu.FireFly.WebEditor.ItemModels; -import java.io.Reader; +import org.dom4j.Element; -import edu.lnu.FireFly.FFManifest.TreeItem; - public abstract class ItemData { private Boolean showOnSummaryPage = false; @@ -15,7 +13,7 @@ this.showOnSummaryPage = showOnSummaryPage; } - public abstract boolean unmarshal(Reader res, TreeItem anItem); + public abstract boolean unmarshal(Element root); - public abstract String marshal(TreeItem anItem); + public abstract Element marshal(); } Added: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemDataFactory.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemDataFactory.java (rev 0) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemDataFactory.java 2008-05-29 09:30:08 UTC (rev 178) @@ -0,0 +1,45 @@ +package edu.lnu.FireFly.WebEditor.ItemModels; + +import edu.lnu.FireFly.WebEditor.ItemModels.Chapter.ChapterItemData; +import edu.lnu.FireFly.WebEditor.ItemModels.CompileQ.CompileQData; +import edu.lnu.FireFly.WebEditor.ItemModels.Lecture.LectureData; +import edu.lnu.FireFly.WebEditor.ItemModels.SimpleQuestion.SimpleQuestionData; +import edu.lnu.FireFly.WebEditor.ItemModels.SummaryPageModel.SummaryPageData; + +public class ItemDataFactory { + private static ItemDataFactory obj = null; + + private ItemDataFactory(){} + + public static ItemDataFactory getInstance(){ + if (obj == null){ + obj = new ItemDataFactory(); + } + + return obj; + } + + public ItemData createItemData(String type){ + if (LectureData.class.getSimpleName().equalsIgnoreCase(type)){ + return new LectureData(); + } + + if (ChapterItemData.class.getSimpleName().equalsIgnoreCase(type)){ + return new ChapterItemData(); + } + + if (SimpleQuestionData.class.getSimpleName().equalsIgnoreCase(type)){ + return new SimpleQuestionData(); + } + + if (SummaryPageData.class.getSimpleName().equalsIgnoreCase(type)){ + return new SummaryPageData(); + } + + if (CompileQData.class.getSimpleName().equalsIgnoreCase(type)){ + return new CompileQData(); + } + + return null; + } +} Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-29 09:30:08 UTC (rev 178) @@ -4,7 +4,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.util.HashMap; import java.util.UUID; import edu.lnu.FireFly.FFManifest.Organization; @@ -23,18 +22,13 @@ import edu.lnu.FireFly.WebEditor.GUI.Dialogs.PropertyDlg; import edu.lnu.FireFly.WebEditor.ItemModels.SummaryPageModel.SummaryPageModel; import edu.lnu.FireFly.WebEditor.UserAnswerStatus.UserAnswerStatus; +import edu.lnu.FireFly.WebEditor.itemConfiguration.ItemConfigurationManager; public abstract class ItemModel { - protected static HashMap<TreeItem, ItemData> questionsData = new HashMap<TreeItem, ItemData>(); - protected String modelName = "Abstract model"; protected abstract String getDefaultTitle(); - public void setItemData(TreeItem anItem, ItemData data) { - questionsData.put(anItem, data); - } - protected boolean isContainerItem = false; private PropertyDlg propertyDlg = null; @@ -119,11 +113,7 @@ } public ItemData getItemData(TreeItem anItem) { - if (questionsData.containsKey(anItem)) { - return questionsData.get(anItem); - } - - return null; + return ItemConfigurationManager.getInstance().get(anItem); } public final String getModelName() { @@ -180,12 +170,8 @@ TreeDataModel.getInstance().treeNodesChanged(item); } - public abstract boolean synchronizeItemWithResource(TreeItem anItem, - String location); + public abstract boolean updateItemResource(TreeItem item, boolean updateSummaryPages); - public abstract boolean updateItemResource(TreeItem item, - boolean updateSummaryPages); - public abstract boolean getLimitConditionsMenuVisible(TreeItem anItem); public abstract boolean getShowOnSummaryPageMenuVisible(); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModels.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModels.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModels.java 2008-05-29 09:30:08 UTC (rev 178) @@ -2,7 +2,6 @@ import java.util.ArrayList; -import edu.lnu.FireFly.FFManifest.Organization; import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.WebEditor.ItemModels.Chapter.ChapterModel; import edu.lnu.FireFly.WebEditor.ItemModels.CompileQ.CompileQModel; @@ -52,30 +51,6 @@ return getUnknownModel(); } - public static void synchronizeAllItemDatas(TreeItem root) { - int childsCount = root.getChildCount(); - - if (root.getClass() == Organization.class) { - // this is a root of tree. - synchronizeItemDatas(root, false); - } - - for (int i = 0; i < childsCount; i++) { - synchronizeItemDatas(root.getChild(i), true); - } - } - - private static void synchronizeItemDatas(TreeItem item, boolean recursivly) { - ItemModel model = ItemModels.getModelFromItem(item); - - model.synchronizeItemWithResource(item, "course"); - - if ((model.getClass() == ChapterModel.class || model.getClass() == OrganizationModel.class) - && recursivly) { - synchronizeAllItemDatas(item); - } - } - public static void clear() { registeredModels.clear(); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureData.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureData.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureData.java 2008-05-29 09:30:08 UTC (rev 178) @@ -1,13 +1,8 @@ package edu.lnu.FireFly.WebEditor.ItemModels.Lecture; -import java.io.Reader; - -import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; -import org.dom4j.io.SAXReader; -import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.WebEditor.ItemModels.ItemData; public class LectureData extends ItemData { @@ -31,19 +26,7 @@ } @Override - public boolean unmarshal(Reader stringReader, TreeItem anItem) { - SAXReader reader = new SAXReader(); - - Document doc = null; - try { - doc = reader.read(stringReader); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - - Element root = doc.getRootElement(); - + public boolean unmarshal(Element root) { setCaption(root.elementTextTrim("caption")); setContent(root.elementTextTrim("content")); @@ -56,15 +39,14 @@ } @Override - public String marshal(TreeItem anItem) { - Document doc = DocumentHelper.createDocument(); - Element root = doc.addElement("LectureData"); + public Element marshal() { + Element root = DocumentHelper.createElement("ItemData"); root.addElement("caption").setText(getCaption()); root.addElement("content").setText(getContent()); root.addElement("ShowOnSummaryPage").setText( String.valueOf(getShowOnSummaryPage())); - return doc.asXML(); + return root; } } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java 2008-05-29 09:30:08 UTC (rev 178) @@ -1,6 +1,5 @@ package edu.lnu.FireFly.WebEditor.ItemModels; -import java.io.StringReader; import java.util.UUID; import edu.lnu.FireFly.FFManifest.Manifest; @@ -12,6 +11,7 @@ import edu.lnu.FireFly.WebEditor.Data.SummaryPageManager; import edu.lnu.FireFly.WebEditor.GUI.TreeDataModel; import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; +import edu.lnu.FireFly.WebEditor.itemConfiguration.ItemConfigurationManager; public abstract class ResourcedItemModel extends ItemModel { @@ -46,7 +46,7 @@ ConfigureItem(item); } - protected final String loadResource(String location, TreeItem anItem) { + protected final String getConfFileContent(String location, TreeItem anItem) { String res = ""; if (location.equalsIgnoreCase("course")) { @@ -125,27 +125,6 @@ return !isSubTreeUsingResource(root, getIdentifier(anItem), anItem); } - @Override - public final boolean synchronizeItemWithResource(TreeItem anItem, - String location) { - String res = loadResource(location, anItem); - - ItemData itemData = getItemData(anItem); - - if (itemData == null) { - itemData = createItemDataInstance(); - setItemData(anItem, itemData); - } - - if (res == null || res.trim().equals("")) { - return false; - } - - itemData.unmarshal(new StringReader(res), anItem); - - return true; - } - protected String getConfFileName(TreeItem anItem) { Resource resource = WebEditor.instance.getManifest().resources .findResourceByIdentifier(getIdentifierRef(anItem)); @@ -157,11 +136,11 @@ protected final void initializeDataForItem(Item anItem) { ItemData itemData = createItemDataInstance(); - String res = loadResource("template", anItem); + //String res = getConfFileContent("template", anItem); - itemData.unmarshal(new StringReader(res), anItem); + //itemData.unmarshal(new StringReader(res), anItem); - setItemData(anItem, itemData); + ItemConfigurationManager.getInstance().update(anItem, itemData); } protected abstract void updateResourceFile(TreeItem anItem); @@ -171,11 +150,7 @@ boolean updateSummaryPages) { updateResourceFile(anItem); - ItemData itemData = getItemData(anItem); - WebEditorServiceClient.getInstance().setFileContent( - getConfFileName(anItem), itemData.marshal(anItem)); - if (updateSummaryPages) { SummaryPageManager.getInstance().updateSummaryPages(); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java 2008-05-29 09:30:08 UTC (rev 178) @@ -1,21 +1,16 @@ package edu.lnu.FireFly.WebEditor.ItemModels.SimpleQuestion; -import java.io.Reader; import java.util.Iterator; -import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; -import org.dom4j.io.SAXReader; -import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.WebEditor.ItemModels.ItemData; public class SimpleQuestionData extends ItemData { @Override - public String marshal(TreeItem anItem) { - Document doc = DocumentHelper.createDocument(); - Element root = doc.addElement("SimpleQuestion"); + public Element marshal() { + Element root = DocumentHelper.createElement("ItemData"); root.addElement("caption").setText(getCaption()); root.addElement("question").setText(getQuestion()); @@ -38,7 +33,7 @@ ansEl.setText(answer.getAnswerText()); } - return doc.asXML(); + return root; } private SimpleQuestionAnswersDataModel answers = new SimpleQuestionAnswersDataModel(); @@ -71,14 +66,8 @@ @Override @SuppressWarnings("unchecked") - public boolean unmarshal(Reader res, TreeItem anItem) { - SAXReader reader = new SAXReader(); - - Document doc = null; + public boolean unmarshal(Element root) { try { - doc = reader.read(res); - - Element root = doc.getRootElement(); Element answers = root.element("answers"); setCaption(root.elementTextTrim("caption")); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageData.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageData.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageData.java 2008-05-29 09:30:08 UTC (rev 178) @@ -1,25 +1,21 @@ package edu.lnu.FireFly.WebEditor.ItemModels.SummaryPageModel; -import java.io.Reader; - -import org.dom4j.Document; import org.dom4j.DocumentHelper; +import org.dom4j.Element; -import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.WebEditor.ItemModels.ItemData; public class SummaryPageData extends ItemData { @Override - public String marshal(TreeItem anItem) { - Document doc = DocumentHelper.createDocument(); - doc.addElement(this.getClass().getSimpleName()); + public Element marshal() { + Element root = DocumentHelper.createElement("ItemData"); - return doc.asXML(); + return root; } @Override - public boolean unmarshal(Reader res, TreeItem anItem) { + public boolean unmarshal(Element root) { // TODO Auto-generated method stub return true; } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java 2008-05-29 09:30:08 UTC (rev 178) @@ -81,10 +81,10 @@ TreeDataModel.getInstance().treeNodesDeleted(anItem); } - @Override - public boolean synchronizeItemWithResource(TreeItem anItem, String location) { - return false; - } +// @Override +// public boolean synchronizeItemWithResource(TreeItem anItem, String location) { +// return false; +// } @Override public boolean updateItemResource(TreeItem item, boolean updateSummaryPages) { Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-28 10:29:19 UTC (rev 177) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-29 09:30:08 UTC (rev 178) @@ -17,9 +17,8 @@ import edu.lnu.FireFly.WebEditor.Data.SummaryPageManager; import edu.lnu.FireFly.WebEditor.GUI.CourseTreePopupMenu; import edu.lnu.FireFly.WebEditor.GUI.TreeDataModel; -import edu.lnu.FireFly.WebEditor.ItemModels.ItemModels; -import edu.lnu.FireFly.WebEditor.ItemModels.OrganizationModel; import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; +import edu.lnu.FireFly.WebEditor.itemConfiguration.ItemConfigurationManager; public class WebEditor extends AppletWithWYSIWYGEditor implements MainMenuListenet { @@ -47,6 +46,8 @@ WebEditorServiceClient.getInstance().setFileContent("imsmanifest.xml", parser.toXML(manifest)); + + ItemConfigurationManager.getInstance().save(); } @Override @@ -59,7 +60,7 @@ .getFileContent("imsmanifest.xml", "course")); TreeDataModel.initInstance(manifest); - ItemModels.synchronizeAllItemDatas(manifest.getRoot()); + ItemConfigurationManager.getInstance().load(); SummaryPageManager.getInstance().setManifest(manifest); AnswersStatusManager.getInstance().resetAllAnswers(); @@ -100,7 +101,7 @@ public void showEmptyDocument() throws MalformedURLException { AppletWithApiHandle.setNextItemIdentifier(""); - getAppletContext().showDocument(new URL("/empty.html"), "ContentFrame"); + getAppletContext().showDocument(new URL(Settings.getInstance().getResourceLocation() + "/empty.html"), "ContentFrame"); System.out.println("redirected to empty page"); } @@ -135,14 +136,9 @@ try { manifest = ManifestFactory.createManifest(); SummaryPageManager.getInstance().setManifest(manifest); - ItemModels.synchronizeAllItemDatas(manifest.getRoot()); + TreeDataModel.initInstance(manifest); - TreeItem root = manifest.getRoot(); - OrganizationModel model = (OrganizationModel) ItemModels - .getModelFromItem(root); - - model.synchronizeItemWithResource(root, "template"); SummaryPageManager.getInstance().updateSummaryPages(); AnswersStatusManager.getInstance().resetAllAnswers(); Added: WebEditor/src/edu/lnu/FireFly/WebEditor/itemConfiguration/ItemConfigurationManager.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/itemConfiguration/ItemConfigurationManager.java (rev 0) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/itemConfiguration/ItemConfigurationManager.java 2008-05-29 09:30:08 UTC (rev 178) @@ -0,0 +1,99 @@ +package edu.lnu.FireFly.WebEditor.itemConfiguration; + +import java.io.StringReader; +import java.util.HashMap; +import java.util.Iterator; + +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import edu.lnu.FireFly.FFManifest.TreeItem; +import edu.lnu.FireFly.WebEditor.ItemModels.ItemData; +import edu.lnu.FireFly.WebEditor.ItemModels.ItemDataFactory; +import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; + +public class ItemConfigurationManager { + protected HashMap<String, ItemData> itemDatas = new HashMap<String, ItemData>(); + + private ItemConfigurationManager() { + } + + private static ItemConfigurationManager obj = null; + + public static ItemConfigurationManager getInstance() { + if (obj == null) { + obj = new ItemConfigurationManager(); + } + + return obj; + } + + public void update(TreeItem anItem, ItemData anItemData) { + itemDatas.put(anItem.getIdentifier(), anItemData); + } + + public ItemData get(TreeItem anItem) { + return itemDatas.get(anItem.getIdentifier()); + } + + @SuppressWarnings("unchecked") + public void load() { + String xml = WebEditorServiceClient.getInstance().getFileContent( + "config.xml", "course"); + + Document document = null; + try { + SAXReader reader = new SAXReader(); + document = reader.read(new StringReader(xml)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + + Element root = document.getRootElement(); + + itemDatas.clear(); + + Iterator<Element> iter = root.elementIterator("ItemData"); + while (iter.hasNext()) { + Element itemDataElement = iter.next(); + ItemData itemData = ItemDataFactory.getInstance().createItemData(itemDataElement.attributeValue("type")); + itemData.unmarshal(itemDataElement); + + itemDatas.put(itemDataElement.attributeValue("id"), itemData); + } + } + + public void save() { + String config = ""; + + Document doc = DocumentHelper.createDocument(); + + Element root = DocumentHelper.createElement("ItemConfigurations"); + doc.add(root); + + String[] keys = new String[itemDatas.size()]; + itemDatas.keySet().toArray(keys); + for (String key : keys) { + ItemData itemData = itemDatas.get(key); + Element itemElement = itemData.marshal(); + + itemElement.add(DocumentHelper.createAttribute(root, "type", + itemData.getClass().getSimpleName())); + itemElement.add(DocumentHelper.createAttribute(root, "id", key)); + + root.add(itemElement); + } + + config = doc.asXML(); + + WebEditorServiceClient.getInstance().setFileContent("config.xml", + config); + } + + public void clear() { + itemDatas.clear(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-05-28 10:29:11
|
Revision: 177 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=177&view=rev Author: Oracle_ Date: 2008-05-28 03:29:19 -0700 (Wed, 28 May 2008) Log Message: ----------- Modified Paths: -------------- ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj ACMServer/branches/sharp tester/tester/Program.cs ACMServer/branches/sharp tester/tester/tester.csproj Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj 2008-05-28 09:14:28 UTC (rev 176) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.vcproj 2008-05-28 10:29:19 UTC (rev 177) @@ -6,7 +6,7 @@ ProjectGUID="{FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}" RootNamespace="SourceTest" Keyword="ManagedCProj" - TargetFrameworkVersion="196613" + TargetFrameworkVersion="131072" > <Platforms> <Platform Modified: ACMServer/branches/sharp tester/tester/Program.cs =================================================================== --- ACMServer/branches/sharp tester/tester/Program.cs 2008-05-28 09:14:28 UTC (rev 176) +++ ACMServer/branches/sharp tester/tester/Program.cs 2008-05-28 10:29:19 UTC (rev 177) @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.IO; using SourceTest; Modified: ACMServer/branches/sharp tester/tester/tester.csproj =================================================================== --- ACMServer/branches/sharp tester/tester/tester.csproj 2008-05-28 09:14:28 UTC (rev 176) +++ ACMServer/branches/sharp tester/tester/tester.csproj 2008-05-28 10:29:19 UTC (rev 177) @@ -10,7 +10,7 @@ <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>tester</RootNamespace> <AssemblyName>tester</AssemblyName> - <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> @@ -32,15 +32,6 @@ </PropertyGroup> <ItemGroup> <Reference Include="System" /> - <Reference Include="System.Core"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Xml.Linq"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Data.DataSetExtensions"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-05-28 09:14:21
|
Revision: 176 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=176&view=rev Author: brus07 Date: 2008-05-28 02:14:28 -0700 (Wed, 28 May 2008) Log Message: ----------- Folders bin and obj added to ignor list Property Changed: ---------------- ACMServer/branches/sharp tester/tester/ Property changes on: ACMServer/branches/sharp tester/tester ___________________________________________________________________ Name: svn:ignore + bin obj This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-05-27 22:57:57
|
Revision: 175 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=175&view=rev Author: brus07 Date: 2008-05-27 15:58:06 -0700 (Tue, 27 May 2008) Log Message: ----------- ?\208?\146?\208?\184?\208?\180?\208?\176?\208?\187?\208?\181?\208?\189?\209?\150 ?\208?\191?\208?\176?\208?\191?\208?\186?\208?\184 bin i obj Removed Paths: ------------- ACMServer/branches/sharp tester/tester/bin/ ACMServer/branches/sharp tester/tester/obj/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-05-27 22:52:59
|
Revision: 174 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=174&view=rev Author: brus07 Date: 2008-05-27 15:53:05 -0700 (Tue, 27 May 2008) Log Message: ----------- ?\208?\146?\208?\184?\208?\180?\208?\176?\208?\187?\208?\181?\208?\189?\208?\176 ?\208?\189?\208?\181?\208?\191?\208?\190?\209?\130?\209?\128?\209?\150?\208?\177?\208?\189?\208?\176 ?\208?\186?\208?\190?\208?\191?\209?\150?\209?\143. ?\208?\160?\208?\190?\208?\177?\208?\190?\209?\135?\208?\176 ?\208?\186?\208?\190?\208?\191?\209?\150?\209?\143 ?\208?\183?\208?\189?\208?\176?\209?\133?\208?\190?\208?\180?\208?\184?\209?\130?\209?\140?\209?\129?\209?\143 ?\208?\178 https://acmcontester.svn.sourceforge.net/svnroot/acmcontester/ACMServer/branches/sharp tester Removed Paths: ------------- ACMServer/branches/Version_2/sharp tester/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-05-27 22:40:17
|
Revision: 173 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=173&view=rev Author: brus07 Date: 2008-05-27 15:40:24 -0700 (Tue, 27 May 2008) Log Message: ----------- ?\208?\159?\208?\181?\209?\128?\208?\181?\208?\188?\209?\150?\209?\129?\209?\130?\208?\184?\208?\178 ?\209?\131 ?\208?\189?\208?\190?\208?\178?\209?\131 ?\208?\179?\209?\150?\208?\187?\208?\186?\209?\131 Added Paths: ----------- ACMServer/branches/sharp tester/ Copied: ACMServer/branches/sharp tester (from rev 172, ACMServer/branches/Version_2/sharp tester) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-05-27 18:21:47
|
Revision: 172 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=172&view=rev Author: Oracle_ Date: 2008-05-27 11:21:33 -0700 (Tue, 27 May 2008) Log Message: ----------- Added Paths: ----------- ACMServer/branches/Version_2/sharp tester/ ACMServer/branches/Version_2/sharp tester/SourceTest/ ACMServer/branches/Version_2/sharp tester/SourceTest/AdvAPI32.Lib ACMServer/branches/Version_2/sharp tester/SourceTest/AssemblyInfo.cpp ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.cpp ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.h ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.vcproj ACMServer/branches/Version_2/sharp tester/SourceTest/Stdafx.cpp ACMServer/branches/Version_2/sharp tester/SourceTest/Stdafx.h ACMServer/branches/Version_2/sharp tester/SourceTest/app.ico ACMServer/branches/Version_2/sharp tester/SourceTest/app.rc ACMServer/branches/Version_2/sharp tester/SourceTest/resource.h ACMServer/branches/Version_2/sharp tester/SourceTest.sln ACMServer/branches/Version_2/sharp tester/tester/ ACMServer/branches/Version_2/sharp tester/tester/Program.cs ACMServer/branches/Version_2/sharp tester/tester/Properties/ ACMServer/branches/Version_2/sharp tester/tester/Properties/AssemblyInfo.cs ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/D7.bat ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Delphi compiler here.txt ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Temp/ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/limits.txt ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/in.txt ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/out.txt ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/in.txt ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/out.txt ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/dcc32.cfg ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/includeD7/ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/includeD7/units for delphi here.txt ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/source.txt ACMServer/branches/Version_2/sharp tester/tester/bin/ ACMServer/branches/Version_2/sharp tester/tester/bin/Debug/ ACMServer/branches/Version_2/sharp tester/tester/bin/Debug/InData.txt ACMServer/branches/Version_2/sharp tester/tester/obj/ ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/ ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/ResolveAssemblyReference.cache ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/TempPE/ ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.csproj.FileListAbsolute.txt ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.exe ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.pdb ACMServer/branches/Version_2/sharp tester/tester/tester.csproj Added: ACMServer/branches/Version_2/sharp tester/SourceTest/AdvAPI32.Lib =================================================================== (Binary files differ) Property changes on: ACMServer/branches/Version_2/sharp tester/SourceTest/AdvAPI32.Lib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: ACMServer/branches/Version_2/sharp tester/SourceTest/AssemblyInfo.cpp =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest/AssemblyInfo.cpp (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest/AssemblyInfo.cpp 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("SourceTest")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("Home")]; +[assembly:AssemblyProductAttribute("SourceTest")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) Home 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; Added: ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.cpp (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.cpp 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,678 @@ +// This is the main DLL file. + +#include "stdafx.h" +#include <stdio.h> +#include "SourceTest.h" + +namespace SourceTest +{ + +char* StrToArr(String^ str) +{ + return (char*)Marshal::StringToHGlobalAnsi(str).ToPointer(); +} + +wchar_t* StrToArrW(String^ str) +{ + return (wchar_t*)Marshal::StringToHGlobalUni(str).ToPointer(); +} + + +void FreeArr(char* buf) +{ + Marshal::FreeHGlobal(IntPtr(buf)); +} + +void FreeArr(wchar_t* buf) +{ + Marshal::FreeHGlobal(IntPtr(buf)); +} + +String^ ToStr(int x) +{ + char intg[15]; + _itoa_s(x,intg,10); + return %String(intg); +} + + +bool FileExists(String^ path) +{ + char* buf=StrToArr(path); + OFSTRUCT of; + ZeroMemory(&of,sizeof(of)); + of.cBytes=sizeof(of); + bool res=(OpenFile(buf,&of,OF_EXIST)!=HFILE_ERROR); + FreeArr(buf); + return res; +} + +TSource::TSource() +{ +FSrc=gcnew String(""); +FExePath=gcnew String(""); +FProblemPath=gcnew String(""); +FState=ssNone; +FCompPath=gcnew String(""); +FRunAll=true; +init(); +} + +TSource::~TSource() +{ +final(); +} + +void TSource::CheckCL() +{ + HMODULE lib=NULL; + try + { + lock(); + lib=LoadLibrary((LPCWSTR)"CheckCodeLimitDLL"); + if (lib==NULL) + { + if (FSrc->Length>FLim.CodeLimit) + { + FCompResult.res=crCL; + FCompResult.Details+="Used std checker for Code Limit\n"; + } + } else + { + TCheckCL prc=(TCheckCL)GetProcAddress(lib,"CheckCL"); + String^ buf; + if (prc(FSrc,buf)) FCompResult.res=crCL; + FCompResult.Details+=buf; + } + FState=ssCheckedCL; + }__finally + { + if (lib!=NULL) + FreeLibrary(lib); + unlock(); + } +} + +void TSource::CheckDF() +{ + try + { + lock(); + //MAIN SOURCE + FState=ssCheckedDF; + }__finally + { + unlock(); + } +} + +void TSource::Compile() +{ + PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); + STARTUPINFO si; ZeroMemory(&si,sizeof(si)); + SECURITY_ATTRIBUTES sec; + sec.bInheritHandle=true; + sec.lpSecurityDescriptor=NULL; + sec.nLength=sizeof(sec); + char* bufA; + wchar_t* bufW; + try + { + lock(); + String^ srcpath=gcnew String(FTempPath+"source.txt"); + String^ outpath=gcnew String(FTempPath+"compoutput.txt"); + FExePath=FTempPath+"source.exe"; + + if (FileExists(FExePath)) + { + DeleteFile((LPCTSTR)(bufW=StrToArrW(FExePath))); + FreeArr(bufW); + } + + si.cb=sizeof(si); + si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; + si.wShowWindow=FALSE; + si.hStdOutput=CreateFile(bufW=StrToArrW(outpath),GENERIC_WRITE,0,&sec,CREATE_ALWAYS,0,NULL); + FreeArr(bufW); + HANDLE src=CreateFile(bufW=StrToArrW(srcpath),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); + FreeArr(bufW); + DWORD len; + WriteFile(src,bufA=StrToArr(FSrc),FSrc->Length,&len,NULL); + FreeArr(bufA); + CloseHandle(src); + + Sleep(100); //waiting for file to flush on hard + + DWORD start=GetTickCount(); + bufW=StrToArrW("\""+FCompPath+"\" \""+srcpath+"\" \""+FTempPath); + if (!CreateProcess(NULL,bufW,&sec,&sec,true,CREATE_NEW_CONSOLE|CREATE_NO_WINDOW,NULL,NULL,&si,&pi)) + { + FreeArr(bufW); + FCompResult.res=crIE; + FCompResult.Details+="Can not run the compiler\n"; + return; + } + FreeArr(bufW); + if (WaitForSingleObject(pi.hProcess,FLim.CompilationTimeLimit)==WAIT_TIMEOUT) + { + TerminateProcess(pi.hProcess,0); + FCompResult.res=crCTL; + FCompResult.UsedTime=FLim.CompilationTimeLimit; + FCompResult.Details+="Time out during compilation\n"; + return; + } + FCompResult.UsedTime=GetTickCount()-start; + + Sleep(100); //waiting for creating the file + CloseHandle(si.hStdOutput); + + HANDLE oup=CreateFile(bufW=StrToArrW(outpath),GENERIC_READ,0,&sec,OPEN_EXISTING,0,NULL); + FreeArr(bufW); + DWORD size=GetFileSize(oup,NULL); + char* compres=new char[size+2]; compres[size+1]='\0'; + ReadFile(oup,compres,size,&len,NULL); + CloseHandle(oup); + + if (!FileExists(FExePath)) + { + FCompResult.res=crCE; + FCompResult.Details+=gcnew String("EXE file not found\n")+gcnew String(compres); + delete[] compres; + return; + } + + FCompResult.Details+=gcnew String(compres); + delete[] compres; + + }__finally + { + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + FState=ssCompiled; + unlock(); + } +} + +void TSource::RunTests() +{ +try +{ + lock(); + int n=1; + while (FileExists(FProblemPath+"test"+ToStr(n)+"\\in.txt")||FileExists(FProblemPath+"test"+ToStr(n)+"\\out.txt")||FileExists(FProblemPath+"test"+ToStr(n)+"\\points.txt")) + { + RunTest(n); + FSummary.res->points+=((TResult^)FRes[n-1])->points; + FSummary.res->UsedMemory=max(((TResult^)FRes[n-1])->UsedMemory,FSummary.res->UsedMemory); + FSummary.res->UsedTime=max(((TResult^)FRes[n-1])->UsedTime,FSummary.res->UsedTime); + FSummary.res->UsedRealTime=max(((TResult^)FRes[n-1])->UsedRealTime,FSummary.res->UsedRealTime); + if (((TResult^)FRes[n-1])->res!=trAC) + { + FSummary.res->res=((TResult^)FRes[n-1])->res; + if (!FRunAll) break; + } + n++; + } +}__finally +{ + FState=ssFinish; + unlock(); +} +} + +void TSource::LoadTest(int index,TTest% test) +{ +FILE* inp,*oup,*points; +char *bufA; +try +{ + lock(); + test.input=""; + test.output=""; + test.points=1; + + if (fopen_s(&inp,bufA=StrToArr(FProblemPath+"test"+ToStr(index)+"\\in.txt"),"rt")==0) + { + fseek(inp,0,SEEK_END); + int size=ftell(inp); + fseek(inp,0,SEEK_SET); + char* buf=new char[size+1];ZeroMemory(buf,(size+1)*sizeof(char)); + fread(buf,sizeof(char),size,inp); + test.input=gcnew String(buf); + } + FreeArr(bufA); + + if (fopen_s(&oup,bufA=StrToArr(FProblemPath+"\\test"+ToStr(index)+"\\out.txt"),"rt")==0) + { + fseek(oup,0,SEEK_END); + int size=ftell(inp); + fseek(oup,0,SEEK_SET); + char* buf=new char[size+1];ZeroMemory(buf,(size+1)*sizeof(char)); + fread(buf,sizeof(char),size,oup); + test.output=gcnew String(buf); + } + FreeArr(bufA); + + if (fopen_s(&points,bufA=StrToArr(FProblemPath+"\\test"+ToStr(index)+"\\points.txt"),"rt")==0) + { + fscanf_s(points,"%d",&test.points); + } + FreeArr(bufA); + +}__finally +{ + if (inp!=NULL) + fclose(inp); + if (oup!=NULL) + fclose(oup); + if (points!=NULL) + fclose(points); + unlock(); +} +} + +TCheckAnsRes TSource::CheckAnswer(int index,String^ output) +{ + HMODULE lib=NULL; + try + { + lock(); + TTest t; + LoadTest(index,t); + lib=LoadLibrary((LPCWSTR)"CheckAnswerDLL"); + if (lib==NULL) + { + if (output!=t.output) + return carWA; + return carAC; + } else + { + TCheckAnswer prc=(TCheckAnswer)GetProcAddress(lib,"CheckAnswer"); + return prc(t.input,output,t.output); + } + }__finally + { + if (lib!=NULL) + FreeLibrary(lib); + unlock(); + } +} + +void TSource::ProcessAll() +{ +CheckCL(); +if (FCompResult.res==crOK) + CheckDF(); else + return ; +if (FCompResult.res==crOK) + Compile(); else + return ; +(*FSummary.compres)=FCompResult; +if (FCompResult.res==crOK) + RunTests(); else + return ; +} + +BOOL DelPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) +{ +TOKEN_PRIVILEGES tp; +LUID luid; +if (!LookupPrivilegeValue( NULL,lpszPrivilege,&luid)) + return FALSE; +tp.PrivilegeCount = 1; +tp.Privileges[0].Luid = luid; +tp.Privileges[0].Attributes = SE_PRIVILEGE_REMOVED; + +if ( !AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),(PTOKEN_PRIVILEGES) NULL,(PDWORD) NULL) ) + return FALSE; +if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) + return FALSE; + +return TRUE; +} + + + +void DeletePrivileges(HANDLE proc) +{ + HANDLE hToken; + try + { + OpenProcessToken(proc,TOKEN_ALL_ACCESS,&hToken); + DelPrivilege(hToken,SE_ASSIGNPRIMARYTOKEN_NAME); + DelPrivilege(hToken,SE_AUDIT_NAME); + DelPrivilege(hToken,SE_BACKUP_NAME); + DelPrivilege(hToken,SE_CHANGE_NOTIFY_NAME); + DelPrivilege(hToken,SE_CREATE_GLOBAL_NAME); + DelPrivilege(hToken,SE_CREATE_PAGEFILE_NAME); + DelPrivilege(hToken,SE_CREATE_PERMANENT_NAME); + DelPrivilege(hToken,SE_CREATE_SYMBOLIC_LINK_NAME); + DelPrivilege(hToken,SE_CREATE_TOKEN_NAME); + DelPrivilege(hToken,SE_DEBUG_NAME); + DelPrivilege(hToken,SE_ENABLE_DELEGATION_NAME); + DelPrivilege(hToken,SE_IMPERSONATE_NAME); + DelPrivilege(hToken,SE_INC_BASE_PRIORITY_NAME); + DelPrivilege(hToken,SE_INCREASE_QUOTA_NAME); + DelPrivilege(hToken,SE_INC_WORKING_SET_NAME); + DelPrivilege(hToken,SE_LOAD_DRIVER_NAME); + DelPrivilege(hToken,SE_LOCK_MEMORY_NAME); + DelPrivilege(hToken,SE_MACHINE_ACCOUNT_NAME); + DelPrivilege(hToken,SE_MANAGE_VOLUME_NAME); + DelPrivilege(hToken,SE_PROF_SINGLE_PROCESS_NAME); + DelPrivilege(hToken,SE_RELABEL_NAME); + DelPrivilege(hToken,SE_REMOTE_SHUTDOWN_NAME); + DelPrivilege(hToken,SE_RESTORE_NAME); + DelPrivilege(hToken,SE_SECURITY_NAME); + DelPrivilege(hToken,SE_SHUTDOWN_NAME); + DelPrivilege(hToken,SE_SYNC_AGENT_NAME); + DelPrivilege(hToken,SE_SYSTEM_ENVIRONMENT_NAME); + DelPrivilege(hToken,SE_SYSTEM_PROFILE_NAME); + DelPrivilege(hToken,SE_SYSTEMTIME_NAME); + DelPrivilege(hToken,SE_TAKE_OWNERSHIP_NAME); + DelPrivilege(hToken,SE_TCB_NAME); + DelPrivilege(hToken,SE_TIME_ZONE_NAME); + DelPrivilege(hToken,SE_TRUSTED_CREDMAN_ACCESS_NAME); + DelPrivilege(hToken,SE_UNDOCK_NAME); + DelPrivilege(hToken,SE_UNSOLICITED_INPUT_NAME); + }__finally + { + CloseHandle(hToken); + } +} + +void TSource::RunTest(int index) +{ +PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); +STARTUPINFO si;ZeroMemory(&si,sizeof(si)); +SECURITY_ATTRIBUTES sec; +sec.bInheritHandle=TRUE; +sec.nLength=sizeof(sec); +sec.lpSecurityDescriptor=NULL; +JOBOBJECT_BASIC_ACCOUNTING_INFORMATION acc; +JOBOBJECT_EXTENDED_LIMIT_INFORMATION mem; +HANDLE job; +JOBOBJECT_ASSOCIATE_COMPLETION_PORT port; +JOBOBJECT_BASIC_UI_RESTRICTIONS uilim; +DWORD len=0; +wchar_t* bufW; +char* bufA; +try +{ + lock(); + FRes.Add(%TResult()); + TResult^ it=(TResult^)FRes[FRes.Count-1]; + it->res=trAC; + it->points=0; + it->Details=""; + it->UsedMemory=-1; + it->UsedRealTime=-1; + it->UsedTime=-1; + String^ inpath=FProblemPath+"test"+ToStr(index)+"\\in.txt"; + String^ oupath=FTempPath+"out.txt"; + String^ erpath=FTempPath+"err.txt"; + String^ pointpath=FProblemPath+"test"+ToStr(index)+"\\points.txt"; + + FState=ssIsRunning; + + TTest t; + LoadTest(index,t); + job=CreateJobObject(NULL,(LPWSTR)""); + si.cb=sizeof(si); + si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; + si.wShowWindow=FALSE; + si.hStdInput=CreateFile(bufW=StrToArrW(inpath),GENERIC_READ,0,&sec,OPEN_EXISTING,0,NULL); FreeArr(bufW); + si.hStdOutput=CreateFile(bufW=StrToArrW(oupath),GENERIC_WRITE,0,&sec,CREATE_ALWAYS,0,NULL); FreeArr(bufW); + si.hStdError=CreateFile(bufW=StrToArrW(erpath),GENERIC_WRITE,0,&sec,CREATE_ALWAYS,0,NULL); FreeArr(bufW); + + SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); + + if (!CreateProcess(NULL,bufW=StrToArrW(FExePath),NULL,NULL,TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW,NULL,NULL,&si,&pi)) + { + FreeArr(bufW); + it->points=0; + int err=GetLastError(); + if ((err==193)||(err==1455)) + { + it->res=trRE; + it->Details="Too large array"; + } else + { + it->res=trIE; + it->Details="Can not start process"; + } + return ; + } + FreeArr(bufW); + mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_PROCESS_MEMORY; + mem.ProcessMemoryLimit=FLim.MemoryLimit; + SetInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem)); + + port.CompletionKey=(void*)123; + port.CompletionPort=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); + + SetInformationJobObject(job,JobObjectAssociateCompletionPortInformation,&port,sizeof(port)); + + uilim.UIRestrictionsClass=JOB_OBJECT_UILIMIT_ALL; + SetInformationJobObject(job,JobObjectBasicUIRestrictions,&uilim,sizeof(uilim)); + + DeletePrivileges(pi.hProcess); + + AssignProcessToJobObject(job,pi.hProcess); + ResumeThread(pi.hThread); + + DWORD start=GetTickCount(); + + while (true) + { + if ((int)GetFileSize(si.hStdOutput,NULL)>FLim.OutputLimit) + { + TerminateJobObject(job,0); + it->res=trOL; + it->Details="Size of output file excided OutputLimit"; + break; + } + if ((int)(GetTickCount()-start)>FLim.RealTimeLimit) + { + TerminateJobObject(job,0); + it->res=trRTL; + it->Details="Real time limit"; + break; + } + QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); + if ((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)>FLim.TimeLimit*10000) + { + TerminateJobObject(job,0); + it->res=trTL; + it->Details="Time Limit"; + break; + } + + unsigned long len,key; + HANDLE proc; + if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)&&key == 123) + { + DWORD code=0; + bool needbreak=false; + switch(len) + { + case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: + GetExitCodeProcess(pi.hProcess,&code); + if (code!=0) + { + it->res=trRE; + it->Details="Runtime error #"+ToStr((int)code); + } + needbreak=true; + break; + case JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: + it->res=trML; + it->Details="Memory Limit"; + needbreak=true; + break; + case JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: + GetExitCodeProcess(pi.hProcess,&code); + if (code!=0) + { + it->res=trRE; + it->Details="Runtime error #"+ToStr((int)code); + } + needbreak=true; + break; + } + if (needbreak) + { + TerminateJobObject(job,0); + break; + } + } + + Sleep(1); + } + CloseHandle(si.hStdOutput); + CloseHandle(si.hStdInput); + + Sleep(100); //waiting for file + + QueryInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem),NULL); + QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); + it->UsedMemory=mem.PeakProcessMemoryUsed; + it->UsedTime=(int)((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)/10000); + it->UsedRealTime=GetTickCount()-start; + if (it->res!=trAC) return; + + if (!FileExists(oupath)) + { + it->res=trWA; + it->Details="No output file"; + return; + } + + HANDLE ouf=CreateFile(bufW=StrToArrW(oupath),GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); FreeArr(bufW); + DWORD size=GetFileSize(ouf,NULL); + char* buf=new char[size+1]; ZeroMemory(buf,(size+1)*sizeof(char)); + ReadFile(ouf,buf,size,&len,NULL); + CloseHandle(ouf); + + TCheckAnsRes r=CheckAnswer(index,gcnew String(buf)); + delete[] buf; + if (r==carAC) + { + if (FileExists(pointpath)) + { + FILE* point; + fopen_s(&point,bufA=StrToArr(pointpath),"rt"); FreeArr(bufA); + fscanf_s(point,"%d",&it->points); + fclose(point); + } else it->points=1; + return ; + } + + switch (r) + { + case carOE: + it->res=trOE; + break; + case carPE: + it->res=trPE; + break; + case carWA: + it->res=trWA; + break; + case carIE: + it->res=trIE; + break; + }; + +}__finally +{ + CloseHandle(job); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + CloseHandle(si.hStdInput); + CloseHandle(si.hStdOutput); + CloseHandle(si.hStdError); + CloseHandle(port.CompletionPort); + FState=ssTestComplete; + if (FTestHandler) + FTestHandler(index,(TResult^)FRes[index-1]); + unlock(); +} +} + +void TSource::ProcessTest(int index) +{ +CheckCL(); +if (FCompResult.res==crOK) + CheckDF(); else + return ; +if (FCompResult.res==crOK) + Compile(); else + return ; +(*FSummary.compres)=FCompResult; +if (FCompResult.res==crOK) + RunTest(index); else + return ; +} + +void TSource::LoadLimits() +{ + String^ path=FProblemPath+"Limits.txt"; + if (!FileExists(path)) + return; + char* buf; + FILE* f; + try + { + lock(); + if (FState!=ssNone) + { + throw "Can not load limits if state is higher than ssNone"; + return; + } + fopen_s(&f,buf=StrToArr(path),"rt"); + fscanf_s(f,"CodeLimit: %d\nCompilationTimeLimit: %d\nMemoryLimit: %d\n",&FLim.CodeLimit,&FLim.CompilationTimeLimit,&FLim.MemoryLimit); + fscanf_s(f,"OutputLimit: %d\nRealTimeLimit: %d\nTimeLimit: %d",&FLim.OutputLimit,&FLim.RealTimeLimit,&FLim.TimeLimit); + }__finally + { + fclose(f); + FreeArr(buf); + unlock(); + } + +} + +String^ TSource::TestResultToString(TRes res) +{ + switch (res) + { + case trAC:return "Accepted"; + case trWA:return "Wrong Answer"; + case trTL:return "Time Limit"; + case trML:return "Memory Limit"; + case trRTL:return "Real Time Limit"; + case trRE:return "Runtime Error"; + case trDF:return "Destricted Function"; + case trIE:return "Internal Error"; + case trOL:return "Output Limit"; + case trPE:return "Presentation Error"; + case trOE:return "Output Error"; + default:return "Unknown Error"; + } +} + +String^ TSource::CompileResultToString(TCompRes res) +{ + switch (res) + { + case crOK:return "No Error"; + case crCE:return "Compilation Error"; + case crCL:return "Code Limit"; + case crCTL:return "Compilation Time Limit"; + case crDF:return "Destricted Function"; + case crIE:return "Internal Error"; + default:return "Unknown Error"; + } +} + +}; + Added: ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.h (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.h 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,552 @@ +// SourceTest.h + +#pragma once +#include <windows.h> +using namespace System; +using namespace System::Collections; +using namespace System::Runtime::InteropServices; + +namespace SourceTest +{ + public ref struct TLimits + { + int OutputLimit; + int TimeLimit; + int MemoryLimit; + int RealTimeLimit; + int CompilationTimeLimit; + int CodeLimit; + + TLimits() + { + OutputLimit=0; + TimeLimit=0; + MemoryLimit=0; + RealTimeLimit=0; + CompilationTimeLimit=0; + CodeLimit=0; + } + + TLimits(TLimits% value) + { + OutputLimit=value.OutputLimit; + TimeLimit=value.TimeLimit; + MemoryLimit=value.MemoryLimit; + RealTimeLimit=value.RealTimeLimit; + CompilationTimeLimit=value.CompilationTimeLimit; + CodeLimit=value.CodeLimit; + } + + TLimits operator=(TLimits value) + { + OutputLimit=value.OutputLimit; + TimeLimit=value.TimeLimit; + MemoryLimit=value.MemoryLimit; + RealTimeLimit=value.RealTimeLimit; + CompilationTimeLimit=value.CompilationTimeLimit; + CodeLimit=value.CodeLimit; + return value; + } + }; + + public enum TCompRes //result of compilation + { + crOK, //all ok + crCE, //compilation error + crCL, //code limit + crCTL, //compilation time limit + crDF, //destricted function + crIE //internal error + }; + + public enum TRes + { + trAC, //accepted + trWA, //wrong answer + trTL, //time limit + trML, //memory limit + trRTL,//real time limit + trRE, //runtime error + trDF, //destricted function + trIE, //internal error + trOL, //output limit + trPE, //presentation error + trOE //output error + }; + + public ref struct TResult + { + TRes res; + int points; + int UsedMemory; + int UsedTime; + int UsedRealTime; + String^ Details; + + TResult() + { + res=trAC; + points=0; + UsedMemory=0; + UsedTime=0; + UsedRealTime=0; + Details=""; + } + + TResult(TResult% value) + { + res=value.res; + points=value.points; + UsedMemory=value.UsedMemory; + UsedTime=value.UsedTime; + UsedRealTime=value.UsedRealTime; + Details=value.Details; + } + + TResult operator=(TResult value) + { + res=value.res; + points=value.points; + UsedMemory=value.UsedMemory; + UsedTime=value.UsedTime; + UsedRealTime=value.UsedRealTime; + Details=value.Details; + return value; + } + }; + + public ref struct TCompResult + { + TCompRes res; + int UsedTime; + String^ Details; + TCompResult(TCompResult% value) + { + res=value.res; + UsedTime=value.UsedTime; + Details=value.Details; + } + + TCompResult() + { + res=crOK; + UsedTime=0; + Details=""; + } + + TCompResult operator=(TCompResult value) + { + res=value.res; + UsedTime=value.UsedTime; + Details=value.Details; + return value; + } + }; + + public enum TSourceState + { + ssNone=0, + ssCheckedCL=1, + ssCheckedDF=2, + ssCompiled=3, + ssIsRunning=4, //for multithreading + ssTestComplete=5, //next test is gonna be tested + ssFinish=6 //all tests is tested + }; + + public ref struct TSummary + { + public: + TResult^ res; //total result of all tests + TCompResult^ compres; //result of compilation + TSummary() + { + res=gcnew TResult(); + compres=gcnew TCompResult(); + } + + TSummary(TSummary% value) + { + (*res)=(*value.res); + (*compres)=(*value.compres); + } + + }; + + public ref struct TTest + { + String^ input,^output; + int points; + }; + + public enum TCheckAnsRes + { + carAC, //accepted + carWA, //wrong answer + carIE, //internal error + carPE, //presentation error + carOE //output error + }; + + typedef bool (*TCheckCL)(String^ src,String^ details); + typedef TCheckAnsRes (*TCheckAnswer)(String^ input, String^ output, String^ rightoutput); + + public delegate void TTestHandler(int index, TResult^ res); + + public ref class TSource + { + private: + String^ FSrc; + String^ FExePath; + String^ FProblemPath; + String^ FCompPath; + String^ FTempPath; //this is the place were temp files will be created + bool FRunAll; + TSourceState FState; + TCompResult FCompResult; + ArrayList FRes; + TSummary FSummary; + TLimits FLim; + TTestHandler^ FTestHandler; + + CRITICAL_SECTION* cs; //for multithreading + void init() + { + cs=new CRITICAL_SECTION; + InitializeCriticalSection(cs); + } + + void lock() + { + EnterCriticalSection(cs); + } + + void unlock() + { + LeaveCriticalSection(cs); + } + + void final() + { + DeleteCriticalSection(cs); + delete cs; + } + public: + TSource(); + ~TSource(); + void CheckCL(); + void CheckDF(); + void Compile(); + void RunTests(); //all tests + void RunTest(int index); + TCheckAnsRes CheckAnswer(int index,String^ output); + void ProcessAll(); //gets result for all tests + void ProcessTest(int index); //gets result for only 1 test + void LoadTest(int index,TTest% test); + void LoadLimits(); //loads limits from a file Limits.txt + static String^ TestResultToString(TRes res); + static String^ CompileResultToString(TCompRes res); + + property TLimits^ Lim + { + void set(TLimits^ value) + { + try + { + lock(); + if (FState>=ssIsRunning) + { + throw "Can not set limits if state is ssIsRunning or higher"; + return ; + } + FLim=(*value); + } + __finally { + unlock(); + } + } + } + + property String^ Src + { + String^ get() + { + try + { + lock(); + return FSrc; + }__finally { + unlock(); + } + } + + void set(String^ value) + { + try + { + lock(); + if (FState!=ssNone) + { + throw "Can not set source unless state is ssNone"; + return; + } + FSrc=value; + } __finally { + unlock(); + } + } + } + + property String^ ExePath + { + String^ get() + { + try + { + lock(); + if (FState<ssCompiled) + { + throw "Can not get exepath unless state is ssCompiled or higher"; + return ""; + } + return FExePath; + }__finally{ + unlock(); + } + } + } + + property String^ ProblemPath + { + String^ get() { + try + { + lock(); + return FProblemPath; + }__finally { + unlock(); + } + } + void set(String^ value) + { + try{ + lock(); + if (FState>ssCompiled) + { + throw "Can not set problempath if state is ssIsRunning or higher"; + return ; + } + FProblemPath=value; + }__finally { + unlock(); + } + } + } + + property TCompResult^ CompResult + { + TCompResult^ get() + { + try + { + lock(); + if (FState==ssNone) + { + throw "Can not get compresult if state is ssNone"; + return %FCompResult; + } + return %FCompResult; + }__finally { + unlock(); + } + } + } + + property TSourceState State + { + TSourceState get() { + try + { + lock(); + return (FState); + }__finally { + unlock(); + } + }; + + void set(TSourceState value) { + try + { + lock(); + FState=(value); + }__finally { + unlock(); + } + }; + } + + property TResult^ Results[int] + { + TResult^ get(int index) + { + try + { + lock(); + if (FState<ssIsRunning) + { + throw "Can not get test results if state is lower than ssIsRunning"; + return (%TResult()); + } + if (index>=FRes.Count) + { + throw "The index is not accesible"; + return (%TResult()); + } + return (TResult^)FRes[index]; + } + __finally + { + unlock(); + } + } + } + + property TSummary^ Summary + { + TSummary^ get() + { + try + { + lock(); + if (FState!=ssFinish) + { + throw "Can not get summary unlest state is ssFinish"; + return (%TSummary()); + } + return (%FSummary); + }__finally + { + unlock(); + } + }; + } + + property TTestHandler^ TestHandler + { + TTestHandler^ get() + { + try + { + lock(); + return FTestHandler; + }__finally + { + unlock(); + } + } + + void set(TTestHandler^ value) + { + try + { + lock(); + FTestHandler=value; + }__finally + { + unlock(); + } + } + } + + property String^ CompPath + { + String^ get() + { + try + { + lock(); + return (FCompPath); + }__finally + { + unlock(); + } + } + + void set(String^ value) + { + try + { + lock(); + if (FState>ssCheckedDF) + { + throw "Can not set compiler path if state is higher than ssCheckedDF"; + return ; + } + FCompPath=value; + }__finally + { + unlock(); + } + } + } + + property String^ TempPath + { + String^ get() + { + try + { + lock(); + return FTempPath; + }__finally + { + unlock(); + } + } + + void set(String^ value) + { + try + { + lock(); + FTempPath=value; + }__finally + { + unlock(); + } + } + } + + property bool RunAll + { + void set(bool value) + { + try + { + lock(); + if (FState>=ssIsRunning) + { + throw "Can not set RunAll if state is higher or equal ssIsRunning"; + return; + } + FRunAll=value; + } __finally + { + unlock(); + } + } + + bool get() + { + try + { + lock(); + return FRunAll; + }__finally + { + unlock(); + } + } + } + }; +} Added: ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.vcproj =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.vcproj (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest/SourceTest.vcproj 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,252 @@ +<?xml version="1.0" encoding="windows-1251"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="SourceTest" + ProjectGUID="{FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}" + RootNamespace="SourceTest" + Keyword="ManagedCProj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + ManagedExtensions="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG" + RuntimeLibrary="3" + UsePrecompiledHeader="2" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="$(NoInherit)" + LinkIncremental="2" + GenerateDebugInformation="true" + AssemblyDebug="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + ManagedExtensions="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG" + RuntimeLibrary="2" + UsePrecompiledHeader="2" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="$(NoInherit)" + LinkIncremental="1" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + <AssemblyReference + RelativePath="System.dll" + AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" + MinFrameworkVersion="131072" + /> + <AssemblyReference + RelativePath="System.Data.dll" + AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86" + MinFrameworkVersion="131072" + /> + <AssemblyReference + RelativePath="System.XML.dll" + AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" + MinFrameworkVersion="131072" + /> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\AssemblyInfo.cpp" + > + </File> + <File + RelativePath=".\SourceTest.cpp" + > + </File> + <File + RelativePath=".\Stdafx.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1" + /> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\resource.h" + > + </File> + <File + RelativePath=".\SourceTest.h" + > + </File> + <File + RelativePath=".\Stdafx.h" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + <File + RelativePath=".\app.ico" + > + </File> + <File + RelativePath=".\app.rc" + > + </File> + </Filter> + <File + RelativePath=".\AdvAPI32.Lib" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: ACMServer/branches/Version_2/sharp tester/SourceTest/Stdafx.cpp =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest/Stdafx.cpp (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest/Stdafx.cpp 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// SourceTest.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" Added: ACMServer/branches/Version_2/sharp tester/SourceTest/Stdafx.h =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest/Stdafx.h (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest/Stdafx.h 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,7 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#pragma once + + Added: ACMServer/branches/Version_2/sharp tester/SourceTest/app.ico =================================================================== (Binary files differ) Property changes on: ACMServer/branches/Version_2/sharp tester/SourceTest/app.ico ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: ACMServer/branches/Version_2/sharp tester/SourceTest/app.rc =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest/app.rc (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest/app.rc 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 25, 1 +#pragma code_page(1251) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + Added: ACMServer/branches/Version_2/sharp tester/SourceTest/resource.h =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest/resource.h (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest/resource.h 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc Added: ACMServer/branches/Version_2/sharp tester/SourceTest.sln =================================================================== --- ACMServer/branches/Version_2/sharp tester/SourceTest.sln (rev 0) +++ ACMServer/branches/Version_2/sharp tester/SourceTest.sln 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SourceTest", "SourceTest\SourceTest.vcproj", "{FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tester", "tester\tester.csproj", "{2D663DAB-3573-4CB6-95A0-2425635CFEC3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Win32.ActiveCfg = Debug|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Win32.Build.0 = Debug|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Any CPU.ActiveCfg = Release|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Mixed Platforms.Build.0 = Release|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Win32.ActiveCfg = Release|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Win32.Build.0 = Release|Win32 + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Win32.ActiveCfg = Debug|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Any CPU.Build.0 = Release|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Win32.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: ACMServer/branches/Version_2/sharp tester/tester/Program.cs =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/Program.cs (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/Program.cs 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using SourceTest; + +namespace tester +{ + class Program + { + static void func(int x,TResult res) + { + Console.WriteLine("test number {0}, result: {1}, details: {2}",x,TSource.TestResultToString(res.res),res.Details); + } + + static void Main(string[] args) + { + TSource c = new TSource(); + StreamReader s = new StreamReader("InData.txt",Encoding.Default); + String compiler = s.ReadLine(); + String problem = s.ReadLine(); + String temp = s.ReadLine(); + String source = s.ReadLine(); + s.Close(); + s=File.OpenText(source); + c.CompPath = compiler; + c.ProblemPath = problem; + c.LoadLimits(); + c.Src = s.ReadToEnd(); + s.Close(); + c.TempPath = temp; + c.TestHandler += new TTestHandler(func); + c.ProcessAll(); + c.State = (TSourceState)6; + Console.WriteLine("Compile result: {0}\nCompilation details: {1}\nUsed Time for compile: {2}", TSource.CompileResultToString(c.Summary.compres.res),c.Summary.compres.Details,c.Summary.compres.UsedTime); + Console.WriteLine("Test result: {0}", TSource.TestResultToString(c.Summary.res.res)); + Console.WriteLine("Points: {0}", c.Summary.res.points); + Console.WriteLine("Used Time: {0}", c.Summary.res.UsedTime); + Console.WriteLine("Used Memory: {0}", c.Summary.res.UsedMemory); + Console.WriteLine("Used Real Time: {0}", c.Summary.res.UsedRealTime); + Console.ReadKey(); + } + } +} Added: ACMServer/branches/Version_2/sharp tester/tester/Properties/AssemblyInfo.cs =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/Properties/AssemblyInfo.cs (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/Properties/AssemblyInfo.cs 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("tester")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Home")] +[assembly: AssemblyProduct("tester")] +[assembly: AssemblyCopyright("Copyright © Home 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9fa887d8-5904-4045-ba4d-c33714e900b8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/D7.bat =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/D7.bat (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/D7.bat 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1 @@ +DCC32.EXE -CC %1 -E%2 \ No newline at end of file Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Delphi compiler here.txt =================================================================== Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/limits.txt =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/limits.txt (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/limits.txt 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,6 @@ +CodeLimit: 1024 +CompilationTimeLimit: 10000 +MemoryLimit: 10000000 +OutputLimit: 1024 +RealTimeLimit: 10000 +TimeLimit: 1000 Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/in.txt =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/in.txt (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/in.txt 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1 @@ +1 1 Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/out.txt =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/out.txt (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test1/out.txt 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1 @@ +2 \ No newline at end of file Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/in.txt =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/in.txt (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/in.txt 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/out.txt =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/out.txt (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/Test/test2/out.txt 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/dcc32.cfg =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/dcc32.cfg (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/dcc32.cfg 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1 @@ +-u"includeD7" Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/includeD7/units for delphi here.txt =================================================================== Added: ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/source.txt =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/source.txt (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/SAMPLE/source.txt 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,8 @@ +program hello; +uses windows; +var a,b:integer; +begin +read(a,b); +while true do; +write(a+b); +end. \ No newline at end of file Added: ACMServer/branches/Version_2/sharp tester/tester/bin/Debug/InData.txt =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/bin/Debug/InData.txt (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/bin/Debug/InData.txt 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,4 @@ +SourceTest\tester\SAMPLE\D7.bat +SourceTest\tester\SAMPLE\Test\ +SourceTest\tester\SAMPLE\Temp\ +SourceTest\tester\SAMPLE\source.txt Added: ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/ResolveAssemblyReference.cache =================================================================== (Binary files differ) Property changes on: ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/ResolveAssemblyReference.cache ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.csproj.FileListAbsolute.txt =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.csproj.FileListAbsolute.txt (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.csproj.FileListAbsolute.txt 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,7 @@ +D:\Пашка\ACM contester\ACM Contester\SourceTest\tester\obj\Debug\ResolveAssemblyReference.cache +D:\Пашка\ACM contester\ACM Contester\SourceTest\tester\bin\Debug\tester.exe +D:\Пашка\ACM contester\ACM Contester\SourceTest\tester\bin\Debug\tester.pdb +D:\Пашка\ACM contester\ACM Contester\SourceTest\tester\bin\Debug\SourceTest.dll +D:\Пашка\ACM contester\ACM Contester\SourceTest\tester\bin\Debug\SourceTest.pdb +D:\Пашка\ACM contester\ACM Contester\SourceTest\tester\obj\Debug\tester.exe +D:\Пашка\ACM contester\ACM Contester\SourceTest\tester\obj\Debug\tester.pdb Added: ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.exe =================================================================== (Binary files differ) Property changes on: ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.exe ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.pdb =================================================================== (Binary files differ) Property changes on: ACMServer/branches/Version_2/sharp tester/tester/obj/Debug/tester.pdb ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: ACMServer/branches/Version_2/sharp tester/tester/tester.csproj =================================================================== --- ACMServer/branches/Version_2/sharp tester/tester/tester.csproj (rev 0) +++ ACMServer/branches/Version_2/sharp tester/tester/tester.csproj 2008-05-27 18:21:33 UTC (rev 172) @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.21022</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{2D663DAB-3573-4CB6-95A0-2425635CFEC3}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>tester</RootNamespace> + <AssemblyName>tester</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\SourceTest\SourceTest.vcproj"> + <Project>{FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}</Project> + <Name>SourceTest</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-26 21:47:32
|
Revision: 171 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=171&view=rev Author: sem62 Date: 2008-05-26 14:47:38 -0700 (Mon, 26 May 2008) Log Message: ----------- Added tabbedPane onto CompileQPropertyDlg. Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/CompileQPropertiestsDlg.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/PropertyDlg.java Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/CompileQPropertiestsDlg.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/CompileQPropertiestsDlg.java 2008-05-26 19:15:22 UTC (rev 170) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/CompileQPropertiestsDlg.java 2008-05-26 21:47:38 UTC (rev 171) @@ -3,9 +3,21 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.BorderFactory; +import javax.swing.GroupLayout; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.LayoutStyle; import javax.swing.ScrollPaneConstants; +import javax.swing.WindowConstants; +import javax.swing.GroupLayout.Alignment; +import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.DefaultTableColumnModel; @@ -25,29 +37,30 @@ private static final long serialVersionUID = 1961383080461718171L; - private javax.swing.JCheckBox sameAsTitleCheckBox; - private javax.swing.JCheckBox oneAnswerCheckBox; - private javax.swing.JComboBox programmingLanguage; - private javax.swing.JLabel titleLabel; - private javax.swing.JLabel programminglanguageLabel; - private javax.swing.JPanel generalPanel; - private javax.swing.JPanel captionPanel; - private javax.swing.JPanel partsPanel; - private javax.swing.JScrollPane jScrollPane1; + private JCheckBox sameAsTitleCheckBox; + private JCheckBox oneAnswerCheckBox; + private JComboBox programmingLanguage; + private JLabel titleLabel; + private JLabel programminglanguageLabel; + private JPanel generalPanel; + private JPanel captionPanel; + private JPanel partsPanel; + private JPanel testingDataPanel; + private JScrollPane jScrollPane1; private PartsTable partsTable; - private javax.swing.JTextField titleTextField; - private javax.swing.JTextField captionTextField; - private javax.swing.JTextField questionTextField; - private javax.swing.JButton editCaptionInHtmlBtn; - private javax.swing.JButton editQuestionInHtmlBtn; - private javax.swing.JButton editAnswerVariantInHtmlEditor; - private javax.swing.JButton insertAnswerVariantBtn; - private javax.swing.JButton deleteAnswerVariantBtn; - private javax.swing.JButton moveUpAnswerVariantBtn; - private javax.swing.JButton moveDownAnswerVariantBtn; + private JTextField titleTextField; + private JTextField captionTextField; + private JTextField questionTextField; + private JButton editCaptionInHtmlBtn; + private JButton editQuestionInHtmlBtn; + private JButton editAnswerVariantInHtmlEditor; + private JButton insertAnswerVariantBtn; + private JButton deleteAnswerVariantBtn; + private JButton moveUpAnswerVariantBtn; + private JButton moveDownAnswerVariantBtn; private CompileQPartsTableModel compileQTableDataModel; - private javax.swing.JTextField currentAnswerVariant; + private JTextField currentAnswerVariant; private MultiLineTableCellEditor multiLineTableCellEditor = new MultiLineTableCellEditor(); private PartAttributesCellEditor partAttributesCellEditor = new PartAttributesCellEditor(); @@ -212,22 +225,25 @@ @Override protected void initComponents() { - setTitle("Propertiests..."); + JTabbedPane tabbedPane = new JTabbedPane(); + add(tabbedPane); - generalPanel = new javax.swing.JPanel(); - titleLabel = new javax.swing.JLabel(); - programminglanguageLabel = new javax.swing.JLabel( - "Programming language:"); - titleTextField = new javax.swing.JTextField(); - captionPanel = new javax.swing.JPanel(); - captionTextField = new javax.swing.JTextField(); - sameAsTitleCheckBox = new javax.swing.JCheckBox(); - questionTextField = new javax.swing.JTextField(); - oneAnswerCheckBox = new javax.swing.JCheckBox(); - partsPanel = new javax.swing.JPanel(); - jScrollPane1 = new javax.swing.JScrollPane(); - cancelButton = new javax.swing.JButton("Cancel"); - okButton = new javax.swing.JButton("Ok"); + JPanel generalTab = new JPanel(); + + generalPanel = new JPanel(); + titleLabel = new JLabel(); + programminglanguageLabel = new JLabel("Programming language:"); + titleTextField = new JTextField(); + captionPanel = new JPanel(); + captionTextField = new JTextField(); + sameAsTitleCheckBox = new JCheckBox(); + questionTextField = new JTextField(); + oneAnswerCheckBox = new JCheckBox(); + partsPanel = new JPanel(); + testingDataPanel = new JPanel(); + jScrollPane1 = new JScrollPane(); + cancelButton = new JButton("Cancel"); + okButton = new JButton("Ok"); editCaptionInHtmlBtn = new JButton("..."); editQuestionInHtmlBtn = new JButton("..."); editAnswerVariantInHtmlEditor = new JButton("HTML Editor"); @@ -243,7 +259,7 @@ moveDownAnswerVariantBtn.addActionListener(this); moveUpAnswerVariantBtn.addActionListener(this); - currentAnswerVariant = new javax.swing.JTextField(); + currentAnswerVariant = new JTextField(); captionTextField.addActionListener(this); cancelButton.addActionListener(this); @@ -256,121 +272,87 @@ partsTable = new PartsTable(); - setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); - generalPanel.setBorder(javax.swing.BorderFactory - .createTitledBorder("General")); + generalPanel.setBorder(BorderFactory.createTitledBorder("General")); titleLabel.setText("Title"); - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout( - generalPanel); + GroupLayout jPanel1Layout = new GroupLayout(generalPanel); generalPanel.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addGroup( + Alignment.LEADING).addGroup( jPanel1Layout.createSequentialGroup().addContainerGap() .addComponent(titleLabel)).addGroup( jPanel1Layout.createSequentialGroup().addContainerGap() + .addComponent(titleTextField, GroupLayout.DEFAULT_SIZE, + 364, Short.MAX_VALUE).addContainerGap())); + + jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup( + Alignment.LEADING).addGroup( + jPanel1Layout.createSequentialGroup().addComponent(titleLabel) + .addPreferredGap(ComponentPlacement.RELATED, + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(titleTextField, - javax.swing.GroupLayout.DEFAULT_SIZE, 364, - Short.MAX_VALUE).addContainerGap())); - jPanel1Layout - .setVerticalGroup(jPanel1Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - jPanel1Layout - .createSequentialGroup() - .addComponent(titleLabel) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - titleTextField, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap())); + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE).addContainerGap())); - captionPanel.setBorder(javax.swing.BorderFactory - .createTitledBorder("Caption")); + captionPanel.setBorder(BorderFactory.createTitledBorder("Caption")); sameAsTitleCheckBox.setText("Some as the title"); - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout( - captionPanel); + GroupLayout jPanel2Layout = new GroupLayout(captionPanel); captionPanel.setLayout(jPanel2Layout); - jPanel2Layout - .setHorizontalGroup(jPanel2Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) + jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup( + Alignment.LEADING).addGroup( + jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup( - jPanel2Layout - .createSequentialGroup() - .addContainerGap() - .addGroup( - jPanel2Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent( - sameAsTitleCheckBox)) - .addContainerGap(283, Short.MAX_VALUE)) - .addGroup( - javax.swing.GroupLayout.Alignment.TRAILING, - jPanel2Layout - .createSequentialGroup() - .addContainerGap() - .addComponent( - captionTextField, - javax.swing.GroupLayout.DEFAULT_SIZE, - 370, Short.MAX_VALUE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent( - editCaptionInHtmlBtn, - javax.swing.GroupLayout.PREFERRED_SIZE, - 30, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap())); - jPanel2Layout - .setVerticalGroup(jPanel2Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - jPanel2Layout - .createSequentialGroup() - .addComponent(sameAsTitleCheckBox) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup( - jPanel2Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent( - editCaptionInHtmlBtn, - javax.swing.GroupLayout.PREFERRED_SIZE, - 20, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent( - captionTextField, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap())); + jPanel2Layout.createParallelGroup( + Alignment.LEADING).addComponent( + sameAsTitleCheckBox)).addContainerGap( + 283, Short.MAX_VALUE)) + .addGroup( + Alignment.TRAILING, + jPanel2Layout.createSequentialGroup().addContainerGap() + .addComponent(captionTextField, + GroupLayout.DEFAULT_SIZE, 370, + Short.MAX_VALUE).addPreferredGap( + LayoutStyle.ComponentPlacement.RELATED) + .addComponent(editCaptionInHtmlBtn, + GroupLayout.PREFERRED_SIZE, 30, + GroupLayout.PREFERRED_SIZE) + .addContainerGap())); + jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup( + Alignment.LEADING).addGroup( + jPanel2Layout.createSequentialGroup().addComponent( + sameAsTitleCheckBox).addPreferredGap( + LayoutStyle.ComponentPlacement.RELATED).addGroup( + jPanel2Layout.createParallelGroup(Alignment.BASELINE) + .addComponent(editCaptionInHtmlBtn, + GroupLayout.PREFERRED_SIZE, 20, + GroupLayout.PREFERRED_SIZE) + .addComponent(captionTextField, + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addContainerGap())); oneAnswerCheckBox.setText("Only one correct answer"); - partsPanel.setBorder(javax.swing.BorderFactory + partsPanel.setBorder(BorderFactory .createTitledBorder("Variants of answer")); + testingDataPanel.setBorder(BorderFactory + .createTitledBorder("Input data / Valid respose")); + jScrollPane1.setViewportView(partsTable); jScrollPane1 .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout( - partsPanel); + GroupLayout jPanel4Layout = new GroupLayout(partsPanel); partsPanel.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.TRAILING).addGroup( + GroupLayout.Alignment.TRAILING).addGroup( jPanel4Layout.createSequentialGroup().addComponent( moveUpAnswerVariantBtn).addContainerGap(10, 10) .addComponent(moveDownAnswerVariantBtn) @@ -381,23 +363,22 @@ editAnswerVariantInHtmlEditor) .addContainerGap()).addGroup( jPanel4Layout.createSequentialGroup().addContainerGap() - .addComponent(jScrollPane1, - javax.swing.GroupLayout.DEFAULT_SIZE, 364, - Short.MAX_VALUE).addContainerGap()).addGroup( - javax.swing.GroupLayout.Alignment.TRAILING, - jPanel4Layout.createSequentialGroup().addContainerGap() - .addComponent(programminglanguageLabel, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(10, 10).addComponent( - programmingLanguage, 118, 118, 118) - .addContainerGap())); + .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, + 364, Short.MAX_VALUE).addContainerGap()) + .addGroup( + Alignment.TRAILING, + jPanel4Layout.createSequentialGroup().addContainerGap() + .addComponent(programminglanguageLabel, + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addContainerGap(10, 10).addComponent( + programmingLanguage, 118, 118, 118) + .addContainerGap())); jPanel4Layout .setVerticalGroup(jPanel4Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) + .createParallelGroup(Alignment.LEADING) .addGroup( jPanel4Layout .createSequentialGroup() @@ -405,11 +386,11 @@ .addGroup( jPanel4Layout .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) + Alignment.BASELINE) .addGroup( jPanel4Layout .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) + Alignment.BASELINE) .addComponent( programminglanguageLabel, 20, @@ -421,15 +402,14 @@ 20, 20))) .addContainerGap(10, 10) - .addComponent( - jScrollPane1, - javax.swing.GroupLayout.DEFAULT_SIZE, - 111, Short.MAX_VALUE) + .addComponent(jScrollPane1, + GroupLayout.DEFAULT_SIZE, 111, + Short.MAX_VALUE) .addContainerGap(10, 10) .addGroup( jPanel4Layout .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) + Alignment.BASELINE) .addComponent( moveUpAnswerVariantBtn, 20, 20, 20) @@ -447,89 +427,104 @@ 20, 20, 20)) .addContainerGap())); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout( - getContentPane()); + GroupLayout generalTabLayout = new GroupLayout(generalTab); + generalTab.setLayout(generalTabLayout); + generalTabLayout + .setHorizontalGroup(generalTabLayout + .createParallelGroup(Alignment.LEADING) + .addGroup( + generalTabLayout + .createSequentialGroup() + .addContainerGap() + .addGroup( + generalTabLayout + .createParallelGroup( + Alignment.LEADING) + .addComponent( + captionPanel, + GroupLayout.DEFAULT_SIZE, + GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent( + generalPanel, + GroupLayout.DEFAULT_SIZE, + GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)) + .addContainerGap())); + generalTabLayout.setVerticalGroup(generalTabLayout.createParallelGroup( + Alignment.LEADING).addGroup( + generalTabLayout.createSequentialGroup().addContainerGap() + .addComponent(generalPanel, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE).addPreferredGap( + ComponentPlacement.RELATED).addComponent( + captionPanel, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE).addPreferredGap( + ComponentPlacement.RELATED).addPreferredGap( + ComponentPlacement.RELATED).addPreferredGap( + ComponentPlacement.RELATED).addContainerGap( + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); + + this.getRootPane().setDefaultButton(okButton); + + tabbedPane.addTab("Main propertiests", generalTab); + tabbedPane.addTab("Content", partsPanel); + tabbedPane.addTab("Checking answers data", testingDataPanel); + + GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout .setHorizontalGroup(layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) + .createParallelGroup(Alignment.LEADING) .addGroup( + GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) + Alignment.TRAILING) .addComponent( - partsPanel, - 600, 600, + tabbedPane, + Alignment.LEADING, + GroupLayout.DEFAULT_SIZE, + 380, Short.MAX_VALUE) - .addComponent( - captionPanel, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - generalPanel, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) .addGroup( - javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addComponent( okButton) .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) + LayoutStyle.ComponentPlacement.RELATED) .addComponent( cancelButton))) .addContainerGap())); layout - .setVerticalGroup(layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) + .setVerticalGroup(layout.createParallelGroup(Alignment.LEADING) .addGroup( - layout - .createSequentialGroup() - .addContainerGap() - .addComponent( - generalPanel, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) + Alignment.TRAILING, + layout.createSequentialGroup() + .addContainerGap().addComponent( + tabbedPane, + GroupLayout.DEFAULT_SIZE, 249, + Short.MAX_VALUE) .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent( - captionPanel, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(partsPanel, 300, 300, 300) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) + ComponentPlacement.RELATED) .addGroup( - layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) + layout.createParallelGroup( + Alignment.BASELINE) + .addComponent(okButton, + 20, 20, 20) .addComponent( cancelButton, - 20, 20, 20) - .addComponent(okButton, 20, 20, 20)) - .addContainerGap( - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE))); + .addContainerGap())); - this.getRootPane().setDefaultButton(okButton); - pack(); + setSize(550, 600); } @Override Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/PropertyDlg.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/PropertyDlg.java 2008-05-26 19:15:22 UTC (rev 170) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/PropertyDlg.java 2008-05-26 21:47:38 UTC (rev 171) @@ -3,6 +3,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.text.JTextComponent; @@ -16,6 +17,9 @@ private static final long serialVersionUID = -6002603750731392120L; public PropertyDlg() { + setLocationByPlatform(true); + setTitle("Propertiests..."); + initComponents(); } @@ -43,8 +47,8 @@ protected abstract void fillFields(); - protected javax.swing.JButton cancelButton; - protected javax.swing.JButton okButton; + protected JButton cancelButton; + protected JButton okButton; public void showDialog(TreeItem item) { manifestItem = item; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-26 19:15:14
|
Revision: 170 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=170&view=rev Author: sem62 Date: 2008-05-26 12:15:22 -0700 (Mon, 26 May 2008) Log Message: ----------- Added "show user answer status dialog" parameter into Settings and put checkBoxMenuItem into MainMenu. Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenu.java WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-26 18:45:06 UTC (rev 169) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-26 19:15:22 UTC (rev 170) @@ -39,15 +39,18 @@ System.out.print("Initialize(" + parameter + ");\n"); if (!nextItemIdentifier.equals("")) { - Manifest manifest = SummaryPageManager.getInstance().getManifest(); - TreeItem item = manifest.findItemByIdentifier(nextItemIdentifier); + Manifest manifest = SummaryPageManager.getInstance() + .getManifest(); + TreeItem item = manifest + .findItemByIdentifier(nextItemIdentifier); if (item != null) { GlobalStateInformation.setCurrentActivity(item); - UserAnswerStatus answer = AnswersStatusManager.getInstance().getAnswerStatus(item); + UserAnswerStatus answer = AnswersStatusManager + .getInstance().getAnswerStatus(item); - if (answer != null){ + if (answer != null) { answer.setRawAnswer(null); } } @@ -82,20 +85,23 @@ String identifier = ""; if (currentActivity != null) { identifier = currentActivity.getIdentifier(); - Manifest manifest = SummaryPageManager.getInstance().getManifest(); - TreeItem item = manifest.findItemByIdentifier(identifier); - ItemModel model = ItemModels.getModelFromItem(item); + if (Settings.getInstance().isShowAnswerResultDlg()) { + Manifest manifest = SummaryPageManager.getInstance() + .getManifest(); + TreeItem item = manifest.findItemByIdentifier(identifier); + ItemModel model = ItemModels.getModelFromItem(item); - UserAnswerStatus answerStatus = AnswersStatusManager.getInstance() - .getAnswerStatus(item); + UserAnswerStatus answerStatus = AnswersStatusManager + .getInstance().getAnswerStatus(item); - if (answerStatus.getRawAnswer() != null - && answerStatus.getRawAnswer().length > 0) { - model.showAnswerStatus(answerStatus); + if (answerStatus.getRawAnswer() != null + && answerStatus.getRawAnswer().length > 0) { + model.showAnswerStatus(answerStatus); + } } + + redirectTo(identifier); } - - redirectTo(identifier); } private void redirectTo(String identifier) { Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenu.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenu.java 2008-05-26 18:45:06 UTC (rev 169) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenu.java 2008-05-26 19:15:22 UTC (rev 170) @@ -3,15 +3,27 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.JCheckBoxMenuItem; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import edu.lnu.FireFly.WebEditor.Data.AnswersStatusManager; import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; -public class MainMenu extends JMenuBar implements ActionListener { +public class MainMenu extends JMenuBar implements ActionListener, + ChangeListener { + @Override + public void stateChanged(ChangeEvent arg0) { + if (arg0.getSource().equals(showUserAnswerStautsMenuItem)) { + boolean selected = showUserAnswerStautsMenuItem.isSelected(); + Settings.getInstance().setShowAnswerResultDlg(selected); + } + } + private MainMenuListenet listener = null; /** * @@ -48,8 +60,8 @@ e.printStackTrace(); } } - - public void setListener(MainMenuListenet listener){ + + public void setListener(MainMenuListenet listener) { this.listener = listener; } @@ -60,9 +72,18 @@ JMenu editMenu = new JMenu("Edit"); add(editMenu); + JMenu optionMenu = new JMenu("Options"); + add(optionMenu); + + showUserAnswerStautsMenuItem = new JCheckBoxMenuItem( + "Show answer result dlg", Settings.getInstance() + .isShowAnswerResultDlg()); + showUserAnswerStautsMenuItem.addChangeListener(this); + optionMenu.add(showUserAnswerStautsMenuItem); + resetMenuItem = new JMenuItem("Reset user activity"); resetMenuItem.addActionListener(this); - fileMenu.add(resetMenuItem); + editMenu.add(resetMenuItem); openMenuItem = new JMenuItem("Open"); openMenuItem.addActionListener(this); @@ -82,6 +103,7 @@ protected JMenuItem openMenuItem = null; protected JMenuItem resetMenuItem = null; + protected JMenuItem showUserAnswerStautsMenuItem = null; protected JMenuItem saveMenuItem = null; Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java 2008-05-26 18:45:06 UTC (rev 169) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java 2008-05-26 19:15:22 UTC (rev 170) @@ -10,6 +10,8 @@ private long autoSaveInterval = 5 * 60 * 1000; private long nopInterval = 60 * 1000; + + private boolean showAnswerResultDlg = false; private static Settings obj = null; @@ -89,4 +91,12 @@ public void setNopInterval(long nopInterval) { this.nopInterval = nopInterval; } + + public boolean isShowAnswerResultDlg() { + return showAnswerResultDlg; + } + + public void setShowAnswerResultDlg(boolean showAnswerResultDlg) { + this.showAnswerResultDlg = showAnswerResultDlg; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-26 18:45:05
|
Revision: 169 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=169&view=rev Author: sem62 Date: 2008-05-26 11:45:06 -0700 (Mon, 26 May 2008) Log Message: ----------- added Lecture model support at summary page. Modified Paths: -------------- WebEditor/template/global/SummaryPage.js Modified: WebEditor/template/global/SummaryPage.js =================================================================== --- WebEditor/template/global/SummaryPage.js 2008-05-24 22:27:29 UTC (rev 168) +++ WebEditor/template/global/SummaryPage.js 2008-05-26 18:45:06 UTC (rev 169) @@ -9,7 +9,7 @@ var records = new Array(1000); var curr_record = 0; -function ins(title, min, max, raw, completionStatus, model){ +function ins(title, min, max, raw, completionStatus, successStatus, model){ var record = new Array(7); record[0] = completionStatus; record[1] = title; @@ -17,7 +17,8 @@ record[3] = max; record[4] = raw; record[5] = model; - record[6] = deep; + record[6] = successStatus; + record[7] = deep; records[curr_record] = record; curr_record++; @@ -28,7 +29,7 @@ record[2] = 0; record[3] = 0; record[4] = 0; - record[6] = 1; + record[7] = 1; records[curr_record] = record; curr_record++; @@ -49,7 +50,7 @@ var parentRec = records[stack[stackPos]]; - while (record[6] < prevRec[6]){ + while (record[7] < prevRec[7]){ stackPos--; var parent_parent = records[stackPos]; @@ -95,11 +96,11 @@ var i; for (i = 0; i < curr_record - 1; i++){ var record = records[i]; - write(record[0], record[1], record[2], record[3], record[4], record[5]); + write(record[0], record[6], record[1], record[2], record[3], record[4], record[5]); } } -function write(completionStatus, title, min, max, raw, modelName){ +function write(completionStatus, successStatus, title, min, max, raw, modelName){ rowNum++; var percents = "0 %"; @@ -112,21 +113,23 @@ } if (modelName == "LectureModel"){ - raw = (completionStatus == "completed") ? "read" : "unread"; - percents = ""; - } - - if (!parseInt(min) && min != 0){ + percents = "--"; min = "--"; - } + max = "--"; + raw = (completionStatus == "completed") ? "read" : "not read jet"; + } else { + if (!parseInt(min) && min != 0){ + min = "--"; + } + + if (!parseInt(max) && max != 0){ + max = "--"; + } - if (!parseInt(max) && max != 0){ - max = "--"; + if (!parseInt(raw) && raw != 0){ + raw = "--"; + } } - - if (!parseInt(raw) && raw != 0){ - raw = "--"; - } var td = "<td class='tbl"; td += 1 - (rowNum % 2) + 1; @@ -139,8 +142,13 @@ startFormat = "<B>"; endFormat = "</B>"; } - - document.write("<TR>" + td + rowNum + "<img src='global/images/" + completionStatus + ".gif'>"); + + var imgName = completionStatus; + if (imgName == "completed"){ + imgName = successStatus; + } + + document.write("<TR>" + td + rowNum + "<img src='global/images/" + imgName + ".gif'>"); document.write(td + title); document.write(td + startFormat + min + endFormat); document.write(td + startFormat + max + endFormat); @@ -164,7 +172,7 @@ title = " " + title; } - ins(title, getScore(id, "min"), getScore(id, "max"), getScore(id, "raw"), getCompletionStatus(id), modelName); + ins(title, getScore(id, "min"), getScore(id, "max"), getScore(id, "raw"), getCompletionStatus(id), getSuccessStatus(id), modelName); } function getObjectiveIndex(id){ @@ -180,17 +188,17 @@ return -1; } +function getSuccessStatus(objectiveID){ + var index = getObjectiveIndex(objectiveID); + if (index == -1) return "undefined"; + var res = GetValue("cmi.objectives." + index + ".success_status"); + return res != null ? res : "undefined"; +} + function getCompletionStatus(objectiveID){ var index = getObjectiveIndex(objectiveID); - - if (index == -1) return "incomplete"; - + if (index == -1) return "undefined"; var res = GetValue("cmi.objectives." + index + ".completion_status"); - - if (res == "completed"){ - res = GetValue("cmi.objectives." + index + ".success_status"); - } - return res != null ? res : "undefined"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-24 22:27:25
|
Revision: 168 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=168&view=rev Author: sem62 Date: 2008-05-24 15:27:29 -0700 (Sat, 24 May 2008) Log Message: ----------- Fixed some bugs. Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/CourseTreePopupMenu.java WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-24 19:20:07 UTC (rev 167) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-24 22:27:29 UTC (rev 168) @@ -38,15 +38,20 @@ try { System.out.print("Initialize(" + parameter + ");\n"); - Manifest manifest = SummaryPageManager.getInstance().getManifest(); - TreeItem item = manifest.findItemByIdentifier(nextItemIdentifier); + if (!nextItemIdentifier.equals("")) { + Manifest manifest = SummaryPageManager.getInstance().getManifest(); + TreeItem item = manifest.findItemByIdentifier(nextItemIdentifier); - GlobalStateInformation.setCurrentActivity(item); + if (item != null) { + GlobalStateInformation.setCurrentActivity(item); - UserAnswerStatus answer = AnswersStatusManager.getInstance() - .getAnswerStatus(item); + UserAnswerStatus answer = AnswersStatusManager.getInstance().getAnswerStatus(item); - answer.setRawAnswer(null); + if (answer != null){ + answer.setRawAnswer(null); + } + } + } } catch (Exception e) { e.printStackTrace(); return "false"; @@ -81,9 +86,11 @@ TreeItem item = manifest.findItemByIdentifier(identifier); ItemModel model = ItemModels.getModelFromItem(item); - UserAnswerStatus answerStatus = AnswersStatusManager.getInstance().getAnswerStatus(item); + UserAnswerStatus answerStatus = AnswersStatusManager.getInstance() + .getAnswerStatus(item); - if (answerStatus.getRawAnswer() != null && answerStatus.getRawAnswer().length > 0) { + if (answerStatus.getRawAnswer() != null + && answerStatus.getRawAnswer().length > 0) { model.showAnswerStatus(answerStatus); } } @@ -139,10 +146,13 @@ cmi.setValue(new ElementName(parameter.substring(4)), value); if (parameter.startsWith("cmi.answers.")) { - String itemIdentifier = GlobalStateInformation.getCurrentActivity().getIdentifier(); + String itemIdentifier = GlobalStateInformation + .getCurrentActivity().getIdentifier(); - Manifest manifest = SummaryPageManager.getInstance().getManifest(); - TreeItem item = manifest.findItemByIdentifier(itemIdentifier); + Manifest manifest = SummaryPageManager.getInstance() + .getManifest(); + TreeItem item = manifest + .findItemByIdentifier(itemIdentifier); AnswersStatusManager.getInstance().cmiAnswersChanged(item); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java 2008-05-24 19:20:07 UTC (rev 167) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java 2008-05-24 22:27:29 UTC (rev 168) @@ -5,7 +5,9 @@ import javax.swing.JTree; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.TreePath; +import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.FFManifest.item.Item; import edu.lnu.FireFly.WebEditor.GUI.TreeDataModel; @@ -36,11 +38,8 @@ public void valueChanged(TreeSelectionEvent event) { if (event.getNewLeadSelectionPath() == null) { try { - AppletWithApiHandle.setNextItemIdentifier(""); - WebEditor.instance.showItemResource(null); - System.out.print("browse to empty document.\n"); Thread.sleep(300); } catch (InterruptedException e1) { // do nothing @@ -51,12 +50,15 @@ } if (event.getNewLeadSelectionPath().getLastPathComponent().getClass() == Item.class) { - Item item = (Item) event.getNewLeadSelectionPath() - .getLastPathComponent(); + Item item = (Item) event.getNewLeadSelectionPath().getLastPathComponent(); - AppletWithApiHandle.setNextItemIdentifier(item.identifier); - WebEditor.instance.showItemResource(item); } } + + public void setSelectionItem(TreeItem anItem, boolean notifyListeners) { + TreeDataModel model = (TreeDataModel)getModel(); + TreePath path = model.getItemPath(anItem); + setSelectionPath(path); + } } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/CourseTreePopupMenu.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/CourseTreePopupMenu.java 2008-05-24 19:20:07 UTC (rev 167) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/CourseTreePopupMenu.java 2008-05-24 22:27:29 UTC (rev 168) @@ -22,6 +22,7 @@ import edu.lnu.FireFly.FFManifest.item.Item; import edu.lnu.FireFly.FFManifest.item.sequencing.Sequencing; import edu.lnu.FireFly.FFManifest.parser.DurationConverter; +import edu.lnu.FireFly.WebEditor.CourseTree; import edu.lnu.FireFly.WebEditor.WebEditor; import edu.lnu.FireFly.WebEditor.Data.ManifestFactory; import edu.lnu.FireFly.WebEditor.GUI.Dialogs.RenameDlg; @@ -181,9 +182,9 @@ private void displayMenu(MouseEvent e) { if (e.isPopupTrigger()) { Point pt = e.getPoint(); - TreePath path = WebEditor.getCourseTree() - .getClosestPathForLocation(pt.x, pt.y); - WebEditor.getCourseTree().setSelectionPath(path); + CourseTree tree = WebEditor.getCourseTree(); + TreePath path = tree.getClosestPathForLocation(pt.x, pt.y); + tree.setSelectionPath(path); manifestItem = (TreeItem) path.getLastPathComponent(); ItemModel model = ItemModels.getModelFromItem(manifestItem); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-24 19:20:07 UTC (rev 167) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-24 22:27:29 UTC (rev 168) @@ -72,25 +72,39 @@ public void showItemResource(TreeItem anItem) { try { - if (anItem.getClass() != Item.class){ + if (anItem == null || anItem.getClass() != Item.class){ + showEmptyDocument(); return; } Manifest manifest = WebEditor.instance.getManifest(); - Resource resource = manifest.resources - .findResourceByIdentifier(((Item)anItem).identifierref); + String identifierref = ((Item)anItem).identifierref; + Resource resource = manifest.resources.findResourceByIdentifier(identifierref); if (resource != null) { String href = Settings.getInstance().getCourseLocation() + resource.getFullHref(); + + AppletWithApiHandle.setNextItemIdentifier(anItem.getIdentifier()); getAppletContext().showDocument(new URL(href), "ContentFrame"); - System.out.print("redirected\n"); + courseTree.setSelectionItem(anItem, false); + + System.out.println("redirected to " + identifierref); + } else { + showEmptyDocument(); } } catch (MalformedURLException e) { e.printStackTrace(); } } + public void showEmptyDocument() throws MalformedURLException { + AppletWithApiHandle.setNextItemIdentifier(""); + getAppletContext().showDocument(new URL("/empty.html"), "ContentFrame"); + + System.out.println("redirected to empty page"); + } + @Override public void init() { Settings.getInstance().parseAppletParameters(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-24 19:20:03
|
Revision: 167 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=167&view=rev Author: sem62 Date: 2008-05-24 12:20:07 -0700 (Sat, 24 May 2008) Log Message: ----------- * Moved frame redirection code to one method. * Called redirect browser after configure item's property. Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-24 18:52:29 UTC (rev 166) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-24 19:20:07 UTC (rev 167) @@ -1,13 +1,10 @@ package edu.lnu.FireFly.WebEditor; -import java.net.URL; - import javax.swing.JApplet; import edu.lnu.FireFly.FFManifest.Manifest; import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.FFManifest.item.Item; -import edu.lnu.FireFly.FFManifest.resource.Resource; import edu.lnu.FireFly.Rte.Cmi; import edu.lnu.FireFly.Rte.CmiManager; import edu.lnu.FireFly.Rte.ElementName; @@ -43,11 +40,12 @@ Manifest manifest = SummaryPageManager.getInstance().getManifest(); TreeItem item = manifest.findItemByIdentifier(nextItemIdentifier); - + GlobalStateInformation.setCurrentActivity(item); - - UserAnswerStatus answer = AnswersStatusManager.getInstance().getAnswerStatus(item); - + + UserAnswerStatus answer = AnswersStatusManager.getInstance() + .getAnswerStatus(item); + answer.setRawAnswer(null); } catch (Exception e) { e.printStackTrace(); @@ -61,7 +59,8 @@ try { System.out.print("Terminate(" + parameter + ");\n"); - if (nextItemIdentifier.equals(GlobalStateInformation.getCurrentActivity().getIdentifier())){ + if (nextItemIdentifier.equals(GlobalStateInformation + .getCurrentActivity().getIdentifier())) { showAnswerResult(); } GlobalStateInformation.setCurrentActivity(null); @@ -78,12 +77,13 @@ String identifier = ""; if (currentActivity != null) { identifier = currentActivity.getIdentifier(); - TreeItem item = SummaryPageManager.getInstance().getManifest().findItemByIdentifier(identifier); + Manifest manifest = SummaryPageManager.getInstance().getManifest(); + TreeItem item = manifest.findItemByIdentifier(identifier); ItemModel model = ItemModels.getModelFromItem(item); UserAnswerStatus answerStatus = AnswersStatusManager.getInstance().getAnswerStatus(item); - - if (answerStatus.getRawAnswer() != null && answerStatus.getRawAnswer().length > 0){ + + if (answerStatus.getRawAnswer() != null && answerStatus.getRawAnswer().length > 0) { model.showAnswerStatus(answerStatus); } } @@ -92,25 +92,14 @@ } private void redirectTo(String identifier) { - try { - TreeItem item = SummaryPageManager.getInstance().getManifest() - .findItemByIdentifier(identifier); + Manifest manifest = SummaryPageManager.getInstance().getManifest(); + TreeItem item = manifest.findItemByIdentifier(identifier); - if (item.getClass() != Item.class) { - return; - } - - Resource resource = WebEditor.instance.getManifest().resources - .findResourceByIdentifier(((Item) item).identifierref); - if (resource != null) { - getAppletContext().showDocument( - new URL(Settings.getInstance().getCourseLocation() - + resource.getFullHref()), "ContentFrame"); - System.out.print("redirected\n"); - } - } catch (Exception exc) { - exc.printStackTrace(); + if (item.getClass() != Item.class) { + return; } + + WebEditor.instance.showItemResource(item); } public synchronized String GetValue(String parameter) { @@ -150,11 +139,10 @@ cmi.setValue(new ElementName(parameter.substring(4)), value); if (parameter.startsWith("cmi.answers.")) { - String itemIdentifier = GlobalStateInformation - .getCurrentActivity().getIdentifier(); + String itemIdentifier = GlobalStateInformation.getCurrentActivity().getIdentifier(); - TreeItem item = SummaryPageManager.getInstance() - .getManifest().findItemByIdentifier(itemIdentifier); + Manifest manifest = SummaryPageManager.getInstance().getManifest(); + TreeItem item = manifest.findItemByIdentifier(itemIdentifier); AnswersStatusManager.getInstance().cmiAnswersChanged(item); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java 2008-05-24 18:52:29 UTC (rev 166) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java 2008-05-24 19:20:07 UTC (rev 167) @@ -1,14 +1,12 @@ package edu.lnu.FireFly.WebEditor; import java.applet.AppletContext; -import java.net.URL; import javax.swing.JTree; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import edu.lnu.FireFly.FFManifest.item.Item; -import edu.lnu.FireFly.FFManifest.resource.Resource; import edu.lnu.FireFly.WebEditor.GUI.TreeDataModel; public class CourseTree extends JTree implements TreeSelectionListener { @@ -35,41 +33,30 @@ } @Override - public void valueChanged(TreeSelectionEvent e) { - if (e.getNewLeadSelectionPath() == null) { + public void valueChanged(TreeSelectionEvent event) { + if (event.getNewLeadSelectionPath() == null) { try { AppletWithApiHandle.setNextItemIdentifier(""); - getAppletContext().showDocument( - new URL(Settings.getInstance().getResourceLocation() - + "/empty.htm"), "ContentFrame"); + WebEditor.instance.showItemResource(null); + System.out.print("browse to empty document.\n"); Thread.sleep(300); + } catch (InterruptedException e1) { + // do nothing } catch (Exception e1) { - // TODO Auto-generated catch block e1.printStackTrace(); } return; } - if (e.getNewLeadSelectionPath().getLastPathComponent().getClass() == Item.class) { - Item item = (Item) e.getNewLeadSelectionPath() + if (event.getNewLeadSelectionPath().getLastPathComponent().getClass() == Item.class) { + Item item = (Item) event.getNewLeadSelectionPath() .getLastPathComponent(); AppletWithApiHandle.setNextItemIdentifier(item.identifier); - try { - Resource resource = WebEditor.instance.getManifest().resources - .findResourceByIdentifier(item.identifierref); - if (resource != null) { - getAppletContext().showDocument( - new URL(Settings.getInstance().getCourseLocation() - + resource.getFullHref()), "ContentFrame"); - System.out.print("redirected\n"); - } - } catch (Exception exc) { - exc.printStackTrace(); - } + WebEditor.instance.showItemResource(item); } } } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-24 18:52:29 UTC (rev 166) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-24 19:20:07 UTC (rev 167) @@ -87,6 +87,7 @@ } TreeDataModel.getInstance().treeNodesChanged(item); + WebEditor.instance.showItemResource(item); } public final void registerConfigDlg(PropertyDlg dlg) { Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-24 18:52:29 UTC (rev 166) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-24 19:20:07 UTC (rev 167) @@ -1,11 +1,16 @@ package edu.lnu.FireFly.WebEditor; +import java.net.MalformedURLException; +import java.net.URL; + import javax.swing.JScrollPane; import edu.lnu.FireFly.FFManifest.Manifest; import edu.lnu.FireFly.FFManifest.TreeItem; +import edu.lnu.FireFly.FFManifest.item.Item; import edu.lnu.FireFly.FFManifest.parser.Parser; import edu.lnu.FireFly.FFManifest.parser.TestDocException; +import edu.lnu.FireFly.FFManifest.resource.Resource; import edu.lnu.FireFly.WebEditor.Data.AnswersStatusManager; import edu.lnu.FireFly.WebEditor.Data.AutoSaveThread; import edu.lnu.FireFly.WebEditor.Data.ManifestFactory; @@ -16,7 +21,8 @@ import edu.lnu.FireFly.WebEditor.ItemModels.OrganizationModel; import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; -public class WebEditor extends AppletWithWYSIWYGEditor implements MainMenuListenet{ +public class WebEditor extends AppletWithWYSIWYGEditor implements + MainMenuListenet { /** * @@ -63,10 +69,32 @@ return manifest; } + public void showItemResource(TreeItem anItem) { + try { + + if (anItem.getClass() != Item.class){ + return; + } + + Manifest manifest = WebEditor.instance.getManifest(); + Resource resource = manifest.resources + .findResourceByIdentifier(((Item)anItem).identifierref); + + if (resource != null) { + String href = Settings.getInstance().getCourseLocation() + resource.getFullHref(); + getAppletContext().showDocument(new URL(href), "ContentFrame"); + + System.out.print("redirected\n"); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + @Override public void init() { Settings.getInstance().parseAppletParameters(this); - + instance = this; autoSaveThread = new AutoSaveThread(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-24 18:52:22
|
Revision: 166 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=166&view=rev Author: sem62 Date: 2008-05-24 11:52:29 -0700 (Sat, 24 May 2008) Log Message: ----------- Fixed bugs with min / max score calculation and showing AnswerStatus dialog Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-24 17:14:09 UTC (rev 165) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-24 18:52:29 UTC (rev 166) @@ -4,6 +4,7 @@ import javax.swing.JApplet; +import edu.lnu.FireFly.FFManifest.Manifest; import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.FFManifest.item.Item; import edu.lnu.FireFly.FFManifest.resource.Resource; @@ -40,9 +41,14 @@ try { System.out.print("Initialize(" + parameter + ");\n"); - GlobalStateInformation.setCurrentActivity(SummaryPageManager - .getInstance().getManifest().findItemByIdentifier( - nextItemIdentifier)); + Manifest manifest = SummaryPageManager.getInstance().getManifest(); + TreeItem item = manifest.findItemByIdentifier(nextItemIdentifier); + + GlobalStateInformation.setCurrentActivity(item); + + UserAnswerStatus answer = AnswersStatusManager.getInstance().getAnswerStatus(item); + + answer.setRawAnswer(null); } catch (Exception e) { e.printStackTrace(); return "false"; @@ -68,18 +74,18 @@ } private void showAnswerResult() { - TreeItem currentActivity = GlobalStateInformation - .getCurrentActivity(); + TreeItem currentActivity = GlobalStateInformation.getCurrentActivity(); String identifier = ""; if (currentActivity != null) { identifier = currentActivity.getIdentifier(); - TreeItem item = SummaryPageManager.getInstance() - .getManifest().findItemByIdentifier(identifier); + TreeItem item = SummaryPageManager.getInstance().getManifest().findItemByIdentifier(identifier); ItemModel model = ItemModels.getModelFromItem(item); - UserAnswerStatus answerStatus = AnswersStatusManager - .getInstance().getAnswerStatus(item); - model.showAnswerStatus(answerStatus); + UserAnswerStatus answerStatus = AnswersStatusManager.getInstance().getAnswerStatus(item); + + if (answerStatus.getRawAnswer() != null && answerStatus.getRawAnswer().length > 0){ + model.showAnswerStatus(answerStatus); + } } redirectTo(identifier); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-24 17:14:09 UTC (rev 165) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-24 18:52:29 UTC (rev 166) @@ -54,7 +54,7 @@ List<SimpleQuestionAnswer> answers = data.getAnswers().answers; - if (data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_SELECT_ONE) { + if (data.getAnswers().getAnswerType() == SimpleQuestionAnswersDataModel.ANSWER_TYPE_CHOOSE_FEW) { result = getSum(result, answers, +1); } else { if (answers.size() > 0) { @@ -72,7 +72,7 @@ List<SimpleQuestionAnswer> answers = data.getAnswers().answers; - if (data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_SELECT_ONE) { + if (data.getAnswers().getAnswerType() == SimpleQuestionAnswersDataModel.ANSWER_TYPE_CHOOSE_FEW) { result = getSum(result, answers, -1); } else { if (answers.size() > 0) { @@ -87,7 +87,7 @@ SimpleQuestionData data = getData(anItem); List<SimpleQuestionAnswer> answers = data.getAnswers().answers; - if (userAnswers.length != 1 || (userAnswers[0].length() != answers.size() && data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_TYPE)) { + if (userAnswers == null || userAnswers.length != 1 || (userAnswers[0].length() != answers.size() && data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_TYPE)) { return getAnswerMinScore(anItem); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-24 17:14:08
|
Revision: 165 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=165&view=rev Author: sem62 Date: 2008-05-24 10:14:09 -0700 (Sat, 24 May 2008) Log Message: ----------- * Change OnlyOneAnswer to QuestionType comboBox and added logic for it. Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/SimpleQuestionPropertiestsDlg.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionAnswersDataModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java WebEditor/template/global/simpleQ.js Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/SimpleQuestionPropertiestsDlg.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/SimpleQuestionPropertiestsDlg.java 2008-05-24 14:29:24 UTC (rev 164) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/SimpleQuestionPropertiestsDlg.java 2008-05-24 17:14:09 UTC (rev 165) @@ -3,8 +3,15 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.BorderFactory; +import javax.swing.GroupLayout; import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; +import javax.swing.GroupLayout.Alignment; +import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.DefaultTableColumnModel; @@ -23,7 +30,7 @@ private static final long serialVersionUID = 1961383080461718171L; private javax.swing.JCheckBox sameAsTitleCheckBox; - private javax.swing.JCheckBox oneAnswerCheckBox; + private javax.swing.JComboBox answerTypeComboBox; private javax.swing.JLabel titleLabel; private javax.swing.JPanel generalPanel; private javax.swing.JPanel captionPanel; @@ -132,15 +139,16 @@ titleTextField.setText(manifestItem.getTitle()); SimpleQuestionModel itemModel = new SimpleQuestionModel(); + SimpleQuestionData data = itemModel.getData(manifestItem); - captionTextField.setText(itemModel.getData(manifestItem).getCaption()); + captionTextField.setText(data.getCaption()); sameAsTitleCheckBox.setSelected(titleTextField.getText().equals( captionTextField.getText())); - questionTextField - .setText(itemModel.getData(manifestItem).getQuestion()); + questionTextField.setText(data.getQuestion()); - simpleQuestionAnswersDataModel = itemModel.getData(manifestItem) - .getAnswers(); + answerTypeComboBox.setSelectedIndex(data.getAnswers().getAnswerType()); + + simpleQuestionAnswersDataModel = data.getAnswers(); answersTable.setModel(simpleQuestionAnswersDataModel); DefaultTableColumnModel columnModel = (DefaultTableColumnModel) answersTable @@ -173,10 +181,18 @@ sameAsTitleCheckBox = new javax.swing.JCheckBox(); questionPanel = new javax.swing.JPanel(); questionTextField = new javax.swing.JTextField(); - oneAnswerCheckBox = new javax.swing.JCheckBox(); - answersPanel = new javax.swing.JPanel(); - jScrollPane1 = new javax.swing.JScrollPane(); - cancelButton = new javax.swing.JButton("Cancel"); + + String[] types = new String[3]; + types[0] = "Select one variant"; + types[1] = "Check corrent variants"; + types[2] = "Type your answer"; + + answerTypeComboBox = new javax.swing.JComboBox(types); + answerTypeComboBox.setSelectedIndex(0); + + answersPanel = new JPanel(); + jScrollPane1 = new JScrollPane(); + cancelButton = new JButton("Cancel"); okButton = new javax.swing.JButton("Ok"); editCaptionInHtmlBtn = new JButton("..."); editQuestionInHtmlBtn = new JButton("..."); @@ -184,6 +200,8 @@ insertAnswerVariantBtn = new JButton("Insert"); deleteAnswerVariantBtn = new JButton("Delete"); + JLabel QTypeLabel = new JLabel("Question type :"); + moveDownAnswerVariantBtn = new JButton("Down"); moveUpAnswerVariantBtn = new JButton("Up"); @@ -198,7 +216,6 @@ cancelButton.addActionListener(this); okButton.addActionListener(this); sameAsTitleCheckBox.addChangeListener(this); - oneAnswerCheckBox.addChangeListener(this); editCaptionInHtmlBtn.addActionListener(this); editQuestionInHtmlBtn.addActionListener(this); editAnswerVariantInHtmlEditor.addActionListener(this); @@ -220,34 +237,22 @@ jPanel1Layout.createSequentialGroup().addContainerGap() .addComponent(titleLabel)).addGroup( jPanel1Layout.createSequentialGroup().addContainerGap() + .addComponent(titleTextField, GroupLayout.DEFAULT_SIZE, + 364, Short.MAX_VALUE).addContainerGap())); + jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup( + Alignment.LEADING).addGroup( + jPanel1Layout.createSequentialGroup().addComponent(titleLabel) + .addPreferredGap(ComponentPlacement.RELATED, + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(titleTextField, - javax.swing.GroupLayout.DEFAULT_SIZE, 364, - Short.MAX_VALUE).addContainerGap())); - jPanel1Layout - .setVerticalGroup(jPanel1Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - jPanel1Layout - .createSequentialGroup() - .addComponent(titleLabel) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - titleTextField, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap())); + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE).addContainerGap())); - captionPanel.setBorder(javax.swing.BorderFactory - .createTitledBorder("Caption")); + captionPanel.setBorder(BorderFactory.createTitledBorder("Caption")); sameAsTitleCheckBox.setText("Some as the title"); - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout( - captionPanel); + GroupLayout jPanel2Layout = new GroupLayout(captionPanel); captionPanel.setLayout(jPanel2Layout); jPanel2Layout .setHorizontalGroup(jPanel2Layout @@ -281,97 +286,70 @@ 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); - jPanel2Layout - .setVerticalGroup(jPanel2Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - jPanel2Layout - .createSequentialGroup() - .addComponent(sameAsTitleCheckBox) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup( - jPanel2Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent( - editCaptionInHtmlBtn, - javax.swing.GroupLayout.PREFERRED_SIZE, - 20, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent( - captionTextField, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap())); + jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup( + Alignment.LEADING).addGroup( + jPanel2Layout.createSequentialGroup().addComponent( + sameAsTitleCheckBox).addPreferredGap( + ComponentPlacement.RELATED).addGroup( + jPanel2Layout.createParallelGroup(Alignment.BASELINE) + .addComponent(editCaptionInHtmlBtn, + javax.swing.GroupLayout.PREFERRED_SIZE, + 20, GroupLayout.PREFERRED_SIZE) + .addComponent(captionTextField, + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addContainerGap())); questionPanel.setBorder(javax.swing.BorderFactory .createTitledBorder("Question")); - oneAnswerCheckBox.setText("Only one correct answer"); - javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout( - questionPanel); + javax.swing.GroupLayout jPanel3Layout = new GroupLayout(questionPanel); questionPanel.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup( + Alignment.LEADING).addGroup( + jPanel3Layout + .createSequentialGroup() + .addContainerGap() + .addComponent(QTypeLabel) + .addContainerGap(10, 10) + .addComponent(answerTypeComboBox) + .addContainerGap(283, Short.MAX_VALUE) + ).addGroup( + Alignment.TRAILING, + jPanel3Layout.createSequentialGroup().addContainerGap() + .addComponent(questionTextField, GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(editQuestionInHtmlBtn, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) + .addContainerGap())); jPanel3Layout - .setHorizontalGroup(jPanel3Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - jPanel3Layout - .createSequentialGroup() - .addContainerGap() - .addGroup( - jPanel3Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent( - oneAnswerCheckBox)) - .addContainerGap(283, Short.MAX_VALUE)) - .addGroup( - javax.swing.GroupLayout.Alignment.TRAILING, - jPanel3Layout - .createSequentialGroup() - .addContainerGap() - .addComponent( - questionTextField, - javax.swing.GroupLayout.DEFAULT_SIZE, - 370, Short.MAX_VALUE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent( - editQuestionInHtmlBtn, - javax.swing.GroupLayout.PREFERRED_SIZE, - 30, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap())); - jPanel3Layout .setVerticalGroup(jPanel3Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) + .createParallelGroup(Alignment.LEADING) .addGroup( jPanel3Layout .createSequentialGroup() .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(oneAnswerCheckBox) + ComponentPlacement.RELATED) + .addGroup( + jPanel3Layout.createParallelGroup(Alignment.BASELINE) + .addComponent(answerTypeComboBox, 20, 20, 20) + .addComponent(QTypeLabel) + ) .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) + ComponentPlacement.RELATED) .addGroup( jPanel3Layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) + .createParallelGroup(Alignment.BASELINE) .addComponent( editQuestionInHtmlBtn, - javax.swing.GroupLayout.PREFERRED_SIZE, + GroupLayout.PREFERRED_SIZE, 20, - javax.swing.GroupLayout.PREFERRED_SIZE) + GroupLayout.PREFERRED_SIZE) .addComponent( questionTextField, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) .addContainerGap())); answersPanel.setBorder(javax.swing.BorderFactory @@ -535,6 +513,8 @@ @Override protected void saveChanges() { SimpleQuestionModel itemModel = new SimpleQuestionModel(); + simpleQuestionAnswersDataModel.setAnswerType(answerTypeComboBox + .getSelectedIndex()); manifestItem.setTitle(titleTextField.getText()); @@ -562,11 +542,5 @@ } captionTextField.setEnabled(!sameAsTitleCheckBox.isSelected()); } - - if (e.getSource() == oneAnswerCheckBox) { - simpleQuestionAnswersDataModel.setSingleVariant(oneAnswerCheckBox - .isSelected()); - } } - } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionAnswersDataModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionAnswersDataModel.java 2008-05-24 14:29:24 UTC (rev 164) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionAnswersDataModel.java 2008-05-24 17:14:09 UTC (rev 165) @@ -11,8 +11,12 @@ */ private static final long serialVersionUID = 1L; - private boolean singleVariant = false; + private int answerType = ANSWER_TYPE_CHOOSE_FEW; + public static final int ANSWER_TYPE_SELECT_ONE = 0; + public static final int ANSWER_TYPE_CHOOSE_FEW = 1; + public static final int ANSWER_TYPE_TYPE = 2; + public List<SimpleQuestionAnswer> answers = new ArrayList<SimpleQuestionAnswer>(); @Override @@ -72,18 +76,14 @@ return arg1 > 0; } - public boolean isSingleVariant() { - return singleVariant; + public int getAnswerType() { + return answerType; } - public void setSingleVariant(boolean singleVariant) { - this.singleVariant = singleVariant; + public void setAnswerType(int answerType) { + this.answerType = answerType; } - public boolean getSingleVariant() { - return this.singleVariant; - } - @Override public void setValueAt(Object arg0, int arg1, int arg2) { if (arg1 == answers.size()) { Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java 2008-05-24 14:29:24 UTC (rev 164) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java 2008-05-24 17:14:09 UTC (rev 165) @@ -24,8 +24,7 @@ Element ans = root.addElement("answers"); - ans.addAttribute("singleVariant", String.valueOf(getAnswers() - .getSingleVariant())); + ans.addAttribute("answerType", String.valueOf(getAnswers().getAnswerType())); Iterator<SimpleQuestionAnswer> iter = getAnswers().answers.iterator(); @@ -89,9 +88,7 @@ .elementTextTrim("ShowOnSummaryPage")); setShowOnSummaryPage(showOnSP); - getAnswers().setSingleVariant( - answers.attributeValue("singleVariant").equalsIgnoreCase( - "true")); + getAnswers().setAnswerType(Integer.valueOf(answers.attributeValue("answerType"))); getAnswers().answers.clear(); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-24 14:29:24 UTC (rev 164) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-24 17:14:09 UTC (rev 165) @@ -1,6 +1,7 @@ package edu.lnu.FireFly.WebEditor.ItemModels.SimpleQuestion; import java.util.Iterator; +import java.util.List; import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.FFManifest.item.Item; @@ -13,12 +14,11 @@ import edu.lnu.FireFly.WebEditor.UserAnswerStatus.ScoredUserAnswerStatus; import edu.lnu.FireFly.WebEditor.UserAnswerStatus.UserAnswerStatus; +/** + * @author Yura + * + */ public class SimpleQuestionModel extends ResourcedItemModel { - @Override - public void showAnswerStatus(UserAnswerStatus answerStatus) { - ((ScoredUserAnswerStatus)answerStatus).showStatus(); - } - public SimpleQuestionModel() { modelName = "SimpleQuestionModel"; registerConfigDlg(new SimpleQuestionPropertiestsDlg()); @@ -52,14 +52,15 @@ SimpleQuestionData data = getData(item); - for (int i = 0; i < data.getAnswers().answers.size(); i++) { - double answerPoint = data.getAnswers().answers.get(i) - .getAnswerPoint(); - if (answerPoint > 0) { - result += answerPoint; + List<SimpleQuestionAnswer> answers = data.getAnswers().answers; + + if (data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_SELECT_ONE) { + result = getSum(result, answers, +1); + } else { + if (answers.size() > 0) { + result = getMax(answers); } } - return result; } @@ -69,34 +70,48 @@ SimpleQuestionData data = getData(item); - for (int i = 0; i < data.getAnswers().answers.size(); i++) { - double answerPoint = data.getAnswers().answers.get(i) - .getAnswerPoint(); - if (answerPoint < 0) { - result += answerPoint; + List<SimpleQuestionAnswer> answers = data.getAnswers().answers; + + if (data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_SELECT_ONE) { + result = getSum(result, answers, -1); + } else { + if (answers.size() > 0) { + result = getMin(answers); } } - return result; } @Override public double getAnswerRawScore(TreeItem anItem, String[] userAnswers) { - SimpleQuestionData data = getData(anItem); - if (userAnswers.length != 1 - || userAnswers[0].length() != data.getAnswers().answers.size()) { + List<SimpleQuestionAnswer> answers = data.getAnswers().answers; + if (userAnswers.length != 1 || (userAnswers[0].length() != answers.size() && data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_TYPE)) { return getAnswerMinScore(anItem); } String answer = userAnswers[0]; double result = 0d; - for (int i = 0; i < data.getAnswers().answers.size(); i++) { - if (answer.charAt(i) == '1') { - result += data.getAnswers().answers.get(i).getAnswerPoint(); + if (data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_TYPE) { + for (int i = 0; i < answers.size(); i++) { + if (answer.charAt(i) == '1') { + result += answers.get(i).getAnswerPoint(); + + if (data.getAnswers().getAnswerType() != SimpleQuestionAnswersDataModel.ANSWER_TYPE_CHOOSE_FEW) { + // Need to avoid some king of hacking + break; + } + } } + } else { + for (int i = 0; i < answers.size(); i++) { + if (answers.get(i).getAnswerText().equalsIgnoreCase(answer)){ + result = answers.get(i).getAnswerPoint(); + break; + } + } } return result; @@ -116,6 +131,34 @@ return true; } + private double getMax(List<SimpleQuestionAnswer> answers) { + double result; + result = answers.get(0).getAnswerPoint(); + + for (int i = 0; i < answers.size(); i++) { + double currentAnswerPoint = answers.get(i).getAnswerPoint(); + + if (currentAnswerPoint > result) { + result = currentAnswerPoint; + } + } + return result; + } + + private double getMin(List<SimpleQuestionAnswer> answers) { + double result; + result = answers.get(0).getAnswerPoint(); + + for (int i = 0; i < answers.size(); i++) { + double currentAnswerPoint = answers.get(i).getAnswerPoint(); + + if (currentAnswerPoint < result) { + result = currentAnswerPoint; + } + } + return result; + } + @Override public boolean getShowOnSummaryPageMenuVisible() { return true; @@ -126,12 +169,39 @@ return false; } + /** + * @param result + * @param answers + * @param order + * If sign is 0, result is a sum of all elements. Else, + * result is a sum only of elements with the same sign with + * this "sign". + * @return + */ + private double getSum(double result, List<SimpleQuestionAnswer> answers, + int sign) { + for (int i = 0; i < answers.size(); i++) { + double answerPoint = answers.get(i).getAnswerPoint(); + + if (sign == 0 || sign * answerPoint > 0) { + result += answerPoint; + } + } + + return result; + } + @Override public boolean isRemovable() { return true; } @Override + public void showAnswerStatus(UserAnswerStatus answerStatus) { + ((ScoredUserAnswerStatus) answerStatus).showStatus(); + } + + @Override protected void updateResourceFile(TreeItem anItem) { Resource resource = WebEditor.instance.getManifest().resources .findResourceByIdentifier(((Item) anItem).identifierref); @@ -145,8 +215,8 @@ Iterator<SimpleQuestionAnswer> iter = itemData.getAnswers().answers .iterator(); - String answers = "\r\nsetSingleVariant(" - + itemData.getAnswers().getSingleVariant() + ");\r\n"; + String answers = "\r\nsetAnswerType(" + + itemData.getAnswers().getAnswerType() + ");\r\n"; while (iter.hasNext()) { SimpleQuestionAnswer answer = iter.next(); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java 2008-05-24 14:29:24 UTC (rev 164) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java 2008-05-24 17:14:09 UTC (rev 165) @@ -11,7 +11,7 @@ public class ScoredUserAnswerStatus extends UserAnswerStatus { private String completion_status = "unknown"; private String success_status = "unknown"; - + public ScoredUserAnswerStatus(TreeItem anItem) { super(anItem); } Modified: WebEditor/template/global/simpleQ.js =================================================================== --- WebEditor/template/global/simpleQ.js 2008-05-24 14:29:24 UTC (rev 164) +++ WebEditor/template/global/simpleQ.js 2008-05-24 17:14:09 UTC (rev 165) @@ -1,7 +1,7 @@ -var singleAnswer=false; +var answerType; var answers=new Array(); -function setSingleVariant(singleVariant){ - singleAnswer = singleVariant; +function setAnswerType(type){ + answerType = type; } function addAnswer(_text, _point){ var answer = { @@ -15,14 +15,21 @@ function show(){ var i; - for (i=0; i < answers.length; i++){ - if (singleAnswer){ - document.write("<input type='radio' name='answer' id='" + answers[i].id + "' value='" + answers[i].id + "'>"); - } else { - document.write("<input type='checkbox' id='" + answers[i].id + "'>"); - } - document.write(answers[i].text); - document.write("<BR>"); + if (answerType != 2){ + for (i=0; i < answers.length; i++){ + if (answerType == 0){ + document.write("<input type='radio' name='answer' id='" + answers[i].id + "' value='" + answers[i].id + "'>"); + } else { + if (answerType == 1){ + document.write("<input type='checkbox' id='" + answers[i].id + "'>"); + } + } + + document.write(answers[i].text); + document.write("<BR>"); + } + } else { + document.write("<input type='text' name='answer' id='answer' value=''><br>"); } } @@ -31,14 +38,19 @@ var i; var answer = ""; - for (i=0; i < answers.length; i++){ - var ans = document.getElementById(answers[i].id); - if (ans.checked){ - answer += "1"; - } else { - answer += "0"; - } - } + + if (answerType != 2){ + for (i=0; i < answers.length; i++){ + var ans = document.getElementById(answers[i].id); + if (ans.checked){ + answer += "1"; + } else { + answer += "0"; + } + } + } else { + answer = document.getElementById("answer").value; + } SetValue("cmi.answers.0.value", answer); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-24 14:29:17
|
Revision: 164 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=164&view=rev Author: sem62 Date: 2008-05-24 07:29:24 -0700 (Sat, 24 May 2008) Log Message: ----------- * Created class for managing main menu * moved parsing parameter to Setting class Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java Added Paths: ----------- WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenu.java WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenuListenet.java Added: WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenu.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenu.java (rev 0) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenu.java 2008-05-24 14:29:24 UTC (rev 164) @@ -0,0 +1,90 @@ +package edu.lnu.FireFly.WebEditor; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; + +import edu.lnu.FireFly.WebEditor.Data.AnswersStatusManager; +import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; + +public class MainMenu extends JMenuBar implements ActionListener { + + private MainMenuListenet listener = null; + /** + * + */ + private static final long serialVersionUID = 8349926727749029112L; + + public MainMenu() { + init(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + try { + if (arg0.getSource() == openMenuItem) { + if (listener != null) { + listener.openManifest(); + } + } + + if (arg0.getSource() == resetMenuItem) { + AnswersStatusManager.getInstance().resetAllAnswers(); + } + + if (arg0.getSource() == publishMenuItem) { + WebEditorServiceClient.getInstance().publish(); + } + + if (arg0.getSource() == saveMenuItem) { + if (listener != null) { + listener.saveManifest(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void setListener(MainMenuListenet listener){ + this.listener = listener; + } + + private void init() { + JMenu fileMenu = new JMenu("File"); + add(fileMenu); + + JMenu editMenu = new JMenu("Edit"); + add(editMenu); + + resetMenuItem = new JMenuItem("Reset user activity"); + resetMenuItem.addActionListener(this); + fileMenu.add(resetMenuItem); + + openMenuItem = new JMenuItem("Open"); + openMenuItem.addActionListener(this); + fileMenu.add(openMenuItem); + + // Create a menu item + saveMenuItem = new JMenuItem("Save"); + saveMenuItem.addActionListener(this); + fileMenu.add(saveMenuItem); + + // Create a menu item + publishMenuItem = new JMenuItem("Publish"); + publishMenuItem.addActionListener(this); + fileMenu.add(publishMenuItem); + } + + protected JMenuItem openMenuItem = null; + + protected JMenuItem resetMenuItem = null; + + protected JMenuItem saveMenuItem = null; + + private JMenuItem publishMenuItem; + +} Added: WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenuListenet.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenuListenet.java (rev 0) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/MainMenuListenet.java 2008-05-24 14:29:24 UTC (rev 164) @@ -0,0 +1,8 @@ +package edu.lnu.FireFly.WebEditor; + +import edu.lnu.FireFly.FFManifest.parser.TestDocException; + +public interface MainMenuListenet { + public void saveManifest() throws TestDocException; + public void openManifest() throws TestDocException; +} Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java 2008-05-24 13:10:11 UTC (rev 163) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java 2008-05-24 14:29:24 UTC (rev 164) @@ -1,5 +1,7 @@ package edu.lnu.FireFly.WebEditor; +import javax.swing.JApplet; + public class Settings { private String courseLocation = "http://127.0.0.1/sem/course/"; private String templateLocation = "http://127.0.0.1/sem/WebEditor/template/"; @@ -19,7 +21,27 @@ return obj; } + + public void parseAppletParameters(JApplet applet){ + String paramCourseLocation = applet.getParameter("courseLocation"); + String paramServiceLocation = applet.getParameter("serviceLocation"); + String paramTemplateLocation = applet.getParameter("templateLocation"); + String paramResourceLocation = applet.getParameter("resourceLocation"); + if (paramCourseLocation != null) { + Settings.getInstance().setCourseLocation(paramCourseLocation); + } + if (paramServiceLocation != null) { + Settings.getInstance().setServiceLocation(paramServiceLocation); + } + if (paramTemplateLocation != null) { + Settings.getInstance().setTemplateLocation(paramTemplateLocation); + } + if (paramResourceLocation != null) { + Settings.getInstance().setResourceLocation(paramResourceLocation); + } + } + public String getCourseLocation() { return courseLocation; } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-24 13:10:11 UTC (rev 163) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-24 14:29:24 UTC (rev 164) @@ -1,11 +1,5 @@ package edu.lnu.FireFly.WebEditor; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JScrollPane; import edu.lnu.FireFly.FFManifest.Manifest; @@ -22,8 +16,7 @@ import edu.lnu.FireFly.WebEditor.ItemModels.OrganizationModel; import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; -public class WebEditor extends AppletWithWYSIWYGEditor implements - ActionListener { +public class WebEditor extends AppletWithWYSIWYGEditor implements MainMenuListenet{ /** * @@ -36,41 +29,11 @@ protected Manifest manifest = null; - protected JMenuItem openMenuItem = null; - - protected JMenuItem resetMenuItem = null; - - protected JMenuItem saveMenuItem = null; - private Thread threadForAautoSave; private AutoSaveThread autoSaveThread; - private JMenuItem publishMenuItem; - @Override - public void actionPerformed(ActionEvent arg0) { - try { - if (arg0.getSource() == openMenuItem) { - openManifest(); - } - - if (arg0.getSource() == resetMenuItem) { - AnswersStatusManager.getInstance().resetAllAnswers(); - } - - if (arg0.getSource() == publishMenuItem) { - WebEditorServiceClient.getInstance().publish(); - } - - if (arg0.getSource() == saveMenuItem) { - saveManifest(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - public void saveManifest() throws TestDocException { Parser parser = new Parser(); @@ -80,6 +43,7 @@ parser.toXML(manifest)); } + @Override public void openManifest() throws TestDocException { Parser parser = new Parser(); @@ -101,8 +65,8 @@ @Override public void init() { - parseParameter(); - + Settings.getInstance().parseAppletParameters(this); + instance = this; autoSaveThread = new AutoSaveThread(); @@ -125,26 +89,6 @@ courseTree.addMouseListener(new CourseTreePopupMenu()); } - private void parseParameter() { - String paramCourseLocation = getParameter("courseLocation"); - String paramServiceLocation = getParameter("serviceLocation"); - String paramTemplateLocation = getParameter("templateLocation"); - String paramResourceLocation = getParameter("resourceLocation"); - - if (paramCourseLocation != null) { - Settings.getInstance().setCourseLocation(paramCourseLocation); - } - if (paramServiceLocation != null) { - Settings.getInstance().setServiceLocation(paramServiceLocation); - } - if (paramTemplateLocation != null) { - Settings.getInstance().setTemplateLocation(paramTemplateLocation); - } - if (paramResourceLocation != null) { - Settings.getInstance().setResourceLocation(paramResourceLocation); - } - } - private void CreateNewCourse() { try { manifest = ManifestFactory.createManifest(); @@ -166,35 +110,8 @@ } public void initMenu() { - // Create the menu bar - JMenuBar menuBar = new JMenuBar(); - - // Create a menu - JMenu fileMenu = new JMenu("File"); - menuBar.add(fileMenu); - - JMenu editMenu = new JMenu("Edit"); - menuBar.add(editMenu); - - resetMenuItem = new JMenuItem("Reset user activity"); - resetMenuItem.addActionListener(this); - fileMenu.add(resetMenuItem); - - openMenuItem = new JMenuItem("Open"); - openMenuItem.addActionListener(this); - fileMenu.add(openMenuItem); - - // Create a menu item - saveMenuItem = new JMenuItem("Save"); - saveMenuItem.addActionListener(this); - fileMenu.add(saveMenuItem); - - // Create a menu item - publishMenuItem = new JMenuItem("Publish"); - publishMenuItem.addActionListener(this); - fileMenu.add(publishMenuItem); - - // Install the menu bar in the frame + MainMenu menuBar = new MainMenu(); + menuBar.setListener(this); this.setJMenuBar(menuBar); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-24 13:10:06
|
Revision: 163 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=163&view=rev Author: sem62 Date: 2008-05-24 06:10:11 -0700 (Sat, 24 May 2008) Log Message: ----------- Added dialog for showing user answer status. Modified Paths: -------------- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java Added Paths: ----------- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/GeneralUserAnswerStatusDlg.java Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-24 13:10:11 UTC (rev 163) @@ -1,14 +1,21 @@ package edu.lnu.FireFly.WebEditor; +import java.net.URL; + import javax.swing.JApplet; import edu.lnu.FireFly.FFManifest.TreeItem; +import edu.lnu.FireFly.FFManifest.item.Item; +import edu.lnu.FireFly.FFManifest.resource.Resource; import edu.lnu.FireFly.Rte.Cmi; import edu.lnu.FireFly.Rte.CmiManager; import edu.lnu.FireFly.Rte.ElementName; import edu.lnu.FireFly.Rte.GlobalStateInformation; import edu.lnu.FireFly.WebEditor.Data.AnswersStatusManager; import edu.lnu.FireFly.WebEditor.Data.SummaryPageManager; +import edu.lnu.FireFly.WebEditor.ItemModels.ItemModel; +import edu.lnu.FireFly.WebEditor.ItemModels.ItemModels; +import edu.lnu.FireFly.WebEditor.UserAnswerStatus.UserAnswerStatus; /** * It is an Applet, but it contain API handlers. @@ -29,81 +36,144 @@ nextItemIdentifier = itemIdentifier; } - public String Initialize(String parameter) { - System.out.print("Initialize(" + parameter + ");\n"); + public synchronized String Initialize(String parameter) { + try { + System.out.print("Initialize(" + parameter + ");\n"); - GlobalStateInformation.setCurrentActivity(SummaryPageManager - .getInstance().getManifest().findItemByIdentifier( - nextItemIdentifier)); + GlobalStateInformation.setCurrentActivity(SummaryPageManager + .getInstance().getManifest().findItemByIdentifier( + nextItemIdentifier)); + } catch (Exception e) { + e.printStackTrace(); + return "false"; + } return "true"; } - public String Terminate(String parameter) { - System.out.print("Terminate(" + parameter + ");\n"); + public synchronized String Terminate(String parameter) { + try { + System.out.print("Terminate(" + parameter + ");\n"); - GlobalStateInformation.setCurrentActivity(null); + if (nextItemIdentifier.equals(GlobalStateInformation.getCurrentActivity().getIdentifier())){ + showAnswerResult(); + } + GlobalStateInformation.setCurrentActivity(null); + } catch (Exception e) { + e.printStackTrace(); + return "false"; + } return "true"; } - public String GetValue(String parameter) { - System.out.print("GetValue(" + parameter + ")"); + private void showAnswerResult() { + TreeItem currentActivity = GlobalStateInformation + .getCurrentActivity(); + String identifier = ""; + if (currentActivity != null) { + identifier = currentActivity.getIdentifier(); + TreeItem item = SummaryPageManager.getInstance() + .getManifest().findItemByIdentifier(identifier); + ItemModel model = ItemModels.getModelFromItem(item); - Cmi cmi = getCmiModel(); + UserAnswerStatus answerStatus = AnswersStatusManager + .getInstance().getAnswerStatus(item); + model.showAnswerStatus(answerStatus); + } + redirectTo(identifier); + } + + private void redirectTo(String identifier) { + try { + TreeItem item = SummaryPageManager.getInstance().getManifest() + .findItemByIdentifier(identifier); + + if (item.getClass() != Item.class) { + return; + } + + Resource resource = WebEditor.instance.getManifest().resources + .findResourceByIdentifier(((Item) item).identifierref); + if (resource != null) { + getAppletContext().showDocument( + new URL(Settings.getInstance().getCourseLocation() + + resource.getFullHref()), "ContentFrame"); + System.out.print("redirected\n"); + } + } catch (Exception exc) { + exc.printStackTrace(); + } + } + + public synchronized String GetValue(String parameter) { String result = ""; - if (parameter.toLowerCase().startsWith("cmi.")) { - result = cmi.getValue(new ElementName(parameter.substring(4))); + + try { + System.out.print("GetValue(" + parameter + ")"); + + Cmi cmi = getCmiModel(); + + if (parameter.toLowerCase().startsWith("cmi.")) { + result = cmi.getValue(new ElementName(parameter.substring(4))); + } + + System.out.println(" returned " + result); + } catch (Exception e) { + e.printStackTrace(); + return ""; } - - System.out.println(" returned " + result); return result; } private Cmi getCmiModel() { - TreeItem activity = GlobalStateInformation.getCurrentActivity(); Cmi cmi = CmiManager.getInstance().getModelForActivity(activity); return cmi; } - public boolean SetValue(String parameter, String value) { - System.out.print("SetValue(" + parameter + ", " + value + ");\n"); + public synchronized String SetValue(String parameter, String value) { + try { + System.out.print("SetValue(" + parameter + ", " + value + ");\n"); - Cmi cmi = getCmiModel(); + Cmi cmi = getCmiModel(); - if (parameter.toLowerCase().startsWith("cmi.")) { - cmi.setValue(new ElementName(parameter.substring(4)), value); + if (parameter.toLowerCase().startsWith("cmi.")) { + cmi.setValue(new ElementName(parameter.substring(4)), value); - if (parameter.startsWith("cmi.answers.")) { - String itemIdentifier = GlobalStateInformation - .getCurrentActivity().getIdentifier(); + if (parameter.startsWith("cmi.answers.")) { + String itemIdentifier = GlobalStateInformation + .getCurrentActivity().getIdentifier(); - TreeItem item = SummaryPageManager.getInstance().getManifest() - .findItemByIdentifier(itemIdentifier); + TreeItem item = SummaryPageManager.getInstance() + .getManifest().findItemByIdentifier(itemIdentifier); - AnswersStatusManager.getInstance().cmiAnswersChanged(item); + AnswersStatusManager.getInstance().cmiAnswersChanged(item); + } + + return "true"; + } else { + return "false"; } - - return true; - } else { - return false; + } catch (Exception e) { + e.printStackTrace(); + return "false"; } } - public String Commit(String parameter) { + public synchronized String Commit(String parameter) { System.out.print("Commit(" + parameter + ");\n"); return "true"; } - public int GetLastError() { + public synchronized int GetLastError() { System.out.print("GetLastError();\n"); return 0; } - public String GetErrorString(String parameter) { + public synchronized String GetErrorString(String parameter) { int code = Integer.parseInt(parameter); String result = ""; @@ -113,7 +183,7 @@ return result; } - public String GetDiagnostic(String parameter) { + public synchronized String GetDiagnostic(String parameter) { System.out.print("GetDiagnostic(" + parameter + ");\n"); return ""; } Added: WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/GeneralUserAnswerStatusDlg.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/GeneralUserAnswerStatusDlg.java (rev 0) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/GeneralUserAnswerStatusDlg.java 2008-05-24 13:10:11 UTC (rev 163) @@ -0,0 +1,222 @@ +package edu.lnu.FireFly.WebEditor.GUI.Dialogs; + +/** + * + * @author Yura + */ +public class GeneralUserAnswerStatusDlg extends javax.swing.JDialog { + /** + * + */ + private static final long serialVersionUID = 1L; + /** A return status code - returned if Cancel button has been pressed */ + public static final int RET_CANCEL = 0; + /** A return status code - returned if OK button has been pressed */ + public static final int RET_OK = 1; + + /** Creates new form NewOkCancelDialog */ + public GeneralUserAnswerStatusDlg(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + } + + /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */ + public int getReturnStatus() { + return returnStatus; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + okButton = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + completionValueLabel = new javax.swing.JLabel(); + succesValueLabel = new javax.swing.JLabel(); + rawValueLabel = new javax.swing.JLabel(); + maxValueLabel = new javax.swing.JLabel(); + minValueLabel = new javax.swing.JLabel(); + + setTitle("Answer status"); + setModal(true); + setResizable(false); + + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeDialog(evt); + } + }); + + okButton.setText("Ok"); + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Checking results")); + + jLabel1.setText("Min score :"); + + jLabel2.setText("Max score :"); + + jLabel3.setText("Raw score :"); + + jLabel4.setText("Completion status :"); + + jLabel5.setText("Success status :"); + + completionValueLabel.setText("6"); + + succesValueLabel.setText("successStatus"); + + rawValueLabel.setText("rawScore"); + + maxValueLabel.setText("maxScore"); + + minValueLabel.setText("minScore"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4) + .addComponent(jLabel5) + .addComponent(jLabel3) + .addComponent(jLabel1) + .addComponent(jLabel2)) + .addGap(12, 12, 12) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(succesValueLabel) + .addComponent(completionValueLabel) + .addComponent(rawValueLabel) + .addComponent(maxValueLabel) + .addComponent(minValueLabel)) + .addContainerGap(16, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(completionValueLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(succesValueLabel)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(minValueLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(maxValueLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(rawValueLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel5))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(okButton) + .addContainerGap()) + ); + + pack(); + } + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + doClose(RET_OK); + } + + /** Closes the dialog */ + private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + doClose(RET_CANCEL); + } + + private void doClose(int retStatus) { + returnStatus = retStatus; + setVisible(false); + dispose(); + } + + public void show(double min, double max, double raw, String completion, String success){ + minValueLabel.setText(String.valueOf(min)); + maxValueLabel.setText(String.valueOf(max)); + rawValueLabel.setText(String.valueOf(raw)); + + completionValueLabel.setText(completion); + succesValueLabel.setText(success); + + setVisible(true); + } + +// /** +// * @param args the command line arguments +// */ +// public static void main(String args[]) { +// java.awt.EventQueue.invokeLater(new Runnable() { +// public void run() { +// GeneralUserAnswerStatusDlg dialog = new GeneralUserAnswerStatusDlg(new javax.swing.JFrame(), true); +// dialog.addWindowListener(new java.awt.event.WindowAdapter() { +// public void windowClosing(java.awt.event.WindowEvent e) { +// System.exit(0); +// } +// }); +// +// dialog.show(0, 1, 0.5, "completed", "passed"); +// } +// }); +// } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel minValueLabel; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel completionValueLabel; + private javax.swing.JLabel succesValueLabel; + private javax.swing.JLabel rawValueLabel; + private javax.swing.JLabel maxValueLabel; + private javax.swing.JPanel jPanel1; + private javax.swing.JButton okButton; + // End of variables declaration//GEN-END:variables + + private int returnStatus = RET_CANCEL; +} Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java 2008-05-24 13:10:11 UTC (rev 163) @@ -181,4 +181,10 @@ // do nothing. // Chapter currently haven't resource file } + + @Override + public void showAnswerStatus(UserAnswerStatus answerStatus) { + // TODO Auto-generated method stub + + } } \ No newline at end of file Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java 2008-05-24 13:10:11 UTC (rev 163) @@ -116,4 +116,10 @@ // TODO Auto-generated method stub return 0; } + + @Override + public void showAnswerStatus(UserAnswerStatus answerStatus) { + // TODO Auto-generated method stub + + } } \ No newline at end of file Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-24 13:10:11 UTC (rev 163) @@ -72,6 +72,8 @@ updateItemResource(anItem, true); } } + + public abstract void showAnswerStatus(UserAnswerStatus answerStatus); public abstract void addItem(TreeItem parent); @@ -286,8 +288,7 @@ public abstract UserAnswerStatus createUserAnswerInstance(TreeItem anItem); - public abstract double getAnswerRawScore(TreeItem anItem, - String[] userAnswers); + public abstract double getAnswerRawScore(TreeItem anItem, String[] userAnswers); public abstract double getAnswerMinScore(TreeItem item); Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java 2008-05-24 13:10:11 UTC (rev 163) @@ -94,4 +94,10 @@ // TODO Auto-generated method stub return 0; } + + @Override + public void showAnswerStatus(UserAnswerStatus answerStatus) { + // TODO Auto-generated method stub + + } } \ No newline at end of file Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-24 13:10:11 UTC (rev 163) @@ -15,6 +15,72 @@ public class SimpleQuestionModel extends ResourcedItemModel { @Override + public void showAnswerStatus(UserAnswerStatus answerStatus) { + ((ScoredUserAnswerStatus)answerStatus).showStatus(); + } + + public SimpleQuestionModel() { + modelName = "SimpleQuestionModel"; + registerConfigDlg(new SimpleQuestionPropertiestsDlg()); + } + + @Override + public boolean canAddToItem(TreeItem parent) { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean canConvertItem(TreeItem parent) { + // TODO Auto-generated method stub + return false; + } + + @Override + protected ItemData createItemDataInstance() { + return new SimpleQuestionData(); + } + + @Override + public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { + return new ScoredUserAnswerStatus(anItem); + } + + @Override + public double getAnswerMaxScore(TreeItem item) { + double result = 0d; + + SimpleQuestionData data = getData(item); + + for (int i = 0; i < data.getAnswers().answers.size(); i++) { + double answerPoint = data.getAnswers().answers.get(i) + .getAnswerPoint(); + if (answerPoint > 0) { + result += answerPoint; + } + } + + return result; + } + + @Override + public double getAnswerMinScore(TreeItem item) { + double result = 0d; + + SimpleQuestionData data = getData(item); + + for (int i = 0; i < data.getAnswers().answers.size(); i++) { + double answerPoint = data.getAnswers().answers.get(i) + .getAnswerPoint(); + if (answerPoint < 0) { + result += answerPoint; + } + } + + return result; + } + + @Override public double getAnswerRawScore(TreeItem anItem, String[] userAnswers) { SimpleQuestionData data = getData(anItem); @@ -36,9 +102,8 @@ return result; } - @Override - public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { - return new ScoredUserAnswerStatus(anItem); + public SimpleQuestionData getData(TreeItem item) { + return ((SimpleQuestionData) getItemData(item)); } @Override @@ -56,38 +121,17 @@ return true; } - public SimpleQuestionModel() { - modelName = "SimpleQuestionModel"; - registerConfigDlg(new SimpleQuestionPropertiestsDlg()); - } - @Override - public boolean canAddToItem(TreeItem parent) { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean canConvertItem(TreeItem parent) { - // TODO Auto-generated method stub + public boolean getShowSummaryPageMenuVisible() { return false; } - public SimpleQuestionData getData(TreeItem item) { - return ((SimpleQuestionData) getItemData(item)); - } - @Override public boolean isRemovable() { return true; } @Override - protected ItemData createItemDataInstance() { - return new SimpleQuestionData(); - } - - @Override protected void updateResourceFile(TreeItem anItem) { Resource resource = WebEditor.instance.getManifest().resources .findResourceByIdentifier(((Item) anItem).identifierref); @@ -114,43 +158,4 @@ template.setProperty("answers", answers); template.updateResource(); } - - @Override - public boolean getShowSummaryPageMenuVisible() { - return false; - } - - @Override - public double getAnswerMaxScore(TreeItem item) { - double result = 0d; - - SimpleQuestionData data = getData(item); - - for (int i = 0; i < data.getAnswers().answers.size(); i++) { - double answerPoint = data.getAnswers().answers.get(i) - .getAnswerPoint(); - if (answerPoint > 0) { - result += answerPoint; - } - } - - return result; - } - - @Override - public double getAnswerMinScore(TreeItem item) { - double result = 0d; - - SimpleQuestionData data = getData(item); - - for (int i = 0; i < data.getAnswers().answers.size(); i++) { - double answerPoint = data.getAnswers().answers.get(i) - .getAnswerPoint(); - if (answerPoint < 0) { - result += answerPoint; - } - } - - return result; - } } \ No newline at end of file Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java 2008-05-24 13:10:11 UTC (rev 163) @@ -16,6 +16,12 @@ import edu.lnu.FireFly.WebEditor.UserAnswerStatus.UserAnswerStatus; public class SummaryPageModel extends ResourcedItemModel { + @Override + public void showAnswerStatus(UserAnswerStatus answerStatus) { + // TODO Auto-generated method stub + + } + public SummaryPageModel() { modelName = "SummaryPageModel"; } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java 2008-05-24 13:10:11 UTC (rev 163) @@ -13,6 +13,10 @@ } @Override + public void showAnswerStatus(UserAnswerStatus answerStatus) { + } + + @Override public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { return new UnknownModelAnswerStatus(anItem); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java 2008-05-23 17:44:49 UTC (rev 162) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java 2008-05-24 13:10:11 UTC (rev 163) @@ -4,6 +4,7 @@ import edu.lnu.FireFly.FFManifest.item.Item; import edu.lnu.FireFly.Rte.Cmi; import edu.lnu.FireFly.Rte.ElementName; +import edu.lnu.FireFly.WebEditor.GUI.Dialogs.GeneralUserAnswerStatusDlg; import edu.lnu.FireFly.WebEditor.ItemModels.ItemModel; import edu.lnu.FireFly.WebEditor.ItemModels.ItemModels; @@ -14,6 +15,11 @@ public ScoredUserAnswerStatus(TreeItem anItem) { super(anItem); } + + public void showStatus(){ + GeneralUserAnswerStatusDlg dlg = new GeneralUserAnswerStatusDlg(null, true); + dlg.show(minScore, maxScore, rawScore, completion_status, success_status); + } @Override public void updateRteFields(Cmi cmi) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-23 17:44:46
|
Revision: 162 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=162&view=rev Author: sem62 Date: 2008-05-23 10:44:49 -0700 (Fri, 23 May 2008) Log Message: ----------- * Using new RTE library. * Realizing mechanism for checking user answer. * CleenUp code. Modified Paths: -------------- WebEditor/resources/index.html WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithWYSIWYGEditor.java WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AnswersStatusManager.java WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AutoSaveThread.java WebEditor/src/edu/lnu/FireFly/WebEditor/Data/ManifestFactory.java WebEditor/src/edu/lnu/FireFly/WebEditor/Data/SummaryPageManager.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/CourseTreePopupMenu.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/ChapterPropertiestsDlg.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/CompileQPropertiestsDlg.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/MultiLineCellRenderer.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/MultiLineTableCellEditor.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/PartAttributesCellEditor.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/PartNumber.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/PartNumberCellRenderer.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/CompileQ/PartOptionsPanel.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/LectureException.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/LecturePropertiestsDlg.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/PropertyDlg.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/RenameDlg.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Dialogs/SimpleQuestionPropertiestsDlg.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/JMenuItemContainedModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/Reorganizer.java WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/TreeDataModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterItemData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQPart.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/PartAttributes.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModels.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/OrganizationModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ResourcedItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionAnswer.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionAnswersDataModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionException.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageData.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Template.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownModelAnswerStatus.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Utils.java WebEditor/src/edu/lnu/FireFly/WebEditor/Settings.java WebEditor/src/edu/lnu/FireFly/WebEditor/WSClients/WebEditorServiceClient.java WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java WebEditor/template/global/SummaryPage.js WebEditor/template/global/simpleQ.js Added Paths: ----------- WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/LectureUserAnswerStatus.java WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/ScoredUserAnswerStatus.java WebEditor/src/edu/lnu/FireFly/WebEditor/UserAnswerStatus/UserAnswerStatus.java WebEditor/template/global/images/failed.gif WebEditor/template/global/images/passed.gif Removed Paths: ------------- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/LectureUserAnswerStatus.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ScoredUserAnswerStatus.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UserAnswerStatus.java Modified: WebEditor/resources/index.html =================================================================== --- WebEditor/resources/index.html 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/resources/index.html 2008-05-23 17:44:49 UTC (rev 162) @@ -128,7 +128,7 @@ </tr> </tbody> </table> - <tr><td><input type=text id='getval'><input type='button' onclick="getVal();"><td><input id='getvalres'></td></tr> + <!--tr><td><input type=text id='getval'><input type='button' value='SetValue' onclick="getVal();"><input id='getvalres'></td></tr--> </table> </body> Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-23 17:44:49 UTC (rev 162) @@ -32,7 +32,9 @@ public String Initialize(String parameter) { System.out.print("Initialize(" + parameter + ");\n"); - GlobalStateInformation.setCurrentActivity(SummaryPageManager.getInstance().getManifest().findItemByIdentifier(nextItemIdentifier)); + GlobalStateInformation.setCurrentActivity(SummaryPageManager + .getInstance().getManifest().findItemByIdentifier( + nextItemIdentifier)); return "true"; } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithWYSIWYGEditor.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithWYSIWYGEditor.java 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithWYSIWYGEditor.java 2008-05-23 17:44:49 UTC (rev 162) @@ -5,63 +5,63 @@ import netscape.javascript.JSObject; import edu.lnu.FireFly.WebEditor.GUI.Dialogs.PropertyDlg; -public class AppletWithWYSIWYGEditor extends AppletWithApiHandle{ - private boolean htmlEditing = false; - private JTextComponent textField = null; - private PropertyDlg editingDlg = null; +public class AppletWithWYSIWYGEditor extends AppletWithApiHandle { + private boolean htmlEditing = false; + private JTextComponent textField = null; + private PropertyDlg editingDlg = null; - public void htmlEdit(JTextComponent captionTextField2, PropertyDlg dlg) { - JSObject win = JSObject.getWindow(this); - Object[] params = new String[1]; - params[0] = captionTextField2.getText(); - - htmlEditing = true; - textField = captionTextField2; - editingDlg = dlg; - - lockPropertyDlg(); - win.call("showEditor", params); - } - - public String getEditedHTML(){ - return textField.getText(); - } + public void htmlEdit(JTextComponent captionTextField2, PropertyDlg dlg) { + JSObject win = JSObject.getWindow(this); + Object[] params = new String[1]; + params[0] = captionTextField2.getText(); - public void cancelHtmlEditing(){ - unlockPropertyDlg(); + htmlEditing = true; + textField = captionTextField2; + editingDlg = dlg; - textField = null; - editingDlg = null; - htmlEditing = false; - - System.out.println("Canceled html editing"); - } + lockPropertyDlg(); + win.call("showEditor", params); + } - private void unlockPropertyDlg() { - editingDlg.setEnabled(true); - } - - public void setEditedHTML(String newHTML){ - if (!htmlEditing){ - return; - } - textField.setText(newHTML); - editingDlg.editedHtmlTextWasSet(); - - htmlEditing = false; - unlockPropertyDlg(); - } + public String getEditedHTML() { + return textField.getText(); + } - private void lockPropertyDlg() { - editingDlg.setEnabled(false); + public void cancelHtmlEditing() { + unlockPropertyDlg(); + + textField = null; + editingDlg = null; + htmlEditing = false; + + System.out.println("Canceled html editing"); + } + + private void unlockPropertyDlg() { + editingDlg.setEnabled(true); + } + + public void setEditedHTML(String newHTML) { + if (!htmlEditing) { + return; } + textField.setText(newHTML); + editingDlg.editedHtmlTextWasSet(); - /** - * - */ - private static final long serialVersionUID = 1L; + htmlEditing = false; + unlockPropertyDlg(); + } - public boolean isHtmlEditing() { - return htmlEditing; - } + private void lockPropertyDlg() { + editingDlg.setEnabled(false); + } + + /** + * + */ + private static final long serialVersionUID = 1L; + + public boolean isHtmlEditing() { + return htmlEditing; + } } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java 2008-05-23 17:44:49 UTC (rev 162) @@ -39,7 +39,7 @@ if (e.getNewLeadSelectionPath() == null) { try { AppletWithApiHandle.setNextItemIdentifier(""); - + getAppletContext().showDocument( new URL(Settings.getInstance().getResourceLocation() + "/empty.htm"), "ContentFrame"); @@ -55,7 +55,7 @@ if (e.getNewLeadSelectionPath().getLastPathComponent().getClass() == Item.class) { Item item = (Item) e.getNewLeadSelectionPath() .getLastPathComponent(); - + AppletWithApiHandle.setNextItemIdentifier(item.identifier); try { Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AnswersStatusManager.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AnswersStatusManager.java 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AnswersStatusManager.java 2008-05-23 17:44:49 UTC (rev 162) @@ -9,7 +9,7 @@ import edu.lnu.FireFly.Rte.CmiManager; import edu.lnu.FireFly.WebEditor.ItemModels.ItemModel; import edu.lnu.FireFly.WebEditor.ItemModels.ItemModels; -import edu.lnu.FireFly.WebEditor.ItemModels.UserAnswerStatus; +import edu.lnu.FireFly.WebEditor.UserAnswerStatus.UserAnswerStatus; public class AnswersStatusManager { private HashMap<TreeItem, UserAnswerStatus> answerStatus = new HashMap<TreeItem, UserAnswerStatus>(); @@ -18,34 +18,34 @@ private AnswersStatusManager() { } - - public void resetAllAnswers(){ + + public void resetAllAnswers() { answerStatus.clear(); - + Manifest manifest = SummaryPageManager.getInstance().getManifest(); - + TreeItem root = null; try { root = manifest.getRoot(); } catch (TestDocException e) { e.printStackTrace(); - - return ; + + return; } - + updateAllCmiModels(root); } public void updateAllCmiModels(TreeItem root) { ItemModel itemModel = ItemModels.getModelFromItem(root); - + Cmi cmi = CmiManager.getInstance().getModelForActivity(root); cmi.clearAnswers(); - + itemModel.handleUserAnswer(root); - - for (int i=0; i < root.getChildCount(); i++){ + + for (int i = 0; i < root.getChildCount(); i++) { updateAllCmiModels(root.getChild(i)); } } @@ -56,7 +56,8 @@ if (userAnswerStatus == null) { ItemModel itemModel = ItemModels.getModelFromItem(anItem); - answerStatus.put(anItem, itemModel.createUserAnswerInstance(anItem)); + answerStatus + .put(anItem, itemModel.createUserAnswerInstance(anItem)); userAnswerStatus = answerStatus.get(anItem); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AutoSaveThread.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AutoSaveThread.java 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AutoSaveThread.java 2008-05-23 17:44:49 UTC (rev 162) @@ -6,36 +6,37 @@ public class AutoSaveThread implements Runnable { - private long nextSaveAt = 0; - - @Override - public void run() { - reset(); + private long nextSaveAt = 0; - try { - while (true) { - Thread.sleep(5000); - if (System.currentTimeMillis() > nextSaveAt){ - processSave(); - reset(); - } - } - } catch (InterruptedException e) { - // If interrupt sleepping. - // Do nothing + @Override + public void run() { + reset(); + + try { + while (true) { + Thread.sleep(5000); + if (System.currentTimeMillis() > nextSaveAt) { + processSave(); + reset(); } + } + } catch (InterruptedException e) { + // If interrupt sleepping. + // Do nothing } + } - public void reset() { - nextSaveAt = System.currentTimeMillis() + Settings.getInstance().getAutoSaveInterval(); - } + public void reset() { + nextSaveAt = System.currentTimeMillis() + + Settings.getInstance().getAutoSaveInterval(); + } - private void processSave() { - try { - WebEditor.instance.saveManifest(); - } catch (TestDocException e) { - System.out.println("WARNING: Can't save manifest."); - } + private void processSave() { + try { + WebEditor.instance.saveManifest(); + } catch (TestDocException e) { + System.out.println("WARNING: Can't save manifest."); } + } } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/Data/ManifestFactory.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/ManifestFactory.java 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Data/ManifestFactory.java 2008-05-23 17:44:49 UTC (rev 162) @@ -17,70 +17,69 @@ import edu.lnu.FireFly.WebEditor.ItemModels.Chapter.ChapterItemData; public class ManifestFactory { - static public Manifest createManifest(){ - Manifest manifest = new Manifest(); - - manifest.setIdentifier(UUID.randomUUID().toString()); - manifest.setOrganizations(createOrganizations()); - manifest.setResources(new Resources()); + static public Manifest createManifest() { + Manifest manifest = new Manifest(); - OrganizationModel model = null; - TreeItem root = null; - try{ - root = manifest.getRoot(); - model = new OrganizationModel(); - } - catch (Exception e) { - e.printStackTrace(); - return null; - } + manifest.setIdentifier(UUID.randomUUID().toString()); + manifest.setOrganizations(createOrganizations()); + manifest.setResources(new Resources()); - model.setItemData(root, new ChapterItemData()); - model.updateItemResource(root, false); - - return manifest; + OrganizationModel model = null; + TreeItem root = null; + try { + root = manifest.getRoot(); + model = new OrganizationModel(); + } catch (Exception e) { + e.printStackTrace(); + return null; } - - static public Organizations createOrganizations(){ - Organizations organizations = new Organizations(); - Organization organization = new Organization(); - organization.setIdentifier(UUID.randomUUID().toString()); - organization.setTitle("New organization"); - organizations.addDefaultOrganization(organization); - - return organizations; - } - - static public Sequencing createSequencing(){ - return new Sequencing(); - } + model.setItemData(root, new ChapterItemData()); + model.updateItemResource(root, false); - static public LimitConditions createLimitConditions(){ - return new LimitConditions(); - } + return manifest; + } - public static Objectives createObjectives() { - return new Objectives(); - } + static public Organizations createOrganizations() { + Organizations organizations = new Organizations(); + Organization organization = new Organization(); + organization.setIdentifier(UUID.randomUUID().toString()); + organization.setTitle("New organization"); - public static Objective createObjective() { - return new Objective(); - } + organizations.addDefaultOrganization(organization); - public static ArrayList<MapInfo> createMapInfos() { - return new ArrayList<MapInfo>(); - } + return organizations; + } - public static MapInfo createMapInfo() { - return new MapInfo(); - } + static public Sequencing createSequencing() { + return new Sequencing(); + } - public static MapInfo createMapInfo(String targetObjectiveID) { - MapInfo mapInfo = new MapInfo(); - - mapInfo.targetObjectiveID = targetObjectiveID; - - return mapInfo; - } + static public LimitConditions createLimitConditions() { + return new LimitConditions(); + } + + public static Objectives createObjectives() { + return new Objectives(); + } + + public static Objective createObjective() { + return new Objective(); + } + + public static ArrayList<MapInfo> createMapInfos() { + return new ArrayList<MapInfo>(); + } + + public static MapInfo createMapInfo() { + return new MapInfo(); + } + + public static MapInfo createMapInfo(String targetObjectiveID) { + MapInfo mapInfo = new MapInfo(); + + mapInfo.targetObjectiveID = targetObjectiveID; + + return mapInfo; + } } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/Data/SummaryPageManager.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/SummaryPageManager.java 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Data/SummaryPageManager.java 2008-05-23 17:44:49 UTC (rev 162) @@ -16,205 +16,205 @@ import edu.lnu.FireFly.WebEditor.ItemModels.SummaryPageModel.SummaryPageModel; public class SummaryPageManager { - private SummaryPageManager() { - } + private SummaryPageManager() { + } - private static SummaryPageManager obj = null; + private static SummaryPageManager obj = null; - public static SummaryPageManager getInstance() { - if (obj == null) { - obj = new SummaryPageManager(); - } - - return obj; + public static SummaryPageManager getInstance() { + if (obj == null) { + obj = new SummaryPageManager(); } - protected Manifest manifest = null; + return obj; + } - public Manifest getManifest() { - return manifest; - } + protected Manifest manifest = null; - public void setManifest(Manifest manifest) { - this.manifest = manifest; - } + public Manifest getManifest() { + return manifest; + } - public void updateSummaryPages(TreeItem root) throws TestDocException { - pushDownSummaryPage(root); + public void setManifest(Manifest manifest) { + this.manifest = manifest; + } - for (int i = 0; i < root.getChildCount(); i++) { - TreeItem item = root.getChild(i); - ItemModel model = ItemModels.getModelFromItem(item); + public void updateSummaryPages(TreeItem root) throws TestDocException { + pushDownSummaryPage(root); - if (model.getClass() == OrganizationModel.class - || model.getClass() == ChapterModel.class) { - updateSummaryPages(item); - } - } + for (int i = 0; i < root.getChildCount(); i++) { + TreeItem item = root.getChild(i); + ItemModel model = ItemModels.getModelFromItem(item); - boolean showSummaryPage = isShowSummaryPageForItem(root); + if (model.getClass() == OrganizationModel.class + || model.getClass() == ChapterModel.class) { + updateSummaryPages(item); + } + } - if (showSummaryPage) { - createSummaryPageIfNotExists(root); - Item summaryPage = (Item) root.getChild(root.getChildCount() - 1); - ItemModel model = ItemModels.getModelFromItem(summaryPage); + boolean showSummaryPage = isShowSummaryPageForItem(root); - insertAllNeededObjectivesIntoSummaryPage(root); + if (showSummaryPage) { + createSummaryPageIfNotExists(root); + Item summaryPage = (Item) root.getChild(root.getChildCount() - 1); + ItemModel model = ItemModels.getModelFromItem(summaryPage); - ((SummaryPageModel) model).updateItemResource(summaryPage, false); - } else { - deleteSummaryPageIfExists(root); - } + insertAllNeededObjectivesIntoSummaryPage(root); + + ((SummaryPageModel) model).updateItemResource(summaryPage, false); + } else { + deleteSummaryPageIfExists(root); } + } - private void insertAllNeededObjectivesIntoSummaryPage(TreeItem root) { - Item summaryPage = (Item) root.getChild(root.getChildCount() - 1); + private void insertAllNeededObjectivesIntoSummaryPage(TreeItem root) { + Item summaryPage = (Item) root.getChild(root.getChildCount() - 1); - ArrayList<String> objectiveIds = getShowingItemsIds(root); + ArrayList<String> objectiveIds = getShowingItemsIds(root); - ItemModel model = ItemModels.getModelFromItem(summaryPage); - Objectives objectives = model.getObjectivesInstance(summaryPage); - objectives.objective = new ArrayList<Objective>(); + ItemModel model = ItemModels.getModelFromItem(summaryPage); + Objectives objectives = model.getObjectivesInstance(summaryPage); + objectives.objective = new ArrayList<Objective>(); - for (int i = 0; i < objectiveIds.size(); i++) { - String objectiveId = objectiveIds.get(i); - Objective objective = ManifestFactory.createObjective(); + for (int i = 0; i < objectiveIds.size(); i++) { + String objectiveId = objectiveIds.get(i); + Objective objective = ManifestFactory.createObjective(); - objective.objectiveID = objectiveId; - objective.mapInfo.add(ManifestFactory.createMapInfo(objectiveId)); + objective.objectiveID = objectiveId; + objective.mapInfo.add(ManifestFactory.createMapInfo(objectiveId)); - summaryPage.sequencing.objectives.objective.add(objective); - } + summaryPage.sequencing.objectives.objective.add(objective); } + } - private ArrayList<String> getShowingItemsIds(TreeItem root) { - ArrayList<String> result = new ArrayList<String>(); + private ArrayList<String> getShowingItemsIds(TreeItem root) { + ArrayList<String> result = new ArrayList<String>(); - for (int i = 0; i < root.getChildCount(); i++) { - TreeItem item = root.getChild(i); - ItemModel model = ItemModels.getModelFromItem(item); - if (model.getShowOnSummaryPage(item)) { - result.add(model.getIdentifier(item)); - } + for (int i = 0; i < root.getChildCount(); i++) { + TreeItem item = root.getChild(i); + ItemModel model = ItemModels.getModelFromItem(item); + if (model.getShowOnSummaryPage(item)) { + result.add(model.getIdentifier(item)); + } - for (int j = 0; j < item.getChildCount(); j++) { - TreeItem child = item.getChild(j); - ItemModel childModel = ItemModels.getModelFromItem(child); + for (int j = 0; j < item.getChildCount(); j++) { + TreeItem child = item.getChild(j); + ItemModel childModel = ItemModels.getModelFromItem(child); - if (childModel.getShowOnSummaryPage(child)) { - result.add(model.getIdentifier(child)); - result.addAll(getShowingItemsIds(child)); - } - } + if (childModel.getShowOnSummaryPage(child)) { + result.add(model.getIdentifier(child)); + result.addAll(getShowingItemsIds(child)); } - - return result; + } } - private void recursivlyUpdateObjectives(TreeItem root) { - - ItemModel model = ItemModels.getModelFromItem(root); - model.updateItemObjectives(root); + return result; + } - for (int i = 0; i < root.getChildCount(); i++) { - recursivlyUpdateObjectives(root.getChild(i)); - } + private void recursivlyUpdateObjectives(TreeItem root) { + + ItemModel model = ItemModels.getModelFromItem(root); + model.updateItemObjectives(root); + + for (int i = 0; i < root.getChildCount(); i++) { + recursivlyUpdateObjectives(root.getChild(i)); } + } - private void createSummaryPageIfNotExists(TreeItem root) { - int childsCount = root.getChildCount(); + private void createSummaryPageIfNotExists(TreeItem root) { + int childsCount = root.getChildCount(); - if (childsCount > 0) { - TreeItem lastItem = root.getChild(childsCount - 1); - ItemModel lastItemModel = ItemModels.getModelFromItem(lastItem); - if (lastItemModel.getClass() == SummaryPageModel.class) { - return; - } - } - SummaryPageModel model = new SummaryPageModel(); - model.addItem(root); + if (childsCount > 0) { + TreeItem lastItem = root.getChild(childsCount - 1); + ItemModel lastItemModel = ItemModels.getModelFromItem(lastItem); + if (lastItemModel.getClass() == SummaryPageModel.class) { + return; + } } + SummaryPageModel model = new SummaryPageModel(); + model.addItem(root); + } - private void deleteSummaryPageIfExists(TreeItem root) { - int childsCount = root.getChildCount(); + private void deleteSummaryPageIfExists(TreeItem root) { + int childsCount = root.getChildCount(); - if (childsCount == 0) { - return; - } + if (childsCount == 0) { + return; + } - TreeItem lastItem = root.getChild(childsCount - 1); - ItemModel lastItemModel = ItemModels.getModelFromItem(lastItem); - if (lastItemModel.getClass() == SummaryPageModel.class) { - SummaryPageModel model = new SummaryPageModel(); - model.remove(lastItem); - } + TreeItem lastItem = root.getChild(childsCount - 1); + ItemModel lastItemModel = ItemModels.getModelFromItem(lastItem); + if (lastItemModel.getClass() == SummaryPageModel.class) { + SummaryPageModel model = new SummaryPageModel(); + model.remove(lastItem); } + } - private boolean isShowSummaryPageForItem(TreeItem root) - throws TestDocException { + private boolean isShowSummaryPageForItem(TreeItem root) + throws TestDocException { - boolean showSummaryPage = false; - ItemModel rootModel = ItemModels.getModelFromItem(root); + boolean showSummaryPage = false; + ItemModel rootModel = ItemModels.getModelFromItem(root); - if (rootModel.getClass() == ChapterModel.class - || rootModel.getClass() == OrganizationModel.class) { - ChapterModel model = (ChapterModel) rootModel; + if (rootModel.getClass() == ChapterModel.class + || rootModel.getClass() == OrganizationModel.class) { + ChapterModel model = (ChapterModel) rootModel; - showSummaryPage = model.getShowSummaryPage(root); - } else { - throw new TestDocException( - "Root element must be a chapter or an organization"); - } - - return showSummaryPage; + showSummaryPage = model.getShowSummaryPage(root); + } else { + throw new TestDocException( + "Root element must be a chapter or an organization"); } - private void recursivlyUpdateChapters(TreeItem root) - throws TestDocException { - int childsCount = root.getChildCount(); - for (int i = 0; i < childsCount; i++) { - Item item = (Item) root.getChild(i); - ItemModel itemModel = ItemModels.getModelFromItem(item); + return showSummaryPage; + } - if (itemModel.getClass() == ChapterModel.class) { - updateSummaryPages(item); - } - } + private void recursivlyUpdateChapters(TreeItem root) + throws TestDocException { + int childsCount = root.getChildCount(); + for (int i = 0; i < childsCount; i++) { + Item item = (Item) root.getChild(i); + ItemModel itemModel = ItemModels.getModelFromItem(item); + + if (itemModel.getClass() == ChapterModel.class) { + updateSummaryPages(item); + } } + } - private void pushDownSummaryPage(TreeItem root) throws TestDocException { - int childsCount = root.getChildCount(); + private void pushDownSummaryPage(TreeItem root) throws TestDocException { + int childsCount = root.getChildCount(); - for (int i = 0; i < childsCount; i++) { - Item item = (Item) root.getChild(i); - ItemModel itemModel = ItemModels.getModelFromItem(item); + for (int i = 0; i < childsCount; i++) { + Item item = (Item) root.getChild(i); + ItemModel itemModel = ItemModels.getModelFromItem(item); - if (itemModel.getClass() == SummaryPageModel.class) { - if (i != childsCount - 1) { - ItemModel lastItemModel = ItemModels.getModelFromItem(root - .getChild(childsCount - 1)); + if (itemModel.getClass() == SummaryPageModel.class) { + if (i != childsCount - 1) { + ItemModel lastItemModel = ItemModels.getModelFromItem(root + .getChild(childsCount - 1)); - if (lastItemModel.getClass() == SummaryPageModel.class) { - throw new TestDocException( - "Count of summary pages is graiter than one!!!"); - } + if (lastItemModel.getClass() == SummaryPageModel.class) { + throw new TestDocException( + "Count of summary pages is graiter than one!!!"); + } - Reorganizer.getInstance().moveDown(item); - } - } + Reorganizer.getInstance().moveDown(item); } - - //TreeDataModel.getInstance().updateAllTree(); + } } - public void updateSummaryPages() { - try { - recursivlyUpdateChapters(manifest.getRoot()); - recursivlyUpdateObjectives(manifest.getRoot()); - updateSummaryPages(manifest.getRoot()); - } catch (TestDocException e) { - e.printStackTrace(); - } + // TreeDataModel.getInstance().updateAllTree(); + } + + public void updateSummaryPages() { + try { + recursivlyUpdateChapters(manifest.getRoot()); + recursivlyUpdateObjectives(manifest.getRoot()); + updateSummaryPages(manifest.getRoot()); + } catch (TestDocException e) { + e.printStackTrace(); } + } } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/CourseTreePopupMenu.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/CourseTreePopupMenu.java 2008-05-23 14:27:49 UTC (rev 161) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/GUI/CourseTreePopupMenu.java 2008-05-23 17:44:49 UTC (rev 162) @@ -32,531 +32,531 @@ import edu.lnu.FireFly.WebEditor.ItemModels.SummaryPageModel.SummaryPageModel; public class CourseTreePopupMenu extends MouseAdapter implements - ActionListener, ChangeListener { + ActionListener, ChangeListener { - protected JMenu addItemMenu; - protected JMenu changeTypeMenu; - protected TreeItem manifestItem = null; - protected JPopupMenu menu; - protected JMenuItem moveDownItemMenu; - protected JMenuItem moveUpItemMenu; - protected JMenuItem propertyItemMenu; - protected JMenuItem removeItemMenu; - protected JMenuItem renameItemMenu; - protected JCheckBoxMenuItem showOnSummaryPageMenuItem; - protected JCheckBoxMenuItem showSummaryPageMenuItem; - protected JMenu limitConditionsMenu; - protected JMenu attemptLimitMenu; - protected JRadioButtonMenuItem attemptLimitNoneItemMenu; - protected JRadioButtonMenuItem attemptLimit1ItemMenu; - protected JRadioButtonMenuItem attemptLimit3ItemMenu; - protected JRadioButtonMenuItem attemptLimit5ItemMenu; - protected JRadioButtonMenuItem attemptLimit10ItemMenu; - protected JRadioButtonMenuItem attemptLimitOtherItemMenu; - protected JMenu attemptAbsoluteDurationMenu; - protected JRadioButtonMenuItem attemptAbsoluteDuration1minItemMenu; - protected JRadioButtonMenuItem attemptAbsoluteDurationNoneItemMenu; - protected JRadioButtonMenuItem attemptAbsoluteDuration3minItemMenu; - protected JRadioButtonMenuItem attemptAbsoluteDuration30minItemMenu; - protected JRadioButtonMenuItem attemptAbsoluteDuration1hourItemMenu; - protected JRadioButtonMenuItem attemptAbsoluteDuration5hourItemMenu; - protected JRadioButtonMenuItem attemptAbsoluteDurationOtherItemMenu; + protected JMenu addItemMenu; + protected JMenu changeTypeMenu; + protected TreeItem manifestItem = null; + protected JPopupMenu menu; + protected JMenuItem moveDownItemMenu; + protected JMenuItem moveUpItemMenu; + protected JMenuItem propertyItemMenu; + protected JMenuItem removeItemMenu; + protected JMenuItem renameItemMenu; + protected JCheckBoxMenuItem showOnSummaryPageMenuItem; + protected JCheckBoxMenuItem showSummaryPageMenuItem; + protected JMenu limitConditionsMenu; + protected JMenu attemptLimitMenu; + protected JRadioButtonMenuItem attemptLimitNoneItemMenu; + protected JRadioButtonMenuItem attemptLimit1ItemMenu; + protected JRadioButtonMenuItem attemptLimit3ItemMenu; + protected JRadioButtonMenuItem attemptLimit5ItemMenu; + protected JRadioButtonMenuItem attemptLimit10ItemMenu; + protected JRadioButtonMenuItem attemptLimitOtherItemMenu; + protected JMenu attemptAbsoluteDurationMenu; + protected JRadioButtonMenuItem attemptAbsoluteDuration1minItemMenu; + protected JRadioButtonMenuItem attemptAbsoluteDurationNoneItemMenu; + protected JRadioButtonMenuItem attemptAbsoluteDuration3minItemMenu; + protected JRadioButtonMenuItem attemptAbsoluteDuration30minItemMenu; + protected JRadioButtonMenuItem attemptAbsoluteDuration1hourItemMenu; + protected JRadioButtonMenuItem attemptAbsoluteDuration5hourItemMenu; + protected JRadioButtonMenuItem attemptAbsoluteDurationOtherItemMenu; - public CourseTreePopupMenu() { - initReorganizeMenus(); - initSummaryPageMenus(); - initLimitConditionsMenu(); + public CourseTreePopupMenu() { + initReorganizeMenus(); + initSummaryPageMenus(); + initLimitConditionsMenu(); - menu = new JPopupMenu(); - addItemMenu = new JMenu("Add item"); + menu = new JPopupMenu(); + addItemMenu = new JMenu("Add item"); - changeTypeMenu = new JMenu("Chage type"); + changeTypeMenu = new JMenu("Chage type"); - propertyItemMenu = new JMenuItem("Property"); - propertyItemMenu.addActionListener(this); + propertyItemMenu = new JMenuItem("Property"); + propertyItemMenu.addActionListener(this); - menu.add(addItemMenu); - menu.add(changeTypeMenu); + menu.add(addItemMenu); + menu.add(changeTypeMenu); - menu.addSeparator(); + menu.addSeparator(); - menu.add(moveUpItemMenu); - menu.add(moveDownItemMenu); - menu.add(removeItemMenu); - menu.add(renameItemMenu); + menu.add(moveUpItemMenu); + menu.add(moveDownItemMenu); + menu.add(removeItemMenu); + menu.add(renameItemMenu); - menu.addSeparator(); + menu.addSeparator(); - menu.add(propertyItemMenu); - menu.add(limitConditionsMenu); - menu.add(showOnSummaryPageMenuItem); - menu.add(showSummaryPageMenuItem); + menu.add(propertyItemMenu); + menu.add(limitConditionsMenu); + menu.add(showOnSummaryPageMenuItem); + menu.add(showSummaryPageMenuItem); + } + + public void actionPerformed(java.awt.event.ActionEvent e) { + JMenuItem menuItem = (JMenuItem) e.getSource(); + + if (menuItem.getClass() == JMenuItemContainedModel.class) { + JMenuItemContainedModel myMenuItem = (JMenuItemContainedModel) menuItem; + if (myMenuItem.type == JMenuItemContainedModel.ADD_ITEM) { + myMenuItem.itemModel.addItem(manifestItem); + return; + } } - public void actionPerformed(java.awt.event.ActionEvent e) { - JMenuItem menuItem = (JMenuItem) e.getSource(); + ItemModel itemModel = ItemModels.getModelFromItem(manifestItem); + if (itemModel == null) { + System.out.print("Can't get model for item.\n"); + return; + } - if (menuItem.getClass() == JMenuItemContainedModel.class) { - JMenuItemContainedModel myMenuItem = (JMenuItemContainedModel) menuItem; - if (myMenuItem.type == JMenuItemContainedModel.ADD_ITEM) { - myMenuItem.itemModel.addItem(manifestItem); - return; - } - } + if (menuItem == renameItemMenu) { + itemModel.rename(manifestItem, RenameDlg.showDialog(manifestItem + .toString())); + } - ItemModel itemModel = ItemModels.getModelFromItem(manifestItem); - if (itemModel == null) { - System.out.print("Can't get model for item.\n"); - return; - } + if (menuItem == removeItemMenu) { + itemModel.remove(manifestItem); + } - if (menuItem == renameItemMenu) { - itemModel.rename(manifestItem, RenameDlg.showDialog(manifestItem - .toString())); - } + if (menuItem == propertyItemMenu) { + itemModel.ConfigureItem(manifestItem); + } - if (menuItem == removeItemMenu) { - itemModel.remove(manifestItem); - } + if (menuItem == moveUpItemMenu) { + Reorganizer.getInstance().moveUp(manifestItem); + } - if (menuItem == propertyItemMenu) { - itemModel.ConfigureItem(manifestItem); - } + if (menuItem == moveDownItemMenu) { + Reorganizer.getInstance().moveDown(manifestItem); + } + } - if (menuItem == moveUpItemMenu) { - Reorganizer.getInstance().moveUp(manifestItem); - } + private void attemptAbsoluteDurationStateChanged(ChangeEvent arg0) { + boolean attemptAbsoluteDurationPerformed = isAttemptAbsoluteDurationPerformed(arg0); - if (menuItem == moveDownItemMenu) { - Reorganizer.getInstance().moveDown(manifestItem); - } + if (attemptAbsoluteDurationPerformed) { + Duration duration = extractDurationLimitValue(arg0); + + setDurationLimit(duration); } + } - private void attemptAbsoluteDurationStateChanged(ChangeEvent arg0) { - boolean attemptAbsoluteDurationPerformed = isAttemptAbsoluteDurationPerformed(arg0); + private void attemptsLimitStateChanged(ChangeEvent arg0) { + boolean attemptLimitPerformed = isAttemptLimitPerformed(arg0); - if (attemptAbsoluteDurationPerformed) { - Duration duration = extractDurationLimitValue(arg0); + if (attemptLimitPerformed) { + Integer attemptLimit = extractAttemptLimitValue(arg0); - setDurationLimit(duration); - } + setAttemptLimitCount(attemptLimit); } - private void attemptsLimitStateChanged(ChangeEvent arg0) { - boolean attemptLimitPerformed = isAttemptLimitPerformed(arg0); + } - if (attemptLimitPerformed) { - Integer attemptLimit = extractAttemptLimitValue(arg0); + public void createAddAndChangeMenuItems() { + ArrayList<ItemModel> models = ItemModels.getAllModels(); + addItemMenu.removeAll(); + changeTypeMenu.removeAll(); - setAttemptLimitCount(attemptLimit); - } + JMenuItemContainedModel item; + for (int i = 0; i < models.size(); i++) { + if (models.get(i).canConvertItem(manifestItem)) { + item = new JMenuItemContainedModel(models.get(i), + JMenuItemContainedModel.CHANGE_ITEM_TYPE); + item.addActionListener(this); + changeTypeMenu.add(item); + } + if (models.get(i).canAddToItem(manifestItem)) { + item = new JMenuItemContainedModel(models.get(i), + JMenuItemContainedModel.ADD_ITEM); + item.addActionListener(this); + addItemMenu.add(item); + } } - public void createAddAndChangeMenuItems() { - ArrayList<ItemModel> models = ItemModels.getAllModels(); - addItemMenu.removeAll(); - changeTypeMenu.removeAll(); + changeTypeMenu.setVisible(changeTypeMenu.getComponentCount() != 0); + } - JMenuItemContainedModel item; - for (int i = 0; i < models.size(); i++) { - if (models.get(i).canConvertItem(manifestItem)) { - item = new JMenuItemContainedModel(models.get(i), - JMenuItemContainedModel.CHANGE_ITEM_TYPE); - item.addActionListener(this); - changeTypeMenu.add(item); - } + private void displayMenu(MouseEvent e) { + if (e.isPopupTrigger()) { + Point pt = e.getPoint(); + TreePath path = WebEditor.getCourseTree() + .getClosestPathForLocation(pt.x, pt.y); + WebEditor.getCourseTree().setSelectionPath(path); + manifestItem = (TreeItem) path.getLastPathComponent(); - if (models.get(i).canAddToItem(manifestItem)) { - item = new JMenuItemContainedModel(models.get(i), - JMenuItemContainedModel.ADD_ITEM); - item.addActionListener(this); - addItemMenu.add(item); - } - } + ItemModel model = ItemModels.getModelFromItem(manifestItem); + if (model == null) { + System.out.print("Can't find model for selected item !!!"); + return; + } - changeTypeMenu.setVisible(changeTypeMenu.getComponentCount() != 0); - } + prepareOrganizeMenuItems(); - private void displayMenu(MouseEvent e) { - if (e.isPopupTrigger()) { - Point pt = e.getPoint(); - TreePath path = WebEditor.getCourseTree() - .getClosestPathForLocation(pt.x, pt.y); - WebEditor.getCourseTree().setSelectionPath(path); - manifestItem = (TreeItem) path.getLastPathComponent(); + createAddAndChangeMenuItems(); - ItemModel model = ItemModels.getModelFromItem(manifestItem); - if (model == null) { - System.out.print("Can't find model for selected item !!!"); - return; - } + showOnSummaryPageMenuItem.setState(model + .getShowOnSummaryPage(manifestItem)); + showOnSummaryPageMenuItem.setVisible(model + .getShowOnSummaryPageMenuVisible()); - prepareOrganizeMenuItems(); + limitConditionsMenu.setVisible(model + .getLimitConditionsMenuVisible(manifestItem)); - createAddAndChangeMenuItems(); + showSummaryPageMenuItem.setVisible(model + .getShowSummaryPageMenuVisible()); - showOnSummaryPageMenuItem.setState(model - .getShowOnSummaryPage(manifestItem)); - showOnSummaryPageMenuItem.setVisible(model - .getShowOnSummaryPageMenuVisible()); + if (model.getShowSummaryPageMenuVisible()) { + ChapterModel chapterModel = (ChapterModel) model; - limitConditionsMenu.setVisible(model - .getLimitConditionsMenuVisible(manifestItem)); + showSummaryPageMenuItem.setState(chapterModel + .getShowSummaryPage(manifestItem)); + } - showSummaryPageMenuItem.setVisible(model - .getShowSummaryPageMenuVisible()); + addItemMenu.setVisible(model.isContainer() + && ItemModels.getAllModels().size() > 0); - if (model.getShowSummaryPageMenuVisible()) { - ChapterModel chapterModel = (ChapterModel) model; - - showSummaryPageMenuItem.setState(chapterModel - .getShowSummaryPage(manifestItem)); - } + removeItemMenu.setVisible(model.isRemovable()); - addItemMenu.setVisible(model.isContainer() - && ItemModels.getAllModels().size() > 0); + menu.show(e.getComponent(), e.getX(), e.getY()); + } + } - removeItemMenu.setVisible(model.isRemovable()); + private Integer extractAttemptLimitValue(ChangeEvent arg0) { + Integer attemptLimit = null; + if (arg0.getSource() == attemptLimitNoneItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + attemptLimit = null; + } + } - menu.show(e.getComponent(), e.getX(), e.getY()); - } + if (arg0.getSource() == attemptLimit1ItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + attemptLimit = 1; + } } - private Integer extractAttemptLimitValue(ChangeEvent arg0) { - Integer attemptLimit = null; - if (arg0.getSource() == attemptLimitNoneItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - attemptLimit = null; - } - } + if (arg0.getSource() == attemptLimit3ItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + attemptLimit = 3; + } + } - if (arg0.getSource() == attemptLimit1ItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - attemptLimit = 1; - } - } + if (arg0.getSource() == attemptLimit5ItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + attemptLimit = 5; + } + } - if (arg0.getSource() == attemptLimit3ItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - attemptLimit = 3; - } - } + if (arg0.getSource() == attemptLimit10ItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + attemptLimit = 10; + } + } - if (arg0.getSource() == attemptLimit5ItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - attemptLimit = 5; - } - } + if (arg0.getSource() == attemptLimitOtherItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + // TODO Need realize dialog box. + attemptLimit = 7; + } + } + return attemptLimit; + } - if (arg0.getSource() == attemptLimit10ItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - attemptLimit = 10; - } - } + private Duration extractDurationLimitValue(ChangeEvent arg0) { + Duration result = null; + DurationConverter converter = new DurationConverter(); - if (arg0.getSource() == attemptLimitOtherItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - // TODO Need realize dialog box. - attemptLimit = 7; - } - } - return attemptLimit; + if (arg0.getSource() == attemptAbsoluteDurationNoneItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + result = null; + } } - private Duration extractDurationLimitValue(ChangeEvent arg0) { - Duration result = null; - DurationConverter converter = new DurationConverter(); + if (arg0.getSource() == attemptAbsoluteDuration1minItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + result = (Duration) converter.fromString("PT1M"); + } + } - if (arg0.getSource() == attemptAbsoluteDurationNoneItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - result = null; - } - } + if (arg0.getSource() == attemptAbsoluteDuration3minItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + result = (Duration) converter.fromString("PT3M"); + } + } - if (arg0.getSource() == attemptAbsoluteDuration1minItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - result = (Duration) converter.fromString("PT1M"); - } - } + if (arg0.getSource() == attemptAbsoluteDuration30minItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + result = (Duration) converter.fromString("PT30M"); + } + } - if (arg0.getSource() == attemptAbsoluteDuration3minItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - result = (Duration) converter.fromString("PT3M"); - } - } + if (arg0.getSource() == attemptAbsoluteDuration1hourItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + result = (Duration) converter.fromString("PT1H"); + } + } - if (arg0.getSource() == attemptAbsoluteDuration30minItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - result = (Duration) converter.fromString("PT30M"); - } - } + if (arg0.getSource() == attemptAbsoluteDuration5hourItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + result = (Duration) converter.fromString("PT5H"); + } + } - if (arg0.getSource() == attemptAbsoluteDuration1hourItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - result = (Duration) converter.fromString("PT1H"); - } - } + if (arg0.getSource() == attemptAbsoluteDurationOtherItemMenu) { + if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { + // TODO need realize dialogBox - if (arg0.getSource() == attemptAbsoluteDuration5hourItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - result = (Duration) converter.fromString("PT5H"); - } - } + result = (Duration) converter.fromString("PT7H"); + } + } - if (arg0.getSource() == attemptAbsoluteDurationOtherItemMenu) { - if (((JRadioButtonMenuItem) arg0.getSource()).isSelected()) { - // TODO need realize dialogBox + return result; + } - result = (Duration) converter.fromString("PT7H"); - } - } + private Sequencing getSequencingInstance() { + Sequencing sequencing = null; - return result; + if (manifestItem.getClass() == Organization.class) { + if (((Organization) manifestItem).sequencing == null) { + ((Organization) manifestItem).sequencing = ManifestFactory + .createSequencing(); + } + + sequencing = ((Organization) manifestItem).sequencing; } - private Sequencing getSequencingInstance() { - Sequencing sequencing = null; + if (manifestItem.getClass() == Item.class) { + if (((Item) manifestItem).sequencing == null) { + ((Item) manifestItem).sequencing = ManifestFactory + .createSequencing(); + } - if (manifestItem.getClass() == Organization.class) { - if (((Organization) manifestItem).sequencing == null) { - ((Organization) manifestItem).sequencing = ManifestFactory - .createSequencing(); - } + sequencing = ((Item) manifestItem).sequencing; + } + return sequencing; + } - sequencing = ((Organization) manifestItem).sequencing; - } + private void initAttemptAbsoluteDurationMenu() { + attemptAbsoluteDurationNoneItemMenu = new JRadioButtonMenuItem("None", + true); + attemptAbsoluteDuration1minItemMenu = new JRadioButtonMenuItem("1 min"); + attemptAbsoluteDuration3minItemMenu = new JRadioButtonMenuItem("3 min"); + attemptAbsoluteDuration30minItemMenu = new JRadioButtonMenuItem( + "30 min"); + attemptAbsoluteDuration1hourItemMenu = new JRadioButtonMenuItem( + "1 hour"); + attemptAbsoluteDuration5hourItemMenu = new JRadioButtonMenuItem( + "5 hour"); + attemptAbsoluteDurationOtherItemMenu = new JRadioButtonMenuItem("Other"); - if (manifestItem.getClass() == Item.class) { - if (((Item) manifestItem).sequencing == null) { - ((Item) manifestItem).sequencing = ManifestFactory - .createSequencing(); - } + ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(attemptAbsoluteDurationNoneItemMenu); + buttonGroup.add(attemptAbsoluteDuration1minItemMenu); + buttonGroup.add(attemptAbsoluteDuration3minItemMenu); + buttonGroup.add(attemptAbsoluteDuration30minItemMenu); + buttonGroup.add(attemptAbsoluteDuration1hourItemMenu); + buttonGroup.add(attemptAbsoluteDuration5hourItemMenu); + buttonGroup.add(attemptAbsoluteDurationOtherItemMenu); - sequencing = ((Item) manifestItem).sequencing; - } - return sequencing; - } + attemptAbsoluteDurationNoneItemMenu.addChangeListener(this); + attemptAbsoluteDuration1minItemMenu.addChangeListener(this); + attemptAbsoluteDuration3minItemMenu.addChangeListener(this); + attemptAbsoluteDuration30minItemMenu.addChangeListener(this); + attemptAbsoluteDuration1hourItemMenu.addChangeListener(this); + attemptAbsoluteDuration5hourItemMenu.addChangeListener(this); + attemptAbsoluteDurationOtherItemMenu.addChangeListener(this); - private void initAttemptAbsoluteDurationMenu() { - attemptAbsoluteDurationNoneItemMenu = new JRadioButtonMenuItem("None", - true); - attemptAbsoluteDuration1minItemMenu = new JRadioButtonMenuItem("1 min"); - attemptAbsoluteDuration3minItemMenu = new JRadioButtonMenuItem("3 min"); - attemptAbsoluteDuration30minItemMenu = new JRadioButtonMenuItem( - "30 min"); - attemptAbsoluteDuration1hourItemMenu = new JRadioButtonMenuItem( - "1 hour"); - attemptAbsoluteDuration5hourItemMenu = new JRadioButtonMenuItem( - "5 hour"); - attemptAbsoluteDurationOtherItemMenu = new JRadioButtonMenuItem("Other"); + attemptAbsoluteDurationMenu = new JMenu("Attempt duration"); + attemptAbsoluteDurationMenu.add(attemptAbsoluteDurationNoneItemMenu); + attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration1minItemMenu); + attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration3minItemMenu); + attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration30minItemMenu); + attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration1hourItemMenu); + attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration5hourItemMenu); + attemptAbsoluteDurationMenu.add(attemptAbsoluteDurationOtherItemMenu); + } - ButtonGroup buttonGroup = new ButtonGroup(); - buttonGroup.add(attemptAbsoluteDurationNoneItemMenu); - buttonGroup.add(attemptAbsoluteDuration1minItemMenu); - buttonGroup.add(attemptAbsoluteDuration3minItemMenu); - buttonGroup.add(attemptAbsoluteDuration30minItemMenu); - buttonGroup.add(attemptAbsoluteDuration1hourItemMenu); - buttonGroup.add(attemptAbsoluteDuration5hourItemMenu); - buttonGroup.add(attemptAbsoluteDurationOtherItemMenu); + private void initAttemptLimitMenu() { + attemptLimitMenu = new JMenu("Attempts count"); + attemptLimitNoneItemMenu = new JRadioButtonMenuItem("None", true); + attemptLimit1ItemMenu = new JRadioButtonMenuItem("1"); + attemptLimit3ItemMenu = new JRadioButtonMenuItem("3"); + attemptLimit5ItemMenu = new JRadioButtonMenuItem("5"); + attemptLimit10ItemMenu = new JRadioButtonMenuItem("10"); + attemptLimitOtherItemMenu = new JRadioButtonMenuItem("Other..."); - attemptAbsoluteDurationNoneItemMenu.addChangeListener(this); - attemptAbsoluteDuration1minItemMenu.addChangeListener(this); - attemptAbsoluteDuration3minItemMenu.addChangeListener(this); - attemptAbsoluteDuration30minItemMenu.addChangeListener(this); - attemptAbsoluteDuration1hourItemMenu.addChangeListener(this); - attemptAbsoluteDuration5hourItemMenu.addChangeListener(this); - attemptAbsoluteDurationOtherItemMenu.addChangeListener(this); + attemptLimitNoneItemMenu.addChangeListener(this); + attemptLimit1ItemMenu.addChangeListener(this); + attemptLimit3ItemMenu.addChangeListener(this); + attemptLimit5ItemMenu.addChangeListener(this); + attemptLimit10ItemMenu.addChangeListener(this); + attemptLimitOtherItemMenu.addChangeListener(this); - attemptAbsoluteDurationMenu = new JMenu("Attempt duration"); - attemptAbsoluteDurationMenu.add(attemptAbsoluteDurationNoneItemMenu); - attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration1minItemMenu); - attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration3minItemMenu); - attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration30minItemMenu); - attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration1hourItemMenu); - attemptAbsoluteDurationMenu.add(attemptAbsoluteDuration5hourItemMenu); - attemptAbsoluteDurationMenu.add(attemptAbsoluteDurationOtherItemMenu); - } + ButtonGroup buttonGroup = new ButtonGroup(); - private void initAttemptLimitMenu() { - attemptLimitMenu = new JMenu("Attempts count"); - attemptLimitNoneItemMenu = new JRadioButtonMenuItem("None", true); - attemptLimit1ItemMenu = new JRadioButtonMenuItem("1"); - attemptLimit3ItemMenu = new JRadioButtonMenuItem("3"); - attemptLimit5ItemMenu = new JRadioButtonMenuItem("5"); - attemptLimit10ItemMenu = new JRadioButtonMenuItem("10"); - attemptLimitOtherItemMenu = new JRadioButtonMenuItem("Other..."); + buttonGroup.add(attemptLimitNoneItemMenu); + buttonGroup.add(attemptLimit1ItemMenu); + buttonGroup.add(attemptLimit3ItemMenu); + buttonGroup.add(attemptLimit5ItemMenu); + buttonGroup.add(attemptLimit10ItemMenu); + buttonGroup.add(attemptLimitOtherItemMenu); - attemptLimitNoneItemMenu.addChangeListener(this); - attemptLimit1ItemMenu.addChangeListener(this); - attemptLimit3ItemMenu.addChangeListener(this); - attemptLimit5ItemMenu.addChangeListener(this); - attemptLimit10ItemMenu.addChangeListener(this); - attemptLimitOtherItemMenu.addChangeListener(this); + attemptLimitMenu.add(attemptLimitNoneItemMenu); + attemptLimitMenu.add(attemptLimit1ItemMenu); + attemptLimitMenu.add(attemptLimit3ItemMenu); + attemptLimitMenu.add(attemptLimit5ItemMenu); + attemptLimitMenu.add(attemptLimit10ItemMenu); + attemptLimitMenu.add(attemptLimitOtherItemMenu); + } - ButtonGroup buttonGroup = new ButtonGroup(); + private void initLimitConditionsMenu() { + limitConditionsMenu = new JMenu("Limit Conditions"); - buttonGroup.add(attemptLimitNoneItemMenu); - buttonGroup.add(attemptLimit1ItemMenu); - buttonGroup.add(attemptLimit3ItemMenu); - buttonGroup.add(attemptLimit5ItemMenu); - buttonGroup.add(attemptLimit10ItemMenu); - buttonGroup.add(attemptLimitOtherItemMenu); + initAttemptLimitMenu(); + initAttemptAbsoluteDurationMenu(); - attemptLimitMenu.add(attemptLimitNoneItemMenu); - attemptLimitMenu.add(attemptLimit1ItemMenu); - attemptLimitMenu.add(attemptLimit3ItemMenu); - attemptLimitMenu.add(attemptLimit5ItemMenu); - attemptLimitMenu.add(attemptLimit10ItemMenu); - attemptLimitMenu.add(attemptLimitOtherItemMenu); - } + limitConditionsMenu.add(attemptLimitMenu); + limitConditionsMenu.add(attemptAbsoluteDurationMenu); + } - private void initLimitConditionsMenu() { - limitConditionsMenu = new JMenu("Limit Conditions"); + private void initReorganizeMenus() { + moveUpItemMenu = new JMenuItem("Move up"); + moveUpItemMenu.addActionListener(this); - initAttemptLimitMenu(); - initAttemptAbsoluteDurationMenu(); + moveDownItemMenu = new JMenuItem("Move down"); + moveDownItemMenu.addActionListener(this); - limitConditionsMenu.add(attemptLimitMenu); - limitConditionsMenu.add(attemptAbsoluteDurationMenu); - } + removeItemMenu = new JMenuItem("Delete"); + removeItemMenu.addActionListener(this); - private void initReorganizeMenus() { - moveUpItemMenu = new JMenuItem("Move up"); - moveUpItemMenu.addActionListener(this); + renameItemMenu = new JMenuItem("Rename"); + renameItemMenu.addActionListener(this); + } - moveDownItemMenu = new JMenuItem("Move down"); - moveDownItemMenu.addActionListener(this); + private void initSummaryPageMenus() { + showOnSummaryPageMenuItem = new JCheckBoxMenuItem( + "Show on summary page", false); + showOnSummaryPageMenuItem.addChangeListener(this); - removeItemMenu = new JMenuItem("Delete"); - removeItemMenu.addActionListener(this); + showSummaryPageMenuItem = new JCheckBoxMenuItem("Show summary page", + true); + showSummaryPageMenuItem.addChangeListener(this); + } - renameItemMenu = new JMenuItem("Rename"); - renameItemMenu.addActionListener(this); + private boolean isAttemptAbsoluteDurationPerformed(ChangeEvent arg0) { + if (arg0.getSource() == attemptAbsoluteDurationNoneItemMenu + || arg0.getSource() == attemptAbsoluteDuration1minItemMenu + || arg0.getSource() == attemptAbsoluteDuration3minItemMenu + || arg0.getSource() == attemptAbsoluteDuration30minItemMenu + || arg0.getSource() == attemptAbsoluteDuration1hourItemMenu + || arg0.getSource() == attemptAbsoluteDuration5hourItemMenu + || arg0.getSource() == attemptAbsoluteDurationOtherItemMenu) { + return true; } - private void initSummaryPageMenus() { - showOnSummaryPageMenuItem = new JCheckBoxMenuItem( - "Show on summary page", false); - showOnSummaryPageMenuItem.addChangeListener(this); + return false; + } - showSummaryPageMenuItem = new JCheckBoxMenuItem("Show summary page", - true); - showSummaryPageMenuItem.addChangeListener(this); + private boolean isAttemptLimitPerformed(ChangeEvent arg0) { + if (arg0.getSource() == attemptLimitNoneItemMenu + || arg0.getSource() == attemptLimit1ItemMenu + || arg0.getSource() == attemptLimit3ItemMenu + || arg0.getSource() == attemptLimit5ItemMenu + || arg0.getSource() == attemptLimit10ItemMenu + || arg0.getSource() == attemptLimitOtherItemMenu) { + return true; } - private boolean isAttemptAbsoluteDurationPerformed(ChangeEvent arg0) { - if (arg0.getSource() == attemptAbsoluteDurationNoneItemMenu - || arg0.getSource() == attemptAbsoluteDuration1minItemMenu - || arg0.getSource() == attemptAbsoluteDuration3minItemMenu - || arg0.getSource() == attemptAbsoluteDuration30minItemMenu - || arg0.getSource() == attemptAbsoluteDuration1hourItemMenu - || arg0.getSource() == attemptAbsoluteDuration5hourItemMenu - || arg0.getSource() == attemptAbsoluteDurationOtherItemMenu) { - return true; - } + return false; + } - return false; - } + @Override + public void mousePressed(java.awt.event.MouseEvent e) { + displayMenu(e); + } - private boolean isAttemptLimitPerformed(ChangeEvent arg0) { - if (arg0.getSource() == attemptLimitNoneItemMenu - || arg0.getSource() == attemptLimit1ItemMenu - || arg0.getSource() == attemptLimit3ItemMenu - || arg0.getSource() == attemptLimit5ItemMenu - || arg0.getSource() == attemptLimit10ItemMenu - || arg0.getSource() == attemptLimitOtherItemMenu) { - return true; - } + @Override + public void mouseReleased(java.awt.event.MouseEvent e) { + displayMenu(e); + } - return false; + private void prepareOrganizeMenuItems() { + if (manifestItem.getParent() == null) { + return; } - @Override - public void mousePressed(java.awt.event.MouseEvent e) { - displayMenu(e); - } + int itemIndex = manifestItem.getParent().getChildIndex(manifestItem); + int childCount = manifestItem.getParent().getChildCount(); - @Override - public void mouseReleased(java.awt.event.MouseEvent e) { - displayMenu(e); - } + boolean upEnabled = true; + boolean downEnabled = true; - private void prepareOrganizeMenuItems() { - if (manifestItem.getParent() == ... [truncated message content] |
From: <se...@us...> - 2008-05-23 14:27:49
|
Revision: 161 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=161&view=rev Author: sem62 Date: 2008-05-23 07:27:49 -0700 (Fri, 23 May 2008) Log Message: ----------- modifying code for checking user answer internally in applet Modified Paths: -------------- WebEditor/resources/index.html WebEditor/src/deploy.jardesc WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/LectureUserAnswerStatus.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownModelAnswerStatus.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UserAnswerStatus.java WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java WebEditor/template/LectureModel.html Added Paths: ----------- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AnswersStatusManager.java WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Utils.java Modified: WebEditor/resources/index.html =================================================================== --- WebEditor/resources/index.html 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/resources/index.html 2008-05-23 14:27:49 UTC (rev 161) @@ -57,6 +57,14 @@ padding: 4px; } </style> + + <script type="text/javascript"> + function getVal(){ + var result = ""; + result = GetValue(document.getElementById('getval').value); + document.getElementById('getvalres').value = result + ""; + } + </script> </head> @@ -85,7 +93,7 @@ </tr> <tr height='*'> <td class='side-body'> - <applet mayscript="" name="webeditor" archive="webeditor.jar,RTEValidators.jar,FFManifest.jar,dom4j.jar,rte.jar" code=edu.lnu.FireFly.WebEditor.WebEditor.class width="100%" height="100%"> + <applet mayscript="" name="webeditor" id="webeditor" archive="webeditor.jar,RTEValidators.jar,FFManifest.jar,dom4j.jar,rte.jar" code=edu.lnu.FireFly.WebEditor.WebEditor.class width="100%" height="100%"> <PARAM NAME="courseLocation" VALUE="http://127.0.0.1/sem/course/"> <PARAM NAME="serviceLocation" VALUE="http://127.0.0.1/sem/WebEditor/service/"> <PARAM NAME="templateLocation" VALUE="http://127.0.0.1/sem/WebEditor/template/"> @@ -120,7 +128,8 @@ </tr> </tbody> </table> - </table> + <tr><td><input type=text id='getval'><input type='button' onclick="getVal();"><td><input id='getvalres'></td></tr> + </table> </body> </html> \ No newline at end of file Modified: WebEditor/src/deploy.jardesc =================================================================== --- WebEditor/src/deploy.jardesc 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/deploy.jardesc 2008-05-23 14:27:49 UTC (rev 161) @@ -11,6 +11,9 @@ </sealing> </manifest> <selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false"> - <javaElement handleIdentifier="=webEditor"/> + <file path="/webEditor/.classpath"/> + <javaElement handleIdentifier="=webEditor/src"/> + <file path="/webEditor/webEditor.eap"/> + <file path="/webEditor/.project"/> </selectedElements> </jardesc> Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/AppletWithApiHandle.java 2008-05-23 14:27:49 UTC (rev 161) @@ -2,10 +2,13 @@ import javax.swing.JApplet; -import edu.lnu.FireFly.Rte.Activity; +import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.Rte.Cmi; import edu.lnu.FireFly.Rte.CmiManager; +import edu.lnu.FireFly.Rte.ElementName; import edu.lnu.FireFly.Rte.GlobalStateInformation; +import edu.lnu.FireFly.WebEditor.Data.AnswersStatusManager; +import edu.lnu.FireFly.WebEditor.Data.SummaryPageManager; /** * It is an Applet, but it contain API handlers. @@ -19,51 +22,73 @@ private static final long serialVersionUID = 5396705469025038804L; public static boolean initialized = false; public static boolean terminated = false; - + + private static String nextItemIdentifier = null; + + public static void setNextItemIdentifier(String itemIdentifier) { + nextItemIdentifier = itemIdentifier; + } + public String Initialize(String parameter) { System.out.print("Initialize(" + parameter + ");\n"); - + + GlobalStateInformation.setCurrentActivity(SummaryPageManager.getInstance().getManifest().findItemByIdentifier(nextItemIdentifier)); + return "true"; } public String Terminate(String parameter) { System.out.print("Terminate(" + parameter + ");\n"); + GlobalStateInformation.setCurrentActivity(null); + return "true"; } public String GetValue(String parameter) { - System.out.print("GetValue(" + parameter + ");\n"); + System.out.print("GetValue(" + parameter + ")"); - Cmi cmi = getCmiModel(); - - if (parameter.toLowerCase().startsWith("cmi.")){ - return cmi.getValue(parameter.substring(4)); - } else { - return ""; + Cmi cmi = getCmiModel(); + + String result = ""; + if (parameter.toLowerCase().startsWith("cmi.")) { + result = cmi.getValue(new ElementName(parameter.substring(4))); } + + System.out.println(" returned " + result); + return result; } private Cmi getCmiModel() { - - Activity activity = GlobalStateInformation.getCurrentActivity(); - + + TreeItem activity = GlobalStateInformation.getCurrentActivity(); + Cmi cmi = CmiManager.getInstance().getModelForActivity(activity); return cmi; } public boolean SetValue(String parameter, String value) { System.out.print("SetValue(" + parameter + ", " + value + ");\n"); - - Cmi cmi = getCmiModel(); - if (parameter.toLowerCase().startsWith("cmi.")){ - cmi.setValue(parameter.substring(4), value); - return true; + Cmi cmi = getCmiModel(); + + if (parameter.toLowerCase().startsWith("cmi.")) { + cmi.setValue(new ElementName(parameter.substring(4)), value); + + if (parameter.startsWith("cmi.answers.")) { + String itemIdentifier = GlobalStateInformation + .getCurrentActivity().getIdentifier(); + + TreeItem item = SummaryPageManager.getInstance().getManifest() + .findItemByIdentifier(itemIdentifier); + + AnswersStatusManager.getInstance().cmiAnswersChanged(item); + } + + return true; } else { return false; } - } public String Commit(String parameter) { Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/CourseTree.java 2008-05-23 14:27:49 UTC (rev 161) @@ -9,8 +9,6 @@ import edu.lnu.FireFly.FFManifest.item.Item; import edu.lnu.FireFly.FFManifest.resource.Resource; -import edu.lnu.FireFly.Rte.Activity; -import edu.lnu.FireFly.Rte.GlobalStateInformation; import edu.lnu.FireFly.WebEditor.GUI.TreeDataModel; public class CourseTree extends JTree implements TreeSelectionListener { @@ -40,7 +38,8 @@ public void valueChanged(TreeSelectionEvent e) { if (e.getNewLeadSelectionPath() == null) { try { - GlobalStateInformation.setCurrentActivity(null); + AppletWithApiHandle.setNextItemIdentifier(""); + getAppletContext().showDocument( new URL(Settings.getInstance().getResourceLocation() + "/empty.htm"), "ContentFrame"); @@ -57,7 +56,7 @@ Item item = (Item) e.getNewLeadSelectionPath() .getLastPathComponent(); - GlobalStateInformation.setCurrentActivity(Activity.findActivityByIdentifier(item.identifier)); + AppletWithApiHandle.setNextItemIdentifier(item.identifier); try { Resource resource = WebEditor.instance.getManifest().resources Added: WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AnswersStatusManager.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AnswersStatusManager.java (rev 0) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/Data/AnswersStatusManager.java 2008-05-23 14:27:49 UTC (rev 161) @@ -0,0 +1,78 @@ +package edu.lnu.FireFly.WebEditor.Data; + +import java.util.HashMap; + +import edu.lnu.FireFly.FFManifest.Manifest; +import edu.lnu.FireFly.FFManifest.TreeItem; +import edu.lnu.FireFly.FFManifest.parser.TestDocException; +import edu.lnu.FireFly.Rte.Cmi; +import edu.lnu.FireFly.Rte.CmiManager; +import edu.lnu.FireFly.WebEditor.ItemModels.ItemModel; +import edu.lnu.FireFly.WebEditor.ItemModels.ItemModels; +import edu.lnu.FireFly.WebEditor.ItemModels.UserAnswerStatus; + +public class AnswersStatusManager { + private HashMap<TreeItem, UserAnswerStatus> answerStatus = new HashMap<TreeItem, UserAnswerStatus>(); + private static AnswersStatusManager obj = null; + + private AnswersStatusManager() { + + } + + public void resetAllAnswers(){ + answerStatus.clear(); + + Manifest manifest = SummaryPageManager.getInstance().getManifest(); + + TreeItem root = null; + try { + root = manifest.getRoot(); + } catch (TestDocException e) { + e.printStackTrace(); + + return ; + } + + updateAllCmiModels(root); + } + + public void updateAllCmiModels(TreeItem root) { + ItemModel itemModel = ItemModels.getModelFromItem(root); + + Cmi cmi = CmiManager.getInstance().getModelForActivity(root); + + cmi.clearAnswers(); + + itemModel.handleUserAnswer(root); + + for (int i=0; i < root.getChildCount(); i++){ + updateAllCmiModels(root.getChild(i)); + } + } + + public UserAnswerStatus getAnswerStatus(TreeItem anItem) { + UserAnswerStatus userAnswerStatus = answerStatus.get(anItem); + + if (userAnswerStatus == null) { + ItemModel itemModel = ItemModels.getModelFromItem(anItem); + + answerStatus.put(anItem, itemModel.createUserAnswerInstance(anItem)); + userAnswerStatus = answerStatus.get(anItem); + } + + return userAnswerStatus; + } + + public static AnswersStatusManager getInstance() { + if (obj == null) { + obj = new AnswersStatusManager(); + } + + return obj; + } + + public void cmiAnswersChanged(TreeItem anItem) { + ItemModel itemModel = ItemModels.getModelFromItem(anItem); + itemModel.handleUserAnswer(anItem); + } +} Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Chapter/ChapterModel.java 2008-05-23 14:27:49 UTC (rev 161) @@ -15,7 +15,7 @@ public class ChapterModel extends ResourcedItemModel { @Override - protected UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { + public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { return null; } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/CompileQ/CompileQModel.java 2008-05-23 14:27:49 UTC (rev 161) @@ -16,7 +16,7 @@ public class CompileQModel extends ResourcedItemModel { @Override - protected UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { + public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { return new ScoredUserAnswerStatus(anItem); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/ItemModel.java 2008-05-23 14:27:49 UTC (rev 161) @@ -14,12 +14,11 @@ import edu.lnu.FireFly.FFManifest.item.sequencing.objectives.MapInfo; import edu.lnu.FireFly.FFManifest.item.sequencing.objectives.Objectives; import edu.lnu.FireFly.FFManifest.resource.Resource; -import edu.lnu.FireFly.Rte.Activity; import edu.lnu.FireFly.Rte.Cmi; import edu.lnu.FireFly.Rte.CmiManager; import edu.lnu.FireFly.WebEditor.WebEditor; +import edu.lnu.FireFly.WebEditor.Data.AnswersStatusManager; import edu.lnu.FireFly.WebEditor.Data.ManifestFactory; -import edu.lnu.FireFly.WebEditor.Data.SummaryPageManager; import edu.lnu.FireFly.WebEditor.GUI.TreeDataModel; import edu.lnu.FireFly.WebEditor.GUI.Dialogs.PropertyDlg; import edu.lnu.FireFly.WebEditor.ItemModels.SummaryPageModel.SummaryPageModel; @@ -90,9 +89,6 @@ // .getItemPath(item)); TreeDataModel.getInstance().treeNodesChanged(item); - - Activity.synchronizeActivitiesStructure(SummaryPageManager - .getInstance().getManifest()); } public final void registerConfigDlg(PropertyDlg dlg) { @@ -274,19 +270,22 @@ protected abstract ItemData createItemDataInstance(); - public void handleUserAnswer(String answer, TreeItem anItem){ - Activity activity = Activity.findActivityByIdentifier(anItem.getIdentifier()); - - Cmi cmi =CmiManager.getInstance().getModelForActivity(activity); - if (cmi == null){ - throw new NullPointerException("Cmi model for activity is null at ItemModel.handleUserAnswer()"); + public void handleUserAnswer(TreeItem anItem) { + Cmi cmi = CmiManager.getInstance().getModelForActivity(anItem); + if (cmi == null) { + throw new NullPointerException( + "Cmi model for activity is null at ItemModel.handleUserAnswer()"); } - - UserAnswerStatus userAnswer = createUserAnswerInstance(anItem); - userAnswer.setRawAnswer(answer); - - userAnswer.updateRteFields(cmi); + + UserAnswerStatus userAnswer = AnswersStatusManager.getInstance().getAnswerStatus(anItem); + if (userAnswer != null) { + String[] rawAnswer = cmi.getAnswers(); + + userAnswer.setRawAnswer(rawAnswer); + + userAnswer.updateRteFields(cmi); + } } - protected abstract UserAnswerStatus createUserAnswerInstance(TreeItem anItem); + public abstract UserAnswerStatus createUserAnswerInstance(TreeItem anItem); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Lecture/LectureModel.java 2008-05-23 14:27:49 UTC (rev 161) @@ -13,7 +13,7 @@ public class LectureModel extends ResourcedItemModel { @Override - protected UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { + public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { return new LectureUserAnswerStatus(anItem); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/LectureUserAnswerStatus.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/LectureUserAnswerStatus.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/LectureUserAnswerStatus.java 2008-05-23 14:27:49 UTC (rev 161) @@ -2,6 +2,9 @@ import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.Rte.Cmi; +import edu.lnu.FireFly.Rte.ElementName; +import edu.lnu.FireFly.Rte.GlobalStateInformation; +import edu.lnu.FireFly.WebEditor.Data.SummaryPageManager; public class LectureUserAnswerStatus extends UserAnswerStatus { @@ -11,14 +14,37 @@ @Override public void updateRteFields(Cmi cmi) { - // TODO Auto-generated method stub + + TreeItem currentActivity = GlobalStateInformation.getCurrentActivity(); + + GlobalStateInformation.setCurrentActivity(SummaryPageManager.getInstance().getManifest().findItemByIdentifier(item.getIdentifier())); + + String[] answers = getRawAnswer(); + String status = "incomplete"; + + cmi.setValue(new ElementName("score.min"), "0"); + cmi.setValue(new ElementName("score.max"), "0"); + cmi.setValue(new ElementName("score.raw"), "0"); + cmi.setValue(new ElementName("score.scaled"), "0"); + + cmi.setValue(new ElementName("objectives.0.score.min"), "0"); + cmi.setValue(new ElementName("objectives.0.score.max"), "0"); + cmi.setValue(new ElementName("objectives.0.score.raw"), "0"); + cmi.setValue(new ElementName("objectives.0.score.scaled"), "0"); + + if (answers != null && answers.length == 1 && answers[0].equals("read")) { + status = "completed"; + } + + cmi.setValue(new ElementName("completion_status"), status); + cmi.setValue(new ElementName("objectives.0.completion_status"), status); + cmi.setValue(new ElementName("objectives.0.score.scaled"), "1"); + + GlobalStateInformation.setCurrentActivity(currentActivity); } @Override protected void updateValues() { - // TODO Auto-generated method stub - } - } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SimpleQuestion/SimpleQuestionModel.java 2008-05-23 14:27:49 UTC (rev 161) @@ -15,7 +15,7 @@ public class SimpleQuestionModel extends ResourcedItemModel { @Override - protected UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { + public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { return new ScoredUserAnswerStatus(anItem); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/SummaryPageModel/SummaryPageModel.java 2008-05-23 14:27:49 UTC (rev 161) @@ -17,7 +17,7 @@ public class SummaryPageModel extends ResourcedItemModel { @Override - protected UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { + public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { return null; } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownItemModel.java 2008-05-23 14:27:49 UTC (rev 161) @@ -7,7 +7,7 @@ public class UnknownItemModel extends ItemModel { @Override - protected UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { + public UserAnswerStatus createUserAnswerInstance(TreeItem anItem) { return new UnknownModelAnswerStatus(anItem); } Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownModelAnswerStatus.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownModelAnswerStatus.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UnknownModelAnswerStatus.java 2008-05-23 14:27:49 UTC (rev 161) @@ -2,6 +2,7 @@ import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.Rte.Cmi; +import edu.lnu.FireFly.Rte.ElementName; public class UnknownModelAnswerStatus extends UserAnswerStatus { @@ -13,7 +14,8 @@ public void updateRteFields(Cmi cmi){ int interaction = 0; String cmiElement = "interactions." + interaction + ".learner_response"; - cmi.setValue(cmiElement, getRawAnswer()); + + cmi.setValue(new ElementName(cmiElement), "{" + Utils.getInstance().marge(getRawAnswer(), ",") + "}"); } @Override Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UserAnswerStatus.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UserAnswerStatus.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/UserAnswerStatus.java 2008-05-23 14:27:49 UTC (rev 161) @@ -4,18 +4,18 @@ import edu.lnu.FireFly.Rte.Cmi; public abstract class UserAnswerStatus { - private String rawAnswer = ""; + private String[] rawAnswer = null; protected TreeItem item = null; public UserAnswerStatus(TreeItem anItem){ item = anItem; } - public String getRawAnswer() { + public String[] getRawAnswer() { return rawAnswer; } - public void setRawAnswer(String rawAnswer) { + public void setRawAnswer(String[] rawAnswer) { this.rawAnswer = rawAnswer; updateValues(); Added: WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Utils.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Utils.java (rev 0) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/ItemModels/Utils.java 2008-05-23 14:27:49 UTC (rev 161) @@ -0,0 +1,31 @@ +package edu.lnu.FireFly.WebEditor.ItemModels; + +public class Utils { + public static Utils obj = null; + + private Utils(){ + + } + + public static Utils getInstance(){ + if (obj == null){ + obj = new Utils(); + } + + return obj; + } + + public String marge(String[] parts, String delimiter) { + String result = ""; + + for (int i = 0; i < parts.length; i++){ + result += parts[i]; + + if (i == parts.length - 1){ + result += delimiter; + } + } + + return result; + } +} Modified: WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java =================================================================== --- WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/src/edu/lnu/FireFly/WebEditor/WebEditor.java 2008-05-23 14:27:49 UTC (rev 161) @@ -12,7 +12,7 @@ import edu.lnu.FireFly.FFManifest.TreeItem; import edu.lnu.FireFly.FFManifest.parser.Parser; import edu.lnu.FireFly.FFManifest.parser.TestDocException; -import edu.lnu.FireFly.Rte.Activity; +import edu.lnu.FireFly.WebEditor.Data.AnswersStatusManager; import edu.lnu.FireFly.WebEditor.Data.AutoSaveThread; import edu.lnu.FireFly.WebEditor.Data.ManifestFactory; import edu.lnu.FireFly.WebEditor.Data.SummaryPageManager; @@ -23,168 +23,182 @@ import edu.lnu.FireFly.WebEditor.WSClients.WebEditorServiceClient; public class WebEditor extends AppletWithWYSIWYGEditor implements - ActionListener { + ActionListener { - /** - * - */ - private static final long serialVersionUID = 1144429894709918030L; + /** + * + */ + private static final long serialVersionUID = 1144429894709918030L; - protected static CourseTree courseTree; + protected static CourseTree courseTree; - public static WebEditor instance = null; + public static WebEditor instance = null; - protected Manifest manifest = null; + protected Manifest manifest = null; - protected JMenuItem openMenuItem = null; + protected JMenuItem openMenuItem = null; - protected JMenuItem saveMenuItem = null; + protected JMenuItem resetMenuItem = null; - private Thread threadForAautoSave; + protected JMenuItem saveMenuItem = null; - private AutoSaveThread autoSaveThread; + private Thread threadForAautoSave; - private JMenuItem publishMenuItem; + private AutoSaveThread autoSaveThread; - @Override - public void actionPerformed(ActionEvent arg0) { - try { - if (arg0.getSource() == openMenuItem) { - openManifest(); - } + private JMenuItem publishMenuItem; - if (arg0.getSource() == publishMenuItem) { - WebEditorServiceClient.getInstance().publish(); - } + @Override + public void actionPerformed(ActionEvent arg0) { + try { + if (arg0.getSource() == openMenuItem) { + openManifest(); + } - if (arg0.getSource() == saveMenuItem) { - saveManifest(); - } - } catch (Exception e) { - e.printStackTrace(); - } + if (arg0.getSource() == resetMenuItem) { + AnswersStatusManager.getInstance().resetAllAnswers(); + } + + if (arg0.getSource() == publishMenuItem) { + WebEditorServiceClient.getInstance().publish(); + } + + if (arg0.getSource() == saveMenuItem) { + saveManifest(); + } + } catch (Exception e) { + e.printStackTrace(); } + } - public void saveManifest() throws TestDocException { - Parser parser = new Parser(); - - autoSaveThread.reset(); + public void saveManifest() throws TestDocException { + Parser parser = new Parser(); - WebEditorServiceClient.getInstance().setFileContent("imsmanifest.xml", - parser.toXML(manifest)); - } + autoSaveThread.reset(); - public void openManifest() throws TestDocException { - Parser parser = new Parser(); - - autoSaveThread.reset(); - - manifest = parser.fromXML(WebEditorServiceClient.getInstance() - .getFileContent("imsmanifest.xml", "course")); - TreeDataModel.initInstance(manifest); + WebEditorServiceClient.getInstance().setFileContent("imsmanifest.xml", + parser.toXML(manifest)); + } - ItemModels.synchronizeAllItemDatas(manifest.getRoot()); - SummaryPageManager.getInstance().setManifest(manifest); - - Activity.fullsynchronizeActivitiesStructure(manifest); - } + public void openManifest() throws TestDocException { + Parser parser = new Parser(); - public Manifest getManifest() { - return manifest; - } + autoSaveThread.reset(); - @Override - public void init() { - parseParameter(); + manifest = parser.fromXML(WebEditorServiceClient.getInstance() + .getFileContent("imsmanifest.xml", "course")); + TreeDataModel.initInstance(manifest); - instance = this; + ItemModels.synchronizeAllItemDatas(manifest.getRoot()); + SummaryPageManager.getInstance().setManifest(manifest); - autoSaveThread = new AutoSaveThread(); - threadForAautoSave = new Thread(autoSaveThread); - threadForAautoSave.start(); + AnswersStatusManager.getInstance().resetAllAnswers(); + } - initMenu(); + public Manifest getManifest() { + return manifest; + } - try { - openManifest(); - } catch (TestDocException e) { - System.out.println("Can't load course. Creating new..."); - CreateNewCourse(); - } + @Override + public void init() { + parseParameter(); - courseTree = new CourseTree(TreeDataModel.getInstance(), getAppletContext()); - this.add(new JScrollPane(courseTree)); + instance = this; - courseTree.addMouseListener(new CourseTreePopupMenu()); + autoSaveThread = new AutoSaveThread(); + threadForAautoSave = new Thread(autoSaveThread); + threadForAautoSave.start(); + + initMenu(); + + try { + openManifest(); + } catch (TestDocException e) { + System.out.println("Can't load course. Creating new..."); + CreateNewCourse(); } - private void parseParameter() { - String paramCourseLocation = getParameter("courseLocation"); - String paramServiceLocation = getParameter("serviceLocation"); - String paramTemplateLocation = getParameter("templateLocation"); - String paramResourceLocation = getParameter("resourceLocation"); + courseTree = new CourseTree(TreeDataModel.getInstance(), + getAppletContext()); + this.add(new JScrollPane(courseTree)); - if (paramCourseLocation != null){ - Settings.getInstance().setCourseLocation(paramCourseLocation); - } - if (paramServiceLocation != null){ - Settings.getInstance().setServiceLocation(paramServiceLocation); - } - if (paramTemplateLocation != null){ - Settings.getInstance().setTemplateLocation(paramTemplateLocation); - } - if (paramResourceLocation != null){ - Settings.getInstance().setResourceLocation(paramResourceLocation); - } + courseTree.addMouseListener(new CourseTreePopupMenu()); + } + + private void parseParameter() { + String paramCourseLocation = getParameter("courseLocation"); + String paramServiceLocation = getParameter("serviceLocation"); + String paramTemplateLocation = getParameter("templateLocation"); + String paramResourceLocation = getParameter("resourceLocation"); + + if (paramCourseLocation != null) { + Settings.getInstance().setCourseLocation(paramCourseLocation); } + if (paramServiceLocation != null) { + Settings.getInstance().setServiceLocation(paramServiceLocation); + } + if (paramTemplateLocation != null) { + Settings.getInstance().setTemplateLocation(paramTemplateLocation); + } + if (paramResourceLocation != null) { + Settings.getInstance().setResourceLocation(paramResourceLocation); + } + } - private void CreateNewCourse() { - try { - manifest = ManifestFactory.createManifest(); - SummaryPageManager.getInstance().setManifest(manifest); - ItemModels.synchronizeAllItemDatas(manifest.getRoot()); - TreeDataModel.initInstance(manifest); + private void CreateNewCourse() { + try { + manifest = ManifestFactory.createManifest(); + SummaryPageManager.getInstance().setManifest(manifest); + ItemModels.synchronizeAllItemDatas(manifest.getRoot()); + TreeDataModel.initInstance(manifest); - TreeItem root = manifest.getRoot(); - OrganizationModel model = (OrganizationModel) ItemModels - .getModelFromItem(root); + TreeItem root = manifest.getRoot(); + OrganizationModel model = (OrganizationModel) ItemModels + .getModelFromItem(root); - model.synchronizeItemWithResource(root, "template"); - SummaryPageManager.getInstance().updateSummaryPages(); - - Activity.fullsynchronizeActivitiesStructure(manifest); - } catch (Exception e) { - e.printStackTrace(); - } + model.synchronizeItemWithResource(root, "template"); + SummaryPageManager.getInstance().updateSummaryPages(); + + AnswersStatusManager.getInstance().resetAllAnswers(); + } catch (Exception e) { + e.printStackTrace(); } + } - public void initMenu() { - // Create the menu bar - JMenuBar menuBar = new JMenuBar(); + public void initMenu() { + // Create the menu bar + JMenuBar menuBar = new JMenuBar(); - // Create a menu - JMenu menu = new JMenu("File"); - menuBar.add(menu); + // Create a menu + JMenu fileMenu = new JMenu("File"); + menuBar.add(fileMenu); - openMenuItem = new JMenuItem("Open"); - openMenuItem.addActionListener(this); - menu.add(openMenuItem); + JMenu editMenu = new JMenu("Edit"); + menuBar.add(editMenu); - // Create a menu item - saveMenuItem = new JMenuItem("Save"); - saveMenuItem.addActionListener(this); - menu.add(saveMenuItem); + resetMenuItem = new JMenuItem("Reset user activity"); + resetMenuItem.addActionListener(this); + fileMenu.add(resetMenuItem); - // Create a menu item - publishMenuItem = new JMenuItem("Publish"); - publishMenuItem.addActionListener(this); - menu.add(publishMenuItem); + openMenuItem = new JMenuItem("Open"); + openMenuItem.addActionListener(this); + fileMenu.add(openMenuItem); - // Install the menu bar in the frame - this.setJMenuBar(menuBar); - } + // Create a menu item + saveMenuItem = new JMenuItem("Save"); + saveMenuItem.addActionListener(this); + fileMenu.add(saveMenuItem); - public static CourseTree getCourseTree() { - return courseTree; - } + // Create a menu item + publishMenuItem = new JMenuItem("Publish"); + publishMenuItem.addActionListener(this); + fileMenu.add(publishMenuItem); + + // Install the menu bar in the frame + this.setJMenuBar(menuBar); + } + + public static CourseTree getCourseTree() { + return courseTree; + } } Modified: WebEditor/template/LectureModel.html =================================================================== --- WebEditor/template/LectureModel.html 2008-05-23 14:26:18 UTC (rev 160) +++ WebEditor/template/LectureModel.html 2008-05-23 14:27:49 UTC (rev 161) @@ -5,7 +5,7 @@ <script type="text/javascript" src="global/APIWrapper.js"></script> <script type="text/javascript"> function finish(){ - SetValue("cmi.completion_status", "completed"); + SetValue("cmi.answers.0.value", "read"); Terminate(); } </script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-23 14:26:19
|
Revision: 160 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=160&view=rev Author: sem62 Date: 2008-05-23 07:26:18 -0700 (Fri, 23 May 2008) Log Message: ----------- Removed code that was write Bohdan Figar and put my own code. This code was writing 2 years ago, bug he replaced it because he couldn't understand it. Modified Paths: -------------- RTE/src/edu/lnu/FireFly/Rte/Cmi.java RTE/src/edu/lnu/FireFly/Rte/CmiManager.java RTE/src/edu/lnu/FireFly/Rte/GlobalStateInformation.java Added Paths: ----------- RTE/src/edu/lnu/FireFly/Rte/Collection.java RTE/src/edu/lnu/FireFly/Rte/CollectionItem.java RTE/src/edu/lnu/FireFly/Rte/Element.java RTE/src/edu/lnu/FireFly/Rte/ElementDataFromItem.java RTE/src/edu/lnu/FireFly/Rte/ElementName.java RTE/src/edu/lnu/FireFly/Rte/LogError.java RTE/src/edu/lnu/FireFly/Rte/SimpleElement.java RTE/src/edu/lnu/FireFly/Rte/answers/ RTE/src/edu/lnu/FireFly/Rte/answers/Answers.java RTE/src/edu/lnu/FireFly/Rte/answers/AnswersItem.java RTE/src/edu/lnu/FireFly/Rte/comments/ RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLMS.java RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLMSItem.java RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLearner.java RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLearnerItem.java RTE/src/edu/lnu/FireFly/Rte/interaction/ RTE/src/edu/lnu/FireFly/Rte/interaction/Interactions.java RTE/src/edu/lnu/FireFly/Rte/interaction/InteractionsItem.java RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/ RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/Correct_responses.java RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/Correct_responsesItem.java RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/ RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/Objectives.java RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/ObjectivesItem.java RTE/src/edu/lnu/FireFly/Rte/learner_preference/ RTE/src/edu/lnu/FireFly/Rte/learner_preference/Learner_preference.java RTE/src/edu/lnu/FireFly/Rte/learner_preference/Learner_preferenceItem.java RTE/src/edu/lnu/FireFly/Rte/objectives/ RTE/src/edu/lnu/FireFly/Rte/objectives/GlobalObjectives.java RTE/src/edu/lnu/FireFly/Rte/objectives/ObjectiveMap.java RTE/src/edu/lnu/FireFly/Rte/objectives/Objectives.java RTE/src/edu/lnu/FireFly/Rte/objectives/ObjectivesItem.java RTE/src/edu/lnu/FireFly/Rte/objectives/score/ RTE/src/edu/lnu/FireFly/Rte/objectives/score/Score.java RTE/src/edu/lnu/FireFly/Rte/objectives/score/ScoreItem.java RTE/src/edu/lnu/FireFly/Rte/score/ RTE/src/edu/lnu/FireFly/Rte/score/Score.java RTE/src/edu/lnu/FireFly/Rte/score/ScoreItem.java RTE/src/make.jardesc Removed Paths: ------------- RTE/src/edu/lnu/FireFly/Rte/Activity.java RTE/src/edu/lnu/FireFly/Rte/CmiElement.java RTE/src/edu/lnu/FireFly/Rte/GlobalObjectivesManager.java RTE/src/edu/lnu/FireFly/Rte/ObjectiveMap.java RTE/src/edu/lnu/FireFly/Rte/Utils.java RTE/src/edu/lnu/FireFly/Rte/elements/ RTE/src/rte.jardesc Deleted: RTE/src/edu/lnu/FireFly/Rte/Activity.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/Activity.java 2008-05-23 11:19:26 UTC (rev 159) +++ RTE/src/edu/lnu/FireFly/Rte/Activity.java 2008-05-23 14:26:18 UTC (rev 160) @@ -1,211 +0,0 @@ -package edu.lnu.FireFly.Rte; - -import java.util.ArrayList; - -import edu.lnu.FireFly.FFManifest.Manifest; -import edu.lnu.FireFly.FFManifest.Organization; -import edu.lnu.FireFly.FFManifest.TreeItem; -import edu.lnu.FireFly.FFManifest.item.Item; -import edu.lnu.FireFly.FFManifest.item.Presentation; -import edu.lnu.FireFly.FFManifest.item.sequencing.Sequencing; -import edu.lnu.FireFly.FFManifest.parser.TestDocException; -import edu.lnu.FireFly.FFManifest.resource.Resource; - -public class Activity { - // from Organization - public String structure; - public boolean objectivesGlobalToSystem; - // from Item - public String identifierref; - public boolean isvisible; - public String parameters; - public String timeLimitAction; - public String dataFromLMS; - public Double completionThreshold; - public Presentation presentation; - // both - public String identifier; - public String title; - public ArrayList<Activity> items; - public String metadata_adlcp_location = ""; - public Sequencing sequencing; - // other - public Activity parent; - public boolean isRoot = false; - private static Activity rootActivity; - - private static Manifest manifest = null; - - public Activity(Manifest manifest, Item item, Activity parentActivity){ - Activity.manifest = manifest; - - copyDataFromItem(item); - - parent = parentActivity; - - items = new ArrayList<Activity>(); - int i; - if (item.items != null){ - for (i = 0; i < item.items.size(); i++){ - items.add(new Activity(manifest, item.items.get(i), this)); - } - } - } - - private void copyDataFromItem(Item item) { - identifierref = item.identifierref; - isvisible = item.isvisible; - parameters = item.parameters; - timeLimitAction = item.timeLimitAction; - dataFromLMS = item.dataFromLMS; - completionThreshold = item.completionThreshold; - presentation = item.presentation; - identifier = item.identifier; - title = item.title; - sequencing = item.sequencing; - } - - public Activity(Manifest manifest, Organization organization){ - Activity.manifest = manifest; - - structure = organization.structure; - objectivesGlobalToSystem = organization.objectivesGlobalToSystem; - identifier = organization.identifier; - title = organization.title; - sequencing = organization.sequencing; - - isRoot = true; - items = new ArrayList<Activity>(); - int i; - for (i = 0; i < organization.items.size(); i++){ - items.add(new Activity(manifest, organization.items.get(i), this)); - } - rootActivity = this; - } - - public static Activity getRoot(){ - return rootActivity; - } - - public static void synchronizeActivitiesStructure(TreeItem anItem){ - Activity activity = Activity.findActivityByIdentifier(anItem.getIdentifier()); - for (int i=0; i<anItem.getChildCount(); i++){ - Item newRoot = (Item)anItem.getChild(i); - - Activity newActivity = Activity.findActivityByIdentifier(newRoot.getIdentifier()); - if (newActivity == null){ - newActivity = new Activity(manifest, newRoot, activity); - - activity.items.add(newActivity); - } else { - newActivity.copyDataFromItem(newRoot); - synchronizeActivitiesStructure(newRoot); - } - } - } - - public static void synchronizeActivitiesStructure(Manifest manifest){ - if (manifest != Activity.manifest){ - fullsynchronizeActivitiesStructure(manifest); - - return; - } - - try { - synchronizeActivitiesStructure(manifest.getRoot()); - } catch (TestDocException e) { - e.printStackTrace(); - } - } - - public static void fullsynchronizeActivitiesStructure(Manifest manifest) { - Activity.manifest = manifest; - - try { - new Activity(manifest, (Organization)manifest.organizations.getDefaultOrganization()); - } catch (TestDocException e) { - e.printStackTrace(); - } - } - - public Resource getResource(){ - if (identifierref == null){ - return null; - } - - for (int i=0; i < manifest.resources.resources.size(); i++){ - if (manifest.resources.resources.get(i).identifier.equals(identifierref)){ - return manifest.resources.resources.get(i); - } - } - return null; - } - - public boolean isLeaf(){ - return items.size() == 0; - } - - public int getChildIndex(String id){ - int i; - for (i = 0; i < items.size(); i++){ - if (id.equals(items.get(i).identifier)){ - break; - } - } - return i; - } - - public static Activity findActivityByIdentifier(String identifier){ - return rootActivity.findActivityByIdentifier2(identifier); - } - - public Activity findActivityByIdentifier2(String identifier){ - if (this.identifier.equals(identifier)){ - return this; - } - - for (int i=0; i<items.size(); i++){ - Activity item = items.get(i).findActivityByIdentifier2(identifier); - if (item != null){ - return item; - } - } - return null; - } - - public Activity getLastLeafInCluester(boolean ignoreForvarOnlyControlMode, boolean use_flow_control_mode_attribute){ - - if (isLeaf()){ - return this; - } - - if (!ignoreForvarOnlyControlMode && sequencing.controlMode.forwardOnly){ - return null; - } - - if (use_flow_control_mode_attribute && sequencing.controlMode.flow){ - return items.get(items.size() - 1).getLastLeafInCluester(ignoreForvarOnlyControlMode, use_flow_control_mode_attribute); - } - - return this; - } - - public Activity getFirstLeafInCluester(boolean use_flow_control_mode_attribute){ - if (isLeaf()){ - return this; - } - - if (use_flow_control_mode_attribute){ - } - - if (use_flow_control_mode_attribute && sequencing.controlMode.flow){ - return items.get(0).getFirstLeafInCluester(use_flow_control_mode_attribute); - } else { - return this; - } - } - - public String toString(){ - return title; - } -} Modified: RTE/src/edu/lnu/FireFly/Rte/Cmi.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/Cmi.java 2008-05-23 11:19:26 UTC (rev 159) +++ RTE/src/edu/lnu/FireFly/Rte/Cmi.java 2008-05-23 14:26:18 UTC (rev 160) @@ -2,296 +2,140 @@ import java.util.ArrayList; -import edu.lnu.FireFly.FFManifest.item.sequencing.objectives.Objective; -import edu.lnu.FireFly.Rte.elements.AnswersElement; -import edu.lnu.FireFly.Rte.elements.CommentsFromLMSElement; -import edu.lnu.FireFly.Rte.elements.CommentsFromLearnerElement; -import edu.lnu.FireFly.Rte.elements.InteractionsElement; -import edu.lnu.FireFly.Rte.elements.LearnerPreferenceElement; -import edu.lnu.FireFly.Rte.elements.ObjectivesElement; -import edu.lnu.FireFly.Rte.elements.ScoreElement; +import edu.lnu.FireFly.FFManifest.TreeItem; +import edu.lnu.FireFly.FFManifest.item.Item; +import edu.lnu.FireFly.Rte.answers.Answers; +import edu.lnu.FireFly.Rte.comments.CommentsFromLMS; +import edu.lnu.FireFly.Rte.comments.CommentsFromLearner; +import edu.lnu.FireFly.Rte.interaction.Interactions; +import edu.lnu.FireFly.Rte.learner_preference.Learner_preference; +import edu.lnu.FireFly.Rte.objectives.Objectives; +import edu.lnu.FireFly.Rte.score.Score; -public class Cmi { - private CmiElement _version = new CmiElement("1.0"); - private ArrayList<CommentsFromLearnerElement> commentsFromLearner = new ArrayList<CommentsFromLearnerElement>(); - private ArrayList<CommentsFromLMSElement> commentsFromLMS = new ArrayList<CommentsFromLMSElement>(); - public CmiElement completionStatus = new CmiElement("unknown", - new String[] { "completed", "incomplete", "not attempted", - "unknown" }); +public class Cmi extends CollectionItem { + protected boolean initialized = false; - private CmiElement completionThreshold = new CmiElement(""); - private CmiElement credit = new CmiElement("credit", new String[] { - "credit", "no-credit" }); + public static LogError logErorr = new LogError(); - private CmiElement entry = new CmiElement("ab-initio", new String[] { - "ab-initio", "resume", "" }); - - private CmiElement exit = new CmiElement("", new String[] { "time-out", - "suspend", "logout", "normal", "" }); - - private ArrayList<InteractionsElement> interactions = new ArrayList<InteractionsElement>(); - private CmiElement launchData = new CmiElement(""); - private CmiElement learnerId = new CmiElement(""); - private CmiElement learnerName = new CmiElement(""); - private LearnerPreferenceElement learnerPreference = new LearnerPreferenceElement(); - private CmiElement location = new CmiElement(""); - private CmiElement maxTimeAllowed = new CmiElement(""); - private CmiElement mode = new CmiElement("normal", new String[] { "normal", - "browse", "review" }); - - private ArrayList<ObjectivesElement> objectives = new ArrayList<ObjectivesElement>(); - private CmiElement progressMeasure = new CmiElement(""); - private CmiElement scaledPassingScore = new CmiElement(""); - private ScoreElement score = new ScoreElement(); - private CmiElement sessionTime = new CmiElement(""); - private CmiElement successStatus = new CmiElement("unknown", new String[] { - "passed", "failed", "unknown" }); - - private CmiElement suspendData = new CmiElement(""); - private CmiElement timeLimitAction = new CmiElement(""); - private CmiElement totalTime = new CmiElement(""); + public Cmi(TreeItem item){ + elements.put("_version", new SimpleElement("characterstring", "r", "1.0")); + elements.put("learner_id", new SimpleElement("characterstring", "r", "ID_developer")); + elements.put("learner_name", new SimpleElement("characterstring", "r", "developer")); + elements.put("completetion_threshold", new ElementDataFromItem("real(10,7)range(0..1)", "r", "completetion_threshold")); + elements.put("progress_measure", new SimpleElement("real(10,7)range(0..1)", "rw", null)); + elements.put("scaled_passing_score", new ElementDataFromItem("real(10,7)range(-1..1)", "r", "scaled_passing_score")); + elements.put("session_time", new SimpleElement("timeinterval(second,10,2)", "w", "")); + elements.put("suspend_data", new SimpleElement("characterstring", "rw", null)); + elements.put("time_limit_action", new ElementDataFromItem("characterstring", "r", "time_limit_action")); + elements.put("total_time", new ElementDataFromItem("timeinterval(second,10,2)", "r", "total_time")); - public ArrayList<AnswersElement> answers = new ArrayList<AnswersElement>(); + SimpleElement t = new SimpleElement("characterstring", "rw", "unknown"); + t.addFixedToken("passed"); + t.addFixedToken("failed"); + t.addFixedToken("unknown"); + elements.put("success_status", t); + + t = new SimpleElement("characterstring", "wr", "unknown"); + t.addFixedToken("completed"); + t.addFixedToken("incomplete"); + t.addFixedToken("not attempted"); + t.addFixedToken("unknown"); + elements.put("completion_status", t); - private ArrayList<CmiElement> queryQueue = new ArrayList<CmiElement>(); + + t = new SimpleElement("characterstring", "r", "credit"); + t.addFixedToken("credit"); + t.addFixedToken("no-credit"); + elements.put("credit", t); - public Cmi(Activity activity) { - addManifestObjectives(activity); - } + t = new SimpleElement("characterstring", "r", "ab-initio"); + t.addFixedToken("ab-initio"); + t.addFixedToken("resume"); + t.addFixedToken(""); + elements.put("entry", t); - private void addManifestObjectives(Activity activity) { - if (activity == null || activity.sequencing == null - || activity.sequencing.objectives == null) { - return; - } + t = new SimpleElement("characterstring", "w", ""); + t.addFixedToken("time-out"); + t.addFixedToken("suspend"); + t.addFixedToken("logout"); + t.addFixedToken("normal"); + t.addFixedToken(""); + elements.put("exit", t); - Objective primaryObjective = activity.sequencing.objectives.primaryObjective; - ObjectivesElement oe = new ObjectivesElement(); - oe.id.value = primaryObjective.objectiveID; - objectives.add(oe); - if (primaryObjective.mapInfo.size() > 0) { - CmiManager.getInstance().getGlobalObjectivesManager() - .setGlobalObjectives(activity, primaryObjective); - } - int i; - for (i = 0; i < activity.sequencing.objectives.objective.size(); i++) { - primaryObjective = activity.sequencing.objectives.objective.get(i); - oe = new ObjectivesElement(); - oe.id.value = primaryObjective.objectiveID; - objectives.add(oe); - if (primaryObjective.mapInfo.size() > 0) { - CmiManager.getInstance().getGlobalObjectivesManager() - .setGlobalObjectives(activity, primaryObjective); - } - } - } + t = new SimpleElement("characterstring", "r", "normal"); + t.addFixedToken("normal"); + t.addFixedToken("browse"); + t.addFixedToken("review"); + elements.put("mode", t); - public void setValue(String element, String value) { - CmiElement current = getCmiElement(element); - if (current != null) { - current.value = value; - int i; - for (i = 0; i < queryQueue.size(); i++) { - queryQueue.get(i).value = value; - } - queryQueue.clear(); + elements.put("launch_data", new ElementDataFromItem("characterstring", "r", "launch_data")); + elements.put("max_time_allowed", new ElementDataFromItem("characterstring", "r", "max_time_allowed")); + elements.put("location", new SimpleElement("characterstring", "rw", null)); + + elements.put("interactions", new Interactions(true)); + elements.put("learner_preference", new Learner_preference(true)); + + if (item.getClass() == Item.class){ + elements.put("objectives", new Objectives((Item)item, true)); } + + elements.put("score", new Score(false)); + elements.put("comments_from_learner", new CommentsFromLearner(true)); + elements.put("comments_from_lms", new CommentsFromLMS(true)); + + answers = new Answers(true); + elements.put("answers", answers); } + + protected Answers answers = null; - public String getValue(String element) { - String result = ""; - CmiElement current = getCmiElement(element); - if (current != null) { - result = current.value; - if (!queryQueue.isEmpty()) { - result = queryQueue.get(queryQueue.size() - 1).value; - } - queryQueue.clear(); - } - return result; + public void initialize(){ + initialized = true; } + + public void terminate(){ + behaviour_completionStatusDetermine(); + initialized = false; + } - private CmiElement getCmiElement(String element) { - String first = element; - String second; - int number = 0; - if (element.indexOf(".") != -1) { - first = Utils.getFirst(element); - element = Utils.removeFirst(element); - } - if (element.indexOf(".") != -1) { - number = Integer.parseInt(Utils.getFirst(element)); - element = Utils.removeFirst(element); - } - second = element; - CmiElement returnElement = null; - if (first.equals("_version")) { - returnElement = _version; - } - if (first.equals("comments_from_learner")) { - if (second.equals("_count")) { - returnElement = new CmiElement(""); - returnElement.value = String - .valueOf(commentsFromLearner.size()); - } else { - CommentsFromLearnerElement cfle; - if (number < commentsFromLearner.size()) { - cfle = commentsFromLearner.get(number); - + private void behaviour_completionStatusDetermine() { + Element complate_status = ((Element)elements.get("completion_status")); + Element completetion_threshold = ((Element)elements.get("completetion_threshold")); + Element progress_measure = ((Element)elements.get("progress_measure")); + + if (completetion_threshold.initialized()){ + double threshold = Double.parseDouble(completetion_threshold.getValue(new ElementName(""))); + + if (progress_measure.initialized()){ + double measure = Double.parseDouble(progress_measure.getValue(new ElementName(""))); + + if (measure >= threshold){ + complate_status.setValue(new ElementName(""), "complate"); } else { - cfle = new CommentsFromLearnerElement(); - commentsFromLearner.add(cfle); + complate_status.setValue(new ElementName(""), "incomplate"); } - returnElement = cfle.getCmiElement(second); } } - if (first.equals("comments_from_LMS")) { - if (second.equals("_count")) { - returnElement = new CmiElement(""); - returnElement.value = String.valueOf(commentsFromLMS.size()); - } else { - CommentsFromLMSElement cfle; - if (number < commentsFromLMS.size()) { - cfle = commentsFromLMS.get(number); - - } else { - cfle = new CommentsFromLMSElement(); - commentsFromLMS.add(cfle); - } - returnElement = cfle.getCmiElement(second); - } - } - if (first.equals("completion_status")) { - returnElement = completionStatus; - } - if (first.equals("completion_threshold")) { - returnElement = completionThreshold; - } - if (first.equals("credit")) { - returnElement = credit; - } - if (first.equals("entry")) { - returnElement = entry; - } - if (first.equals("exit")) { - returnElement = exit; - } - if (first.equals("interactions")) { - if (second.equals("_count")) { - returnElement = new CmiElement(""); - returnElement.value = String.valueOf(interactions.size()); - } else { - InteractionsElement ie; - if (number < interactions.size()) { - ie = interactions.get(number); - - } else { - ie = new InteractionsElement(); - interactions.add(ie); - } - returnElement = ie.getCmiElement(second); - } - } - if (first.equals("launch_data")) { - returnElement = launchData; - } - if (first.equals("learner_id")) { - returnElement = learnerId; - } - if (first.equals("learner_name")) { - returnElement = learnerName; - } - if (first.equals("learner_preference")) { - returnElement = learnerPreference.getCmiElement(second); - } - if (first.equals("location")) { - returnElement = location; - } - if (first.equals("max_time_allowed")) { - returnElement = maxTimeAllowed; - } - if (first.equals("mode")) { - returnElement = mode; - } - if (first.equals("objectives")) { - if (second.equals("_count")) { - returnElement = new CmiElement(""); - returnElement.value = String.valueOf(objectives.size()); - } else { - ObjectivesElement oe; - if (number < objectives.size()) { - if (number < 0) { - return null; - } - - oe = objectives.get(number); - CmiManager.getInstance().getGlobalObjectivesManager() - .getGlobalObjectives(oe, second, queryQueue); - } else { - oe = new ObjectivesElement(); - objectives.add(oe); - } - returnElement = oe.getCmiElement(second); - } - } - if (first.equals("progress_measure")) { - returnElement = progressMeasure; - } - if (first.equals("scaled_passing_score")) { - returnElement = scaledPassingScore; - } - if (first.equals("score")) { - returnElement = score.getCmiElement(second); - } - if (first.equals("session_time")) { - returnElement = sessionTime; - } - if (first.equals("success_status")) { - returnElement = successStatus; - } - if (first.equals("suspend_data")) { - returnElement = suspendData; - } - if (first.equals("time_limit_action")) { - returnElement = timeLimitAction; - } - if (first.equals("total_time")) { - returnElement = totalTime; - } - if (first.equals("answers")) { - if (second.equals("_count")) { - returnElement = new CmiElement(""); - returnElement.value = String.valueOf(answers.size()); - } else { - AnswersElement ae; - if (number < answers.size()) { - ae = answers.get(number); - - } else { - ae = new AnswersElement(); - answers.add(ae); - } - returnElement = ae.getCmiElement(second); - } - } - return returnElement; } + public void clearAnswers(){ + answers.items.clear(); + } + public String[] getAnswers(){ ArrayList<String> res = new ArrayList<String>(); - for (int i=0; i < answers.size(); i++){ - res.add(answers.get(i).value.value); + for (int i=0; i < answers.items.size(); i++){ + CollectionItem item = answers.items.get(i); + res.add(item.getValue(new ElementName("value"))); } String[] result = new String[res.size()]; res.toArray(result); return result; } - - // public void checkResult(){ - // AnswersManager answersManager = new - // AnswersManager(GlobalStateInformation.getCurrentActivity()); - // answersManager.checkResult(); - // } + + public boolean initialized(){ + return initialized; + } } Deleted: RTE/src/edu/lnu/FireFly/Rte/CmiElement.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/CmiElement.java 2008-05-23 11:19:26 UTC (rev 159) +++ RTE/src/edu/lnu/FireFly/Rte/CmiElement.java 2008-05-23 14:26:18 UTC (rev 160) @@ -1,19 +0,0 @@ -package edu.lnu.FireFly.Rte; - -public class CmiElement { - public String value; - public String[] tokens; - - public CmiElement(String v){ - value = v; - } - - public CmiElement(String v, String[] t){ - value = v; - tokens = new String[t.length]; - int i; - for (i = 0; i < t.length; i++){ - tokens[i] = t[i]; - } - } -} Modified: RTE/src/edu/lnu/FireFly/Rte/CmiManager.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/CmiManager.java 2008-05-23 11:19:26 UTC (rev 159) +++ RTE/src/edu/lnu/FireFly/Rte/CmiManager.java 2008-05-23 14:26:18 UTC (rev 160) @@ -2,49 +2,52 @@ import java.util.HashMap; +import edu.lnu.FireFly.FFManifest.TreeItem; + /** * Manager of Cmi models * * @author Yuryj Semen */ public class CmiManager { - private static CmiManager obj = null; - private CmiManager(){} - - public static CmiManager getInstance(){ - - if (obj == null){ - obj = new CmiManager(); - } - - return obj; - } - /** * This hashmap containe pairs activity_id <==> CmiModel. */ - private HashMap<String, Cmi> activitiesVSModels = new HashMap<String, Cmi>(); + private HashMap<TreeItem, Cmi> activitiesVSModels = new HashMap<TreeItem, Cmi>(); /** * Global objectives models manager for managing global objectives. * It is under CMI models. */ - private GlobalObjectivesManager globalObjectivesManager = new GlobalObjectivesManager(); - public GlobalObjectivesManager getGlobalObjectivesManager() { - return globalObjectivesManager; - } +// private GlobalObjectivesManager globalObjectivesManager = new GlobalObjectivesManager(); +// public GlobalObjectivesManager getGlobalObjectivesManager() { +// return globalObjectivesManager; +// } /** * It give a requested Tracking model for specified activity * @param activity A specified activity for getting Cmi model * @return Cmi model for specified activity */ - public Cmi getModelForActivity(Activity activity){ - if (!activitiesVSModels.containsKey(activity.identifier)){ - activitiesVSModels.put(activity.identifier, new Cmi(activity)); + public Cmi getModelForActivity(TreeItem activity){ + if (!activitiesVSModels.containsKey(activity)){ + activitiesVSModels.put(activity, new Cmi(activity)); } - return activitiesVSModels.get(activity.identifier); + return activitiesVSModels.get(activity); } + + private static CmiManager obj = null; + private CmiManager(){ + + } + + public static CmiManager getInstance(){ + if (obj == null){ + obj = new CmiManager(); + } + + return obj; + } } Added: RTE/src/edu/lnu/FireFly/Rte/Collection.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/Collection.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/Collection.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,107 @@ +package edu.lnu.FireFly.Rte; + +import java.util.*; + +public class Collection extends Element{ + public ArrayList <CollectionItem>items = new ArrayList<CollectionItem>(); + public String _children = ""; + private boolean indexed = false; + + public Collection (boolean indexed){ + this.indexed = indexed; + } + + public void AddNewItem(){ + items.add(new CollectionItem()); + } + + + public boolean initialized(){ + return true; + } + + public String setValue(ElementName name, String value){ + Cmi.logErorr.LastError = 0; + + if (name.size() == 1){ + if (name.get(0).equals("_count")){ + Cmi.logErorr.LastError = 404; + System.out.print("error 404 at Collection.java(setValue(_count is read only))\n"); + return "False"; + } + + if (name.get(0).equals("_children")){ + Cmi.logErorr.LastError = 404; + System.out.print("error 404 at Collection.java(setValue(_children is read only))\n"); + return "False"; + } + } + + if (!indexed){ + name.push_top("0"); + } + + if (name.size() > 1){ + try{ + int n = Integer.valueOf((String)name.get(0)).intValue(); + + if (n > items.size()){ + Cmi.logErorr.LastError = 351; + System.out.print("error 351 at Collection.java(setValue(n > items.size()))\n"); + return "False"; + } + if (n == items.size()){ + AddNewItem(); + } + + return ((CollectionItem)items.get(n)).setValue(new ElementName(name, 1), value); + } + catch (Exception e){ + Cmi.logErorr.LastError = 401; + System.out.print("error 401 at Collection.java(setValue(Exception))\n"); + return "False"; + } + } + + Cmi.logErorr.LastError = 401; + System.out.print("error 401 at Collection.java(setValue(unknown value))\n"); + return "False"; + } + + public String getValue(ElementName name){ + Cmi.logErorr.LastError = 0; + + if (name.size() == 1){ + if (name.get(0).equals("_count")){ + return String.valueOf(items.size()); + } + + if (name.get(0).equals("_children")){ + return _children; + } + } + + if (!indexed){ + name.push_top("0"); + } + + if (name.size() > 1){ + try{ + int n = Integer.valueOf((String)name.get(0)).intValue(); + if (n >= items.size()){ + Cmi.logErorr.LastError = 301; + return ""; + } + + return ((CollectionItem)items.get(n)).getValue(new ElementName(name, 1)); + } + catch (Exception e){ + Cmi.logErorr.LastError = 401; + return ""; + } + } + + Cmi.logErorr.LastError = 401; + return ""; + } +} Added: RTE/src/edu/lnu/FireFly/Rte/CollectionItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/CollectionItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/CollectionItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,37 @@ +package edu.lnu.FireFly.Rte; + +import java.util.HashMap; + +public class CollectionItem extends Element { + public HashMap<String, Element> elements = new HashMap<String, Element>(); + + public String getValue(ElementName name){ + if (elements.containsKey(name.get(0))) + { + return ((Element)elements.get((String)name.get(0))).getValue(new ElementName(name, 1)); + } + + Cmi.logErorr.LastError = 201; + return ""; + } + + public String setValue(ElementName name, String val){ + if (name.size() < 1){ + Cmi.logErorr.LastError = 201; + System.out.print("error 201 at CollectionItem.java(setValue(name.size() < 1))\n"); + return "false"; + } + + if (elements.containsKey((String)name.get(0))){ + return ((Element)elements.get((String)name.get(0))).setValue(new ElementName(name, 1), val); + } + + System.out.print("error 201 at CollectionItem.java(setValue(element \"" + (String)name.get(0) + "\" not found))\n"); + Cmi.logErorr.LastError = 201; + return "false"; + } + + public boolean initialized(){ + return true; + } +} Added: RTE/src/edu/lnu/FireFly/Rte/Element.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/Element.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/Element.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,8 @@ +package edu.lnu.FireFly.Rte; + +public abstract class Element { + protected ElementName name; + public abstract String setValue(ElementName name, String value); + public abstract String getValue(ElementName name); + public abstract boolean initialized(); +} Added: RTE/src/edu/lnu/FireFly/Rte/ElementDataFromItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/ElementDataFromItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/ElementDataFromItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,95 @@ +package edu.lnu.FireFly.Rte; + +import java.util.ArrayList; + +import edu.lnu.FireFly.FFManifest.item.Item; + +public class ElementDataFromItem extends Element{ + protected String type; + protected String mode; + protected String fieldName; + + protected ArrayList<String> fixedTokens = new ArrayList<String>(); + + public void addFixedToken(String token){ + fixedTokens.add(token); + } + + public ElementDataFromItem(){ + type = "characterstring"; + mode = "r"; + } + + public ElementDataFromItem(String type, String mode, String fieldName){ + this.type = type; + this.mode = mode; + this.fieldName = fieldName; + } + + private String Value(){ + if (fieldName.equals("lunch_data")){ + return ((Item)GlobalStateInformation.getCurrentActivity()).dataFromLMS; + } + + if (fieldName.equals("completetion_threshold")){ + if (((Item)GlobalStateInformation.getCurrentActivity()).completionThreshold == null){ + return null; + } + return String.valueOf(((Item)GlobalStateInformation.getCurrentActivity()).completionThreshold); + } + + if (fieldName.equals("max_time_allowed")){ + return String.valueOf(((Item)GlobalStateInformation.getCurrentActivity()).sequencing.limitConditions.attemptAbsoluteDurationLimit); + } + + if (fieldName.equals("scaled_passing_score")){ + // TODO need realize !!! + return null; //String.valueOf(GlobalStateInformation.currentActivity.); + } + + if (fieldName.equals("time_limit_action")){ + // TODO need realize !!! + return null; //String.valueOf(GlobalStateInformation.currentActivity.); + } + + if (fieldName.equals("total_time")){ + // TODO need realize !!! + return null; //String.valueOf(GlobalStateInformation.currentActivity.); + } + + Cmi.logErorr.LastError = 401; + return ""; + } + + public String setValue(ElementName name, String value){ + Cmi.logErorr.LastError = 404; + return "false"; + } + + public boolean initialized(){ + return Value() != null; + } + + public String getValue(ElementName name){ + Cmi.logErorr.LastError = 0; + + if (GlobalStateInformation.getCurrentActivity() == null || name.size() != 1){ + Cmi.logErorr.LastError = 403; + return ""; + } + + if (((Item)GlobalStateInformation.getCurrentActivity()).completionThreshold == null){ + Cmi.logErorr.LastError = 403; + return ""; + } + + String res = Value(); + + if (res == null){ + Cmi.logErorr.LastError = 403; + return ""; + } + + return res; + } +} Added: RTE/src/edu/lnu/FireFly/Rte/ElementName.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/ElementName.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/ElementName.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,46 @@ +package edu.lnu.FireFly.Rte; + +import java.util.*; + +public class ElementName { + public ArrayList<String> path = null; + + public ElementName(ElementName name, int skipFirst) { + path = new ArrayList<String>(); + for (int i = skipFirst; i < name.size(); i++) { + path.add(name.get(i)); + } + } + + public ElementName(String name) { + path = explode(name, "."); + } + + private ArrayList<String> explode(String value, String delimiter) { + ArrayList<String> result = new ArrayList<String>(); + + while (true) { + int delimPos = value.indexOf(delimiter); + + if (delimPos < 0) { + result.add(value); + return result; + } + + result.add(value.substring(0, delimPos)); + value = value.substring(delimPos + 1); + } + } + + public void push_top(String s) { + path.add(0, s); + } + + public int size() { + return path.size(); + } + + public String get(int i) { + return (String) path.get(i); + } +} Deleted: RTE/src/edu/lnu/FireFly/Rte/GlobalObjectivesManager.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/GlobalObjectivesManager.java 2008-05-23 11:19:26 UTC (rev 159) +++ RTE/src/edu/lnu/FireFly/Rte/GlobalObjectivesManager.java 2008-05-23 14:26:18 UTC (rev 160) @@ -1,50 +0,0 @@ -package edu.lnu.FireFly.Rte; - -import java.util.ArrayList; - -import edu.lnu.FireFly.FFManifest.item.sequencing.objectives.Objective; -import edu.lnu.FireFly.Rte.elements.ObjectivesElement; - -public class GlobalObjectivesManager { - private ArrayList<ObjectivesElement> globalObjectives = new ArrayList<ObjectivesElement>(); - private ArrayList<ObjectiveMap> objectiveMaps = new ArrayList<ObjectiveMap>(); - - public void setGlobalObjectives(Activity activity, Objective objective){ - int i; - for (i = 0; i < objective.mapInfo.size(); i++){ - if (getObjectiveById(objective.mapInfo.get(i).targetObjectiveID) == null){ - ObjectivesElement oe = new ObjectivesElement(); - oe.id.value = objective.mapInfo.get(i).targetObjectiveID; - globalObjectives.add(oe); - } - ObjectiveMap om = new ObjectiveMap(activity.identifier + objective.objectiveID, objective.mapInfo.get(i).targetObjectiveID); - objectiveMaps.add(om); - } - } - - public void getGlobalObjectives(ObjectivesElement oe, String element, ArrayList<CmiElement> list){ - String id = GlobalStateInformation.getCurrentActivity().identifier + oe.id.value; - int i; - for (i = 0; i < objectiveMaps.size(); i++){ - ObjectiveMap current = objectiveMaps.get(i); - if (current.activityObjectiveID.equals(id)){ - ObjectivesElement global = getObjectiveById(current.targetObjectiveID); - CmiElement ce = global.getCmiElement(element); - list.add(ce); - } - } - - } - - private ObjectivesElement getObjectiveById(String id){ - ObjectivesElement result = null; - int i; - for (i = 0; i < globalObjectives.size(); i++){ - if (globalObjectives.get(i).id.value.equals(id)){ - result = globalObjectives.get(i); - break; - } - } - return result; - } -} Modified: RTE/src/edu/lnu/FireFly/Rte/GlobalStateInformation.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/GlobalStateInformation.java 2008-05-23 11:19:26 UTC (rev 159) +++ RTE/src/edu/lnu/FireFly/Rte/GlobalStateInformation.java 2008-05-23 14:26:18 UTC (rev 160) @@ -1,20 +1,22 @@ package edu.lnu.FireFly.Rte; +import edu.lnu.FireFly.FFManifest.TreeItem; + public class GlobalStateInformation { - protected static Activity currentActivity = null; - protected static Activity suspendedActivity = null; + protected static TreeItem currentActivity = null; + protected static TreeItem suspendedActivity = null; - public static Activity getCurrentActivity(){ + public static TreeItem getCurrentActivity(){ return currentActivity; } - public static void setCurrentActivity(Activity value){ + public static void setCurrentActivity(TreeItem value){ currentActivity = value; } - public static Activity getSuspendedActivity(){ + public static TreeItem getSuspendedActivity(){ return suspendedActivity; } - public static void setSuspendedActivity(Activity value){ + public static void setSuspendedActivity(TreeItem value){ suspendedActivity = value; } } Added: RTE/src/edu/lnu/FireFly/Rte/LogError.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/LogError.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/LogError.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,5 @@ +package edu.lnu.FireFly.Rte; + +public class LogError { + public int LastError = 0; +} Deleted: RTE/src/edu/lnu/FireFly/Rte/ObjectiveMap.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/ObjectiveMap.java 2008-05-23 11:19:26 UTC (rev 159) +++ RTE/src/edu/lnu/FireFly/Rte/ObjectiveMap.java 2008-05-23 14:26:18 UTC (rev 160) @@ -1,16 +0,0 @@ -package edu.lnu.FireFly.Rte; - -public class ObjectiveMap { - public String activityObjectiveID = ""; - public String targetObjectiveID = ""; - public boolean readObjectiveSatisfiedStatus = true; - public boolean writeObjectiveSatisfiedStatus = false; - public boolean readObjectiveNormalizedMeasure = true; - public boolean writeObjectiveNormalizedMeasure = false; - - public ObjectiveMap(String localId, String globalId){ - activityObjectiveID = localId; - targetObjectiveID = globalId; - } - -} Added: RTE/src/edu/lnu/FireFly/Rte/SimpleElement.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/SimpleElement.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/SimpleElement.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,93 @@ +package edu.lnu.FireFly.Rte; + +import java.util.*; + +public class SimpleElement extends Element{ + protected String value; + protected String type; + protected String mode; + + protected ArrayList<String> fixedTokens = new ArrayList<String>(); + + public void addFixedToken(String token){ + fixedTokens.add(token); + } + + public boolean initialized(){ + return value != null; + } + + public SimpleElement(){ + value = ""; + type = "characterstring"; + mode = "rw"; + } + + public SimpleElement(String type, String mode, String value){ + this.value = value; + this.type = type; + this.mode = mode; + } + + public String setValue(ElementName name, String value){ + Cmi.logErorr.LastError = 0; + + if (name.size() != 0){ + Cmi.logErorr.LastError = 403; + System.out.print("error 403 at SimpleElement.java(setValue(name.size() != 0))\n"); + return "False"; + } + + if (fixedTokens.size() > 0){ + boolean contain = false; + for (int i=0; i<fixedTokens.size(); i++){ + if (fixedTokens.get(i).equals(value)){ + contain = true; + } + } + if (!contain){ + Cmi.logErorr.LastError = 406; + System.out.print("error 406 at SimpleElement.java(setValue(!contain fixed value))\n"); + return "False"; + } + } + + if (!mode.contains("w")){ + Cmi.logErorr.LastError = 404; + System.out.print("error 404 at SimpleElement.java(setValue(read only))\n"); + return "false"; + } + + // TODO \xCD\xE5\xEE\xE1\xF5\xB3\xE4\xED\xE0 \xEF\xE5\xF0\xE5\xE2\xB3\xF0\xEA\xE0 \xED\xE0 \xE2\xB3\xE4\xEF\xEE\xE2\xB3\xE4\xED\xB3\xF1\xF2\xFC \xF2\xE8\xEF\xF3 (field type) + + this.value = value; + +// Navigation.updateUI(); + + return "true"; + } + + public String getValue(ElementName name){ + Cmi.logErorr.LastError = 0; + + if (value == null || name.size() != 0){ + Cmi.logErorr.LastError = 403; + return ""; + } + + if (fixedTokens.size() > 0){ + if (!fixedTokens.contains(value)){ + Cmi.logErorr.LastError = 406; + System.out.print("\nInternal error. May be default element value not in fixed list!!!"); + return ""; + } + } + + if (!mode.contains("r")){ + Cmi.logErorr.LastError = 405; + return ""; + } + + return value; + } +} Deleted: RTE/src/edu/lnu/FireFly/Rte/Utils.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/Utils.java 2008-05-23 11:19:26 UTC (rev 159) +++ RTE/src/edu/lnu/FireFly/Rte/Utils.java 2008-05-23 14:26:18 UTC (rev 160) @@ -1,32 +0,0 @@ -package edu.lnu.FireFly.Rte; - -public class Utils { - public static String getFirst(String s){ - return s.substring(0, s.indexOf(".")); - } - - public static String removeFirst(String s){ - int index = s.indexOf(".") + 1; - return s.substring(index, s.length()); - } - - public static String getActivityType(Activity activity){ - if (activity == null || activity.getResource() == null){ - return "asset"; - } - - if (activity.getResource().scormType.equals("sco")){ - return "sco"; - } - return "asset"; - } - - public static String getChoiceTarget(String choice){ - choice = choice.substring(choice.indexOf("choice") + 6, choice.length()); - choice = choice.trim(); - choice = choice.substring(choice.indexOf("target") + 6, choice.length() - 1); - choice = choice.trim(); - choice = choice.substring(choice.indexOf("=") + 1, choice.length()); - return choice.trim(); - } -} Added: RTE/src/edu/lnu/FireFly/Rte/answers/Answers.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/answers/Answers.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/answers/Answers.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,14 @@ +package edu.lnu.FireFly.Rte.answers; + +import edu.lnu.FireFly.Rte.Collection; + +public class Answers extends Collection { + public Answers(boolean indexed){ + super(indexed); + _children = AnswersItem._children; + } + + public void AddNewItem(){ + items.add(new AnswersItem()); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/answers/AnswersItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/answers/AnswersItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/answers/AnswersItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,12 @@ +package edu.lnu.FireFly.Rte.answers; + +import edu.lnu.FireFly.Rte.CollectionItem; +import edu.lnu.FireFly.Rte.SimpleElement; + +public class AnswersItem extends CollectionItem{ + public static String _children = "value"; + + public AnswersItem(){ + elements.put("value", new SimpleElement("characterstring", "rw", "")); + } +} \ No newline at end of file Added: RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLMS.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLMS.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLMS.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,14 @@ +package edu.lnu.FireFly.Rte.comments; + +import edu.lnu.FireFly.Rte.Collection; + +public class CommentsFromLMS extends Collection{ + public CommentsFromLMS(boolean indexed){ + super(indexed); + _children = CommentsFromLMSItem._children; + } + + public void AddNewItem(){ + items.add(new CommentsFromLMSItem()); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLMSItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLMSItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLMSItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,15 @@ +package edu.lnu.FireFly.Rte.comments; + +import edu.lnu.FireFly.Rte.CollectionItem; +import edu.lnu.FireFly.Rte.SimpleElement; + +public class CommentsFromLMSItem extends CollectionItem { +public static String _children = "comment,location,timestamp"; + + public CommentsFromLMSItem() + { + elements.put("comment", new SimpleElement("characterstring", "r", null)); + elements.put("location", new SimpleElement("characterstring", "r", "")); + elements.put("timestamp", new SimpleElement("time(second,10,0)", "r", null)); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLearner.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLearner.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLearner.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,14 @@ +package edu.lnu.FireFly.Rte.comments; + +import edu.lnu.FireFly.Rte.Collection; + +public class CommentsFromLearner extends Collection{ + public CommentsFromLearner(boolean indexed){ + super(indexed); + _children = CommentsFromLearnerItem._children; + } + + public void AddNewItem(){ + items.add(new CommentsFromLearnerItem()); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLearnerItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLearnerItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/comments/CommentsFromLearnerItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,16 @@ +package edu.lnu.FireFly.Rte.comments; + +import edu.lnu.FireFly.Rte.CollectionItem; +import edu.lnu.FireFly.Rte.SimpleElement; + +public class CommentsFromLearnerItem extends CollectionItem { + public static String _children = "comment,location,timestamp"; + + public CommentsFromLearnerItem() + { + elements.put("comment", new SimpleElement("characterstring", "rw", null)); + elements.put("location", new SimpleElement("characterstring", "rw", null)); + elements.put("timestamp", new SimpleElement("time(second,10,0)", "rw", null)); + } + +} Added: RTE/src/edu/lnu/FireFly/Rte/interaction/Interactions.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/interaction/Interactions.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/interaction/Interactions.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,14 @@ +package edu.lnu.FireFly.Rte.interaction; + +import edu.lnu.FireFly.Rte.Collection; + +public class Interactions extends Collection { + public Interactions(boolean indexed){ + super(indexed); + _children = InteractionsItem._children; + } + + public void AddNewItem(){ + items.add(new InteractionsItem()); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/interaction/InteractionsItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/interaction/InteractionsItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/interaction/InteractionsItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,46 @@ +package edu.lnu.FireFly.Rte.interaction; + +import edu.lnu.FireFly.Rte.CollectionItem; +import edu.lnu.FireFly.Rte.SimpleElement; + +public class InteractionsItem extends CollectionItem{ + public static String _children = "id,type,objectives,timestamp,correct_responses,weighting,result,latency,description"; + + public InteractionsItem(){ + SimpleElement t; + + elements.put("id", new SimpleElement("characterstring", "rw", "")); + elements.put("description", new SimpleElement("characterstring", "rw", null)); + elements.put("timestamp", new SimpleElement("time(second, 10, 0)", "rw", null)); + elements.put("weighting", new SimpleElement("real(10, 7)", "rw", null)); + elements.put("learner_response", new SimpleElement("characterstring", "rw", null)); + elements.put("latency", new SimpleElement("timeinterval(second, 10, 2)", "rw", null)); + + t = new SimpleElement("characterstring", "rw", null); + // TODO Must be uncommmented. +/* + t.addFixedToken("correct"); + t.addFixedToken("incorrect"); + t.addFixedToken("unanticipated"); + t.addFixedToken("neutral"); + t.addFixedToken("real(10,7)"); // not realized +*/ + elements.put("result", t); + + t = new SimpleElement("characterstring", "rw", null); + t.addFixedToken("true-false"); + t.addFixedToken("choice"); + t.addFixedToken("fill-in"); + t.addFixedToken("long-fill-in"); + t.addFixedToken("likert"); + t.addFixedToken("matching"); + t.addFixedToken("performaqnce"); + t.addFixedToken("sequencing"); + t.addFixedToken("numeric"); + t.addFixedToken("other"); + elements.put("type", t); + + elements.put("objectives", new edu.lnu.FireFly.Rte.interaction.objectives.Objectives(true)); + elements.put("correct_responses", new edu.lnu.FireFly.Rte.interaction.correct_responses.Correct_responses(true)); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/Correct_responses.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/Correct_responses.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/Correct_responses.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,14 @@ +package edu.lnu.FireFly.Rte.interaction.correct_responses; + +import edu.lnu.FireFly.Rte.Collection; + +public class Correct_responses extends Collection { + public Correct_responses(boolean indexed){ + super(indexed); + _children = Correct_responsesItem._children; + } + + public void AddNewItem(){ + items.add(new Correct_responsesItem()); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/Correct_responsesItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/Correct_responsesItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/interaction/correct_responses/Correct_responsesItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,17 @@ +package edu.lnu.FireFly.Rte.interaction.correct_responses; + +import edu.lnu.FireFly.Rte.CollectionItem; +import edu.lnu.FireFly.Rte.SimpleElement; + +public class Correct_responsesItem extends CollectionItem { + public static String _children = "pattern"; + + public Correct_responsesItem(){ + elements.put("pattern", new SimpleElement("characterstring", "rw", "")); + elements.put("weighting", new SimpleElement("real(10,7)", "rw", null)); + elements.put("learner_response", new SimpleElement("characterstring", "rw", "")); + elements.put("result", new SimpleElement("characterstring", "rw", "")); + elements.put("description", new SimpleElement("characterstring", "rw", "")); + + } +} Added: RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/Objectives.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/Objectives.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/Objectives.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,14 @@ +package edu.lnu.FireFly.Rte.interaction.objectives; + +import edu.lnu.FireFly.Rte.Collection; + +public class Objectives extends Collection { + public Objectives(boolean indexed){ + super(indexed); + _children = ObjectivesItem._children; + } + + public void AddNewItem(){ + items.add(new ObjectivesItem()); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/ObjectivesItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/ObjectivesItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/interaction/objectives/ObjectivesItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,12 @@ +package edu.lnu.FireFly.Rte.interaction.objectives; + +import edu.lnu.FireFly.Rte.CollectionItem; +import edu.lnu.FireFly.Rte.SimpleElement; + +public class ObjectivesItem extends CollectionItem{ + public static String _children = "id"; + + public ObjectivesItem(){ + elements.put("id", new SimpleElement("characterstring", "rw", "")); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/learner_preference/Learner_preference.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/learner_preference/Learner_preference.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/learner_preference/Learner_preference.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,14 @@ +package edu.lnu.FireFly.Rte.learner_preference; + +import edu.lnu.FireFly.Rte.Collection; + +public class Learner_preference extends Collection { + public Learner_preference(boolean indexed){ + super(indexed); + _children = Learner_preferenceItem._children; + } + + public void AddNewItem(){ + items.add(new Learner_preferenceItem()); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/learner_preference/Learner_preferenceItem.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/learner_preference/Learner_preferenceItem.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/learner_preference/Learner_preferenceItem.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,24 @@ +package edu.lnu.FireFly.Rte.learner_preference; + +import edu.lnu.FireFly.Rte.CollectionItem; +import edu.lnu.FireFly.Rte.SimpleElement; + +public class Learner_preferenceItem extends CollectionItem{ + public static String _children = "audio_level,language,delivery_speed,"; + + public Learner_preferenceItem(){ + elements.put("audio_level", new SimpleElement("real(10,7)range(0..*)", "rw", "0")); + elements.put("language", new SimpleElement("characterstring", "rw", "")); + elements.put("delivery_speed", new SimpleElement("real(10,7)range(0..*)", "rw", "1")); + + SimpleElement t = new SimpleElement("real(10,7)", "rw", "0"); + t.addFixedToken("off"); + t.addFixedToken("on"); + t.addFixedToken("no_change"); + t.addFixedToken("-1"); + t.addFixedToken("0"); + t.addFixedToken("1"); + // TODO -1 equals to off ... etc. Need realize !!! + elements.put("audio_captioning", t); + } +} Added: RTE/src/edu/lnu/FireFly/Rte/objectives/GlobalObjectives.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/objectives/GlobalObjectives.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/objectives/GlobalObjectives.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,41 @@ +package edu.lnu.FireFly.Rte.objectives; + +import java.util.*; +import edu.lnu.FireFly.Rte.ElementName; + +public class GlobalObjectives { + private static ArrayList<ObjectivesItem> list = new ArrayList<ObjectivesItem>(); + + public static boolean registered(String id){ + for (int i=0; i < list.size(); i++){ + ObjectivesItem item = (ObjectivesItem) list.get(i); + String globalId = item.getValue(new ElementName("globalId")); + if (globalId.equals(id)){ + return true; + } + } + + return false; + } + + public static void put(ObjectivesItem item){ + String id = item.getValue(new ElementName("id")); + + if (!registered(id)){ + item.setValue(new ElementName("globalId"), id.substring(0)); + list.add(item); + } + } + + public static ObjectivesItem get(String id){ + for (int i=0; i < list.size(); i++){ + ObjectivesItem item = (ObjectivesItem) list.get(i); + String globalId = item.getValue(new ElementName("globalId")); + if (globalId.equals(id)){ + return item; + } + } + + return null; + } +} Added: RTE/src/edu/lnu/FireFly/Rte/objectives/ObjectiveMap.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/objectives/ObjectiveMap.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/objectives/ObjectiveMap.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,16 @@ +package edu.lnu.FireFly.Rte.objectives; + +public class ObjectiveMap { + public String activityObjectiveID = ""; + public String targetObjectiveID = ""; + public boolean readObjectiveSatisfiedStatus = true; + public boolean writeObjectiveSatisfiedStatus = false; + public boolean readObjectiveNormalizedMeasure = true; + public boolean writeObjectiveNormalizedMeasure = false; + + public ObjectiveMap(String localId, String globalId){ + activityObjectiveID = localId; + targetObjectiveID = globalId; + } + +} Added: RTE/src/edu/lnu/FireFly/Rte/objectives/Objectives.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/objectives/Objectives.java (rev 0) +++ RTE/src/edu/lnu/FireFly/Rte/objectives/Objectives.java 2008-05-23 14:26:18 UTC (rev 160) @@ -0,0 +1,102 @@ +package edu.lnu.FireFly.Rte.objectives; + +import java.util.ArrayList; + +import edu.lnu.FireFly.FFManifest.item.Item; +import edu.lnu.FireFly.FFManifest.item.sequencing.objectives.MapInfo; +import edu.lnu.FireFly.FFManifest.item.sequencing.objectives.Objective; +import edu.lnu.FireFly.Rte.Collection; +import edu.lnu.FireFly.Rte.ElementName; + +public class Objectives extends Collection { + public static ArrayList<ObjectiveMap> objectiveMap = new ArrayList<ObjectiveMap>(); + + public static void registerGlobalObjective(String id){ + if (!GlobalObjectives.registered(id)){ + ObjectivesItem item = new ObjectivesItem(); + item.setValue(new ElementName("id"), id); + GlobalObjectives.put(item); + } + } + + public Objectives(Item current, boolean indexed){ + super(indexed); + _children = ObjectivesItem._children; + String localId = ""; + + try{ + if (current.sequencing.objectives.primaryObjective.objectiveID.length() > 0){ + localId = current.sequencing.objectives.primaryObjective.objectiveID; + setValue(new ElementName("0.id"), localId); + + for (int i = 0; i < current.sequencing.objectives.primaryObjective.mapInfo.size(); i++){ + String globalId = ((MapInfo)current.sequencing.objectives.primaryObjective.mapInfo.get(i)).targetObjectiveID; + + registerGlobalObjective(globalId); + objectiveMap.add(new ObjectiveMap(localId, globalId)); + }; + + for (int i = 0; i < current.sequencing.objectives.objective.size(); i++){ + Objecti... [truncated message content] |
From: <se...@us...> - 2008-05-23 11:19:18
|
Revision: 159 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=159&view=rev Author: sem62 Date: 2008-05-23 04:19:26 -0700 (Fri, 23 May 2008) Log Message: ----------- Fixed bug in findItemById Modified Paths: -------------- FFManifest/src/edu/lnu/FireFly/FFManifest/Manifest.java Modified: FFManifest/src/edu/lnu/FireFly/FFManifest/Manifest.java =================================================================== --- FFManifest/src/edu/lnu/FireFly/FFManifest/Manifest.java 2008-05-23 09:19:27 UTC (rev 158) +++ FFManifest/src/edu/lnu/FireFly/FFManifest/Manifest.java 2008-05-23 11:19:26 UTC (rev 159) @@ -276,7 +276,11 @@ } for (int i = 0; i < root.getChildCount(); i++){ - return findItemByIdentifier(root.getChild(i), identifier); + TreeItem res = findItemByIdentifier(root.getChild(i), identifier); + + if (res != null){ + return res; + } } return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-23 09:19:19
|
Revision: 158 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=158&view=rev Author: sem62 Date: 2008-05-23 02:19:27 -0700 (Fri, 23 May 2008) Log Message: ----------- Added method that return array of user's answers. Modified Paths: -------------- RTE/src/edu/lnu/FireFly/Rte/Cmi.java Modified: RTE/src/edu/lnu/FireFly/Rte/Cmi.java =================================================================== --- RTE/src/edu/lnu/FireFly/Rte/Cmi.java 2008-05-23 08:32:45 UTC (rev 157) +++ RTE/src/edu/lnu/FireFly/Rte/Cmi.java 2008-05-23 09:19:27 UTC (rev 158) @@ -12,14 +12,23 @@ import edu.lnu.FireFly.Rte.elements.ScoreElement; public class Cmi { - private CmiElement _version = new CmiElement("1.0"); - private ArrayList<CommentsFromLearnerElement> commentsFromLearner = new ArrayList<CommentsFromLearnerElement>(); + private CmiElement _version = new CmiElement("1.0"); + private ArrayList<CommentsFromLearnerElement> commentsFromLearner = new ArrayList<CommentsFromLearnerElement>(); private ArrayList<CommentsFromLMSElement> commentsFromLMS = new ArrayList<CommentsFromLMSElement>(); - public CmiElement completionStatus = new CmiElement("unknown", new String[]{"completed", "incomplete", "not attempted", "unknown"}); + public CmiElement completionStatus = new CmiElement("unknown", + new String[] { "completed", "incomplete", "not attempted", + "unknown" }); + private CmiElement completionThreshold = new CmiElement(""); - private CmiElement credit = new CmiElement("credit", new String[]{"credit", "no-credit"}); - private CmiElement entry = new CmiElement("ab-initio", new String[]{"ab-initio", "resume", ""}); - private CmiElement exit = new CmiElement("", new String[]{"time-out", "suspend", "logout", "normal", ""}); + private CmiElement credit = new CmiElement("credit", new String[] { + "credit", "no-credit" }); + + private CmiElement entry = new CmiElement("ab-initio", new String[] { + "ab-initio", "resume", "" }); + + private CmiElement exit = new CmiElement("", new String[] { "time-out", + "suspend", "logout", "normal", "" }); + private ArrayList<InteractionsElement> interactions = new ArrayList<InteractionsElement>(); private CmiElement launchData = new CmiElement(""); private CmiElement learnerId = new CmiElement(""); @@ -27,239 +36,238 @@ private LearnerPreferenceElement learnerPreference = new LearnerPreferenceElement(); private CmiElement location = new CmiElement(""); private CmiElement maxTimeAllowed = new CmiElement(""); - private CmiElement mode = new CmiElement("normal", new String[]{"normal", "browse", "review"}); + private CmiElement mode = new CmiElement("normal", new String[] { "normal", + "browse", "review" }); + private ArrayList<ObjectivesElement> objectives = new ArrayList<ObjectivesElement>(); private CmiElement progressMeasure = new CmiElement(""); private CmiElement scaledPassingScore = new CmiElement(""); private ScoreElement score = new ScoreElement(); private CmiElement sessionTime = new CmiElement(""); - private CmiElement successStatus = new CmiElement("unknown", new String[]{"passed", "failed", "unknown"}); + private CmiElement successStatus = new CmiElement("unknown", new String[] { + "passed", "failed", "unknown" }); + private CmiElement suspendData = new CmiElement(""); private CmiElement timeLimitAction = new CmiElement(""); private CmiElement totalTime = new CmiElement(""); - + public ArrayList<AnswersElement> answers = new ArrayList<AnswersElement>(); - + private ArrayList<CmiElement> queryQueue = new ArrayList<CmiElement>(); - - public Cmi(Activity activity){ + + public Cmi(Activity activity) { addManifestObjectives(activity); } - - private void addManifestObjectives(Activity activity){ - if (activity == null || activity.sequencing == null || activity.sequencing.objectives == null){ - return; - } - Objective primaryObjective = activity.sequencing.objectives.primaryObjective; - ObjectivesElement oe = new ObjectivesElement(); + private void addManifestObjectives(Activity activity) { + if (activity == null || activity.sequencing == null + || activity.sequencing.objectives == null) { + return; + } + + Objective primaryObjective = activity.sequencing.objectives.primaryObjective; + ObjectivesElement oe = new ObjectivesElement(); oe.id.value = primaryObjective.objectiveID; objectives.add(oe); - if (primaryObjective.mapInfo.size() > 0){ - CmiManager.getInstance().getGlobalObjectivesManager().setGlobalObjectives(activity, primaryObjective); + if (primaryObjective.mapInfo.size() > 0) { + CmiManager.getInstance().getGlobalObjectivesManager() + .setGlobalObjectives(activity, primaryObjective); } int i; - for (i = 0; i < activity.sequencing.objectives.objective.size(); i++){ + for (i = 0; i < activity.sequencing.objectives.objective.size(); i++) { primaryObjective = activity.sequencing.objectives.objective.get(i); oe = new ObjectivesElement(); oe.id.value = primaryObjective.objectiveID; objectives.add(oe); - if (primaryObjective.mapInfo.size() > 0){ - CmiManager.getInstance().getGlobalObjectivesManager().setGlobalObjectives(activity, primaryObjective); + if (primaryObjective.mapInfo.size() > 0) { + CmiManager.getInstance().getGlobalObjectivesManager() + .setGlobalObjectives(activity, primaryObjective); } } } - - public void setValue(String element, String value){ + + public void setValue(String element, String value) { CmiElement current = getCmiElement(element); - if (current != null){ + if (current != null) { current.value = value; int i; - for (i = 0; i < queryQueue.size(); i++){ + for (i = 0; i < queryQueue.size(); i++) { queryQueue.get(i).value = value; } queryQueue.clear(); } } - - public String getValue(String element){ + + public String getValue(String element) { String result = ""; CmiElement current = getCmiElement(element); - if (current != null){ + if (current != null) { result = current.value; - if (!queryQueue.isEmpty()){ + if (!queryQueue.isEmpty()) { result = queryQueue.get(queryQueue.size() - 1).value; } queryQueue.clear(); } return result; } - - private CmiElement getCmiElement(String element){ + + private CmiElement getCmiElement(String element) { String first = element; String second; int number = 0; - if (element.indexOf(".") != -1){ + if (element.indexOf(".") != -1) { first = Utils.getFirst(element); element = Utils.removeFirst(element); } - if (element.indexOf(".") != -1){ + if (element.indexOf(".") != -1) { number = Integer.parseInt(Utils.getFirst(element)); element = Utils.removeFirst(element); } - second = element; - CmiElement returnElement = null; - if (first.equals("_version")){ + second = element; + CmiElement returnElement = null; + if (first.equals("_version")) { returnElement = _version; } - if (first.equals("comments_from_learner")){ - if (second.equals("_count")){ + if (first.equals("comments_from_learner")) { + if (second.equals("_count")) { returnElement = new CmiElement(""); - returnElement.value = String.valueOf(commentsFromLearner.size()); - } - else{ + returnElement.value = String + .valueOf(commentsFromLearner.size()); + } else { CommentsFromLearnerElement cfle; - if (number < commentsFromLearner.size()){ + if (number < commentsFromLearner.size()) { cfle = commentsFromLearner.get(number); - - } - else{ + + } else { cfle = new CommentsFromLearnerElement(); commentsFromLearner.add(cfle); } returnElement = cfle.getCmiElement(second); } } - if (first.equals("comments_from_LMS")){ - if (second.equals("_count")){ + if (first.equals("comments_from_LMS")) { + if (second.equals("_count")) { returnElement = new CmiElement(""); returnElement.value = String.valueOf(commentsFromLMS.size()); - } - else{ + } else { CommentsFromLMSElement cfle; - if (number < commentsFromLMS.size()){ + if (number < commentsFromLMS.size()) { cfle = commentsFromLMS.get(number); - - } - else{ + + } else { cfle = new CommentsFromLMSElement(); commentsFromLMS.add(cfle); } returnElement = cfle.getCmiElement(second); } } - if (first.equals("completion_status")){ + if (first.equals("completion_status")) { returnElement = completionStatus; } - if (first.equals("completion_threshold")){ + if (first.equals("completion_threshold")) { returnElement = completionThreshold; } - if (first.equals("credit")){ + if (first.equals("credit")) { returnElement = credit; } - if (first.equals("entry")){ + if (first.equals("entry")) { returnElement = entry; } - if (first.equals("exit")){ + if (first.equals("exit")) { returnElement = exit; } - if (first.equals("interactions")){ - if (second.equals("_count")){ + if (first.equals("interactions")) { + if (second.equals("_count")) { returnElement = new CmiElement(""); returnElement.value = String.valueOf(interactions.size()); - } - else{ + } else { InteractionsElement ie; - if (number < interactions.size()){ + if (number < interactions.size()) { ie = interactions.get(number); - - } - else{ + + } else { ie = new InteractionsElement(); interactions.add(ie); } returnElement = ie.getCmiElement(second); } } - if (first.equals("launch_data")){ + if (first.equals("launch_data")) { returnElement = launchData; } - if (first.equals("learner_id")){ + if (first.equals("learner_id")) { returnElement = learnerId; } - if (first.equals("learner_name")){ + if (first.equals("learner_name")) { returnElement = learnerName; } - if (first.equals("learner_preference")){ + if (first.equals("learner_preference")) { returnElement = learnerPreference.getCmiElement(second); } - if (first.equals("location")){ + if (first.equals("location")) { returnElement = location; - } - if (first.equals("max_time_allowed")){ + } + if (first.equals("max_time_allowed")) { returnElement = maxTimeAllowed; } - if (first.equals("mode")){ + if (first.equals("mode")) { returnElement = mode; - } - if (first.equals("objectives")){ - if (second.equals("_count")){ + } + if (first.equals("objectives")) { + if (second.equals("_count")) { returnElement = new CmiElement(""); returnElement.value = String.valueOf(objectives.size()); - } - else{ + } else { ObjectivesElement oe; - if (number < objectives.size()){ - if (number < 0){ - return null; - } - - oe = objectives.get(number); - CmiManager.getInstance().getGlobalObjectivesManager().getGlobalObjectives(oe, second, queryQueue); - } - else{ + if (number < objectives.size()) { + if (number < 0) { + return null; + } + + oe = objectives.get(number); + CmiManager.getInstance().getGlobalObjectivesManager() + .getGlobalObjectives(oe, second, queryQueue); + } else { oe = new ObjectivesElement(); objectives.add(oe); } returnElement = oe.getCmiElement(second); } - } - if (first.equals("progress_measure")){ + } + if (first.equals("progress_measure")) { returnElement = progressMeasure; - } - if (first.equals("scaled_passing_score")){ + } + if (first.equals("scaled_passing_score")) { returnElement = scaledPassingScore; - } - if (first.equals("score")){ + } + if (first.equals("score")) { returnElement = score.getCmiElement(second); - } - if (first.equals("session_time")){ + } + if (first.equals("session_time")) { returnElement = sessionTime; } - if (first.equals("success_status")){ + if (first.equals("success_status")) { returnElement = successStatus; - } - if (first.equals("suspend_data")){ + } + if (first.equals("suspend_data")) { returnElement = suspendData; - } - if (first.equals("time_limit_action")){ + } + if (first.equals("time_limit_action")) { returnElement = timeLimitAction; } - if (first.equals("total_time")){ + if (first.equals("total_time")) { returnElement = totalTime; } - if (first.equals("answers")){ - if (second.equals("_count")){ + if (first.equals("answers")) { + if (second.equals("_count")) { returnElement = new CmiElement(""); returnElement.value = String.valueOf(answers.size()); - } - else{ + } else { AnswersElement ae; - if (number < answers.size()){ + if (number < answers.size()) { ae = answers.get(number); - - } - else{ + + } else { ae = new AnswersElement(); answers.add(ae); } @@ -268,9 +276,22 @@ } return returnElement; } + + public String[] getAnswers(){ + ArrayList<String> res = new ArrayList<String>(); -// public void checkResult(){ -// AnswersManager answersManager = new AnswersManager(GlobalStateInformation.getCurrentActivity()); -// answersManager.checkResult(); -// } + for (int i=0; i < answers.size(); i++){ + res.add(answers.get(i).value.value); + } + + String[] result = new String[res.size()]; + res.toArray(result); + return result; + } + + // public void checkResult(){ + // AnswersManager answersManager = new + // AnswersManager(GlobalStateInformation.getCurrentActivity()); + // answersManager.checkResult(); + // } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <se...@us...> - 2008-05-23 08:32:37
|
Revision: 157 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=157&view=rev Author: sem62 Date: 2008-05-23 01:32:45 -0700 (Fri, 23 May 2008) Log Message: ----------- added method findItemByIdentifier. Modified Paths: -------------- FFManifest/src/edu/lnu/FireFly/FFManifest/Manifest.java Modified: FFManifest/src/edu/lnu/FireFly/FFManifest/Manifest.java =================================================================== --- FFManifest/src/edu/lnu/FireFly/FFManifest/Manifest.java 2008-05-22 20:21:05 UTC (rev 156) +++ FFManifest/src/edu/lnu/FireFly/FFManifest/Manifest.java 2008-05-23 08:32:45 UTC (rev 157) @@ -269,4 +269,30 @@ public String toString() { return "manifest"; } + + protected TreeItem findItemByIdentifier(TreeItem root, String identifier){ + if (root.getIdentifier().equals(identifier)){ + return root; + } + + for (int i = 0; i < root.getChildCount(); i++){ + return findItemByIdentifier(root.getChild(i), identifier); + } + + return null; + } + + public TreeItem findItemByIdentifier(String identifier){ + TreeItem root = null; + + try { + root = getRoot(); + } catch (TestDocException e) { + e.printStackTrace(); + + return null; + } + + return findItemByIdentifier(root, identifier); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |