]> Devoid-pointer.net GitWeb - Nine-Q.git/commitdiff
- Finish implementation of walkthrough for acidobazic suite
authorMichal Malý <madcatxster@devoid-pointer.net>
Sun, 28 Dec 2014 23:08:46 +0000 (00:08 +0100)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sun, 28 Dec 2014 23:08:46 +0000 (00:08 +0100)
- Unlock problem mutex after the exception message gets logged
- Unlock problem mutex after the HTML face is generated

16 files changed:
bin/templates/face_acidobazic.html
bin/templates/static/error_display_walkthrough.html [new file with mode: 0644]
bin/templates/walkthrough_acidobazic.html [new file with mode: 0644]
bin/templates/walkthrough_acidobazic_dissoc.html [new file with mode: 0644]
bin/tex2ima [new file with mode: 0755]
src/face_generators/face_generator.adb
src/face_generators/face_generator.ads
src/face_generators/face_generator_static.adb
src/face_generators/face_generator_static.ads
src/handlers/handler_show_walkthrough.adb [new file with mode: 0644]
src/handlers/handler_show_walkthrough.ads [new file with mode: 0644]
src/problem_generators/problem_generator-acidobazic_suite.adb
src/problem_generators/problem_generator.ads
src/problem_generators/problem_generator_syswides.ads
src/problem_manager.adb
src/problem_manager.ads

index ce5629db5a82bba33ca791348c7c1ecb09ce6102..54631714709e1e05b9112c41645a6228e97d9de3 100644 (file)
@@ -28,6 +28,7 @@
       </form>
     </div>
  
+    @_WALKTHROUGH_SECTION_@
     @_ANSWER_SECTION_@
 
     <div class="backgrounded_block">
diff --git a/bin/templates/static/error_display_walkthrough.html b/bin/templates/static/error_display_walkthrough.html
new file mode 100644 (file)
index 0000000..349ddf4
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
+
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+  <meta http-equiv="content-language" content="cs" />
+  @_META_EXPIRE_NOW_@
+  @_META_NO_CACHE_@
+  <link rel="stylesheet" type="text/css" href="/main_stylesheet" /> 
+  <title>TGen_Prototype</title>
+</head>
+
+<body>
+  <div id="container">
+    <div id="page_caption">
+      <div id="page_caption_text"><a class="back_link" href="/">Oops...</a></div>
+    </div>
+    <div id="content">
+
+    <div class="error_box">
+      <div class="caption_v1">Something didn't go quite as it was supposed to. We're sorry about this.</div>
+      <div class="error_text">Cannot display walkthrough.</div>
+      <div class="error_text">You can report the problem to the <a class="default_link" href="mailto:webmaster-nineq@devoid-pointer.net">webmaster</a>.</div>
+    </div>
+
+    </div>
+    <div id="spacer"></div>
+    <div id="footer">
+      <span id="core_info">Powered by: <a class="footer_link" href="http://libre.adacore.com/tools/aws/">AWS</a> | <a class="footer_link" href="http://gitweb.devoid-pointer.net/?p=Nine-Q.git;a=summary">Nine-Q</a></span>
+    </div>
+  </div>
+</body>
+
+</html>
diff --git a/bin/templates/walkthrough_acidobazic.html b/bin/templates/walkthrough_acidobazic.html
new file mode 100644 (file)
index 0000000..00eef20
--- /dev/null
@@ -0,0 +1,41 @@
+  <div class="backgrounded_block">
+    <div class="caption_v1">Řešení:</div>
+      <div class="hint_block">
+        <div class="hint_caption">
+         Koncentrace příslušného iontu:
+       </div>
+       <img class="math_formula" src="@_WT_CONC_ION_FORMULA_@" alt="Koncentrace příslušného iontu" />
+       <img class="math_formula" src="@_WT_CONC_ION_RESULT_@" alt="Koncentrace příslušného iontu" />
+      </div>
+
+      <div class="hint_block">
+        <div class="hint_caption">
+         Zkontrolujeme, zda lze zanedbat autoprotolýzu:
+       </div>
+       <img class="math_formula_multiline" src="@_WT_IGN_ATPR_FORMULA_@" alt="Zanedbání autoprotolýzy" />
+       <img class="math_formula_multiline" src="@_WT_IGN_ATPR_RESULT_@" alt="Zanedbání autoprotolýzy" />
+      </div>
+
+      <div class="hint_block">
+        <div class="hint_caption">
+         Zkontrolujeme, zda lze zanedbat úbytek disociací:
+       </div>
+       <img class="math_formula_multiline" src="@_WT_IGN_DISSOC_FORMULA_@" alt="Zanedbání úbytku disociací" />
+       <img class="math_formula_multiline" src="@_WT_IGN_DISSOC_RESULT_@" alt="Zanedbání úbytku disociací" />
+      </div>
+
+      <div class="hint_block">
+       <div class="hint_caption">
+         Výsledek kontroly zanedbání: <span class="emphasis">@_IGN_CONCLUSION_@</span>
+       </div>
+      </div>
+
+      @_WT_DISSOC_CALCULATION_@
+
+      <div class="hint_block">
+        <div class="hint_caption">
+         Konečný výsledek:
+       </div>
+       <img class="math_formula" src="@_WT_FINAL_RESULT_@" alt="Konečný výsledek" />
+      </div>
+  </div>
\ No newline at end of file
diff --git a/bin/templates/walkthrough_acidobazic_dissoc.html b/bin/templates/walkthrough_acidobazic_dissoc.html
new file mode 100644 (file)
index 0000000..8dc0b46
--- /dev/null
@@ -0,0 +1,7 @@
+      <div class="hint_block">
+        <div class="hint_caption">
+         Výpočet koncentrace příslušného iontu, je-li uvažován úbytek disociací:
+       </div>
+       <img class="math_formula_multiline" src="@_WT_DISSOC_CORR_FORMULA_@" alt="Korekce na úbytek disociací" />
+       <img class="math_formula_multiline" src="@_WT_DISSOC_CORR_RESULT_@" alt="Korekce na úbytek disociací" />
+      </div>
\ No newline at end of file
diff --git a/bin/tex2ima b/bin/tex2ima
new file mode 100755 (executable)
index 0000000..eed8844
--- /dev/null
@@ -0,0 +1,113 @@
+#!/bin/bash
+#############################################################
+# TEX2IM:   Converts LaTeX formulas to pixel graphics which #
+#           can be easily included in Text-Processors like  #
+#           M$ or Staroffice.                               #
+#                                                           #
+# Required software: latex, convert (image magic)           #
+# to get color, the latex color package is required         #
+#############################################################
+# Version 1.8  (http://www.nought.de/tex2im.html)           #
+# published under the GNU public licence (GPL)              #
+# (c) 14. May 2004 by Andreas Reigber                   #
+# Email: anderl@nought.de                                   #
+#############################################################
+
+#
+# Default values
+#
+
+resolution="400x400"
+format="png"
+color1="white"
+color2="black"
+
+while getopts o:s: Options; do
+  case $Options in
+    s) TEXCODE=$OPTARG;;
+    o) outfile=$OPTARG;;
+  esac;
+done
+
+if [ -z "$TEXCODE" ]; then
+  echo "No TeX code specified";
+  exit 1;
+fi
+if [ -z "$outfile" ]; then
+  echo "No output file specified";
+  exit 1;
+fi;
+
+#
+# Generate temporary directory
+#
+
+homedir="`pwd`" || exit 1  
+
+if test -n "`type -p mktemp`" ; then
+       tmpdir=`mktemp ${homedir}/tmp/tex2imXXXXXX`
+       rm $tmpdir
+       mkdir $tmpdir
+else
+       tmpdir=${homedir}/tmp/tex2im$$
+       if [ -e $tmpdir ] ; then
+               echo "$0: Temporary directory $tmpdir already exists." 1>&2
+               exit 1
+       fi
+       mkdir $tmpdir
+fi
+
+
+#
+# Here we go
+#
+
+# Constuct the TeX code
+(
+cat << ENDHEADER1
+\documentclass[12pt]{article}
+\usepackage{color}
+\usepackage[dvips]{graphicx}
+\usepackage{mathspec}
+\usepackage{siunitx}
+\usepackage{xltxtra}
+\pagestyle{empty}
+\sisetup{output-decimal-marker = {,},
+exponent-product = {\cdot}}
+\setromanfont[Mapping=tex-text]{Linux Libertine O}
+\setallmainfonts(Digits,Latin,Greek){Linux Libertine O}
+ENDHEADER1
+) > $tmpdir/out.tex
+
+(
+cat << ENDHEADER2
+\pagecolor{$color1}
+\begin{document}
+{\color{$color2}
+\begin{eqnarray*}
+ENDHEADER2
+) >> $tmpdir/out.tex
+
+echo $TEXCODE >> $tmpdir/out.tex
+
+(
+cat << ENDFOOTER
+\end{eqnarray*}}
+\end{document}
+ENDFOOTER
+) >> $tmpdir/out.tex
+
+cd $tmpdir
+xelatex -interaction=batchmode out.tex > /dev/null 2>&1
+cd "$homedir"
+pdfcrop --margins 0 $tmpdir/out.pdf $tmpdir/cout.pdf > /dev/null 2>&1
+pdftops -eps $tmpdir/cout.pdf $tmpdir/out.eps > /dev/null 2>&1
+
+convert +adjoin -antialias -transparent $color1 -density $resolution $tmpdir/out.eps $outfile.png
+
+#
+# Cleanup
+#
+
+rm -rf $tmpdir
+exit 0
index 37988b1350107fa8c9ff0cf31480ececbeec0114..7e9e6c76ed2503a2b35a035b780490edf7116cec 100644 (file)
@@ -44,12 +44,16 @@ 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;
+    use Problem_Generator_Syswides;
+    FillIns: constant FillIns_Map.Map := FillIns_Map.Empty_Map;
+    Walkthrough: constant Walkthrough_Info.Map := Walkthrough_Info.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,
-                                    FillIns => FillIns);
+    return Generate_Face_Internal(Mode => Default_Mode,
+                                 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,
+                                 FillIns => FillIns,
+                                 Walkthrough => Walkthrough);
   end Generate_Face;
 
   function Generate_Face_With_Answer(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
@@ -59,8 +63,42 @@ package body Face_Generator 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;
+    Walkthrough: constant Walkthrough_Info.Map := Walkthrough_Info.Empty_Map;
+  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,
+                                 Pr_ID => Pr_ID, Pr_Cat => Pr_Cat,
+                                 FillIns => FillIns,
+                                 Walkthrough => Walkthrough);
+  end Generate_Face_With_Answer;
+
+  function Generate_Face_With_Walkthrough(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
+                                         Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
+                                         HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String;
+                                         Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode is
+    use Problem_Generator_Syswides;
+    FillIns: constant FillIns_Map.Map := FillIns_Map.Empty_Map;
+  begin
+    return Generate_Face_Internal(Mode => Walkthrough_Mode,
+                                 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,
+                                 FillIns => FillIns,
+                                 Walkthrough => Walkthrough);
+  end Generate_Face_With_Walkthrough;
+  -- BEGIN: Private functions
 
+  function Generate_Face_Internal(Mode: in Display_Mode;
+                                 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;
+                                 FillIns: in Problem_Generator_Syswides.FillIns_Map.Map;
+                                 Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode is
+    use Problem_Generator_Syswides;
+    use Problem_Generator_Syswides.Assignment_Info;
   begin
     if Assignment.Find(PROBLEM_TYPE_KEY) = Assignment_Info.No_Element then
       return E_NOTFOUND;
@@ -70,18 +108,16 @@ 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, FillIns);
+       return Generate_Face_Acidobazic(Mode, Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat, FillIns, Walkthrough);
       elsif Problem_Type_Str = PROBLEM_TYPE_SOLUBILITY then
-        return Generate_Face_Solubility(Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat, FillIns);
+       return Generate_Face_Solubility(Mode, Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat, FillIns, Walkthrough);
       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, FillIns);
+       return Generate_Face_Titration_Curve(Mode, Assignment, Answer_Message, Answer_Code, Parameters, HTML, Pr_ID, Pr_Cat, FillIns, Walkthrough);
       else
        return E_INVAL;
       end if;
     end;
-  end Generate_Face_With_Answer;
-
-  -- BEGIN: Private functions
+  end Generate_Face_Internal;
 
   procedure Add_Answer_Section(Translations: in out AWS.Templates.Translate_Set; Answer_Message: in UB_Text;
                               AR: in Problem_Generator_Syswides.Answer_RetCode) is
@@ -107,12 +143,83 @@ package body Face_Generator is
     end case;
   end Add_Answer_Section;
 
-  function Generate_Face_Acidobazic(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
+  function Add_Walkthrough_Acidobazic(Translations: in out AWS.Templates.Translate_Set;
+                                     Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode is
+    use AWS.Templates;
+    use Problem_Generator_Syswides;
+    use Problem_Generator_Syswides.Acidobazic_Suite;
+    use Problem_Generator_Syswides.Walkthrough_Info;
+
+    WTrans: Translate_Set;
+    HTML: HTML_Code;
+  begin
+    if Walkthrough.Find(WT_CONC_ION_FORMULA_KEY) = Walkthrough_Info.No_Element then
+      return E_INVAL;
+    end if;
+    Insert(WTrans, Assoc(WT_CONC_ION_FORMULA_KEY, Walkthrough.Element(WT_CONC_ION_FORMULA_KEY)));
+    if Walkthrough.Find(WT_CONC_ION_RESULT_KEY) = Walkthrough_Info.No_Element then
+      return E_INVAL;
+    end if;
+    Insert(WTrans, Assoc(WT_CONC_ION_RESULT_KEY, Walkthrough.Element(WT_CONC_ION_RESULT_KEY)));
+    --
+    if Walkthrough.Find(WT_IGN_ATPR_FORMULA_KEY) = Walkthrough_Info.No_Element then
+      return E_INVAL;
+    end if;
+    Insert(WTrans, Assoc(WT_IGN_ATPR_FORMULA_KEY, Walkthrough.Element(WT_IGN_ATPR_FORMULA_KEY)));
+    if Walkthrough.Find(WT_IGN_ATPR_RESULT_KEY) = Walkthrough_Info.No_Element then
+      return E_INVAL;
+    end if;
+    Insert(WTrans, Assoc(WT_IGN_ATPR_RESULT_KEY, Walkthrough.Element(WT_IGN_ATPR_RESULT_KEY)));
+    --
+    if Walkthrough.Find(WT_IGN_DISSOC_FORMULA_KEY) = Walkthrough_Info.No_Element then
+      return E_INVAL;
+    end if;
+    Insert(WTrans, Assoc(WT_IGN_DISSOC_FORMULA_KEY, Walkthrough.Element(WT_IGN_DISSOC_FORMULA_KEY)));
+    if Walkthrough.Find(WT_IGN_DISSOC_RESULT_KEY) = Walkthrough_Info.No_Element then
+      return E_INVAL;
+    end if;
+    Insert(WTrans, Assoc(WT_IGN_DISSOC_RESULT_KEY, Walkthrough.Element(WT_IGN_DISSOC_RESULT_KEY)));
+    --
+    Insert(WTrans, Assoc(WT_IGN_CONCLUSION_KEY, Walkthrough.Element(WT_IGN_CONCLUSION_KEY)));
+
+    if Walkthrough.Find(WT_DISSOC_CORR_FORMULA_KEY) /= Walkthrough_Info.No_Element then
+      declare
+       DC_HTML: HTML_Code;
+       DCTrans: Translate_Set;
+      begin
+       if Walkthrough.Find(WT_DISSOC_CORR_FORMULA_KEY) = Walkthrough_Info.No_Element then
+         return E_INVAL;
+       end if;
+       Insert(DCTrans, Assoc(WT_DISSOC_CORR_FORMULA_KEY, Walkthrough.Element(WT_DISSOC_CORR_FORMULA_KEY)));
+       if Walkthrough.Find(WT_DISSOC_CORR_RESULT_KEY) = Walkthrough_Info.No_Element then
+         return E_INVAL;
+       end if;
+       Insert(DCTrans, Assoc(WT_DISSOC_CORR_RESULT_KEY, Walkthrough.Element(WT_DISSOC_CORR_RESULT_KEY)));
+       DC_HTML := Parse(Filename => "templates/walkthrough_acidobazic_dissoc.html", Translations => DCTrans);
+
+       Insert(WTrans, Assoc(WT_DISSOC_CALCULATION_KEY, HTML_To_Fixed_String(DC_HTML)));
+      end;
+    end if;
+
+    if Walkthrough.Find(WT_FINAL_RESULT_KEY) = Walkthrough_Info.No_Element then
+      return E_INVAL;
+    end if;
+    Insert(WTrans, Assoc(WT_FINAL_RESULT_KEY, Walkthrough.Element(WT_FINAL_RESULT_KEY)));
+    HTML := Parse(Filename => "templates/walkthrough_acidobazic.html", Translations => WTrans);
+
+    Insert(Translations, Assoc(WALKTHROUGH_SECTION_KEY, HTML_To_Fixed_String(HTML)));
+
+    return OK;
+  end Add_Walkthrough_Acidobazic;
+
+  function Generate_Face_Acidobazic(Mode: in Display_Mode;
+                                   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;
-                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode is
+                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map;
+                                   Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode is
     use AWS.Templates;
     use Problem_Generator_Syswides;
     use Problem_Generator_Syswides.Assignment_Info;
@@ -181,7 +288,21 @@ package body Face_Generator is
       Insert(Translations, Assoc("PARAMETER_NO_BOTH_SIMPLIFICATIONS_CHECKED", "checked"));
     end if;
 
-    Add_Answer_Section(Translations, Answer_Message, Answer_Code);
+    case Mode is
+      when Answer_Mode =>
+       Add_Answer_Section(Translations, Answer_Message, Answer_Code);
+      when Walkthrough_Mode =>
+       declare
+         Ret: RetCode;
+       begin
+         Ret := Add_Walkthrough_Acidobazic(Translations, Walkthrough);
+         if Ret /= OK then
+           return Ret;
+         end if;
+       end;
+      when Default_Mode =>
+       null;
+    end case;
 
     -- Add FillIns
     if FillIns.Is_Empty = False then
@@ -210,12 +331,14 @@ package body Face_Generator is
     return OK;
   end Generate_Face_Acidobazic;
 
-  function Generate_Face_Solubility(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
+  function Generate_Face_Solubility(Mode: in Display_Mode;
+                                   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;
-                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode is
+                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map;
+                                   Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode is
     use Ada.Strings.Unbounded;
     use AWS.Templates;
     use Problem_Generator_Syswides;
@@ -426,12 +549,14 @@ package body Face_Generator is
     return OK;
   end Generate_Face_Solubility;
 
-  function Generate_Face_Titration_Curve(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
+  function Generate_Face_Titration_Curve(Mode: in Display_Mode;
+                                        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;
-                                        FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode is
+                                        FillIns: in Problem_Generator_Syswides.FillIns_Map.Map;
+                                        Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode is
     use AWS.Templates;
     use Problem_Generator_Syswides;
     use Problem_Generator_Syswides.Assignment_Info;
index 7e4acf6ac3b4831641b3648c3454edddd0b4c1bd..89002e70c70af8c6da15e58cab6620e2611e3a8c 100644 (file)
@@ -19,33 +19,58 @@ package Face_Generator is
                                     Pr_ID: in String; Pr_Cat: in String;
                                     FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode;
 
+  function Generate_Face_With_Walkthrough(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
+                                         Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
+                                         HTML: out HTML_Code; Pr_ID: in String; Pr_Cat: in String;
+                                         Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode;
+
 private
+  type Display_Mode is (Default_Mode, Answer_Mode, Walkthrough_Mode);
+
+  function Generate_Face_Internal(Mode: in Display_Mode;
+                                 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;
+                                 FillIns: in Problem_Generator_Syswides.FillIns_Map.Map;
+                                 Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode;
+
   procedure Add_Answer_Section(Translations: in out AWS.Templates.Translate_Set; Answer_Message: in UB_Text;
                               AR: in Problem_Generator_Syswides.Answer_RetCode);
 
-  function Generate_Face_Acidobazic(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
+  function Add_Walkthrough_Acidobazic(Translations: in out AWS.Templates.Translate_Set;
+                                     Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode;
+  function Generate_Face_Acidobazic(Mode: in Display_Mode;
+                                   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;
-                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode;
+                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map;
+                                   Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode;
 
-  function Generate_Face_Solubility(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
+  function Generate_Face_Solubility(Mode: in Display_Mode;
+                                   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;
-                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode;
+                                   FillIns: in Problem_Generator_Syswides.FillIns_Map.Map;
+                                   Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode;
 
-  function Generate_Face_Titration_Curve(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
+  function Generate_Face_Titration_Curve(Mode: in Display_Mode;
+                                        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;
-                                        FillIns: in Problem_Generator_Syswides.FillIns_Map.Map) return RetCode;
+                                        FillIns: in Problem_Generator_Syswides.FillIns_Map.Map;
+                                        Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode;
 
   ERROR_MESSAGE_KEY: constant String := "ERROR_MESSAGE";
   HEADER_CAPTION_KEY: constant String := "HEADER_CAPTION";
index 2e430c4d6ea66902a4542aa6385e1b79dc1dd040..d92d7268d6181c8593dc2dbd84206121661fe308 100644 (file)
@@ -33,6 +33,12 @@ package body Face_Generator_Static is
     return Parse(Filename => "templates/static/error_display_assignment.html");
   end Error_Display_Assignment;
 
+  function Error_Display_Walkthrough return HTML_Code is
+    use AWS.Templates;
+  begin
+    return Parse(Filename => "templates/static/error_display_answer.html");
+  end Error_Display_Walkthrough;
+
   function Error_UID_Registration return HTML_Code is
     use AWS.Templates;
   begin
index 7059c230ea64321ab582845b09c56efedfced17f..279083eaf76151a1773b371a04392736a0009e03 100644 (file)
@@ -5,6 +5,7 @@ package Face_Generator_Static is
   function Display_Static_Page(Path: in String) return HTML_Code;
   function Error_Display_Answer return HTML_Code;
   function Error_Display_Assignment return HTML_Code;
+  function Error_Display_Walkthrough return HTML_Code;
   function Error_UID_Registration return HTML_Code;
   function Error_Prepare_Problem return HTML_Code;
   function Error_Problem_Category return HTML_Code;
diff --git a/src/handlers/handler_show_walkthrough.adb b/src/handlers/handler_show_walkthrough.adb
new file mode 100644 (file)
index 0000000..d0cf8ec
--- /dev/null
@@ -0,0 +1,92 @@
+with AWS.Containers.Tables;
+with AWS.Messages;
+with AWS.MIME;
+with AWS.Parameters;
+with AWS.Response;
+with AWS.Session;
+with AWS.Status;
+
+with Face_Generator_Static;
+with Global_Types;
+with Problem_Manager;
+with Problem_Generator_Syswides;
+
+use Global_Types;
+package body Handler_Show_Walkthrough is
+
+  function Handle(Request: AWS.Status.Data) return AWS.Response.Data is
+    SID: constant AWS.Session.ID := AWS.Status.Session(Request);
+    Req_Type: constant AWS.Status.Request_Method := AWS.Status.Method(Request);
+
+    Raw_UID: constant String := AWS.Session.Get(SID, "UID");
+    UID: Unique_ID;
+    HTML: HTML_Code;
+  begin
+    case Req_Type is
+      when AWS.Status.POST =>
+       declare
+         use Problem_Generator_Syswides;
+         use Problem_Generator_Syswides.Answer_Info;
+
+         POST_Data: constant AWS.Parameters.List := AWS.Status.Parameters(Request);
+         Answer: Answer_Info.Map;
+         Pr_ID: Problem_ID;
+         Ret: RetCode;
+         Success: Boolean;
+       begin
+         -- Get UID
+         Success := Problem_Manager.Get_UID(Raw_UID, UID);
+         if Success = False then
+           -- This UID is invalid, redirect to index
+           return AWS.Response.URL(Location => "/");
+         end if;
+
+         for Idx in 1 .. POST_Data.Count loop
+           declare
+             C: Answer_Info.Cursor;
+             E: constant AWS.Containers.Tables.Element := POST_Data.Get(Idx);
+             Success: Boolean;
+           begin
+             Answer.Insert(E.Name, E.Value, C, Success);
+             -- TODO: Handle error
+           end;
+         end loop;
+
+         -- Get problem ID
+         if Answer.Find(Problem_Generator_Syswides.RESERVED_PROBLEM_ID_KEY) = Answer_Info.No_Element then
+           return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+                                     Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Problem_ID),
+                                     Status_Code => AWS.Messages.S200);
+         end if;
+
+         begin
+           Pr_ID := Problem_ID'Value(Answer.Element(Problem_Generator_Syswides.RESERVED_PROBLEM_ID_KEY));
+         exception
+           when Constraint_Error =>
+             return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+                                       Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Problem_ID),
+                                       Status_Code => AWS.Messages.S200);
+         end;
+
+         Ret := Problem_Manager.Display_Walkthrough(UID, HTML, Pr_ID);
+         if Ret /= OK then
+           return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+                                     Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Display_Walkthrough),
+                                     Status_Code => AWS.Messages.S200);
+         end if;
+
+         return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+                                   Message_Body => HTML_To_Fixed_String(HTML),
+                                   Status_Code => AWS.Messages.S200);
+       end;
+      when others =>
+       return AWS.Response.URL(Location => "/");
+    end case;
+  end Handle;
+
+  function Callback return AWS.Dispatchers.Callback.Handler is
+  begin
+    return AWS.Dispatchers.Callback.Create(Handle'Access);
+  end Callback;
+
+end Handler_Show_Walkthrough;
diff --git a/src/handlers/handler_show_walkthrough.ads b/src/handlers/handler_show_walkthrough.ads
new file mode 100644 (file)
index 0000000..56a1024
--- /dev/null
@@ -0,0 +1,5 @@
+with AWS.Dispatchers.Callback;
+
+package Handler_Show_Walkthrough is
+  function Callback return AWS.Dispatchers.Callback.Handler;
+end Handler_Show_Walkthrough;
index 5806a1a51a6b2542c846f8c37073c5df9039dfc3..f3e26c50f3b07aef1db0492c949d51ab42619f53 100644 (file)
@@ -156,6 +156,11 @@ package body Acidobazic_Suite is
   end Get_Parameters;
 
   function Get_Walkthrough(Problem: in out Acidobazic_Problem; Walkthrough: out Walkthrough_Info.Map) return RetCode is
+    function Fix_Str(T: in UB_Text) return String is
+    begin
+      return UB_Text_To_Fixed_String(T);
+    end Fix_Str;
+
     package FH is new Formatting_Helpers(pH_Float);
     use AWS.Templates;
 
@@ -185,6 +190,7 @@ package body Acidobazic_Suite is
     Ret: RetCode;
   begin
     if Problem.Walkthrough_Generated then
+      Walkthrough := Problem.Walkthrough_Stored;
       return OK;
     end if;
 
@@ -212,6 +218,14 @@ package body Acidobazic_Suite is
       return Ret;
     end if;
     Problem.Add_Tracked_Resource(WT_F_ION_CONC & WT_F_EXTENSION);
+    case Problem.Subst_Type is
+      when Acid =>
+       Walkthrough.Insert(WT_CONC_ION_FORMULA_KEY, "/images/h3o_calc.png");
+      when Base =>
+       Walkthrough.Insert(WT_CONC_ION_FORMULA_KEY, "/images/oh_calc.png");
+    end case;
+    Walkthrough.Insert(WT_CONC_ION_RESULT_KEY, Fix_Str(Problem.Resource_Prefix) & WT_F_ION_CONC & WT_F_EXTENSION);
+
 
     Insert(Trans_DC, Assoc(CONC_ION_INT_KEY, c_Ion_I));
     Insert(Trans_DC, Assoc(CONC_ION_DEC_KEY, c_Ion_D));
@@ -231,6 +245,14 @@ package body Acidobazic_Suite is
       return Ret;
     end if;
     Problem.Add_Tracked_Resource(WT_F_CHECK_DISSOC & WT_F_EXTENSION);
+    case Problem.Subst_Type is
+      when Acid =>
+       Walkthrough.Insert(WT_IGN_DISSOC_FORMULA_KEY, "/images/ign_dissoc_acid.png");
+      when Base =>
+       Walkthrough.Insert(WT_IGN_DISSOC_FORMULA_KEY, "/images/ign_dissoc_base.png");
+    end case;
+    Walkthrough.Insert(WT_IGN_DISSOC_RESULT_KEY, Fix_Str(Problem.Resource_Prefix) & WT_F_CHECK_DISSOC & WT_F_EXTENSION);
+
 
     Insert(Trans_AC, Assoc(CONC_ION_INT_KEY, c_Ion_I));
     Insert(Trans_AC, Assoc(CONC_ION_DEC_KEY, c_Ion_D));
@@ -246,6 +268,14 @@ package body Acidobazic_Suite is
       return Ret;
     end if;
     Problem.Add_Tracked_Resource(WT_F_CHECK_ATPR & WT_F_EXTENSION);
+    case Problem.Subst_Type is
+      when Acid =>
+       Walkthrough.Insert(WT_IGN_ATPR_FORMULA_KEY, "/images/ign_atpr_acid.png");
+      when Base =>
+       Walkthrough.Insert(WT_IGN_ATPR_FORMULA_KEY, "/images/ign_atpr_base.png");
+    end case;
+    Walkthrough.Insert(WT_IGN_ATPR_RESULT_KEY, Fix_Str(Problem.Resource_Prefix) & WT_F_CHECK_ATPR & WT_F_EXTENSION);
+
 
     case Problem.Simpl is
       when Both =>
@@ -275,6 +305,9 @@ package body Acidobazic_Suite is
            return Ret;
          end if;
          Problem.Add_Tracked_Resource(WT_F_RESULT & WT_F_EXTENSION);
+         Walkthrough.Insert(WT_FINAL_RESULT_KEY, Fix_Str(Problem.Resource_Prefix) & WT_F_RESULT & WT_F_EXTENSION);
+
+         Walkthrough.Insert(WT_IGN_CONCLUSION_KEY, "Lze zanedbat vše");
        end;
 
       when Autoprotolysis =>
@@ -304,6 +337,14 @@ package body Acidobazic_Suite is
            return Ret;
          end if;
          Problem.Add_Tracked_Resource(WT_F_WITH_DISSOC & WT_F_EXTENSION);
+         case Problem.Subst_Type is
+           when Acid =>
+             Walkthrough.Insert(WT_DISSOC_CORR_FORMULA_KEY, "/images/h3o_calc_dissoc_acid.png");
+           when Base =>
+             Walkthrough.Insert(WT_DISSOC_CORR_FORMULA_KEY, "/images/oh_calc_dissoc_base.png");
+         end case;
+         Walkthrough.Insert(WT_DISSOC_CORR_RESULT_KEY, Fix_Str(Problem.Resource_Prefix) & WT_F_WITH_DISSOC & WT_F_EXTENSION);
+
 
          Insert(Trans_A, Assoc(WT_ANSWER_PH_INT_KEY, pH_I));
          Insert(Trans_A, Assoc(WT_ANSWER_PH_DEC_KEY, pH_D));
@@ -322,6 +363,9 @@ package body Acidobazic_Suite is
            return Ret;
          end if;
          Problem.Add_Tracked_Resource(WT_F_RESULT & WT_F_EXTENSION);
+         Walkthrough.Insert(WT_FINAL_RESULT_KEY, Fix_Str(Problem.Resource_Prefix) & WT_F_RESULT & WT_F_EXTENSION);
+
+         Walkthrough.Insert(WT_IGN_CONCLUSION_KEY, "Lze zanedbat autoprotolýzu");
        end;
       when Dissociation =>
        declare
@@ -350,9 +394,13 @@ package body Acidobazic_Suite is
          end if;
          Ret := Problem_Generator.TeX_To_PNG(TeXCode, WT_F_RESULT, Problem.Resource_Prefix);
          Problem.Add_Tracked_Resource(WT_F_RESULT & WT_F_EXTENSION);
+         Walkthrough.Insert(WT_FINAL_RESULT_KEY, Fix_Str(Problem.Resource_Prefix) & WT_F_RESULT & WT_F_EXTENSION);
+
+         Walkthrough.Insert(WT_IGN_CONCLUSION_KEY, "Lze zanedbat úbytek disociací");
        end;
     end case;
 
+    Problem.Walkthrough_Stored := Walkthrough;  -- Store the walkthrough for possible future use
     Problem.Walkthrough_Generated := True;
     return OK;
   end Get_Walkthrough;
index 93f117aa098ec33aeabbd68c9fcd9732b4f46fb0..edfd1ee8369807c1c305c19e17bdb9bb17e30325 100644 (file)
@@ -88,6 +88,7 @@ private
          Simpl: Simplification;
          Subst_Type: Substance_Type;
          Walkthrough_Generated: Boolean;
+         Walkthrough_Stored: Problem_Generator_Syswides.Walkthrough_Info.Map;
        end record;
 
       Acidic_Min_pH: constant pH_Float := 1.75;
index 29747f6a990c6711488f3116817a37c0f66cc394..b26667a716202e6cb9abb59bd23707500e03eda7 100644 (file)
@@ -16,6 +16,8 @@ package Problem_Generator_Syswides is
   ANSWER_MESSAGE_KEY: constant String := "ANSWER_MESSAGE";
   ANSWER_SECTION_KEY: constant String := "ANSWER_SECTION";
   --
+  WALKTHROUGH_SECTION_KEY: constant String := "WALKTHROUGH_SECTION";
+  --
   PARAMETER_TRUE: constant String := "True";
   PARAMETER_FALSE: constant String := "False";
   --
@@ -51,6 +53,18 @@ package Problem_Generator_Syswides is
     PARAMETER_NO_BOTH_SIMPLIFICATIONS_KEY: constant String := "PARAMETER_NO_BOTH_SIMPLIFICATIONS";
     --
     FILLIN_ANSWER_KEY: constant String := "FILLIN_ANSWER";
+    --
+    WT_CONC_ION_FORMULA_KEY: constant String := "WT_CONC_ION_FORMULA";
+    WT_CONC_ION_RESULT_KEY: constant String := "WT_CONC_ION_RESULT";
+    WT_DISSOC_CALCULATION_KEY: constant String := "WT_DISSOC_CALCULATION";
+    WT_DISSOC_CORR_FORMULA_KEY: constant String := "WT_DISSOC_CORR_FORMULA";
+    WT_DISSOC_CORR_RESULT_KEY: constant String := "WT_DISSOC_CORR_RESULT";
+    WT_FINAL_RESULT_KEY: constant String := "WT_FINAL_RESULT";
+    WT_IGN_ATPR_FORMULA_KEY: constant String := "WT_IGN_ATPR_FORMULA";
+    WT_IGN_ATPR_RESULT_KEY: constant String := "WT_IGN_ATPR_RESULT";
+    WT_IGN_CONCLUSION_KEY: constant String := "IGN_CONCLUSION";
+    WT_IGN_DISSOC_FORMULA_KEY: constant String := "WT_IGN_DISSOC_FORMULA";
+    WT_IGN_DISSOC_RESULT_KEY: constant String := "WT_IGN_DISSOC_RESULT";
   end Acidobazic_Suite;
 
   package Solubility_Suite is
@@ -176,7 +190,6 @@ package Problem_Generator_Syswides is
     FILLIN_6_PH_KEY: constant String := "FILLIN_6_PH";
     FILLIN_6_VOL_KEY: constant String := "FILLIN_6_VOL";
 
-
   end Titration_Curve_Suite;
 
 end Problem_Generator_Syswides;
index 11dac59b49baf44c54d37679c28f1384b2ffd2da..8e37edbf25cdb5483728f1d93384115cd543d283 100644 (file)
@@ -32,14 +32,14 @@ package body Problem_Manager is
     begin
       Ret := Stored.Problem.Get_Assignment(Assignment);
       if Ret /= OK then
-       Stored.Mutex.Unlock;
        Logging_System.Log(ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")", Logging_System.ERROR);
+       Stored.Mutex.Unlock;
        return Face_Generator.Generate_Error_Face(HTML, ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")");
       end if;
     exception
       when Ex: others =>
-       Stored.Mutex.Unlock;
        Logging_System.Log(ERRMSG_UNHANDLED_EXCEPTION & " (" & Ada.Exceptions.Exception_Information(Ex) & ")", Logging_System.ERROR);
+       Stored.Mutex.Unlock;
        return Face_Generator.Generate_Error_Face(HTML, ERRMSG_UNHANDLED_EXCEPTION & " (" & Ada.Exceptions.Exception_Information(Ex) & ")");
     end;
 
@@ -47,15 +47,16 @@ package body Problem_Manager is
       ARC := Stored.Problem.Check_Answer(Answer, FillIns, Answer_Message);
     exception
       when Ex: others =>
-       Stored.Mutex.Unlock;
        Logging_System.Log(ERRMSG_UNHANDLED_EXCEPTION & " (" & Ada.Exceptions.Exception_Information(Ex) & ")", Logging_System.ERROR);
+       Stored.Mutex.Unlock;
        return Face_Generator.Generate_Error_Face(HTML, ERRMSG_UNHANDLED_EXCEPTION & " (" & Ada.Exceptions.Exception_Information(Ex) & ")");
     end;
-    Stored.Mutex.Unlock;
-    return Face_Generator.Generate_Face_With_Answer(Assignment => Assignment, Answer_Message => Answer_Message,
+    Ret := 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),
                                                    FillIns => FillIns);
+    Stored.Mutex.Unlock;
+    return Ret;
   end Display_Checked_Answer;
 
   function Display_Assignment(UID: in Unique_ID; HTML: out HTML_Code) return RetCode is
@@ -82,20 +83,21 @@ package body Problem_Manager is
     begin
       Ret := Stored.Problem.Get_Assignment(Assignment);
       if Ret /= OK then
-       Stored.Mutex.Unlock;
        Logging_System.Log(ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")", Logging_System.ERROR);
+       Stored.Mutex.Unlock;
        return Face_Generator.Generate_Error_Face(HTML, ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")");
       end if;
     exception
       when Ex: others =>
-       Stored.Mutex.Unlock;
        Logging_System.Log(ERRMSG_UNHANDLED_EXCEPTION & " (" & Ada.Exceptions.Exception_Information(Ex) & ")", Logging_System.ERROR);
+       Stored.Mutex.Unlock;
        return Face_Generator.Generate_Error_Face(HTML, ERRMSG_UNHANDLED_EXCEPTION & " (" & Ada.Exceptions.Exception_Information(Ex) & ")");
     end;
 
-    Stored.Mutex.Unlock;
-    return Face_Generator.Generate_Face(Assignment => Assignment, HTML => HTML, Parameters => Parameters, Pr_ID => Problem_ID'Image(Pr_ID),
+    Ret := Face_Generator.Generate_Face(Assignment => Assignment, HTML => HTML, Parameters => Parameters, Pr_ID => Problem_ID'Image(Pr_ID),
                                        Pr_Cat => Problem_Category'Image(Pr_Cat));
+    Stored.Mutex.Unlock;
+    return Ret;
   end Display_Assignment;
 
   function Display_Walkthrough(UID: in Unique_ID; HTML: out HTML_Code; Pr_ID: in Problem_ID) return RetCode is
@@ -121,23 +123,26 @@ package body Problem_Manager is
     begin
       Ret := Stored.Problem.Get_Assignment(Assignment);
       if Ret /= OK then
-       Stored.Mutex.Unlock;
        Logging_System.Log(ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")", Logging_System.ERROR);
+       Stored.Mutex.Unlock;
        return Face_Generator.Generate_Error_Face(HTML, ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")");
       end if;
       Ret := Stored.Problem.Get_Walkthrough(Walkthrough);
       if Ret /= OK then
-       Stored.Mutex.Unlock;
        Logging_System.Log(ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")", Logging_System.ERROR);
+       Stored.Mutex.Unlock;
        return Face_Generator.Generate_Error_Face(HTML, ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")");
       end if;
     exception
       when Ex: others =>
-       Stored.Mutex.Unlock;
        Logging_System.Log(ERRMSG_UNHANDLED_EXCEPTION & " (" & Ada.Exceptions.Exception_Information(Ex) & ")", Logging_System.ERROR);
+       Stored.Mutex.Unlock;
        return Face_Generator.Generate_Error_Face(HTML, ERRMSG_UNHANDLED_EXCEPTION & " (" & Ada.Exceptions.Exception_Information(Ex) & ")");
     end;
 
+    Ret := Face_Generator.Generate_Face_With_Walkthrough(Assignment => Assignment, HTML => HTML,
+                                                        Parameters => Parameters, Pr_ID => Problem_ID'Image(Pr_ID), Pr_Cat => Problem_Category'Image(Pr_Cat),
+                                                        Walkthrough => Walkthrough);
     Stored.Mutex.Unlock;
     return Ret;
   end Display_Walkthrough;
index 58aafe766f392ac90e75a8d702e25b8dcb106076..60016e4b3f59ab38c495b3ad487f1c1e37e1f0fc 100644 (file)
@@ -68,5 +68,5 @@ private
     Last_UID: Unique_ID := Unique_ID'First;
   end Active_Sessions;
 
-  MAX_STORED_PROBLEMS: Problem_ID := 3;
+  MAX_STORED_PROBLEMS: Problem_ID := 20;
 end Problem_Manager;