font-style: italic;
}
+.error_text {
+ font-size: 12pt;
+ margin-left: 32px;
+ margin-right: 32px;
+ margin-bottom: 16px;
+}
+
.exponent {
font-size: 75%;
vertical-align: super;
-webkit-border-radius: 4px;
}
+a.default_link {
+ color: inherit;
+ font-weight: bold;
+ text-decoration: none;
+}
+
+a:visited.default_link {
+ color: black;
+}
+
a:hover.main_navlink {
background-color: #58acf4;
}
text-decoration: none;
}
+div.error_box {
+ background-color: #ff4141;
+ margin-left: 32px;
+ margin-right: 32px;
+ padding-top: 16px;
+ padding-bottom: 16px;
+
+ /* CSS3 only */
+ border-radius: 10px;
+ /* Pre CSS3 Mozilla */
+ -moz-border-radius: 10px;
+ /* Pre CSS3 Webkit */
+ -webkit-border-radius: 10px;
+}
+
div.hint_block {
margin-left: 32px;
margin-right: 32px;
--- /dev/null
+ <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">@_ERROR_MESSAGE_@</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>
--- /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 answer.</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
+<!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 assignment.</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
+<!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 prepare problem.</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
+<!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">Problem category is missing.</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
+<!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">Problem ID not present.</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
+<!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 register UID.</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>
package body Face_Generator is
+ function Generate_Error_Face(HTML: out HTML_Code; Message: in String) return RetCode is
+ use AWS.Templates;
+
+ Temp: HTML_Code;
+ Translations_Hdr: Translate_Set;
+ Translations: Translate_Set;
+ begin
+ Insert(Translations_Hdr, Assoc(HEADER_CAPTION_KEY, "Oops..."));
+ HTML := Parse(Filename => "templates/header.html", Translations => Translations_Hdr);
+
+ Insert(Translations, Assoc(ERROR_MESSAGE_KEY, Message));
+ Temp := Parse(Filename => "templates/error.html", Translations => Translations);
+ Append_HTML(Source => HTML, New_Item => Temp);
+
+ Temp := Parse(Filename => "templates/footer.html");
+ Append_HTML(Source => HTML, New_Item => Temp);
+
+ return OK;
+ end Generate_Error_Face;
+
function Generate_Index_Face(HTML: out HTML_Code) return RetCode is
use AWS.Templates;
use Global_Types;
package Face_Generator is
+ function Generate_Error_Face(HTML: out HTML_Code; Message: in String) return RetCode;
function Generate_Index_Face(HTML: out HTML_Code) return RetCode;
-
function Generate_Face(Assignment: in Problem_Generator_Syswides.Assignment_Info.Map;
Parameters: in Problem_Generator_Syswides.Parameters_Info.Map;
HTML: out HTML_Code;
HTML: out HTML_Code;
Pr_ID: in String; Pr_Cat: in String) return RetCode;
+ ERROR_MESSAGE_KEY: constant String := "ERROR_MESSAGE";
HEADER_CAPTION_KEY: constant String := "HEADER_CAPTION";
HINTS_SECTION_KEY: constant String := "HINTS_SECTION";
META_EXPIRE_NOW_KEY: constant String := "META_EXPIRE_NOW";
with AWS.Session;
with AWS.Status;
+with Face_Generator_Static;
with Global_Types;
with Problem_Manager;
with Problem_Generator_Syswides;
-with Ada.Text_IO;
-
use Global_Types;
package body Handler_Check_Answer is
-- Get UID
Success := Problem_Manager.Get_UID(Raw_UID, UID);
if Success = False then
- -- UID could not have been registered
- -- TODO: Print some sensible error message, for now just redirect to index
- Ada.Text_IO.Put_Line("UID has not been registered: " & Raw_UID);
+ -- This UID is invalid, redirect to index
return AWS.Response.URL(Location => "/");
end if;
-- Get problem ID
if Answer.Find(Problem_Generator_Syswides.RESERVED_PROBLEM_ID_KEY) = Answer_Info.No_Element then
- Ada.Text_IO.Put_Line("Problem ID not found!");
- return AWS.Response.URL(Location => "/");
+ 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 =>
- Ada.Text_IO.Put_Line("Invalid problem ID value");
- return AWS.Response.URL(Location => "/");
+ 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_Checked_Answer(UID, Answer, HTML, Pr_ID);
if Ret /= OK then
- Ada.Text_IO.Put_Line("No such problem in storage");
- return AWS.Response.URL(Location => "/");
+ return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+ Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Display_Answer),
+ Status_Code => AWS.Messages.S200);
end if;
return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
Status_Code => AWS.Messages.S200);
end;
when others =>
- Ada.Text_IO.Put_Line("Invalid request");
return AWS.Response.URL(Location => "/");
end case;
end Handle;
with Ada.Text_IO;
+with Face_Generator_Static;
with Global_Types;
with Problem_Generator_Syswides;
with Problem_Manager;
-- Get UID
Success := Problem_Manager.Get_UID(Raw_UID, UID);
if Success = False then
- -- UID could not have been registered
- -- TODO: Print some sensible error message, for now just redirect to index
+ -- This UID is invalid, redirect to index
return AWS.Response.URL(Location => "/");
end if;
-- Create a new problem
if Problem_Parameters.Find(Problem_Generator_Syswides.RESERVED_PROBLEM_CATEGORY_KEY) = Parameters_Info.No_Element then
- Ada.Text_IO.Put_Line("No problem category tag");
- return AWS.Response.URL(Location => "/");
+ return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+ Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Problem_Category),
+ Status_Code => AWS.Messages.S200);
end if;
declare
begin
Ret := Problem_Manager.Prepare_Problem(UID, Raw_P_Cat, Problem_Parameters);
if Ret /= OK then
- -- TODO: Handle error in a less reckless manner
- return AWS.Response.URL(Location => "/");
+ return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+ Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Prepare_Problem),
+ Status_Code => AWS.Messages.S200);
end if;
-- Display new problem
Ret := Problem_Manager.Display_Assignment(UID, HTML);
if Ret /= OK then
- -- TODO: Handle error in a less reckless manner
- return AWS.Response.URL(Location => "/");
+ return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+ Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Display_Assignment),
+ Status_Code => AWS.Messages.S200);
end if;
return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
with AWS.Response;
with AWS.Session;
with AWS.Status;
+with Face_Generator_Static;
with Global_Types;
with Problem_Manager;
---with Ada.Text_IO;
-
use Global_Types;
package body Handler_Start is
UID: Unique_ID;
Ret: RetCode;
Success: Boolean;
- begin
+ begin
+ -- Check that the problem category is not empty
+ if Raw_Problem_Category'Length = 0 then
+ return AWS.Response.URL(Location => "/");
+ end if;
+
-- Register new UID if necessary and create a first problem
Success := Problem_Manager.Get_UID(Raw_UID, UID);
if Success = False then
if Ret /= OK then
-- UID could not have been registered
-- TODO: Print some sensible error message, for now just redirect to index
- return AWS.Response.URL(Location => "/");
+ return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+ Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_UID_Registration),
+ Status_Code => AWS.Messages.S200);
end if;
-- Save the new UID
AWS.Session.Set(SID, "UID", Unique_ID'Image(UID));
if Ret /= OK then
-- Something went wrong when generating the problem
-- TODO: Print some sensible error message, for now just redirect to index
- return AWS.Response.URL(Location => "/");
+ return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+ Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Prepare_Problem),
+ Status_Code => AWS.Messages.S200);
end if;
Ret := Problem_Manager.Display_Assignment(UID, HTML);
if Ret /= OK then
- HTML := To_HTML_Code("Cannot display assignment");
+ return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
+ Message_Body => HTML_To_Fixed_String(Face_Generator_Static.Error_Display_Assignment),
+ Status_Code => AWS.Messages.S200);
end if;
return AWS.Response.Build(Content_Type => AWS.MIME.Text_HTML,
Message_Body => HTML_To_Fixed_String(HTML),
Ret := Stored.Problem.Get_Parameters(Parameters);
if Ret /= OK then
Stored.Mutex.Unlock;
- return Ret;
+ return Face_Generator.Generate_Error_Face(HTML, ERRMSG_GET_PARAMETERS & " (" & RetCode'Image(Ret) & ")");
end if;
begin
Ret := Stored.Problem.Get_Assignment(Assignment);
if Ret /= OK then
Stored.Mutex.Unlock;
- return Ret;
+ return Face_Generator.Generate_Error_Face(HTML, ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")");
end if;
exception
when others =>
+ return Face_Generator.Generate_Error_Face(HTML, ERRMSG_UNHANDLED_EXCEPTION);
Stored.Mutex.Unlock;
return E_UNKW;
end;
Ret := Stored.Problem.Get_Parameters(Parameters);
if Ret /= OK then
Stored.Mutex.Unlock;
- return Ret;
+ return Face_Generator.Generate_Error_Face(HTML, ERRMSG_GET_PARAMETERS & " (" & RetCode'Image(Ret) & ")");
end if;
-- Get assignment
Ret := Stored.Problem.Get_Assignment(Assignment);
if Ret /= OK then
Stored.Mutex.Unlock;
- return Ret;
+ return Face_Generator.Generate_Error_Face(HTML, ERRMSG_GET_ASSIGNMENT & " (" & RetCode'Image(Ret) & ")");
end if;
exception
when others =>
Stored.Mutex.Unlock;
- return E_UNKW;
+ return Face_Generator.Generate_Error_Face(HTML, ERRMSG_UNHANDLED_EXCEPTION);
end;
Pr_Cat := Stored.Category;
end record;
type User_Session_All_Access is access all User_Session_Data;
+ ERRMSG_GET_ASSIGNMENT: constant String := "Unable to get assignment";
+ ERRMSG_GET_PARAMETERS: constant String := "Unable to get problem parameters";
+ ERRMSG_UNHANDLED_EXCEPTION: constant String := "Unhandled exception occured";
+
package Session_Keeping is new Ada.Containers.Ordered_Maps(Key_Type => Unique_ID, Element_Type => User_Session_All_Access);
protected Active_Sessions is