diff --git a/src/app/learnocaml_partition_view.ml b/src/app/learnocaml_partition_view.ml index d1571a151..6ae40dd48 100644 --- a/src/app/learnocaml_partition_view.ml +++ b/src/app/learnocaml_partition_view.ml @@ -12,6 +12,7 @@ open Js_utils open Lwt open Learnocaml_data open Learnocaml_common +open Learnocaml_config module H = Tyxml_js.Html5 module React = Lwt_react @@ -35,7 +36,8 @@ let anon_id_map = ref Token.Map.empty let partition = ref None let open_tok tok = - let _win = window_open ("/student-view.html?token="^tok) "_blank" in + let _win = window_open (Learnocaml_config.api_server^"/student-view.html?token="^tok) "_blank" + in false let rec render_tree = diff --git a/src/state/learnocaml_api.ml b/src/state/learnocaml_api.ml index 30a084402..5b66e7398 100644 --- a/src/state/learnocaml_api.ml +++ b/src/state/learnocaml_api.ml @@ -278,11 +278,13 @@ module Conversions (Json: JSON_CODEC) = struct let to_http_request : type resp. resp request -> http_request = - let get ?token path = { + let get ?(e_arg = []) ?token path = { meth = `GET; path; - args = match token with None -> [] | Some t -> ["token", Token.to_string t]; - } in + args = match token with + None-> [] + |Some t -> [("token", Token.to_string t)] @ e_arg + } in let post ~token path body = { meth = `POST body; path; @@ -368,8 +370,8 @@ module Conversions (Json: JSON_CODEC) = struct status) | Partition (token, eid, fid, prof) -> - get ~token - ["partition"; eid; fid; string_of_int prof] + get ~token ~e_arg:[("exercise_id", eid)] + ["partition"; fid; string_of_int prof] | Invalid_request s -> failwith ("Error request "^s) @@ -497,9 +499,12 @@ module Server (Json: JSON_CODEC) (Rh: REQUEST_HANDLER) = struct | `GET, ["playgrounds"; f], _ when Filename.check_suffix f ".json" -> Playground (Filename.chop_suffix f ".json") |> k - | `GET, ["partition"; eid; fid; prof], Some token - when Token.is_teacher token -> - Partition (token, eid, fid, int_of_string prof) |> k + | `GET, ["partition"; fid; prof], Some token + when Token.is_teacher token -> + (match List.assoc_opt "exercise_id" request.args with + | None -> Invalid_request ("Exercise_id missing") |> k + | Some eid -> + Partition (token, eid, fid, int_of_string prof) |> k) | `GET, ["teacher"; "exercise-status.json"], Some token when Token.is_teacher token ->