]> Devoid-pointer.net GitWeb - Nine-Q.git/commitdiff
Fix handling of Generate_Face_With_Answer
authorMichal Malý <madcatxster@devoid-pointer.net>
Sun, 28 Dec 2014 23:34:04 +0000 (00:34 +0100)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sun, 28 Dec 2014 23:34:04 +0000 (00:34 +0100)
src/face_generators/face_generator.adb

index 7e9e6c76ed2503a2b35a035b780490edf7116cec..96b1e0e417d11273ffc3646c14dff1a21392f878 100644 (file)
@@ -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;