rage / tmc-langs-rust

A library and CLI for supporting different programming languages in the TestMyCode programming assignment evaluator.
https://tmc.mooc.fi/
Apache License 2.0
8 stars 9 forks source link

Proposed submit/paste functionality that handles submission_url #160

Closed noobLue closed 3 years ago

noobLue commented 3 years ago

resolves #159

noobLue commented 3 years ago

Would it be better to save the submission url in a local configuration file (when downloading exercises)?

Or perhaps query for CourseDetails before the submit command to get the url?

Heliozoa commented 3 years ago

Sorry for the late response. I agree that the current API is awkward. For an improved API, I think I'd prefer one that either

The first one is more flexible and can be used for exercises that aren't in any projects directory, but the second one might be more convenient if that's not necessary. For langs either one is fine I think, not sure which is better for TMC CLI. "Hard-coding" the URLs like this is fine for now, It can always be changed later if there's need to customise them in the future.

noobLue commented 3 years ago

Sorry for the late response. I agree that the current API is awkward. For an improved API, I think I'd prefer one that either

* takes an id and exercise path and isn't dependent on ProjectsConfig, or

* takes the course and exercise slugs and uses the ProjectsConfig to get the id and path

The first one is more flexible and can be used for exercises that aren't in any projects directory, but the second one might be more convenient if that's not necessary. For langs either one is fine I think, not sure which is better for TMC CLI. "Hard-coding" the URLs like this is fine for now, It can always be changed later if there's need to customise them in the future.

The second option would be convenient for us to use in tmc-cli. I could write both of those functions and have the function that's reading ProjectsConfig pass exercise id and path to the more general function in the first example.

The functions could look like something like this, right?

pub fn submit_exercise_by_id(
    client: &TmcClient,
    exercise_id: usize,
    exercise_path: &Path,
    locale: Option<Language>,
) ... {
...
}

pub fn submit_exercise(
    client: &TmcClient,
    projects_dir: &Path,
    course_slug: &str,
    exercise_slug: &str,
    locale: Option<Language>,
) ... {
    // read id and path from ProjectsConfig to ex_id, ex_path
    // submit_exercise_by_id(client, ex_id, ex_path, locale)
}
Heliozoa commented 3 years ago

Yeah, I think having both would be fine. The function signatures look good to me.

noobLue commented 3 years ago

Good to hear! I will apply these changes tomorrow.

noobLue commented 3 years ago

I added the url-handling submit/paste functions that take exercise_id and path to TmcClient. Those functions are then called by submit/paste functions in tmc_langs, that take in ProjectsConfig, exercise- and course slugs.