From 97ba763f9517880ecfa6245c172a0e330ebdd11a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me>
Date: Tue, 3 Oct 2023 18:45:41 +0200
Subject: [PATCH] ExerciseResultsSanVal => Bug fix: path of the results file
 opened

---
 helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts b/helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts
index 608e406..37217d4 100644
--- a/helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts
+++ b/helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts
@@ -33,11 +33,11 @@ class ExerciseResultsSanitizerAndValidator {
         this.events.emit('endStep', 'RESULTS_FILE_SANITIZATION', 'Results file sanitized', false);
     }
 
-    private async resultsFileProvided(): Promise<boolean> {
+    private async resultsFileProvided(path: string): Promise<boolean> {
         // Results file schema validation
         {
             this.events.emit('step', 'VALIDATE_RESULTS_FILE', 'Validating results file schema');
-            const validationResults = SharedExerciseHelper.validateResultFile(this.resultsFilePath);
+            const validationResults = SharedExerciseHelper.validateResultFile(path);
             if ( !validationResults.isValid ) {
                 this.events.emit('endStep', 'VALIDATE_RESULTS_FILE', `Results file is not valid. Here are the errors :\n${ JSON.stringify(validationResults.errors) }`, true);
                 this.events.emit('finished', false, ExerciseCheckerError.EXERCISE_RESULTS_FILE_SCHEMA_NOT_VALID);
@@ -84,7 +84,7 @@ class ExerciseResultsSanitizerAndValidator {
             if ( fs.existsSync(resultsFileOriginPath) ) {
                 this.events.emit('endStep', 'CHECK_RESULTS_FILE_EXIST', 'Results file found', false);
 
-                result = await this.resultsFileProvided();
+                result = await this.resultsFileProvided(resultsFileOriginPath);
 
                 if ( result ) {
                     fs.rmSync(resultsFileOriginPath, { force: true });
@@ -98,7 +98,7 @@ class ExerciseResultsSanitizerAndValidator {
             }
 
             if ( result ) {
-                fs.writeFileSync(this.resultsFilePath, JSON5.stringify(this.exerciseResults), 'utf8');
+                fs.writeFileSync(this.resultsFilePath, JSON5.stringify(this.exerciseResults, { space: 4 }), 'utf8');
 
                 this.events.emit('finished', true, 0);
             }
-- 
GitLab