let show_student env (cgi:Netcgi1_compat.Netcgi_types.cgi_activation) =
let hpr = cgi # output # output_string in
export_type := HtmlJscpt;
handle_export_type cgi;
handle_html_arg cgi "login" (fun s -> loginsel := s);
handle_html_arg cgi "projnum" (fun s -> projectssel := (try pa_of_string s
with _ -> []));
handle_html_arg cgi "grade" (fun s -> try
Printf.printf "Update : grade '%.1f' for %s for project '%s'\n"
(float_of_string s) !loginsel (pa_to_string !projectssel); flush stdout;
give_mark_to_student !loginsel
!projectssel (float_of_string s)
with _ -> ());
begin match !export_type with
| HtmlJscpt
| Html -> begin
initialize_html hpr "Display student";
hpr "<h2><a href='list.html'>Student list</a></h2>\n\n";
(try
let stu = find_student !student_list !loginsel in
I.print_student_html hpr !student_list
(get_group_project_addresses (stu.group)) stu;
with _ ->
hpr "The selected student was not found or is invalid");
display_exports_html hpr cgi;
if (!verbose_mode) then begin
hpr "<hr/>\n";
display_args_html hpr cgi;
display_values_html hpr;
end;
finalize_html hpr;
end;
| Xml -> begin
cgi # set_header ~content_type:"text/xml" ();
try
let stu = find_student !student_list !loginsel in
I.print_student_xml hpr !student_list
(get_group_project_addresses (stu.group)) stu;
with _ ->
hpr "The selected student was not found or is invalid";
end;
| Text -> begin
cgi # set_header ~content_type:"text/plain" ();
try
let stu = find_student !student_list !loginsel in
I.print_student_txt hpr !student_list
(get_group_project_addresses (stu.group)) stu;
with _ ->
hpr "The selected student was not found or is invalid";
end;
| _ -> hpr "This export type has not been implemented yet";
end;
cgi # output # commit_work();