Closed noobLue closed 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?
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.
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)
}
Yeah, I think having both would be fine. The function signatures look good to me.
Good to hear! I will apply these changes tomorrow.
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.
resolves #159