From 9f70643d88b17ae56e8551c7bd9a5637e64af8cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Mon, 29 Dec 2014 00:34:04 +0100 Subject: [PATCH] Fix handling of Generate_Face_With_Answer --- src/face_generators/face_generator.adb | 52 +++++++++++++++----------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/face_generators/face_generator.adb b/src/face_generators/face_generator.adb index 7e9e6c7..96b1e0e 100644 --- a/src/face_generators/face_generator.adb +++ b/src/face_generators/face_generator.adb @@ -67,7 +67,7 @@ package body Face_Generator is begin return Generate_Face_Internal(Mode => Answer_Mode, Assignment => Assignment, Parameters => Parameters, HTML => HTML, - Answer_Message => To_UB_Text(""), Answer_Code => Problem_Generator_Syswides.Invalid_Answer, + Answer_Message => Answer_Message, Answer_Code => Answer_Code, Pr_ID => Pr_ID, Pr_Cat => Pr_Cat, FillIns => FillIns, Walkthrough => Walkthrough); @@ -361,7 +361,12 @@ package body Face_Generator is Temp := Parse(Filename => "scripts/expand_collapse.js", Cached => True); Append_HTML(Source => HTML, New_Item => Temp); - Add_Answer_Section(Translations, Answer_Message, Answer_Code); + case Mode is + when Answer_Mode => + Add_Answer_Section(Translations, Answer_Message, Answer_Code); + when others => + null; + end case; -- Add submit section -- - Mandatory parameters @@ -679,25 +684,30 @@ package body Face_Generator is end if; Insert(Translations, Assoc(HINTS_SECTION_KEY, HTML_To_Fixed_String(Temp))); - case Answer_Code is - when Correct_Answer => - if Assignment.Find(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_PATH_KEY) = Assignment_Info.No_Element then - return E_INVAL; - end if; - - Insert(Translations_Answer, Assoc(ANSWER_KIND_KEY, ANSWER_KIND_GOOD)); - Insert(Translations_Answer, Assoc(ANSWER_MESSAGE_KEY, UB_Text_To_Fixed_String(Answer_Message))); - Insert(Translations_Answer, Assoc(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_PATH_KEY, Assignment.Element(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_PATH_KEY))); - Insert(Translations_Answer, Assoc(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_CLASS_KEY, Titration_Curve_Suite.TITRATION_CURVE_IMAGE_CLASS_NORM)); - Temp := Parse(Filename => "templates/titration_curve_answer_section.html", Translations => Translations_Answer); - Insert(Translations, Assoc(ANSWER_SECTION_KEY, HTML_To_Fixed_String(Temp))); - when Wrong_Answer | Malformed_Answer => - Insert(Translations_Answer, Assoc(ANSWER_KIND_KEY, ANSWER_KIND_BAD)); - Insert(Translations_Answer, Assoc(ANSWER_MESSAGE_KEY, UB_Text_To_Fixed_String(Answer_Message))); - Insert(Translations_Answer, Assoc(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_PATH_KEY, "/resources/noimage.png")); - Insert(Translations_Answer, Assoc(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_CLASS_KEY, Titration_Curve_Suite.TITRATION_CURVE_IMAGE_CLASS_NODISP)); - Temp := Parse(Filename => "templates/titration_curve_answer_section.html", Translations => Translations_Answer); - Insert(Translations, Assoc(ANSWER_SECTION_KEY, HTML_To_Fixed_String(Temp))); + case Mode is + when Answer_Mode => + case Answer_Code is + when Correct_Answer => + if Assignment.Find(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_PATH_KEY) = Assignment_Info.No_Element then + return E_INVAL; + end if; + + Insert(Translations_Answer, Assoc(ANSWER_KIND_KEY, ANSWER_KIND_GOOD)); + Insert(Translations_Answer, Assoc(ANSWER_MESSAGE_KEY, UB_Text_To_Fixed_String(Answer_Message))); + Insert(Translations_Answer, Assoc(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_PATH_KEY, Assignment.Element(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_PATH_KEY))); + Insert(Translations_Answer, Assoc(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_CLASS_KEY, Titration_Curve_Suite.TITRATION_CURVE_IMAGE_CLASS_NORM)); + Temp := Parse(Filename => "templates/titration_curve_answer_section.html", Translations => Translations_Answer); + Insert(Translations, Assoc(ANSWER_SECTION_KEY, HTML_To_Fixed_String(Temp))); + when Wrong_Answer | Malformed_Answer => + Insert(Translations_Answer, Assoc(ANSWER_KIND_KEY, ANSWER_KIND_BAD)); + Insert(Translations_Answer, Assoc(ANSWER_MESSAGE_KEY, UB_Text_To_Fixed_String(Answer_Message))); + Insert(Translations_Answer, Assoc(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_PATH_KEY, "/resources/noimage.png")); + Insert(Translations_Answer, Assoc(Titration_Curve_Suite.TITRATION_CURVE_IMAGE_CLASS_KEY, Titration_Curve_Suite.TITRATION_CURVE_IMAGE_CLASS_NODISP)); + Temp := Parse(Filename => "templates/titration_curve_answer_section.html", Translations => Translations_Answer); + Insert(Translations, Assoc(ANSWER_SECTION_KEY, HTML_To_Fixed_String(Temp))); + when others => + Insert(Translations, Assoc(ANSWER_SECTION_KEY, "")); + end case; when others => Insert(Translations, Assoc(ANSWER_SECTION_KEY, "")); end case; -- 2.43.5