package Global_Types is
type Problem_ID is new Ada.Containers.Count_Type;
- type RetCode is (OK, E_NOTFOUND, E_UNKW, E_INVAL, E_NOMEM, E_NULLPTR, E_FAIL);
+ type RetCode is (OK, E_NOTFOUND, E_UNKW, E_INVAL, E_NOMEM, E_NULLPTR, E_FAIL, E_NOTIMPL);
type Unique_ID is new Ada.Containers.Count_Type;
subtype HTML_Code is Ada.Strings.Unbounded.Unbounded_String;
subtype UB_Text is Ada.Strings.Unbounded.Unbounded_String;
package body Acidobazic_Suite is
-- BEGIN: Inherited functions
- function Create return access Acidobazic_Problem is
+ function Create return access Acidobazic_Problem is
Parameters: Acidobazic_Parameters;
Problem: access Acidobazic_Problem;
begin
end;
end Check_Answer;
- function Get_Assignment(Problem: in out Acidobazic_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode is
+ function Get_Assignment(Problem: in out Acidobazic_Problem; Assignment: in out Assignment_Info.Map) return RetCode is
C: Assignment_Info.Cursor;
Success: Boolean;
pKx: pH_Float;
return OK;
end Get_Parameters;
+ function Get_Walkthrough(Problem: in out Acidobazic_Problem; Walkthrough: out Walkthrough_Info.Map) return RetCode is
+ begin
+ return E_NOTIMPL;
+ end Get_Walkthrough;
+
procedure New_Problem(Problem: in out Acidobazic_Problem) is
package Random_Substance_Type_Gen is new Ada.Numerics.Discrete_Random(Result_Subtype => Substance_Type);
return Correct_Answer;
end Check_Answer;
- function Get_Assignment(Problem: in out Solubility_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode is
+ function Get_Assignment(Problem: in out Solubility_Problem; Assignment: in out Assignment_Info.Map) return RetCode is
package FH is new Formatting_Helpers(SS_Float);
use FH;
begin
Problem.Answer_Num := Answer_Num;
end New_Problem;
+ function Get_Walkthrough(Problem: in out Solubility_Problem; Walkthrough: out Walkthrough_Info.Map) return RetCode is
+ begin
+ return E_NOTIMPL;
+ end Get_Walkthrough;
+
function Set_Parameters(Problem: in out Solubility_Problem; Parameters: in Parameters_Info.Map) return RetCode is
use Parameters_Info;
begin
return Correct_Answer;
end Check_Answer;
- function Get_Assignment(Problem: in out Titration_Curve_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode is
+ function Get_Assignment(Problem: in out Titration_Curve_Problem; Assignment: in out Assignment_Info.Map) return RetCode is
package FH is new Formatting_Helpers(T_Float);
use FH;
pKx1_Int, pKx1_Dec: UB_Text;
pKx2_Int, pKx2_Dec: UB_Text;
begin
- Problem.Resource_Prefix := Ada.Strings.Unbounded.To_Unbounded_String(Resource_Prefix);
-
Split_Integer_Decimal_Exponent_Strs(Problem.Sample_Concentration, DECIMALS, Sample_Conc_Int, Sample_Conc_Dec, Sample_Conc_Exp);
Split_Integer_Decimal_Exponent_Strs(Problem.Sample_Volume, DECIMALS, Sample_Volume_Int, Sample_Volume_Dec, Sample_Volume_Exp);
Split_Integer_Decimal_Exponent_Strs(Problem.T_Concentration, DECIMALS, Titrant_Conc_Int, Titrant_Conc_Dec, Titrant_Conc_Exp);
return OK;
end Get_Parameters;
+ function Get_Walkthrough(Problem: in out Titration_Curve_Problem; Walkthrough: out Walkthrough_Info.Map) return RetCode is
+ begin
+ return E_NOTIMPL;
+ end Get_Walkthrough;
+
procedure New_Problem(Problem: in out Titration_Curve_Problem) is
package FH is new Formatting_Helpers(T_Float);
package TFEF is new Ada.Numerics.Generic_Elementary_Functions(T_Float);
end case;
end Get_Problem;
+ procedure Set_Resource_Prefix(Problem: in out Chem_Problem; Prefix: in String) is
+ begin
+ Problem.Resource_Prefix := Ada.Strings.Unbounded.To_Unbounded_String(Prefix);
+ end Set_Resource_Prefix;
+
package body Acidobazic_Suite is separate;
package body Solubility_Suite is separate;
package body Titration_Curve_Suite is separate;
function Create return access Chem_Problem is abstract;
function Check_Answer(Problem: in out Chem_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode is abstract;
- function Get_Assignment(Problem: in out Chem_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode is abstract;
+ function Get_Assignment(Problem: in out Chem_Problem; Assignment: in out Assignment_Info.Map) return RetCode is abstract;
function Get_Parameters(Problem: in out Chem_Problem; Parameters: out Parameters_Info.Map) return RetCode is abstract;
+ function Get_Walkthrough(Problem: in out Chem_Problem; Walkthrough: out Walkthrough_Info.Map) return RetCode is abstract;
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
- type Chem_Problem is abstract limited new Ada.Finalization.Limited_Controlled with null record;
+ type Chem_Problem is abstract limited new Ada.Finalization.Limited_Controlled with
+ record
+ Resource_Prefix: Ada.Strings.Unbounded.Unbounded_String;
+ end record;
package Acidobazic_Suite is
use Problem_Generator_Syswides.Acidobazic_Suite;
-- Inherited
function Check_Answer(Problem: in out Acidobazic_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode;
procedure New_Problem(Problem: in out Acidobazic_Problem);
- function Get_Assignment(Problem: in out Acidobazic_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode;
+ function Get_Assignment(Problem: in out Acidobazic_Problem; Assignment: in out Assignment_Info.Map) return RetCode;
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;
private
-- Inherited
function Check_Answer(Problem: in out Solubility_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode;
procedure New_Problem(Problem: in out Solubility_Problem);
- function Get_Assignment(Problem: in out Solubility_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode;
+ function Get_Assignment(Problem: in out Solubility_Problem; Assignment: in out Assignment_Info.Map) return RetCode;
function Get_Parameters(Problem: in out Solubility_Problem; Parameters: out Parameters_Info.Map) return RetCode;
+ function Get_Walkthrough(Problem: in out Solubility_Problem; Walkthrough: out Walkthrough_Info.Map) return RetCode;
function Set_Parameters(Problem: in out Solubility_Problem; Parameters: in Parameters_Info.Map) return RetCode;
private
function Create return access Titration_Curve_Problem;
-- Inherited
function Check_Answer(Problem: in out Titration_Curve_Problem; Answer: in Answer_Info.Map; FillIns: in out FillIns_Map.Map; Message: out UB_Text) return Answer_RetCode;
- function Get_Assignment(Problem: in out Titration_Curve_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode;
+ function Get_Assignment(Problem: in out Titration_Curve_Problem; Assignment: in out Assignment_Info.Map) return RetCode;
function Get_Parameters(Problem: in out Titration_Curve_Problem; Parameters: out Parameters_Info.Map) return RetCode;
+ 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);
SType: Sample_Type;
pKx1: T_Float;
pKx2: T_Float;
- Resource_Prefix: Ada.Strings.Unbounded.Unbounded_String;
Sample_Volume: T_Float;
Sample_Concentration: T_Float;
T_Concentration: T_Float;
package Assignment_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String);
package FillIns_Map is new Ada.Containers.Indefinite_Ordered_Maps(String, String);
package Parameters_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String);
+ package Walkthrough_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String);
ANSWER_KIND_KEY: constant String := "ANSWER_KIND";
ANSWER_KIND_GOOD: constant String := "answer_kind_good";
end if;
begin
- Ret := Stored.Problem.Get_Assignment(Assignment, Build_Resource_Prefix(UID, Pr_Cat, Pr_ID));
+ 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);
-- Get assignment
begin
- Ret := Stored.Problem.Get_Assignment(Assignment, Build_Resource_Prefix(UID, Pr_Cat, Pr_ID));
+ 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);
Parameters: in Problem_Generator_Syswides.Parameters_Info.Map := Problem_Generator_Syswides.Parameters_Info.Empty_Map) return RetCode is
Problem: Chem_Problem_All_Access;
Storage: Stored_Problem_All_Access;
- P_Cat: Problem_Category;
+ Pr_Cat: Problem_Category;
+ Pr_ID: Problem_ID;
Ret: RetCode;
begin
if Raw_P_Cat = Problem_Manager.Problem_Category'Image(Problem_Manager.Acidobazic) then
- P_Cat := Problem_Manager.Acidobazic;
+ Pr_Cat := Problem_Manager.Acidobazic;
elsif Raw_P_Cat = Problem_Manager.Problem_Category'Image(Problem_Manager.Solubility) then
- P_Cat := Problem_Manager.Solubility;
+ Pr_Cat := Problem_Manager.Solubility;
elsif Raw_P_Cat = Problem_Manager.Problem_Category'Image(Problem_Manager.Titration_Curve) then
- P_Cat := Problem_Manager.Titration_Curve;
+ Pr_Cat := Problem_Manager.Titration_Curve;
else
return E_INVAL;
end if;
- case P_Cat is
+ case Pr_Cat is
when Acidobazic =>
Problem := Problem_Generator.Get_Problem(Problem_Generator_Syswides.Acidobazic);
when Solubility =>
Storage := new Stored_Problem;
Storage.Problem := Problem;
- Storage.Category := P_Cat;
- Active_Sessions.Add_Problem(UID, Storage, Ret);
+ Storage.Category := Pr_Cat;
+ Active_Sessions.Add_Problem(UID, Storage, Pr_ID, Ret);
if Ret /= OK then
Free_Chem_Problem(Problem);
Free_Stored_Problem(Storage);
end if;
+
+ Problem.Set_Resource_Prefix(Build_Resource_Prefix(UID, Pr_Cat, Pr_ID));
return Ret;
end Prepare_Problem;
protected body Active_Sessions is
- procedure Add_Problem(UID: in Unique_ID; Problem: in Stored_Problem_All_Access; Ret: out RetCode) is
+ procedure Add_Problem(UID: in Unique_ID; Problem: in Stored_Problem_All_Access; Pr_ID: out Problem_ID; Ret: out RetCode) is
use Problem_Storage;
use Session_Keeping;
use Ada.Containers;
Ret := E_NOMEM;
return;
end if;
+ Pr_ID := USD.Last_Problem_ID;
USD.Last_Problem_ID := USD.Last_Problem_ID + 1;
-- Delete old problems
package Session_Keeping is new Ada.Containers.Ordered_Maps(Key_Type => Unique_ID, Element_Type => User_Session_All_Access);
protected Active_Sessions is
- procedure Add_Problem(UID: in Unique_ID; Problem: in Stored_Problem_All_Access; Ret: out RetCode);
+ procedure Add_Problem(UID: in Unique_ID; Problem: in Stored_Problem_All_Access; Pr_ID: out Problem_ID; Ret: out RetCode);
function Contains(UID: in Unique_ID) return Boolean;
function Get_Problem(UID: in Unique_ID; Pr_ID: in Problem_ID) return Stored_Problem_All_Access;
function Get_Latest_Problem_With_ID(UID: in Unique_ID; Pr_ID: out Problem_ID) return Stored_Problem_All_Access;