<input type="submit" name="send_answer" value="Zkontrolovat" />
</div>
</form>
+ <form class="problem_form" method="post" action="/show_walkthrough">
+ <input type="hidden" name="@_RESERVED__PROBLEM_ID_@" value="@_RESERVED__PROBLEM_ID_VAL_@" />
+ <div class="form_line">
+ <input type="submit" name="show_walkthrough" value="Zobrazit řešení" />
+ </div>
+ </form>
@_SUBMIT_FORM_@
</div>
+ @_WALKTHROUGH_SECTION_@
@_ANSWER_SECTION_@
<div class="backgrounded_block">
--- /dev/null
+ <div class="backgrounded_block">
+ <div class="caption_v1">Řešení:</div>
+ <div class="hint_block">
+ <div class="hint_caption">
+ Koncentrace rozpuštěné soli:
+ </div>
+ <img class="math_formula_multiline" src="/images/sol_def_soluted_conc.png" alt="Koncentrace rozpuštěné soli" />
+ <img class="math_formula_multiline" src="@_WT_V_PLUG_C_RESULT_@" alt="Koncentrace rozpuštěné soli" />
+ <img class="math_formula" src="@_WT_V_PRE_RADEX_RESULT_@" alt="Koncentrace rozpuštěné soli" />
+ <img class="math_formula" src="@_WT_V_DISS_C_RESULT_@" alt="Koncentrace rozpuštěné soli" />
+ </div>
+
+ <div class="hint_block">
+ <div class="hint_caption">
+ Objem, ve kterém se dané množství soli práve zcela rozpustí:
+ </div>
+ <img class="math_formula_multiline" src="/images/sol_volume.png" alt="Objem" />
+ <img class="math_formula_multiline" src="@_WT_V_PLUG_VOLUME_RESULT_@" alt="Objem" />
+ </div>
+
+ <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>
homedir="`pwd`" || exit 1
if test -n "`type -p mktemp`" ; then
- tmpdir=`mktemp ${homedir}/tmp/tex2imXXXXXX`
+ tmpdir=`mktemp ${homedir}/tmp/tex2imXXXXXX` || exit 1
rm $tmpdir
mkdir $tmpdir
else
--- /dev/null
+V = @_WT_RES_INT_@,@_WT_RES_DEC_@ \cdot 10^{@_WT_RES_EXP_@}~\si{\cubic\deci\metre}
--- /dev/null
+c = @_WT_DC_INT_@,@_WT_DC_DEC_@ \cdot 10^{@_WT_DC_EXP_@}~\si{\mol\per\cubic\deci\metre}
--- /dev/null
+c = \sqrt[@_WT_M_@ + @_WT_N_@]{\frac{@_WT_KS_INT_@,@_WT_KS_DEC_@ \cdot 10^{@_WT_KS_EXP_@}}{@_WT_M_@^@_WT_M_@ @_WT_N_@^@_WT_N_@}}~\si{\mol\per\cubic\deci\metre}
--- /dev/null
+V = \frac{@_WT_G_INT_@,@_WT_G_DEC_@}{@_WT_MW_INT_@,@_WT_MW_DEC_@ \cdot @_WT_DC_INT_@,@_WT_DC_DEC_@ \cdot 10^{@_WT_DC_EXP_@}}~\si{\cubic\deci\metre}
--- /dev/null
+c = \sqrt[@_WT_MPN_@]{@_WT_KDMN_INT_@,@_WT_KDMN_DEC_@ \cdot 10^{@_WT_KDMN_EXP_@}}~\si{\mol\per\cubic\deci\metre}
return OK;
end Add_Walkthrough_Acidobazic;
+ function Add_Walkthrough_Solubility_V_FROM_G_KS(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.Solubility_Suite;
+ use Problem_Generator_Syswides.Walkthrough_Info;
+
+ WTrans: Translate_Set;
+ HTML: HTML_Code;
+ begin
+ if Walkthrough.Find(WT_V_PLUG_C_RESULT_KEY) = Walkthrough_Info.No_Element then
+ return E_INVAL;
+ end if;
+ Insert(WTrans, Assoc(WT_V_PLUG_C_RESULT_KEY, Walkthrough.Element(WT_V_PLUG_C_RESULT_KEY)));
+
+ if Walkthrough.Find(WT_V_PRE_RADEX_RESULT_KEY) = Walkthrough_Info.No_Element then
+ return E_INVAL;
+ end if;
+ Insert(WTrans, Assoc(WT_V_PRE_RADEX_RESULT_KEY, Walkthrough.Element(WT_V_PRE_RADEX_RESULT_KEY)));
+
+ if Walkthrough.Find(WT_V_DISS_C_RESULT_KEY) = Walkthrough_Info.No_Element then
+ return E_INVAL;
+ end if;
+ Insert(WTrans, Assoc(WT_V_DISS_C_RESULT_KEY, Walkthrough.Element(WT_V_DISS_C_RESULT_KEY)));
+
+ if Walkthrough.Find(WT_V_PLUG_VOLUME_RESULT_KEY) = Walkthrough_Info.No_Element then
+ return E_INVAL;
+ end if;
+ Insert(WTrans, Assoc(WT_V_PLUG_VOLUME_RESULT_KEY, Walkthrough.Element(WT_V_PLUG_VOLUME_RESULT_KEY)));
+
+ 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_solubility_vksgmw.html", Translations => WTrans);
+ Insert(Translations, Assoc(WALKTHROUGH_SECTION_KEY, HTML_To_Fixed_String(HTML)));
+ return OK;
+ end Add_Walkthrough_Solubility_V_FROM_G_KS;
+
function Generate_Face_Acidobazic(Mode: in Display_Mode;
Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
Answer_Message: in UB_Text;
P_Subtype: UB_Text;
begin
+ P_Subtype := To_UB_Text(Parameters.Element(Solubility_Suite.PARAMETER_PROBLEM_SUBTYPE_KEY));
Insert(Translations_Hdr, Assoc(HEADER_CAPTION_KEY, "< " & Solubility_Suite.PROBLEM_NAME_READABLE));
HTML := Parse(Filename => "templates/header.html", Translations => Translations_Hdr);
-- Add JavaScripts
case Mode is
when Answer_Mode =>
Add_Answer_Section(Translations, Answer_Message, Answer_Code);
+ when Walkthrough_Mode =>
+ declare
+ Ret: RetCode;
+ begin
+ if P_Subtype = Solubility_Suite.PROBLEM_SUBTYPE_V_FROM_G_KS then
+ Ret := Add_Walkthrough_Solubility_V_FROM_G_KS(Translations, Walkthrough);
+ else
+ return E_NOTIMPL;
+ end if;
+
+ if Ret /= OK then
+ return Ret;
+ end if;
+ end;
when others =>
null;
end case;
-- This parameter must be always present
return E_INVAL;
end if;
- P_Subtype := To_UB_Text(Parameters.Element(Solubility_Suite.PARAMETER_PROBLEM_SUBTYPE_KEY));
Insert(Translations_Params, Assoc(Solubility_Suite.PARAMETER_PROBLEM_SUBTYPE_KEY, Solubility_Suite.PARAMETER_PROBLEM_SUBTYPE_KEY));
Insert(Translations_Params, Assoc(Solubility_Suite.PROBLEM_SUBTYPE_V_FROM_G_KS, Solubility_Suite.PROBLEM_SUBTYPE_V_FROM_G_KS));
Insert(Translations_Params, Assoc(Solubility_Suite.PROBLEM_SUBTYPE_KS_FROM_G_V, Solubility_Suite.PROBLEM_SUBTYPE_KS_FROM_G_V));
function Add_Walkthrough_Acidobazic(Translations: in out AWS.Templates.Translate_Set;
Walkthrough: in Problem_Generator_Syswides.Walkthrough_Info.Map) return RetCode;
+
+ function Add_Walkthrough_Solubility_V_FROM_G_KS(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;
function Error_Display_Walkthrough return HTML_Code is
use AWS.Templates;
begin
- return Parse(Filename => "templates/static/error_display_answer.html");
+ return Parse(Filename => "templates/static/error_display_walkthrough.html");
end Error_Display_Walkthrough;
function Error_UID_Registration return HTML_Code is
return ((Problem.Kx * Problem.cX) ** (0.5)) / Problem.cX;
end Walkthrough_Check_Dissociation;
- -- Destructor
- overriding procedure Finalize(Problem: in out Acidobazic_Problem) is
- begin
- Problem.Free_Tracked_Resources;
- end Finalize;
-
end Acidobazic_Suite;
begin
Problem := new Solubility_Problem;
Problem.Parameters := Solubility_Parameters'(Ionic_Strength => False, P_Subtype => V_FROM_G_KS);
+ Problem.Walkthrough_Generated := False;
return Problem;
end;
-- This parameter must be always present
return E_INVAL;
end if;
-
+
return OK;
end Set_Parameters;
DC_Dec_Str: UB_Text;
DC_Exp_Str: UB_Text;
- M_Int: Integer := Integer(Problem.Prob_Data.M);
- N_Int: Integer := Integer(Problem.Prob_Data.N);
- Final_Trans: Translate_Set;
+ M_Int: constant Integer := Integer(Problem.Prob_Data.M);
+ N_Int: constant Integer := Integer(Problem.Prob_Data.N);
TeXCode: UB_Text;
Ret: RetCode;
begin
+ if Problem.Walkthrough_Generated then
+ Walkthrough := Problem.Walkthrough_Stored;
+ return OK;
+ end if;
-- Init multicontext data
FH.Split_Integer_Decimal_Exponent_Strs(Diss_C, DECIMALS, DC_Int_Str, DC_Dec_Str, DC_Exp_Str);
-- Plug the numbers into the raw equation for dissolved concentration
declare
- M_Str: String := Integer'Image(M_Int);
- N_Str: String := Integer'Image(N_Int);
+ M_Str: constant String := Integer'Image(M_Int);
+ N_Str: constant String := Integer'Image(N_Int);
Ks_Int_Str: UB_Text;
Ks_Dec_Str: UB_Text;
Ks_Exp_Str: UB_Text;
Insert(Trans, Assoc(WT_M_KEY, M_Str));
Insert(Trans, Assoc(WT_N_KEY, N_Str));
- TeXCode := Parse(Filename => WT_T_PREFIX & "v_plug_numbers.ttex", Translations => Trans);
- Ret := TeX_To_PNG(TeXCode, WT_F_V_PLUGNUMS, Problem.Resource_Prefix);
+ TeXCode := Parse(Filename => WT_T_PREFIX & "v_plug_c.ttex", Translations => Trans);
+ Ret := TeX_To_PNG(TeXCode, WT_F_V_PLUG_C, Problem.Resource_Prefix);
if Ret /= OK then
return Ret;
end if;
- Problem.Add_Tracked_Resource(WT_F_V_PLUGNUMS & WT_F_EXTENSION);
- Insert(Final_Trans, Assoc(WT_V_PLUG_C_RESULT_KEY, PRP_Fixed & WT_F_V_PLUGNUMS & WT_F_EXTENSION));
+ Problem.Add_Tracked_Resource(WT_F_V_PLUG_C & WT_F_EXTENSION);
+ Walkthrough.Insert(WT_V_PLUG_C_RESULT_KEY, PRP_Fixed & WT_F_V_PLUG_C & WT_F_EXTENSION);
end;
-- Show the result just before root extraction
return Ret;
end if;
Problem.Add_Tracked_Resource(WT_F_V_PRE_RADEX & WT_F_EXTENSION);
- Insert(Final_Trans, Assoc(WT_V_PRE_RADEX_RESULT_KEY, PRP_Fixed & WT_F_V_PRE_RADEX & WT_F_EXTENSION));
+ Walkthrough.Insert(WT_V_PRE_RADEX_RESULT_KEY, PRP_Fixed & WT_F_V_PRE_RADEX & WT_F_EXTENSION);
end;
-- Dissolved concentration
Insert(Trans, Assoc(WT_DC_EXP_KEY, DC_Exp_Str));
TeXCode := Parse(Filename => WT_T_PREFIX & "v_diss_c.ttex", Translations => Trans);
- Ret := TeX_To_PNG(TeXCode, WT_F_V_PRE_RADEX, Problem.Resource_Prefix);
+ Ret := TeX_To_PNG(TeXCode, WT_F_V_DISS_C, Problem.Resource_Prefix);
if Ret /= OK then
return Ret;
end if;
Problem.Add_Tracked_Resource(WT_F_V_DISS_C & WT_F_EXTENSION);
- Insert(Final_Trans, Assoc(WT_V_DISS_C_RESULT_KEY, PRP_Fixed & WT_F_V_PRE_RADEX & WT_F_EXTENSION));
+ Walkthrough.Insert(WT_V_DISS_C_RESULT_KEY, PRP_Fixed & WT_F_V_DISS_C & WT_F_EXTENSION);
end;
-- Plug the numbers into the volume calculation
Trans: Translate_Set;
begin
FH.Split_Integer_Decimal_Unscaled_Strs(Problem.Prob_Data.V_G, DECIMALS, G_Int_Str, G_Dec_Str);
- FH.Split_Integer_Decimal_Unscaled_Strs(Problem.Prob_Data.V_MW, DECIMALS, MW_Int_Str, MW_Dec_Str);
+ FH.Split_Integer_Decimal_Unscaled_Strs(Problem.Prob_Data.V_MW, DECIMALS_MW, MW_Int_Str, MW_Dec_Str);
Insert(Trans, Assoc(WT_G_INT_KEY, G_Int_Str));
Insert(Trans, Assoc(WT_G_DEC_KEY, G_Dec_Str));
Insert(Trans, Assoc(WT_DC_DEC_KEY, DC_Dec_Str));
Insert(Trans, Assoc(WT_DC_EXP_KEY, DC_Exp_Str));
- TeXCode := Parse(Filename => WT_T_PREFIX & "v_volume_plug.ttex", Translations => Trans);
- Ret := TeX_To_PNG(TeXCode, WT_F_V_PLUG, Problem.Resource_Prefix);
+ TeXCode := Parse(Filename => WT_T_PREFIX & "v_plug_volume.ttex", Translations => Trans);
+ Ret := TeX_To_PNG(TeXCode, WT_F_V_PLUG_VOLUME, Problem.Resource_Prefix);
if Ret /= OK then
return Ret;
end if;
- Problem.Add_Tracked_Resource(WT_F_V_PLUG & WT_F_EXTENSION);
- Insert(Final_Trans, Assoc(WT_V_PLUG_VOLUME_RESULT_KEY, PRP_Fixed & WT_F_V_PLUG & WT_F_EXTENSION));
+ Problem.Add_Tracked_Resource(WT_F_V_PLUG_VOLUME & WT_F_EXTENSION);
+ Walkthrough.Insert(WT_V_PLUG_VOLUME_RESULT_KEY, PRP_Fixed & WT_F_V_PLUG_VOLUME & WT_F_EXTENSION);
end;
-- Display the final result
return Ret;
end if;
Problem.Add_Tracked_Resource(WT_F_ANSWER & WT_F_EXTENSION);
- Insert(Final_Trans, Assoc(WT_ANSWER_RESULT_KEY, PRP_Fixed & WT_F_ANSWER & WT_F_EXTENSION));
+ Walkthrough.Insert(WT_FINAL_RESULT_KEY, PRP_Fixed & WT_F_ANSWER & WT_F_EXTENSION);
end;
+ Problem.Walkthrough_Generated := True;
return OK;
end Gen_Walkthrough_V_FROM_G_KS;
begin
return OK;
end Set_Parameters;
-
- overriding procedure Finalize(Problem: in out Titration_Curve_Problem) is
- begin
- Free_Tracked_Resources(Problem);
- end Finalize;
-- END: Inherited functions
-- BEGIN: Private functions
Problem.Resource_Prefix := Ada.Strings.Unbounded.To_Unbounded_String(Prefix);
end Set_Resource_Prefix;
+ procedure Finalize(Problem: in out Chem_Problem) is
+ begin
+ Free_Tracked_Resources(Problem);
+ end Finalize;
+
package body Acidobazic_Suite is separate;
package body Solubility_Suite is separate;
package body Titration_Curve_Suite is separate;
procedure New_Problem(Problem: in out Chem_Problem) is abstract;
function Set_Parameters(Problem: in out Chem_Problem; Parameters: in Parameters_Info.Map) return RetCode is abstract;
procedure Set_Resource_Prefix(Problem: in out Chem_Problem; Prefix: in String);
+ --
function Get_Problem(P_Type: in Problem_Type) return access Chem_Problem'Class;
private
record
Resource_Prefix: Ada.Strings.Unbounded.Unbounded_String;
TRL: Resource_List.List;
+ Walkthrough_Generated: Boolean;
+ Walkthrough_Stored: Problem_Generator_Syswides.Walkthrough_Info.Map;
end record;
procedure Add_Tracked_Resource(Problem: in out Chem_Problem; Name: in String);
procedure Free_Tracked_Resources(Problem: in out Chem_Problem);
+ procedure Finalize(Problem: in out Chem_Problem);
WT_F_EXTENSION: constant String := ".png";
WALKTHROUGH_TEMPLATES_PATH: constant String := "walkthrough_templates/";
function Get_Parameters(Problem: in out Acidobazic_Problem; Parameters: out Parameters_Info.Map) return RetCode;
function Get_Walkthrough(Problem: in out Acidobazic_Problem; Walkthrough: out Walkthrough_Info.Map) return RetCode;
function Set_Parameters(Problem: in out Acidobazic_Problem; Parameters: in Parameters_Info.Map) return RetCode;
- overriding procedure Finalize(Problem: in out Acidobazic_Problem);
private
type pH_Float is digits 15;
Parameters: Acidobazic_Parameters;
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;
WT_T_PREFIX: constant String := WALKTHROUGH_TEMPLATES_PATH & "solubility_suite/";
WT_F_ANSWER: constant String := "answer";
WT_F_V_DISS_C: constant String := "v_diss_c";
- WT_F_V_PLUGNUMS: constant String := "v_plug_nums";
+ WT_F_V_PLUG_C: constant String := "v_plug_c";
WT_F_V_PRE_RADEX: constant String := "v_pre_radex";
- WT_F_V_PLUG: constant String := "v_plug";
+ WT_F_V_PLUG_VOLUME: constant String := "v_plug_volume";
--
WT_DC_INT_KEY: constant String := "WT_DC_INT";
WT_DC_DEC_KEY: constant String := "WT_DC_DEC";
WT_M_KEY: constant String := "WT_M";
WT_N_KEY: constant String := "WT_N";
WT_MPN_KEY: constant String := "WT_MPN";
- WT_MW_INT_KEY: constant String := "WT_MW_INT_KEY";
- WT_MW_DEC_KEY: constant String := "WT_MW_DEC_KEY";
- WT_RES_INT_KEY: constant String := "WT_RES_INT_KEY";
- WT_RES_DEC_KEY: constant String := "WT_RES_DEC_KEY";
- WT_RES_EXP_KEY: constant String := "WT_RES_EXP_KEY";
+ WT_MW_INT_KEY: constant String := "WT_MW_INT";
+ WT_MW_DEC_KEY: constant String := "WT_MW_DEC";
+ WT_RES_INT_KEY: constant String := "WT_RES_INT";
+ WT_RES_DEC_KEY: constant String := "WT_RES_DEC";
+ WT_RES_EXP_KEY: constant String := "WT_RES_EXP";
end Solubility_Suite;
function Get_Walkthrough(Problem: in out Titration_Curve_Problem; Walkthrough: out Walkthrough_Info.Map) return RetCode;
procedure New_Problem(Problem: in out Titration_Curve_Problem);
function Set_Parameters(Problem: in out Titration_Curve_Problem; Parameters: in Parameters_Info.Map) return RetCode;
- overriding procedure Finalize(Problem: in out Titration_Curve_Problem);
private
Math_Limitation: exception;
RESERVED_PROBLEM_ID_VAL_KEY: constant String := "RESERVED__PROBLEM_ID_VAL";
RESERVED_PROBLEM_CATEGORY_KEY: constant String := "RESERVED__PROBLEM_CATEGORY";
RESERVED_PROBLEM_CATEGORY_VAL_KEY: constant String := "RESERVED__PROBLEM_CATEGORY_VAL";
+ --
+ WT_FINAL_RESULT_KEY: constant String := "WT_FINAL_RESULT";
package Acidobazic_Suite is
-- What effect to ignore in calculations?
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";
--
FILLIN_ANSWER_KEY: constant String := "FILLIN_ANSWER";
--
- WT_ANSWER_RESULT_KEY: constant String := "WT_ANSWER_RESULT_KEY";
- WT_V_DISS_C_RESULT_KEY: constant String := "WT_V_DISS_C_RESULT_KEY";
+ WT_V_DISS_C_RESULT_KEY: constant String := "WT_V_DISS_C_RESULT";
WT_V_PLUG_C_RESULT_KEY: constant String := "WT_V_PLUG_C_RESULT";
WT_V_PLUG_VOLUME_RESULT_KEY: constant String := "WT_V_PLUG_VOLUME_RESULT";
WT_V_PRE_RADEX_RESULT_KEY: constant String := "WT_V_PRE_RADEX_RESULT";