</form>
</div>
+ @_WALKTHROUGH_SECTION_@
@_ANSWER_SECTION_@
<div class="backgrounded_block">
--- /dev/null
+<!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>
--- /dev/null
+ <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
--- /dev/null
+ <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
--- /dev/null
+#!/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
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;
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;
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
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;
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
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;
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;
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";
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
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;
--- /dev/null
+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;
--- /dev/null
+with AWS.Dispatchers.Callback;
+
+package Handler_Show_Walkthrough is
+ function Callback return AWS.Dispatchers.Callback.Handler;
+end Handler_Show_Walkthrough;
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;
Ret: RetCode;
begin
if Problem.Walkthrough_Generated then
+ Walkthrough := Problem.Walkthrough_Stored;
return OK;
end if;
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));
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));
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 =>
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 =>
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));
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
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;
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;
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";
--
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
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;
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;
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
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
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;
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;