@@ -282,25 +282,27 @@ pub fn download_or_update_course_exercises(
282
282
. into_iter ( )
283
283
. max_by_key ( |s| s. created_at )
284
284
{
285
- // previous submission found
286
- to_be_downloaded. push ( DownloadTarget {
287
- target : ExerciseDownload {
288
- id : exercise_detail. id ,
289
- course_slug : exercise_detail. course_name ,
290
- exercise_slug : exercise_detail. exercise_name ,
291
- path : target,
292
- } ,
293
- checksum : exercise_detail. checksum ,
294
- kind : DownloadTargetKind :: Submission {
295
- submission_id : latest_submission. id ,
296
- } ,
297
- } ) ;
298
- continue ;
285
+ // previous submission found, check if exercise submission results hidden (part of exam)
286
+ if !exercise_detail. hide_submission_results {
287
+ to_be_downloaded. push ( DownloadTarget {
288
+ target : ExerciseDownload {
289
+ id : exercise_detail. id ,
290
+ course_slug : exercise_detail. course_name ,
291
+ exercise_slug : exercise_detail. exercise_name ,
292
+ path : target,
293
+ } ,
294
+ checksum : exercise_detail. checksum ,
295
+ kind : DownloadTargetKind :: Submission {
296
+ submission_id : latest_submission. id ,
297
+ } ,
298
+ } ) ;
299
+ continue ;
300
+ }
299
301
}
300
302
}
301
303
}
302
304
303
- // not skipped, either not on disk or no previous submissions, downloading template
305
+ // not skipped, either not on disk or no previous submissions or submission result hidden , downloading template
304
306
to_be_downloaded. push ( DownloadTarget {
305
307
target : ExerciseDownload {
306
308
id : exercise_detail. id ,
@@ -1052,12 +1054,14 @@ mod test {
1052
1054
course_name: "some course" . to_string( ) ,
1053
1055
exercise_name: "some exercise" . to_string( ) ,
1054
1056
checksum: "new checksum" . to_string( ) ,
1057
+ hide_submission_results: false ,
1055
1058
} ,
1056
1059
ExercisesDetails {
1057
1060
id: 2 ,
1058
1061
course_name: "some course" . to_string( ) ,
1059
1062
exercise_name: "another exercise" . to_string( ) ,
1060
1063
checksum: "old checksum" . to_string( ) ,
1064
+ hide_submission_results: false ,
1061
1065
} ,
1062
1066
] ;
1063
1067
let mut response = HashMap :: new ( ) ;
@@ -1157,24 +1161,37 @@ checksum = 'new checksum'
1157
1161
checksum: "new checksum" . to_string( ) ,
1158
1162
course_name: "some course" . to_string( ) ,
1159
1163
exercise_name: "on disk exercise with update and submission" . to_string( ) ,
1164
+ hide_submission_results: false ,
1160
1165
} ,
1161
1166
ExercisesDetails {
1162
1167
id: 2 ,
1163
1168
checksum: "new checksum" . to_string( ) ,
1164
1169
course_name: "some course" . to_string( ) ,
1165
1170
exercise_name: "on disk exercise without update" . to_string( ) ,
1171
+ hide_submission_results: false ,
1166
1172
} ,
1167
1173
ExercisesDetails {
1168
1174
id: 3 ,
1169
1175
checksum: "new checksum" . to_string( ) ,
1170
1176
course_name: "another course" . to_string( ) ,
1171
1177
exercise_name: "not on disk exercise with submission" . to_string( ) ,
1178
+ hide_submission_results: false ,
1172
1179
} ,
1173
1180
ExercisesDetails {
1174
1181
id: 4 ,
1175
1182
checksum: "new checksum" . to_string( ) ,
1176
1183
course_name: "another course" . to_string( ) ,
1177
1184
exercise_name: "not on disk exercise without submission" . to_string( ) ,
1185
+ hide_submission_results: false ,
1186
+ } ,
1187
+ ExercisesDetails {
1188
+ id: 5 ,
1189
+ checksum: "new checksum" . to_string( ) ,
1190
+ course_name: "another course" . to_string( ) ,
1191
+ exercise_name:
1192
+ "not on disk exercise with submission exercise hide submission result"
1193
+ . to_string( ) ,
1194
+ hide_submission_results: true ,
1178
1195
} ,
1179
1196
] ,
1180
1197
) ;
@@ -1252,6 +1269,16 @@ checksum = 'new checksum'
1252
1269
. with_body ( serde_json:: to_string ( & [ 0 ; 0 ] ) . unwrap ( ) )
1253
1270
. create ( ) ;
1254
1271
1272
+ let _m = mockito:: mock (
1273
+ "GET" ,
1274
+ mockito:: Matcher :: AllOf ( vec ! [
1275
+ mockito:: Matcher :: Regex ( "exercises/5" . to_string( ) ) ,
1276
+ mockito:: Matcher :: Regex ( "submissions" . to_string( ) ) ,
1277
+ ] ) ,
1278
+ )
1279
+ . with_body ( serde_json:: to_string ( & sub_body) . unwrap ( ) )
1280
+ . create ( ) ;
1281
+
1255
1282
let mut template_zw = zip:: ZipWriter :: new ( std:: io:: Cursor :: new ( vec ! [ ] ) ) ;
1256
1283
template_zw
1257
1284
. start_file ( "src/student_file.py" , zip:: write:: FileOptions :: default ( ) )
@@ -1310,6 +1337,15 @@ checksum = 'new checksum'
1310
1337
)
1311
1338
. with_body ( & template_z)
1312
1339
. create ( ) ;
1340
+ let _m = mockito:: mock (
1341
+ "GET" ,
1342
+ mockito:: Matcher :: AllOf ( vec ! [
1343
+ mockito:: Matcher :: Regex ( "exercises/5" . to_string( ) ) ,
1344
+ mockito:: Matcher :: Regex ( "download" . to_string( ) ) ,
1345
+ ] ) ,
1346
+ )
1347
+ . with_body ( & template_z)
1348
+ . create ( ) ;
1313
1349
1314
1350
let mut sub_zw = zip:: ZipWriter :: new ( std:: io:: Cursor :: new ( vec ! [ ] ) ) ;
1315
1351
sub_zw
@@ -1354,13 +1390,14 @@ checksum = 'new checksum'
1354
1390
other => panic ! ( "{:?}" , other) ,
1355
1391
} ;
1356
1392
1357
- assert_eq ! ( downloaded. len( ) , 3 ) ;
1393
+ assert_eq ! ( downloaded. len( ) , 4 ) ;
1358
1394
assert_eq ! ( skipped. len( ) , 1 ) ;
1359
1395
1360
1396
let e1 = downloaded. iter ( ) . find ( |e| e. id == 1 ) . unwrap ( ) ;
1361
1397
let _e2 = skipped. iter ( ) . find ( |e| e. id == 2 ) . unwrap ( ) ;
1362
1398
let e3 = downloaded. iter ( ) . find ( |e| e. id == 3 ) . unwrap ( ) ;
1363
1399
let e4 = downloaded. iter ( ) . find ( |e| e. id == 4 ) . unwrap ( ) ;
1400
+ let e5 = downloaded. iter ( ) . find ( |e| e. id == 5 ) . unwrap ( ) ;
1364
1401
1365
1402
// did not download submission even though it was available because it was on disk
1366
1403
let f = file_util:: read_file_to_string ( e1. path . join ( "src/student_file.py" ) ) . unwrap ( ) ;
@@ -1383,9 +1420,16 @@ checksum = 'new checksum'
1383
1420
// did not download submission because one was not available
1384
1421
let f = file_util:: read_file_to_string ( e4. path . join ( "src/student_file.py" ) ) . unwrap ( ) ;
1385
1422
assert_eq ! ( f, "template" ) ;
1386
- assert ! ( e1 . path. join( "src/template_only_student_file.py" ) . exists( ) ) ;
1423
+ assert ! ( e4 . path. join( "src/template_only_student_file.py" ) . exists( ) ) ;
1387
1424
let f = file_util:: read_file_to_string ( e4. path . join ( "test/exercise_file.py" ) ) . unwrap ( ) ;
1388
1425
assert_eq ! ( f, "template" ) ;
1426
+
1427
+ // did not download submission because exercise hides submission results, for example exam exercise
1428
+ let f = file_util:: read_file_to_string ( e5. path . join ( "src/student_file.py" ) ) . unwrap ( ) ;
1429
+ assert_eq ! ( f, "template" ) ;
1430
+ assert ! ( e5. path. join( "src/template_only_student_file.py" ) . exists( ) ) ;
1431
+ let f = file_util:: read_file_to_string ( e5. path . join ( "test/exercise_file.py" ) ) . unwrap ( ) ;
1432
+ assert_eq ! ( f, "template" ) ;
1389
1433
}
1390
1434
1391
1435
#[ test]
0 commit comments