]> Devoid-pointer.net GitWeb - Nine-Q.git/commitdiff
Preserve values entered in the input fields so that user can correct their answer...
authorMichal Malý <madcatxster@devoid-pointer.net>
Thu, 25 Dec 2014 23:17:10 +0000 (00:17 +0100)
committerMichal Malý <madcatxster@devoid-pointer.net>
Thu, 25 Dec 2014 23:17:10 +0000 (00:17 +0100)
bin/templates/face_acidobazic.html
bin/templates/face_solubility_submit.html
bin/templates/face_titration_curve.html
src/face_generators/face_generator.adb
src/face_generators/face_generator.ads
src/problem_generators/problem_generator-acidobazic_suite.adb
src/problem_generators/problem_generator-solubility_suite.adb
src/problem_generators/problem_generator-titration_curve_suite.adb
src/problem_generators/problem_generator.ads
src/problem_generators/problem_generator_syswides.ads
src/problem_manager.adb

index e36074df43d323b6bca845d8a9764e05c69f4d75..1016d8eefc48fb091936c5c712809ede2ad8ded9 100644 (file)
@@ -6,7 +6,7 @@
        <input type="hidden" name="@_RESERVED__PROBLEM_ID_@" value="@_RESERVED__PROBLEM_ID_VAL_@">
        <div class="form_line">
          <label class="form_label_ac" for="@_ANSWER_PH_@">pH:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_PH_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_PH_@" maxlength="128" value="@_FILLIN_ANSWER_@" />
        </div>
        <div class="form_line">
          <label class="form_label_ac" for="@_ANSWER_SIMPLIFICATION_@">Lze zanedbat:</label>
index 5b2c8e3bee99469cfd155b1a8b26ade0505c51fd..7994b92b7f74f3811c567a9c24f2f33ea585e8e7 100644 (file)
@@ -2,7 +2,7 @@
        <input type="hidden" name="@_RESERVED__PROBLEM_ID_@" value="@_RESERVED__PROBLEM_ID_VAL_@">
        <div class="form_line">
          <label class="form_label_sol" for="ANSWER_NUM">Výsledek:</label>
-         <input class="form_input_sol" type="text" name="ANSWER_NUM" maxlength="128" value="" />
+         <input class="form_input_sol" type="text" name="ANSWER_NUM" maxlength="128" value="@_FILLIN_ANSWER_@" />
        </div>
        <div class="form_line">
          <input type="submit" name="send_answer" value="Zkontrolovat" />
index a65ab5356d5865c04cdc714c911d3b043360349d..3edd081a67d48cc8d20f1b2c48a05c4107989be1 100644 (file)
@@ -19,7 +19,7 @@
         </div>
        <div class="form_line">
          <label class="form_label_ac" for="@_ANSWER_PH_START_@">pH:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_PH_START_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_PH_START_@" maxlength="128" value="@_FILLIN_1_PH_@" />
        </div>
 
         <div class="form_line">
@@ -27,9 +27,9 @@
         </div>
         <div class="form_line">
          <label class="form_label_ac" for="@_ANSWER_PH_FIRST_HALF_@">pH:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_PH_FIRST_HALF_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_PH_FIRST_HALF_@" maxlength="128" value="@_FILLIN_2_PH_@" />
           <label class="form_label_ac" for="@_ANSWER_VOLUME_FIRST_HALF_@">Objem [mL]:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_FIRST_HALF_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_FIRST_HALF_@" maxlength="128" value="@_FILLIN_2_VOL_@" />
        </div>
 
         <div class="form_line">
@@ -37,9 +37,9 @@
        </div>
         <div class="form_line">
          <label class="form_label_ac" for="@_ANSWER_PH_FIRST_EQUIV_@">pH:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_PH_FIRST_EQUIV_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_PH_FIRST_EQUIV_@" maxlength="128" value="@_FILLIN_3_PH_@" />
           <label class="form_label_ac" for="@_ANSWER_VOLUME_FIRST_EQUIV_@">Objem [mL]:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_FIRST_EQUIV_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_FIRST_EQUIV_@" maxlength="128" value="@_FILLIN_3_VOL_@" />
        </div>
 
         <div class="form_line">
@@ -47,9 +47,9 @@
        </div>
         <div class="form_line">
          <label class="form_label_ac" for="@_ANSWER_PH_SECOND_HALF_@">pH:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_PH_SECOND_HALF_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_PH_SECOND_HALF_@" maxlength="128" value="@_FILLIN_4_PH_@" />
           <label class="form_label_ac" for="@_ANSWER_VOLUME_SECOND_HALF_@">Objem [mL]:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_SECOND_HALF_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_SECOND_HALF_@" maxlength="128" value="@_FILLIN_4_VOL_@" />
        </div>
 
         <div class="form_line">
@@ -57,9 +57,9 @@
        </div>
         <div class="form_line">
          <label class="form_label_ac" for="@_ANSWER_PH_SECOND_EQUIV_@">pH:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_PH_SECOND_EQUIV_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_PH_SECOND_EQUIV_@" maxlength="128" value="@_FILLIN_5_PH_@" />
           <label class="form_label_ac" for="@_ANSWER_VOLUME_SECOND_EQUIV_@">Objem [mL]:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_SECOND_EQUIV_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_SECOND_EQUIV_@" maxlength="128" value="@_FILLIN_5_VOL_@" />
        </div>
 
         <div class="form_line">
@@ -67,9 +67,9 @@
        </div>
         <div class="form_line">
          <label class="form_label_ac" for="@_ANSWER_PH_OVER_SECOND_EQUIV_@">pH:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_PH_OVER_SECOND_EQUIV_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_PH_OVER_SECOND_EQUIV_@" maxlength="128" value="@_FILLIN_6_PH_@" />
           <label class="form_label_ac" for="@_ANSWER_VOLUME_OVER_SECOND_EQUIV_@">Objem [mL]:</label>
-         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_OVER_SECOND_EQUIV_@" maxlength="128" value="" />
+         <input class="form_input_ac" type="text" name="@_ANSWER_VOLUME_OVER_SECOND_EQUIV_@" maxlength="128" value="@_FILLIN_6_VOL_@" />
        </div>
 
        <div class="form_line">
index d084bea5988fd907d52632a053ef7aed49e57a10..37988b1350107fa8c9ff0cf31480ececbeec0114 100644 (file)
@@ -44,17 +44,20 @@ package body Face_Generator is
                         in Problem_Generator_Syswides.Parameters_Info.Map;
                         HTML: out HTML_Code;
                         Pr_ID: in String; Pr_Cat: in String) return RetCode is
+    FillIns: constant Problem_Generator_Syswides.FillIns_Map.Map := Problem_Generator_Syswides.FillIns_Map.Empty_Map;
   begin
     return Generate_Face_With_Answer(Assignment => Assignment, Parameters => Parameters, HTML => HTML,
                                     Answer_Message => To_UB_Text(""), Answer_Code => Problem_Generator_Syswides.Invalid_Answer,
-                                    Pr_ID => Pr_ID, Pr_Cat => Pr_Cat);
+                                    Pr_ID => Pr_ID, Pr_Cat => Pr_Cat,
+                                    FillIns => FillIns);
   end Generate_Face;
 
   function Generate_Face_With_Answer(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
                                     Answer_Message: in UB_Text;
                                     Answer_Code: in Problem_Generator_Syswides.Answer_RetCode;
                                     Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
-                                    HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String) return RetCode is
+                                    HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String;
+                                    FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode is
     use Problem_Generator_Syswides;
     use Problem_Generator_Syswides.Assignment_Info;
 
@@ -67,11 +70,11 @@ package body Face_Generator is
       Problem_Type_Str: constant String := Assignment.Element(PROBLEM_TYPE_KEY);
     begin
       if Problem_Type_Str = PROBLEM_TYPE_ACIDOBAZIC then
-        return Generate_Face_Acidobazic(Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat);
+        return Generate_Face_Acidobazic(Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat, FillIns);
       elsif Problem_Type_Str = PROBLEM_TYPE_SOLUBILITY then
-        return Generate_Face_Solubility(Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat);
+        return Generate_Face_Solubility(Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat, FillIns);
       elsif Problem_Type_Str = PROBLEM_TYPE_TITRATION_CURVE then
-       return Generate_Face_Titration_Curve(Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat);
+       return Generate_Face_Titration_Curve(Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat, FillIns);
       else
        return E_INVAL;
       end if;
@@ -108,10 +111,12 @@ package body Face_Generator is
                                    Answer_Message: in UB_Text;
                                    Answer_Code: in Problem_Generator_Syswides.Answer_RetCode;
                                    Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
-                                   HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String) return RetCode is
+                                   HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String;
+                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode is
     use AWS.Templates;
     use Problem_Generator_Syswides;
     use Problem_Generator_Syswides.Assignment_Info;
+    use Problem_Generator_Syswides.FillIns_Map;
     use Problem_Generator_Syswides.Parameters_Info;
 
     Translations_Hdr: Translate_Set;
@@ -178,6 +183,14 @@ package body Face_Generator is
 
     Add_Answer_Section(Translations, Answer_Message, Answer_Code);
 
+    -- Add FillIns
+    if FillIns.Is_Empty = False then
+      if FillIns.Find(Acidobazic_Suite.FILLIN_ANSWER_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Acidobazic_Suite.FILLIN_ANSWER_KEY, FillIns.Element(Acidobazic_Suite.FILLIN_ANSWER_KEY)));
+    end if;
+
     -- Generate hints
     if Assignment.Element(Acidobazic_Suite.PKX_KEY) = Acidobazic_Suite.PKX_PKA_TEXT then
       Temp := Parse(Filename => "templates/hints_acidobazic_acid.html", Cached => True);
@@ -201,11 +214,13 @@ package body Face_Generator is
                                    Answer_Message: in UB_Text;
                                    Answer_Code: in Problem_Generator_Syswides.Answer_RetCode;
                                    Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
-                                   HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String) return RetCode is
+                                   HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String;
+                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode is
     use Ada.Strings.Unbounded;
     use AWS.Templates;
     use Problem_Generator_Syswides;
     use Problem_Generator_Syswides.Assignment_Info;
+    use Problem_Generator_Syswides.FillIns_Map;
     use Problem_Generator_Syswides.Parameters_Info;
 
     Translations_Hdr: Translate_Set;
@@ -229,6 +244,13 @@ package body Face_Generator is
     -- - Mandatory parameters
     Insert(Translations_Submit, Assoc(RESERVED_PROBLEM_ID_KEY, RESERVED_PROBLEM_ID_KEY));
     Insert(Translations_Submit, Assoc(RESERVED_PROBLEM_ID_VAL_KEY, Pr_ID));
+    -- Add FillIns
+    if FillIns.Is_Empty = False then
+      if FillIns.Find(Solubility_Suite.FILLIN_ANSWER_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations_Submit, Assoc(Solubility_Suite.FILLIN_ANSWER_KEY, FillIns.Element(Solubility_Suite.FILLIN_ANSWER_KEY)));
+    end if;
     --
     Temp := Parse(Filename => "templates/face_solubility_submit.html", Translations => Translations_Submit);
     Insert(Translations, Assoc("SUBMIT_FORM", HTML_To_Fixed_String(Temp)));
@@ -258,7 +280,6 @@ package body Face_Generator is
     -- Put the processed parameters template into the face
     Insert(Translations, Assoc("PARAMETERS_FORM", HTML_To_Fixed_String(Params_Code)));
 
-
       if P_Subtype = Solubility_Suite.PROBLEM_SUBTYPE_V_FROM_G_KS then
        -- Check that we have all necessary fields in the assignment
        if Assignment.Find(Solubility_Suite.X_STOCHIO_KEY) = Assignment_Info.No_Element then
@@ -409,10 +430,12 @@ package body Face_Generator is
                                         Answer_Message: in UB_Text;
                                         Answer_Code: in Problem_Generator_Syswides.Answer_RetCode;
                                         Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
-                                        HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String) return RetCode is
+                                        HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String;
+                                        FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode is
     use AWS.Templates;
     use Problem_Generator_Syswides;
     use Problem_Generator_Syswides.Assignment_Info;
+    use Problem_Generator_Syswides.FillIns_Map;
     use Problem_Generator_Syswides.Parameters_Info;
 
     Translations_Hdr: Translate_Set;
@@ -554,6 +577,56 @@ package body Face_Generator is
        Insert(Translations, Assoc(ANSWER_SECTION_KEY, ""));
     end case;
 
+    -- Add FillIns
+    if FillIns.Is_Empty = False then
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_1_PH_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_1_PH_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_1_PH_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_2_PH_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_2_PH_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_2_PH_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_3_PH_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_3_PH_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_3_PH_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_4_PH_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_4_PH_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_4_PH_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_5_PH_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_5_PH_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_5_PH_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_6_PH_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_6_PH_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_6_PH_KEY)));
+      --
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_2_VOL_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_2_VOL_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_2_VOL_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_3_VOL_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_3_VOL_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_3_VOL_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_4_VOL_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_4_VOL_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_4_VOL_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_5_VOL_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_5_VOL_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_5_VOL_KEY)));
+      if FillIns.Find(Titration_Curve_Suite.FILLIN_6_VOL_KEY) = FillIns_Map.No_Element then
+       return E_INVAL;
+      end if;
+      Insert(Translations, Assoc(Titration_Curve_Suite.FILLIN_6_VOL_KEY, FillIns.Element(Titration_Curve_Suite.FILLIN_6_VOL_KEY)));
+    end if;
+
+
     Temp := Parse(Filename => "templates/face_titration_curve.html", Translations => Translations);
 
     Append_HTML(Source => HTML, New_Item => Temp);
index e1b6fc9a677996c347bb9210db222da033542435..7e4acf6ac3b4831641b3648c3454edddd0b4c1bd 100644 (file)
@@ -16,7 +16,8 @@ package Face_Generator is
                                     Answer_Code: in Problem_Generator_Syswides.Answer_RetCode;
                                     Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
                                     HTML: out HTML_Code;
-                                    Pr_ID: in String; Pr_Cat: in String) return RetCode;
+                                    Pr_ID: in String; Pr_Cat: in String;
+                                    FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode;
 
 private
   procedure Add_Answer_Section(Translations: in out AWS.Templates.Translate_Set; Answer_Message: in UB_Text;
@@ -27,21 +28,24 @@ private
                                    Answer_Code: in Problem_Generator_Syswides.Answer_RetCode;
                                    Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
                                    HTML: out HTML_Code;
-                                   Pr_ID: in String; Pr_Cat: in String) return RetCode;
+                                   Pr_ID: in String; Pr_Cat: in String;
+                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode;
 
   function Generate_Face_Solubility(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
                                    Answer_Message: in UB_Text;
                                    Answer_Code: in Problem_Generator_Syswides.Answer_RetCode;
                                    Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
                                    HTML: out HTML_Code;
-                                   Pr_ID: in String; Pr_Cat: in String) return RetCode;
+                                   Pr_ID: in String; Pr_Cat: in String;
+                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode;
 
   function Generate_Face_Titration_Curve(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
                                         Answer_Message: in UB_Text;
                                         Answer_Code: in Problem_Generator_Syswides.Answer_RetCode;
                                         Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
                                         HTML: out HTML_Code;
-                                        Pr_ID: in String; Pr_Cat: in String) return RetCode;
+                                        Pr_ID: in String; Pr_Cat: in String;
+                                        FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode;
 
   ERROR_MESSAGE_KEY: constant String := "ERROR_MESSAGE";
   HEADER_CAPTION_KEY: constant String := "HEADER_CAPTION";
index 4aa8a877796dcd5318260f97dcf63b8222ddb58e..5bdd0bf63656f410b25c4462e6bfc57e7167f4ae 100644 (file)
@@ -21,7 +21,7 @@ package body Acidobazic_Suite is
     return Problem;
   end Create;
 
-  function Check_Answer(Problem: in out Acidobazic_Problem; Answer: in Answer_Info.Map;
+  function Check_Answer(Problem: in out Acidobazic_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map;
                        Message: out UB_Text) return Answer_RetCode is
     package FH is new Formatting_Helpers(pH_Float);
     use Answer_Info;
@@ -48,6 +48,9 @@ package body Acidobazic_Suite is
        return Malformed_Answer;
     end;
 
+    -- Prepare FillIns
+    FillIns.Insert(FILLIN_ANSWER_KEY, Answer.Element(ANSWER_PH_KEY));
+
     -- Check correctness of simplification
     declare
       Simplification_Str: constant String := Answer.Element(ANSWER_SIMPLIFICATION_KEY);
index 7363637edf69cc43505c79f70a4a2747eb225fa0..79f1f8741645bf7fcd75ce510358268dc6db69e7 100644 (file)
@@ -18,7 +18,7 @@ package body Solubility_Suite is
     return Problem;
   end;
 
-  function Check_Answer(Problem: in out Solubility_Problem; Answer: in Answer_Info.Map; Message: out UB_Text) return Answer_RetCode is
+  function Check_Answer(Problem: in out Solubility_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode is
     package FH is new Formatting_Helpers(SS_Float);
     use Answer_Info;
     use FH;
@@ -45,6 +45,8 @@ package body Solubility_Suite is
        Message := To_UB_Text("Nesprávně zadaná odpověď");
        return Malformed_Answer;
     end;
+    -- Prepare FillIns
+    FillIns.Insert(FILLIN_ANSWER_KEY, Answer.Element(ANSWER_NUM_KEY));
 
     Split_Integer_Decimal_Exponent_Strs(AF, DECIMALS, Int_Part_A_Str, Dec_Part_A_Str, Exp_Part_A_Str);
     Split_Integer_Decimal_Exponent_Strs(Problem.Answer_Num, DECIMALS, Int_Part_C_Str, Dec_Part_C_Str, Exp_Part_C_Str);
index 4293c540ef9e84a58c7e66715381c6fa52706a00..67bda5fdc814a2ddef8e5f293c294a818d3acc4a 100644 (file)
@@ -25,7 +25,7 @@ package body Titration_Curve_Suite is
     return Problem;
   end Create;
 
-  function Check_Answer(Problem: in out Titration_Curve_Problem; Answer: in Answer_Info.Map;
+  function Check_Answer(Problem: in out Titration_Curve_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map;
                         Message: out UB_Text) return Answer_RetCode is
     package FH is new Formatting_Helpers(T_Float);
     package TFEF is new Ada.Numerics.Generic_Elementary_Functions(T_Float);
@@ -168,6 +168,21 @@ package body Titration_Curve_Suite is
 
     Status_Out := Cairo.Png.Write_To_Png(Surface, Ada.Strings.Unbounded.To_String(Problem.Resource_Prefix) & TITRATION_CURVE_FILENAME);
     Message := To_UB_Text("");
+
+    -- Prepare FillIns
+    FillIns.Insert(FILLIN_1_PH_KEY, Answer.Element(ANSWER_PH_START_KEY)); 
+    FillIns.Insert(FILLIN_2_PH_KEY, Answer.Element(ANSWER_PH_FIRST_HALF_KEY));
+    FillIns.Insert(FILLIN_3_PH_KEY, Answer.Element(ANSWER_PH_FIRST_EQUIV_KEY));
+    FillIns.Insert(FILLIN_4_PH_KEY, Answer.Element(ANSWER_PH_SECOND_HALF_KEY));
+    FillIns.Insert(FILLIN_5_PH_KEY, Answer.Element(ANSWER_PH_SECOND_EQUIV_KEY));
+    FillIns.Insert(FILLIN_6_PH_KEY, Answer.Element(ANSWER_PH_OVER_SECOND_EQUIV_KEY));
+    --
+    FillIns.Insert(FILLIN_2_VOL_KEY, Answer.Element(ANSWER_VOLUME_FIRST_HALF_KEY));
+    FillIns.Insert(FILLIN_3_VOL_KEY, Answer.Element(ANSWER_VOLUME_FIRST_EQUIV_KEY));
+    FillIns.Insert(FILLIN_4_VOL_KEY, Answer.Element(ANSWER_VOLUME_SECOND_HALF_KEY));
+    FillIns.Insert(FILLIN_5_VOL_KEY, Answer.Element(ANSWER_VOLUME_SECOND_EQUIV_KEY));
+    FillIns.Insert(FILLIN_6_VOL_KEY, Answer.Element(ANSWER_VOLUME_OVER_SECOND_EQUIV_KEY));
+
     return Correct_Answer;
   end Check_Answer;
 
index e8e72e16419070b4f3a75457ecea5caab2681b94..0de05e5532650634b70ad3e3f9f2bf25151366cd 100644 (file)
@@ -11,7 +11,7 @@ package Problem_Generator is
   type Chem_Problem is abstract limited new Ada.Finalization.Limited_Controlled with private;
 
   function Create return access Chem_Problem is abstract;
-  function Check_Answer(Problem: in out Chem_Problem; Answer: in Answer_Info.Map; Message: out UB_Text) return Answer_RetCode is abstract;
+  function Check_Answer(Problem: in out Chem_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode is abstract;
   function Get_Assignment(Problem: in out Chem_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode is abstract;
   function Get_Parameters(Problem: in out Chem_Problem; Parameters: out Parameters_Info.Map) return RetCode is abstract;
   procedure New_Problem(Problem: in out Chem_Problem) is abstract;
@@ -30,7 +30,7 @@ private
       -- Constructor
       function Create return access Acidobazic_Problem;
       -- Inherited
-      function Check_Answer(Problem: in out Acidobazic_Problem; Answer: in Answer_Info.Map; Message: out UB_Text) return Answer_RetCode;
+      function Check_Answer(Problem: in out Acidobazic_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode;
       procedure New_Problem(Problem: in out Acidobazic_Problem);
       function Get_Assignment(Problem: in out Acidobazic_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode;
       function Get_Parameters(Problem: in out Acidobazic_Problem; Parameters: out Parameters_Info.Map) return RetCode;
@@ -90,7 +90,7 @@ private
     -- Constructor
     function Create return access Solubility_Problem;
     -- Inherited
-    function Check_Answer(Problem: in out Solubility_Problem; Answer: in Answer_Info.Map; Message: out UB_Text) return Answer_RetCode;
+    function Check_Answer(Problem: in out Solubility_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode;
     procedure New_Problem(Problem: in out Solubility_Problem);
     function Get_Assignment(Problem: in out Solubility_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode;
     function Get_Parameters(Problem: in out Solubility_Problem; Parameters: out Parameters_Info.Map) return RetCode;
@@ -176,7 +176,7 @@ private
     -- Constructor
     function Create return access Titration_Curve_Problem;
     -- Inherited
-    function Check_Answer(Problem: in out Titration_Curve_Problem; Answer: in Answer_Info.Map; Message: out UB_Text) return Answer_RetCode;
+    function Check_Answer(Problem: in out Titration_Curve_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode;
     function Get_Assignment(Problem: in out Titration_Curve_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode;
     function Get_Parameters(Problem: in out Titration_Curve_Problem; Parameters: out Parameters_Info.Map) return RetCode;
     procedure New_Problem(Problem: in out Titration_Curve_Problem);
index a679138970acdf0a0087794153ca3c8a399375c6..77ab92a9970779e09d6bc0f6c61b5e9b2969271a 100644 (file)
@@ -6,6 +6,7 @@ package Problem_Generator_Syswides is
   type Problem_Type is (Acidobazic, Solubility, Titration_Curve);
   package Answer_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String);
   package Assignment_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String);
+  package FillIns_Map is new Ada.Containers.Indefinite_Ordered_Maps(String, String);
   package Parameters_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String);
 
   ANSWER_KIND_KEY: constant String := "ANSWER_KIND";
@@ -47,6 +48,8 @@ package Problem_Generator_Syswides is
     ANSWER_SIMPLIFICATION_KEY: constant String := "ANSWER_SIMPLIFICATION";
     --
     PARAMETER_NO_BOTH_SIMPLIFICATIONS_KEY: constant String := "PARAMETER_NO_BOTH_SIMPLIFICATIONS";
+    --
+    FILLIN_ANSWER_KEY: constant String := "FILLIN_ANSWER";
   end Acidobazic_Suite;
 
   package Solubility_Suite is
@@ -78,6 +81,8 @@ package Problem_Generator_Syswides is
     --
     PARAMETER_IONIC_STRENGTH_KEY: constant String := "PARAMETER_IONIC_STRENGTH";
     PARAMETER_PROBLEM_SUBTYPE_KEY: constant String := "PARAMETER_PROBLEM_SUBTYPE";
+    --
+    FILLIN_ANSWER_KEY: constant String := "FILLIN_ANSWER";
 
   end Solubility_Suite;
 
@@ -157,6 +162,18 @@ package Problem_Generator_Syswides is
       TITRATION_CURVE_IMAGE_CLASS_NODISP: constant String := "hidden_image";
       TITRATION_CURVE_IMAGE_CLASS_NORM: constant String := "titration_curve_image";
     TITRATION_CURVE_IMAGE_PATH_KEY: constant String := "TITRATION_CURVE_IMAGE_PATH";
+    --
+    FILLIN_1_PH_KEY: constant String := "FILLIN_1_PH";
+    FILLIN_2_PH_KEY: constant String := "FILLIN_2_PH";
+    FILLIN_2_VOL_KEY: constant String := "FILLIN_2_VOL";
+    FILLIN_3_PH_KEY: constant String := "FILLIN_3_PH";
+    FILLIN_3_VOL_KEY: constant String := "FILLIN_3_VOL";
+    FILLIN_4_PH_KEY: constant String := "FILLIN_4_PH";
+    FILLIN_4_VOL_KEY: constant String := "FILLIN_4_VOL";
+    FILLIN_5_PH_KEY: constant String := "FILLIN_5_PH";
+    FILLIN_5_VOL_KEY: constant String := "FILLIN_5_VOL";
+    FILLIN_6_PH_KEY: constant String := "FILLIN_6_PH";
+    FILLIN_6_VOL_KEY: constant String := "FILLIN_6_VOL";
 
 
   end Titration_Curve_Suite;
index 213bc53ed405f1768c99538a7f501e4b3357bffb..990123d5be35fe236b5fac7e1d917d44a2ec6174 100644 (file)
@@ -11,6 +11,7 @@ package body Problem_Manager is
     Answer_Message: UB_Text;
     ARC: Problem_Generator_Syswides.Answer_RetCode;
     Assignment: Problem_Generator_Syswides.Assignment_Info.Map;
+    FillIns: Problem_Generator_Syswides.Fillins_Map.Map;
     Parameters: Problem_Generator_Syswides.Parameters_Info.Map;
     Pr_Cat: Problem_Category;
     Ret: RetCode;
@@ -43,7 +44,7 @@ package body Problem_Manager is
     end;
 
     begin
-      ARC := Stored.Problem.Check_Answer(Answer, Answer_Message);
+      ARC := Stored.Problem.Check_Answer(Answer, FillIns, Answer_Message);
     exception
       when Ex: others =>
        Stored.Mutex.Unlock;
@@ -53,7 +54,8 @@ package body Problem_Manager is
     Stored.Mutex.Unlock;
     return Face_Generator.Generate_Face_With_Answer(Assignment => Assignment, Answer_Message => Answer_Message,
                                                    Answer_Code => ARC, HTML => HTML,
-                                                   Parameters => Parameters, Pr_ID => Problem_ID'Image(Pr_ID), Pr_Cat => Problem_Category'Image(Pr_Cat));
+                                                   Parameters => Parameters, Pr_ID => Problem_ID'Image(Pr_ID), Pr_Cat => Problem_Category'Image(Pr_Cat),
+                                                   FillIns => FillIns);
   end Display_Checked_Answer;
 
   function Display_Assignment(UID: in Unique_ID; HTML: out HTML_Code) return RetCode is