// Handles interpretation of code and returns the output of the code
        public static string SubmitCode(string Code, Exercise CurrentExercise, string Username)
        {
            bool Correct;
            string ConsoleOutput = "Sorry, that was incorrect. Please, read the task and try again.";

            Code += CurrentExercise.ExAppendCode ?? "";

            Marker.Marker.MarkScheme = CurrentExercise.ExMarkScheme;

            try
            {
                LuaInterpreter.RunCode(Code);
                Correct = Marker.Marker.FullMark();
            }
            catch (Exception ex)
            {
                Correct = false;

                ConsoleOutput = ex.Message;
            }

            if (Correct)
            {
                Account.LevelUp(Username, CurrentExercise);
                ConsoleOutput = LuaInterpreter.CodeReport.Output;

                return ConsoleOutput;
            }
            else
                return ConsoleOutput;
        }
예제 #2
0
        public static void LevelUp(string Username, Exercise Exercise)
        {
            User User = UserDB.Users.Where(x => x.Username == Username).FirstOrDefault();

            if (User.UserLevel <= Exercise.ExID)
            {
                User.UserLevel++;

                UserDB.SaveChangesAsync();
            }
        }