Skip to content

Bug(partition-view): two implementation details are fragile #456

@erikmd

Description

@erikmd

Related project scope(s): partition-view

Bug description

Regarding learnocaml_partition_view.ml, it seems two points would deserve to be improved after fixing #438:

  1. | Partition (token, eid, fid, prof) ->
    get ~token
    ["partition"; eid; fid; string_of_int prof]

    → this basically turn Partition("X-U1O-AB1-1FJ-ZOF", "demo", "times", 30) into an HTTP request to
    http://localhost:8080/partition/demo/times/30?token=X-U1O-AB1-1FJ-ZOF
    → I believe this is an issue if the exercise_id contains a /, e.g.: "fpottier/alpha_beta"
    → the URL should be changed to something like
    http://localhost:8080/partition/fpottier%2Falpha_beta/times/30?token=X-U1O-AB1-1FJ-ZOF
    or http://localhost:8080/partition/times/30?id=fpottier/alpha_beta&token=X-U1O-AB1-1FJ-ZOF
    → a bit like the already-existing URL http://localhost:8080/partition-view.html?id=demo&function=times&prof=30
    → Fortunately, changing this wouldn't impact the learn-ocaml-client-related backward-compatibility claim:
    Regarding the inevitable extensions of the API:
    - make sure we only add constructors to this [request] type,
    - and that their semantics does not change
    (or at least in a backward-compatible way;
    see PR https://github.com/ocaml-sf/learn-ocaml/pull/397
    for a counter-example);
    - but if a given entrypoint would need to be removed,
    add a [Compat.Upto] constraint (*<*) instead.
    *)

  2. let _win = window_open ("/student-view.html?token="^tok) "_blank" in

    → the "BASE_URL" should be prepended, similarly to:
    document.getElementById('chamo-img').src = learnocaml_config.baseUrl + '/icons/tryocaml_loading_' + n + '.gif';

    (Note to myself: this line of learnocaml_description_main.ml is also impacted ↓)
    (Printf.sprintf "/description/%s#%s=%s"

Current configuration

  • OS name (and version): GNU/Linux
  • Browser name (and version): Firefox
  • learn-ocaml --version: 0.13.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions