let show_gradelist env (cgi:Netcgi1_compat.Netcgi_types.cgi_activation) = 
  let hpr = cgi # output # output_string in 
    (* Reading the posted values *)
    export_type := HtmlJscpt(* Default export type *)
    handle_export_type 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 _ -> []));

    (* Processing actions *)
    begin match !export_type with 
      | HtmlJscpt 
      | Html -> begin
          initialize_html hpr "Grade sheet";

          if (!export_type = HtmlJscptthen begin
            hpr "<a href='list.html'>Student list</a> / Project list : ";
            hpr "<a href='gradelist.html?projnum='>G\233n\233ral</a> / ";
            let paddl = get_all_project_addresses () in 
            let pstr  = String.concat " / " (List.map (fun padd ->Printf.sprintf 
               "<a href='gradelist.html?projnum=%s'>n\176 %s</a>" 
                                (pa_to_string padd) (pa_to_string padd)) paddl) in
            hpr pstr;
            hpr "<hr/>\n\n";
          end;

          if (List.length !projectssel = 0) then
            hpr "<h2>Liste des notes pour le projet g\233n\233ral</h2>\n\n"
          else hpr (Printf.sprintf "<h2>Liste des notes pour le projet n\176%s</h2>\n\n"
              (pa_to_string !projectssel));

          (try 
             I.print_gradelist_html hpr !student_list !projectssel;
           with _ -> 
             hpr "No valid project selected");

          (* Export types *)
          display_exports_html hpr cgi;

          (* Form values *)
          if (!verbose_mode) then begin
            hpr "<hr/>\n";
            display_args_html hpr cgi;
            display_values_html hpr;
          end;

          finalize_html hpr;
        end;
      | Text -> begin
          cgi # set_header ~content_type:"text/plain" ();

          (try 
             I.print_gradelist_txt hpr !student_list !projectssel;
           with _ -> 
             hpr "The selected project was not found or is invalid");

        end;
      | _ -> hpr "This export type has not been implemented yet";
    end;

    cgi # output # commit_work();