Skip to content

Commit 435929d

Browse files
committed
Update exercises
1 parent 1967ff9 commit 435929d

File tree

49 files changed

+358
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+358
-174
lines changed

Cargo.lock

Lines changed: 37 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ ts-rs = { git = "https://github.com/Heliozoa/ts-rs.git", rev = "16362e1936b328f9
4444
# [patch.'https://github.com/Heliozoa/ts-rs.git']
4545
# ts-rs = { path = "../ts-rs/ts-rs" }
4646

47-
# [patch.'https://github.com/rage/secret-project-331.git']
48-
# mooc-langs-api = { path = "../secret-project-331/services/headless-lms/langs-api" }
47+
[patch.'https://github.com/rage/secret-project-331.git']
48+
mooc-langs-api = { path = "../secret-project-331/services/headless-lms/langs-api" }

crates/bindings/tmc-langs-node/src/bin/generate-node-bindings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ fn main() {
3333
// checkExerciseUpdates
3434
tmc_langs::UpdatedExercise,
3535
// downloadOrUpdateCourseExercises
36-
tmc_langs::DownloadOrUpdateCourseExercisesResult,
37-
tmc_langs::ExerciseDownload,
36+
tmc_langs::DownloadOrUpdateTmcCourseExercisesResult,
37+
tmc_langs::TmcExerciseDownload,
3838
// getCourseData
3939
tmc_langs::CombinedCourseData,
4040

crates/bindings/tmc-langs-node/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{
1616
};
1717
use thiserror::Error;
1818
use tmc_langs::{
19-
Compression, Credentials, DownloadOrUpdateCourseExercisesResult, LangsError, Language,
19+
Compression, Credentials, DownloadOrUpdateTmcCourseExercisesResult, LangsError, Language,
2020
PrepareSubmission, TmcConfig, file_util,
2121
tmc::{
2222
TestMyCodeClient, TestMyCodeClientError,
@@ -352,7 +352,7 @@ fn download_or_update_course_exercises(mut cx: FunctionContext) -> JsResult<JsVa
352352
tmc_langs::DownloadResult::Success {
353353
downloaded,
354354
skipped,
355-
} => DownloadOrUpdateCourseExercisesResult {
355+
} => DownloadOrUpdateTmcCourseExercisesResult {
356356
downloaded,
357357
skipped,
358358
failed: None,
@@ -361,7 +361,7 @@ fn download_or_update_course_exercises(mut cx: FunctionContext) -> JsResult<JsVa
361361
downloaded,
362362
skipped,
363363
failed,
364-
} => DownloadOrUpdateCourseExercisesResult {
364+
} => DownloadOrUpdateTmcCourseExercisesResult {
365365
downloaded,
366366
skipped,
367367
failed: Some(failed),
@@ -746,7 +746,7 @@ fn update_exercises(mut cx: FunctionContext) -> JsResult<JsValue> {
746746
let projects_dir =
747747
tmc_langs::get_projects_dir(&client_name).map_err(|e| convert_err(&mut cx, e))?;
748748
let res = with_client(client_name, client_version, |client| {
749-
tmc_langs::update_exercises(client, &projects_dir)
749+
tmc_langs::update_tmc_exercises(client, &projects_dir)
750750
});
751751
convert_res(&mut cx, res)
752752
}

crates/tmc-langs-cli/src/app.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clap::Parser;
55
use schemars::JsonSchema;
66
use std::{path::PathBuf, str::FromStr};
77
use tmc_langs::{
8-
CombinedCourseData, Compression, DownloadOrUpdateCourseExercisesResult, ExerciseDesc,
8+
CombinedCourseData, Compression, DownloadOrUpdateTmcCourseExercisesResult, ExerciseDesc,
99
ExercisePackagingConfiguration, Language, LocalExercise, RunResult, StyleValidationResult,
1010
UpdatedExercise,
1111
mooc::CourseInstance,
@@ -307,7 +307,7 @@ pub enum TestMyCodeCommand {
307307
},
308308

309309
/// Downloads exercises. If downloading an exercise that has been downloaded before, the student file policy will be used to avoid overwriting student files, effectively just updating the exercise files
310-
#[clap(long_about = schema_leaked::<DownloadOrUpdateCourseExercisesResult>())]
310+
#[clap(long_about = schema_leaked::<DownloadOrUpdateTmcCourseExercisesResult>())]
311311
DownloadOrUpdateCourseExercises {
312312
/// If set, will always download the course template instead of the latest submission, even if one exists.
313313
#[clap(long)]
@@ -569,6 +569,9 @@ pub enum MoocCommand {
569569
#[clap(long)]
570570
target: PathBuf,
571571
},
572+
/// Updates all local exercises that have been updated on the server
573+
#[clap(long_about = SCHEMA_NULL)]
574+
UpdateExercises,
572575
/// Submits an exercise.
573576
Submit {
574577
#[clap(long)]

crates/tmc-langs-cli/src/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::path::PathBuf;
44
use thiserror::Error;
5-
use tmc_langs::ExerciseDownload;
5+
use tmc_langs::TmcExerciseDownload;
66

77
#[derive(Debug, Error)]
88
#[error("Invalid token. Deleted credentials file")]
@@ -20,7 +20,7 @@ pub struct SandboxTestError {
2020
#[derive(Debug, Error)]
2121
#[error("Failed to download one or more exercises")]
2222
pub struct DownloadsFailedError {
23-
pub downloaded: Vec<ExerciseDownload>,
24-
pub skipped: Vec<ExerciseDownload>,
25-
pub failed: Vec<(ExerciseDownload, Vec<String>)>,
23+
pub downloaded: Vec<TmcExerciseDownload>,
24+
pub skipped: Vec<TmcExerciseDownload>,
25+
pub failed: Vec<(TmcExerciseDownload, Vec<String>)>,
2626
}

crates/tmc-langs-cli/src/lib.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use std::{
2424
path::{Path, PathBuf},
2525
};
2626
use tmc_langs::{
27-
CommandError, Compression, Credentials, DownloadOrUpdateCourseExercisesResult, DownloadResult,
28-
Language, StyleValidationResult, TmcConfig, UpdatedExercise,
27+
CommandError, Compression, Credentials, DownloadOrUpdateTmcCourseExercisesResult,
28+
DownloadResult, Language, StyleValidationResult, TmcConfig, UpdatedExercise,
2929
file_util::{self, Lock, LockOptions},
3030
mooc::{MoocClient, MoocClientError},
3131
tmc::{TestMyCodeClient, TestMyCodeClientError, request::FeedbackAnswer},
@@ -231,7 +231,7 @@ fn run_app(cli: Cli) -> Result<CliOutput> {
231231
let mut lock = Lock::dir(&exercise_path, LockOptions::Read)?;
232232
let _guard = lock.lock()?;
233233

234-
let hash = tmc_langs::compress_project_to(
234+
let hash = tmc_langs::compress_project_to_with_hash(
235235
&exercise_path,
236236
&output_path,
237237
compression,
@@ -674,7 +674,7 @@ fn run_tmc_inner(
674674
DownloadResult::Success {
675675
downloaded,
676676
skipped,
677-
} => DownloadOrUpdateCourseExercisesResult {
677+
} => DownloadOrUpdateTmcCourseExercisesResult {
678678
downloaded,
679679
skipped,
680680
failed: None,
@@ -683,15 +683,15 @@ fn run_tmc_inner(
683683
downloaded,
684684
skipped,
685685
failed,
686-
} => DownloadOrUpdateCourseExercisesResult {
686+
} => DownloadOrUpdateTmcCourseExercisesResult {
687687
downloaded,
688688
skipped,
689689
failed: Some(failed),
690690
},
691691
};
692692
CliOutput::finished_with_data(
693693
"downloaded or updated exercises",
694-
DataKind::ExerciseDownload(data),
694+
DataKind::TmcExerciseDownload(data),
695695
)
696696
}
697697

@@ -1011,10 +1011,10 @@ fn run_tmc_inner(
10111011

10121012
TestMyCodeCommand::UpdateExercises => {
10131013
let projects_dir = tmc_langs::get_projects_dir(client_name)?;
1014-
let data = tmc_langs::update_exercises(client, &projects_dir)?;
1014+
let data = tmc_langs::update_tmc_exercises(client, &projects_dir)?;
10151015
CliOutput::finished_with_data(
10161016
"downloaded or updated exercises",
1017-
DataKind::ExerciseDownload(data),
1017+
DataKind::TmcExerciseDownload(data),
10181018
)
10191019
}
10201020

@@ -1064,6 +1064,8 @@ fn run_mooc(mooc: Mooc) -> Result<CliOutput> {
10641064
}
10651065

10661066
fn run_mooc_inner(mooc: Mooc, client: &mut MoocClient) -> Result<CliOutput> {
1067+
let client_name = &mooc.client_name;
1068+
10671069
let output = match mooc.command {
10681070
MoocCommand::CourseInstance {
10691071
course_instance_id: _,
@@ -1102,6 +1104,11 @@ fn run_mooc_inner(mooc: Mooc, client: &mut MoocClient) -> Result<CliOutput> {
11021104
)?;
11031105
CliOutput::finished("downloaded exercise")
11041106
}
1107+
MoocCommand::UpdateExercises => {
1108+
let projects_dir = tmc_langs::get_projects_dir(client_name)?;
1109+
let res = tmc_langs::update_mooc_exercises(client, &projects_dir)?;
1110+
CliOutput::finished_with_data("updated exercises", DataKind::MoocExerciseDownload(res))
1111+
}
11051112
MoocCommand::Submit {
11061113
exercise_id,
11071114
slide_id,

0 commit comments

Comments
 (0)