Skip to content
Snippets Groups Projects
Commit 0b6c1480 authored by Janis Daniel Dähne's avatar Janis Daniel Dähne
Browse files

- fixed issue where the tutor view could not run tests when the main file was hidden

  - this was because tutor tests are executed with frontend data only (files) thus the file content was empty
  - tutor view now get the hidden file content (from the template)
parent 7d14ea62
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ namespace ClientServer.Helpers
/// </summary>
public static class Constants
{
public static string VersionString = "2.6.3";
public static string VersionString = "2.6.4";
/// <summary>
/// this is only set once at program.cs!!
......
......@@ -575,10 +575,18 @@ namespace ClientServer.Controllers.Core.Exercises
int userId = GetUserId();
await _GetSolutionForExercise(generatedCode, pLangId, userId);
await _GetSolutionForExercise(generatedCode, pLangId, userId, false);
}
internal async Task _GetSolutionForExercise(string generatedCode, int pLangId, int targetUserId)
/// <summary>
///
/// </summary>
/// <param name="generatedCode"></param>
/// <param name="pLangId"></param>
/// <param name="targetUserId"></param>
/// <param name="asTutor">true: tutors need the hidden file content because currently tutor editors are not stored yet so only the frontend gives data to run tests for tutors... false: a student, so hide hidden files</param>
/// <returns></returns>
internal async Task _GetSolutionForExercise(string generatedCode, int pLangId, int targetUserId, bool asTutor)
{
int userId = targetUserId;
......@@ -715,8 +723,22 @@ namespace ClientServer.Controllers.Core.Exercises
return;
}
//template files should be loaded
var errorMsg = UserSolutionHelper.ReplaceReadonlyFiles(userSolution, template, true, false);
//template files should be loaded
string errorMsg;
if (asTutor)
{
//currently tutor editors are not persistent so the frontend needs all data to run a test
//this includes the hidden file contents...
errorMsg = UserSolutionHelper.ReplaceReadonlyFiles(userSolution, template, false, true);
}
else
{
//normal student, replace hidden files with empty content
errorMsg = UserSolutionHelper.ReplaceReadonlyFiles(userSolution, template, true, false);
}
if (errorMsg != null)
{
......
......@@ -361,7 +361,7 @@ namespace ClientServer.Controllers.Core.Exercises
if (exerciseRelease == null) return;
var doExerciseController = new DoExerciseController(_context) {ControllerContext = this.ControllerContext};
await doExerciseController._GetSolutionForExercise(exerciseRelease.GeneratedCode, pLangId, userId);
await doExerciseController._GetSolutionForExercise(exerciseRelease.GeneratedCode, pLangId, userId, true);
}
[HttpGet("testresults/{exerciseReleaseId}/{userId}/{pLangId}")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment