-- Add submit section
-- - Mandatory parameters
- Insert(Translations_Submit, Assoc(RESERVED_PROBLEM_ID_KEY, Pr_ID));
+ Insert(Translations_Submit, Assoc(RESERVED_PROBLEM_ID_KEY, RESERVED_PROBLEM_ID_KEY));
Insert(Translations_Submit, Assoc(RESERVED_PROBLEM_ID_VAL_KEY, Pr_ID));
--
Temp := Parse(Filename => "templates/face_solubility_submit.html", Translations => Translations_Submit);
-- Add parameters section
-- - Mandatory parameters
- Insert(Translations_Params, Assoc(RESERVED_PROBLEM_CATEGORY_KEY, Pr_Cat));
- Insert(Translations, Assoc(RESERVED_PROBLEM_CATEGORY_VAL_KEY, Pr_Cat));
+ Insert(Translations_Params, Assoc(RESERVED_PROBLEM_CATEGORY_KEY, RESERVED_PROBLEM_CATEGORY_KEY));
+ Insert(Translations_Params, Assoc(RESERVED_PROBLEM_CATEGORY_VAL_KEY, Pr_Cat));
--
Insert(Translations_Params, Assoc(Solubility_Suite.PARAMETER_IONIC_STRENGTH_KEY, Solubility_Suite.PARAMETER_IONIC_STRENGTH_KEY));
if Parameters.Find(Solubility_Suite.PARAMETER_IONIC_STRENGTH_KEY) /= Parameters_Info.No_Element then
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Strings.Fixed;
+with Ada.Strings.Unbounded;
--with Ada.Text_IO;
package body Formatting_Helpers is
-
- function Get_Decimal_Part_Flt(Num: in FH_Float) return FH_Float is
- package FHEF is new Ada.Numerics.Generic_Elementary_Functions(FH_Float);
- use FHEF;
-
- Log_Arg_Floored: FH_Float;
- begin
- Log_Arg_Floored := FH_Float'Floor(FHEF.Log(Base => 10.0, X => Num));
-
- return ((10.0 ** Log_Arg_Floored) - 1.0) / Log_Arg_Floored;
- end Get_Decimal_Part_Flt;
-
- function Get_Integer_Part_Int(Num: in FH_Float) return Integer is
- package FHEF is new Ada.Numerics.Generic_Elementary_Functions(FH_Float);
- use FHEF;
-
- Log_Arg_Floored: FH_Float;
- Scaled: FH_Float;
- begin
- Log_Arg_Floored := FH_Float'Floor(FHEF.Log(Base => 10.0, X => Num));
- Scaled := Num / Log_Arg_Floored;
-
- return Integer(Scaled - Get_Decimal_Part_Flt(Num));
- end Get_Integer_Part_Int;
-
+
function String_To_Float(S: in String) return FH_Float is
Idx: Natural;
SS: String := S;
end if;
begin
- return FH_Float'Value(S);
+ return FH_Float'Value(SS);
exception
when Constraint_Error =>
raise Constraint_Error;
package FHEF is new Ada.Numerics.Generic_Elementary_Functions(FH_Float);
use FHEF;
- F_Log_Num: constant FH_Float := FH_Float'Floor(FHEF.Log(Base => 10.0, X => Num));
- F_Log_Dec: constant FH_Float := FH_Float'Floor(FHEF.Log(Base => 10.0, X => Decimals));
- Shift: FH_Float;
- TNum: FH_Float;
+ Log_Arg_Floor: FH_Float;
+ Temp: FH_Float;
begin
- Shift := 10.0 ** (F_Log_Num - F_Log_Dec);
- TNum := FH_Float'Rounding(Num / Shift) * Shift;
-
- --Ada.Text_IO.Put_Line("FLN: " & FH_Float'Image(F_Log_Num) & " FLD: " & FH_Float'Image(F_Log_Dec) & " S: " & FH_Float'Image(Shift) & " Res: " & FH_Float'Image(TNum));
- return TNum;
+ Log_Arg_Floor := FH_Float'Floor(Log(Base => 10.0, X => Num));
+ Temp := Num / (10.0 ** Log_Arg_Floor);
+ Temp := FH_Float'Rounding(Temp * (Decimals / 10.0));
+ return (Temp / (Decimals / 10.0)) * (10.0 ** Log_Arg_Floor);
end Round_To_Valid_Nums;
-
- procedure Split_Integer_Decimal_Strs(Num: in FH_Float; Decimals: in FH_Float; Integer_Part: out UB_Text; Decimal_Part: out UB_Text) is
- I: Integer;
- D: Integer;
+
+ procedure Split_Integer_Decimal_Unscaled_Strs(Num: in FH_Float; Decimals: in FH_Float; Integer_Part: out UB_Text; Decimal_Part: out UB_Text) is
+ Integer_Part_F: FH_Float;
+ Decimal_Part_F: FH_Float;
+ Decimal_Part_I: Integer;
+ begin
+ Integer_Part_F := FH_Float'Floor(Num);
+ Decimal_Part_F := (Num - Integer_Part_F) * Decimals;
+ Decimal_Part_I := Integer(Decimal_Part_F);
+
+ Integer_Part := To_UB_Text(Ada.Strings.Fixed.Trim(Source => Integer'Image(Integer(Integer_Part_F)), Side => Ada.Strings.Left));
+ Decimal_Part := To_UB_Text(Ada.Strings.Fixed.Trim(Source => Integer'Image(Decimal_Part_I), Side => Ada.Strings.Left));
+ Prepend_Zeros_To_Text(Decimal_Part_F, Decimals, Decimal_Part);
+ end Split_Integer_Decimal_Unscaled_Strs;
+
+ procedure Split_Integer_Decimal_Exponent_Nums(Num: in FH_Float; Decimals: in FH_Float; Integer_Part: out Integer; Decimal_Part: out FH_Float; Exponent_Part: out Integer) is
+ package FHEF is new Ada.Numerics.Generic_Elementary_Functions(FH_Float);
+ use FHEF;
+
+ Expanded: FH_Float;
+ Integer_Part_F: FH_Float;
+ Log_Arg_Floored: FH_Float;
begin
- Split_Integer_Decimal_Ints(Num, Decimals, I, D);
+ if Num = 0.0 then
+ Integer_Part := 0;
+ Decimal_Part := 0.0;
+ Exponent_Part := 0;
+ return;
+ end if;
+
+ Log_Arg_Floored := FH_Float'Floor(Log(Base => 10.0, X => Num));
+ Expanded := 10.0 ** Log_Arg_Floored;
+
+ Integer_Part_F := FH_Float'Floor(Num / Expanded);
+ Decimal_Part := ((Num - (Integer_Part_F * Expanded)) / Expanded) * Decimals;
- Integer_Part := To_UB_Text(Integer'Image(I));
- Get_Decimal_Part_Str(Decimal_Part, D, Decimals);
+ Exponent_Part := Integer(Log_Arg_Floored);
+ Integer_Part := Integer(Integer_Part_F);
- --Ada.Text_IO.Put_Line("I: " & Integer'Image(I) & " D: " & Integer'Image(D) & " Num: " & FH_Float'Image(Num));
- end Split_Integer_Decimal_Strs;
+ --Ada.Text_IO.Put_Line(FH_Float'Image(Num) & " --- " & Integer'Image(Integer_Part) & "," & FH_Float'Image(Decimal_Part) & "e" & Integer'Image(Exponent_Part));
+ end Split_Integer_Decimal_Exponent_Nums;
procedure Split_Integer_Decimal_Exponent_Strs(Num: in FH_Float; Decimals: in FH_Float; Integer_Part: out UB_Text; Decimal_Part: out UB_Text;
Exponent_Part: out UB_Text) is
package FHEF is new Ada.Numerics.Generic_Elementary_Functions(FH_Float);
use FHEF;
- FE: FH_Float;
- TNum: FH_Float;
+ Integer_Part_I: Integer;
+ Decimal_Part_F: FH_Float;
+ Decimal_Part_I: Integer;
+ Exponent_Part_I: Integer;
begin
- --Ada.Text_IO.Put_Line("Num: " & FH_Float'Image(Num));
- FE := FH_Float'Floor(FHEF.Log(Base => 10.0, X => Num));
- --Ada.Text_IO.Put_Line("Exp: " & FH_Float'Image(FE));
- TNum := Num / (10.0 ** FE);
-
- Split_Integer_Decimal_Strs(TNum, Decimals, Integer_Part, Decimal_Part);
- Append_UB_Text(Exponent_Part, To_UB_Text(Integer'Image(Integer(FE))));
+ Split_Integer_Decimal_Exponent_Nums(Num, Decimals, Integer_Part_I, Decimal_Part_F, Exponent_Part_I);
+ Decimal_Part_I := Integer(Decimal_Part_F);
+ Integer_Part := To_UB_Text(Ada.Strings.Fixed.Trim(Source => Integer'Image(Integer_Part_I), Side => Ada.Strings.Left));
+ Decimal_Part := To_UB_Text(Ada.Strings.Fixed.Trim(Source => Integer'Image(Decimal_Part_I), Side => Ada.Strings.Left));
+ Prepend_Zeros_To_Text(Decimal_Part_F, Decimals, Decimal_Part);
+ Exponent_Part := To_UB_Text(Ada.Strings.Fixed.Trim(Source => Integer'Image(Exponent_Part_I), Side => Ada.Strings.Left));
end Split_Integer_Decimal_Exponent_Strs;
-- BEGIN: Private functions
- procedure Get_Decimal_Part_Str(Decimal_Part: out UB_Text; D: in Integer; Decimals: in FH_Float) is
- Pos: Integer := Integer(Decimals) / 10;
- begin
- while Pos > 1 loop
- if D < Pos then
- Append_UB_Text(Decimal_Part, To_UB_Text("0"));
- else
- exit;
- end if;
- Pos := Pos / 10;
- end loop;
- Append_UB_Text(Decimal_Part, To_UB_Text(Ada.Strings.Fixed.Trim(Integer'Image(D), Ada.Strings.Left)));
- end Get_Decimal_Part_Str;
+ procedure Prepend_Zeros_To_Text(Num: in FH_Float; Decimals: in FH_Float; Text: in out UB_Text) is
+ package FHEF is new Ada.Numerics.Generic_Elementary_Functions(FH_Float);
+ use Ada.Strings.Unbounded;
+ use FHEF;
- procedure Split_Integer_Decimal_Ints(Num: in FH_Float; Decimals: in FH_Float; I: out Integer; D: out Integer) is
+ Log_Dec: constant FH_Float := Log(Base => 10.0, X => Decimals);
+ Log_Num: FH_Float;
+ Diff: Integer;
+ Zero_String: UB_Text;
begin
- I := Integer(FH_Float'Floor(Num));
- D := Integer(FH_Float'Rounding((Num - FH_Float(I)) * Decimals));
- end Split_Integer_Decimal_Ints;
+ if Num = 0.0 then
+ Log_Num := 1.0;
+ else
+ Log_Num := FH_Float'Ceiling(Log(Base => 10.0, X => Num));
+ end if;
+ Diff := Integer(Log_Dec - Log_Num);
+ if Diff = 0 then
+ return;
+ end if;
+
+ for I in 1 .. Diff loop
+ Append_UB_Text(Source => Zero_String, New_Item => "0");
+ end loop;
+
+ Append_UB_Text(Source => Zero_String, New_Item => Text);
+ Text := Zero_String;
+ end Prepend_Zeros_To_Text;
end Formatting_Helpers;
type FH_Float is digits <>;
package Formatting_Helpers is
- function Get_Decimal_Part_Flt(Num: in FH_Float) return FH_Float;
- function Get_Integer_Part_Int(Num: in FH_Float) return Integer;
function String_To_Float(S: in String) return FH_Float;
function Round_To_Valid_Nums(Num: in FH_Float; Decimals: FH_Float) return FH_Float;
- procedure Split_Integer_Decimal_Strs(Num: in FH_Float; Decimals: in FH_Float; Integer_Part: out UB_Text; Decimal_Part: out UB_Text);
+ procedure Split_Integer_Decimal_Unscaled_Strs(Num: in FH_Float; Decimals: in FH_Float; Integer_Part: out UB_Text; Decimal_Part: out UB_Text);
+ procedure Split_Integer_Decimal_Exponent_Nums(Num: in FH_Float; Decimals: in FH_Float; Integer_Part: out Integer; Decimal_Part: out FH_Float;
+ Exponent_Part: out Integer);
procedure Split_Integer_Decimal_Exponent_Strs(Num: in FH_Float; Decimals: in FH_Float; Integer_Part: out UB_Text; Decimal_Part: out UB_Text;
Exponent_Part: out UB_Text);
private
- procedure Get_Decimal_Part_Str(Decimal_Part: out UB_Text; D: Integer; Decimals: in FH_Float);
- procedure Split_Integer_Decimal_Ints(Num: in FH_Float; Decimals: in FH_Float; I: out Integer; D: out Integer);
+ procedure Prepend_Zeros_To_Text(Num: in FH_Float; Decimals: in FH_Float; Text: in out UB_Text);
end Formatting_Helpers;
begin
Pr_ID := Problem_ID'Value(Answer.Element(Problem_Generator_Syswides.RESERVED_PROBLEM_ID_KEY));
- Ada.Text_IO.Put_Line("Got problem ID " & Problem_ID'Image(Pr_ID));
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line("Invalid problem ID value");
end if;
declare
- pH_Answered_S: String := Answer.Element(ANSWER_PH_KEY);
- Idx: Natural;
+ pH_Answered_S: constant String := Answer.Element(ANSWER_PH_KEY);
begin
- -- Replace "," with "." as decimal seaprator
- Idx := Ada.Strings.Fixed.Index(Source => pH_Answered_S, Pattern => ",", From => 1);
- if Idx > 0 then
- Ada.Strings.Fixed.Replace_Slice(Source => pH_Answered_S, Low => Idx, High => Idx, By => ".");
- end if;
- pH_Answered := pH_Float'Value(pH_Answered_S);
+ pH_Answered := FH.String_To_Float(pH_Answered_S);
exception
when Constraint_Error =>
Message := To_UB_Text("Nesprávně zadaná hodnota pH");
Int_S: UB_Text;
Dec_S: UB_Text;
begin
- FH.Split_Integer_Decimal_Strs(pH, Decimals, Int_S, Dec_S);
+ FH.Split_Integer_Decimal_Unscaled_Strs(pH, Decimals, Int_S, Dec_S);
Message := To_UB_Text("Nesprávná odpověď. (pH vypočtené programem = ");
Append_UB_Text(Source => Message, New_Item => Int_S);
Append_UB_Text(Source => Message, New_Item => To_UB_Text(","));
Int_S: UB_Text;
Dec_S: UB_Text;
begin
- FH.Split_Integer_Decimal_Strs(pKx, Decimals, Int_S, Dec_S);
+ FH.Split_Integer_Decimal_Unscaled_Strs(pKx, Decimals, Int_S, Dec_S);
Assignment.Insert(PKX_VALUE_INT_KEY, UB_Text_To_Fixed_String(Int_S), C, Success);
Assignment.Insert(PKX_VALUE_DEC_KEY, UB_Text_To_Fixed_String(Dec_S), C, Success);
if Success = False then
Int_Part_Calcd: Integer;
Dec_Part_Got: SS_Float;
Dec_Part_Calcd: SS_Float;
+ Exp_Part_Got: Integer;
+ Exp_Part_Calcd: Integer;
begin
Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
Guard.Lock;
return Malformed_Answer;
end;
- Int_Part_Got := Get_Integer_Part_Int(AF);
- Int_Part_Calcd := Get_Integer_Part_Int(Problem.Answer_Num);
- if Int_Part_Got /= Int_Part_Calcd then
- Get_Correct_Answer_String(Message, Problem.Parameters.P_Subtype, Problem.Answer_Num);
+ Split_Integer_Decimal_Exponent_Nums(AF, Decimals, Int_Part_Got, Dec_Part_Got, Exp_Part_Got);
+ Split_Integer_Decimal_Exponent_Nums(Problem.Answer_Num, Decimals, Int_Part_Calcd, Dec_Part_Calcd, Exp_Part_Calcd);
+
+ --Ada.Text_IO.Put_Line(SS_Float'Image(AF) & " " & Integer'Image(Int_Part_Got) & " " & SS_Float'Image(Dec_Part_Got) & " " & Integer'Image(Exp_Part_Got));
+ --Ada.Text_IO.Put_Line(SS_Float'Image(Problem.Answer_Num) & " " & Integer'Image(Int_Part_Calcd) & " " & SS_Float'Image(Dec_Part_Calcd) & " " & Integer'Image(Exp_Part_Calcd));
+
+ if Int_Part_Got /= Int_Part_Calcd or Exp_Part_Got /= Exp_Part_Calcd then
+ Message := To_UB_Text("Špatná odpověď, správný výsledek je ");
+ Get_Precise_Answer_String(Message, Problem.Parameters.P_Subtype, Problem.Answer_Num);
return Wrong_Answer;
end if;
- Dec_Part_Got := Get_Decimal_Part_Flt(AF);
- Dec_Part_Calcd := Get_Decimal_Part_Flt(Problem.Answer_Num);
-
- if Dec_Part_Calcd + PRECISION < Dec_Part_Got and Dec_Part_Calcd - PRECISION > Dec_Part_Got then
+ if (Dec_Part_Calcd + PRECISION) > Dec_Part_Got and (Dec_Part_Calcd - PRECISION) < Dec_Part_Got then
+ Message := To_UB_Text("Správná odpověď");
return Correct_Answer;
else
- Get_Correct_Answer_String(Message, Problem.Parameters.P_Subtype, Problem.Answer_Num);
+ Message := To_UB_Text("Špatná odpověď, správný výsledek je ");
+ Get_Precise_Answer_String(Message, Problem.Parameters.P_Subtype, Problem.Answer_Num);
return Wrong_Answer;
end if;
end Check_Answer;
-- Stochiometry
if (Problem.Prob_Data.M > 1.0) then
- Assignment.Insert(X_STOCHIO_KEY, Stochiometric_Count'Image(Stochiometric_Count(Problem.Prob_Data.M)));
+ Assignment.Insert(X_STOCHIO_KEY, Ada.Strings.Fixed.Trim(Source => Stochiometric_Count'Image(Stochiometric_Count(Problem.Prob_Data.M)), Side => Ada.Strings.Left));
else
Assignment.Insert(X_STOCHIO_KEY, "");
end if;
if (Problem.Prob_Data.N > 1.0) then
- Assignment.Insert(Z_STOCHIO_KEY, Stochiometric_Count'Image(Stochiometric_Count(Problem.Prob_Data.N)));
+ Assignment.Insert(Z_STOCHIO_KEY, Ada.Strings.Fixed.Trim(Stochiometric_Count'Image(Stochiometric_Count(Problem.Prob_Data.N)), Side => Ada.Strings.Left));
else
Assignment.Insert(Z_STOCHIO_KEY, "");
end if;
MW_Str_Int: UB_Text;
MW_Str_Dec: UB_Text;
begin
- Split_Integer_Decimal_Strs(Problem.Prob_Data.V_G, DECIMALS, G_Str_Int, G_Str_Dec);
- Split_Integer_Decimal_Strs(Problem.Prob_Data.V_MW, DECIMALS_MW, MW_Str_Int, MW_Str_Dec);
+ Split_Integer_Decimal_Unscaled_Strs(Problem.Prob_Data.V_G, DECIMALS, G_Str_Int, G_Str_Dec);
+ Split_Integer_Decimal_Unscaled_Strs(Problem.Prob_Data.V_MW, DECIMALS_MW, MW_Str_Int, MW_Str_Dec);
Split_Integer_Decimal_Exponent_Strs(Problem.Prob_Data.V_Ks, DECIMALS, Ks_Str_Int, Ks_Str_Dec, Ks_Str_Exp);
Assignment.Insert(SAMPLE_WEIGHT_INT_KEY, UB_Text_To_Fixed_String(G_Str_Int));
V_Str_Dec: UB_Text;
V_Str_Exp: UB_Text;
begin
- Split_Integer_Decimal_Strs(Problem.Prob_Data.Ks_G, DECIMALS, G_Str_Int, G_Str_Dec);
- Split_Integer_Decimal_Strs(Problem.Prob_Data.Ks_MW, DECIMALS_MW, MW_Str_Int, MW_Str_Dec);
+ Split_Integer_Decimal_Unscaled_Strs(Problem.Prob_Data.Ks_G, DECIMALS, G_Str_Int, G_Str_Dec);
+ Split_Integer_Decimal_Unscaled_Strs(Problem.Prob_Data.Ks_MW, DECIMALS_MW, MW_Str_Int, MW_Str_Dec);
Split_Integer_Decimal_Exponent_Strs(Problem.Prob_Data.Ks_V, DECIMALS, V_Str_Int, V_Str_Dec, V_Str_Exp);
Assignment.Insert(SAMPLE_WEIGHT_INT_KEY, UB_Text_To_Fixed_String(G_Str_Int));
G := Round_To_Valid_Nums(G, DECIMALS);
Ks := Round_To_Valid_Nums(Generate_Solubility_Product, DECIMALS);
MW := (SS_Float(Random(Gen => Float_RGen)) * MOLAR_WEIGHT_RANGE) + MOLAR_WEIGHT_MIN;
- MW := Round_To_Valid_Nums(MW, DECIMALS_MW);
+ MW := SS_Float'Rounding(MW * DECIMALS_MW) / DECIMALS_MW;
Prob_Data := (Option => V_FROM_G_KS,
M => SS_Float(M), N => SS_Float(N),
V_G => G, V_Ks => Ks, V_MW => MW);
G := (SS_Float(Random(Gen => Float_RGen)) * SAMPLE_WEIGHT_RANGE) + SAMPLE_WEIGHT_MIN;
G := Round_To_Valid_Nums(G, DECIMALS);
MW := (SS_Float(Random(Gen => Float_RGen)) * MOLAR_WEIGHT_RANGE) + MOLAR_WEIGHT_MIN;
- MW := Round_To_Valid_Nums(MW, DECIMALS_MW);
+ MW := SS_Float'Rounding(MW * DECIMALS_MW) / DECIMALS_MW;
V := Round_To_Valid_Nums(Generate_Sample_Volume, DECIMALS);
Prob_Data := (Option => KS_FROM_G_V,
M => SS_Float(M), N => SS_Float(N),
I := I + (Ions(Idx).Concentration * SS_Float((Ions(Idx).Charge ** 2)));
end loop;
- return 0.5 * I;
+ I := 0.5 * I;
+ return I;
end Calculate_Ionic_Strength;
function Calculate_Sample_Volume(Prob_Data: in Solubility_Problem_Data; Ionic_Strength: in Boolean) return SS_Float is
Ions: Ion_List(1 .. 2);
begin
- Ions(1) := (Concentration => C, Charge => Prob_Data.N);
- Ions(2) := (Concentration => C, Charge => Prob_Data.M);
+ Ions(1) := (Concentration => C * Prob_Data.M, Charge => Prob_Data.N);
+ Ions(2) := (Concentration => C * Prob_Data.N, Charge => Prob_Data.M);
I := Calculate_Ionic_Strength(Ions);
GM := Calculate_Activity_Coefficient(Prob_Data.N, I);
begin
Ions_All(1) := (Concentration => Prob_Data.C_EC, Charge => 1.0);
Ions_All(2) := (Concentration => Prob_Data.C_EC, Charge => 1.0);
- Ions_All(3) := (Concentration => C, Charge => Prob_Data.N);
- Ions_All(4) := (Concentration => C, Charge => Prob_Data.M);
+ Ions_All(3) := (Concentration => C * Prob_Data.M, Charge => Prob_Data.N);
+ Ions_All(4) := (Concentration => C * Prob_Data.N, Charge => Prob_Data.M);
I_All := Calculate_Ionic_Strength(Ions_All);
GM := Calculate_Activity_Coefficient(Prob_Data.M, I_All);
Ions: Ion_List(1 .. 2);
begin
- Ions(1) := (Concentration => C, Charge => Prob_Data.N); -- Cation
- Ions(2) := (Concentration => C, Charge => Prob_Data.M); -- Anion
+ Ions(1) := (Concentration => C * Prob_Data.M, Charge => Prob_Data.N); -- Cation
+ Ions(2) := (Concentration => C * Prob_Data.N, Charge => Prob_Data.M); -- Anion
I := Calculate_Ionic_Strength(Ions);
GM := Calculate_Activity_Coefficient(M, I); -- Cation
return 10.0 ** (-R);
end Generate_Solubility_Product;
- procedure Get_Correct_Answer_String(Message: in out UB_Text; P_Subtype: in Problem_Subtype; Answer: in SS_Float) is
+ procedure Get_Precise_Answer_String(Message: in out UB_Text; P_Subtype: in Problem_Subtype; Answer: in SS_Float) is
package FH is new Formatting_Helpers(SS_Float);
use FH;
Ans_Exp_Str: UB_Text;
begin
Split_Integer_Decimal_Exponent_Strs(Answer, DECIMALS, Ans_Int_Str, Ans_Dec_Str, Ans_Exp_Str);
- Message := To_UB_Text("Špatná odpověď, hodnota správného výsledku je ");
case P_Subtype is
when V_FROM_G_KS =>
Append_UB_Text(Source => Message, New_Item => "V = ");
when KS_FROM_G_V =>
- Append_UB_Text(Source => Message, New_Item => "K<span class=""subscript""s</span> = ");
+ Append_UB_Text(Source => Message, New_Item => "K<span class=""subscript"">s</span> = ");
when C_FROM_KS_DIFFERENT_IONS | C_FROM_KS_SHARED_ION =>
Append_UB_Text(Source => Message, New_Item => "c = ");
end case;
when C_FROM_KS_DIFFERENT_IONS | C_FROM_KS_SHARED_ION =>
Append_UB_Text(Source => Message, New_Item => "mol/dm<span class=""exponent"">3</span>");
end case;
- end Get_Correct_Answer_String;
+ end Get_Precise_Answer_String;
end Solubility_Suite;
function Set_Parameters(Problem: in out Solubility_Problem; Parameters: in Parameters_Info.Map) return Boolean;
private
- type SS_Float is digits 18;
+ type SS_Float is digits 17;
subtype Stochiometric_Count is Positive range 1 .. 5;
ELECTROLYTE_CONCENTRATION_LOG_MAX: constant SS_Float := 0.176;
SAMPLE_WEIGHT_MIN: constant SS_Float := 0.1;
DECIMALS: constant SS_Float := 1.0E3;
DECIMALS_MW: constant SS_Float := 1.0E2;
- PRECISION: constant SS_Float := 1.0E-2;
+ PRECISION: constant SS_Float := 1.0E2;
type Ion is
record
function Generate_Electrolyte_Concentration return SS_Float;
function Generate_Sample_Volume return SS_Float;
function Generate_Solubility_Product return SS_Float;
- procedure Get_Correct_Answer_String(Message: in out UB_Text; P_Subtype: in Problem_Subtype; Answer: in SS_Float);
+ procedure Get_Precise_Answer_String(Message: in out UB_Text; P_Subtype: in Problem_Subtype; Answer: in SS_Float);
end Solubility_Suite;
return False;
end if;
- Ada.Text_IO.Put_Line("Checking problem ID " & Problem_ID'Image(Pr_ID));
ARC := Stored.Problem.Check_Answer(Answer, Answer_Message);
Pr_Cat := Stored.Category;
Stored.Mutex.Unlock;