let show_project 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 "action" (handle_actions cgi);
handle_html_arg cgi "sort" (fun s -> sort_student_list (string_to_sort s));
handle_html_arg cgi "projnum" (fun s -> projectssel := (try pa_of_string s with _ -> []));
handle_html_arg cgi "groupnum" (fun s -> groupssel :=
(try (List.sort compare (convert_to_int_list s))
with _ -> []));
handle_html_arg cgi "projname" (fun s ->
debug (Printf.sprintf "Update : name '%s' in all groups\n" s);
update_groups_project_name !projectssel s);
handle_html_arg cgi "projid" (fun s ->
debug (Printf.sprintf "Update : id '%s' in all groups\n" s);
update_groups_project_id !projectssel s);
handle_html_arg cgi "projcoeff" (fun s ->
debug (Printf.sprintf "Update : coeff '%s' in all groups\n" s);
update_groups_project_coeff !projectssel (float_of_string s));
handle_html_arg cgi "projdgrad" (fun s ->
debug (Printf.sprintf "Update : default grade '%s' in all groups\n" s);
update_groups_project_dgrad !projectssel (float_of_string s));
handle_add_team cgi;
handle_del_team cgi;
handle_grade_team cgi;
handle_create_team cgi;
handle_delete_team cgi;
begin match !export_type with
| HtmlJscpt
| Html -> begin
initialize_html hpr "Display project";
hpr "<center>\n";
List.iter (fun gnum ->
I.print_project_html hpr !student_list !projectssel gnum;)
(if (!groupssel = []) then (List.sort compare !num_groups) else !groupssel);
I.print_missing_html hpr !student_list !projectssel;
hpr "</center>\n";
if (!export_type = HtmlJscpt) then begin
hpr "<form id='selstu' method='post' action =''>\nSelected student : ";
hpr "<input type='text' disabled='disabled' name='student'/>\n";
hpr "</form>\n";
if (!allow_naming_projects) then begin
hpr "<form method='post' action =''>\nProject name : ";
hpr (Printf.sprintf "<input type='text' name='projname' value='%s'/>\n"
(get_group_project_name
(if (!groupssel = []) then (List.hd !num_groups) else (List.hd !groupssel))
!projectssel));
hpr (Printf.sprintf "<input type='hidden' name='projnum' value='%s'/>\n"
(pa_to_string !projectssel));
hpr "<input type='submit' value='Set'/>\n";
hpr "</form>\n";
end;
if (!allow_naming_projects) then begin
hpr "<form method='post' action =''>\nProject id : ";
hpr (Printf.sprintf "<input type='text' name='projid' value='%s'/>\n"
(get_group_project_id
(if (!groupssel = []) then (List.hd !num_groups) else (List.hd !groupssel))
!projectssel));
hpr (Printf.sprintf "<input type='hidden' name='projnum' value='%s'/>\n"
(pa_to_string !projectssel));
hpr "<input type='submit' value='Set'/>\n";
hpr "</form>\n";
end;
hpr "<form method='post' action =''>\nProject coeff : ";
hpr (Printf.sprintf "<input type='text' name='projcoeff' value='%.1f'/>\n"
(get_group_project_coeff
(if (!groupssel = []) then (List.hd !num_groups) else (List.hd !groupssel))
!projectssel));
hpr (Printf.sprintf "<input type='hidden' name='projnum' value='%s'/>\n"
(pa_to_string !projectssel));
hpr "<input type='submit' value='Set'/>\n";
hpr "</form>\n";
hpr "<form method='post' action =''>\nProject default grade : ";
hpr (Printf.sprintf "<input type='text' name='projdgrad' value='%.1f'/>\n"
(get_group_project_dgrad
(if (!groupssel = []) then (List.hd !num_groups) else (List.hd !groupssel))
!projectssel));
hpr (Printf.sprintf "<input type='hidden' name='projnum' value='%s'/>\n"
(pa_to_string !projectssel));
hpr "<input type='submit' value='Set'/>\n";
hpr "</form>\n";
save_student_form hpr;
end;
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" ();
List.iter (fun gnum ->
I.print_project_xml hpr gnum !projectssel)
(if (!groupssel = []) then !num_groups else !groupssel);
end;
| Text -> begin
cgi # set_header ~content_type:"text/plain" ();
List.iter (fun gnum ->
I.print_project_txt hpr gnum !projectssel)
(if (!groupssel = []) then !num_groups else !groupssel);
end;
| Latex -> begin
cgi # set_header ~content_type:"text/plain" ();
I.print_project_latex hpr !student_list !projectssel;
end;
| Postscript -> begin
cgi # set_header ~content_type:"application/postscript" ();
let tmp_out_chan = open_out "tmp/test.tex" in
let tmp_out_fun = (fun s -> Printf.fprintf tmp_out_chan "%s" s) in
I.print_project_latex tmp_out_fun !student_list !projectssel;
close_out tmp_out_chan;
silent_tex_to_ps "test" "tmp";
input_file_into_hpr hpr "tmp/test.ps";
end;
| _ -> hpr "This export type has not been implemented yet";
end;
cgi # output # commit_work();