/// <summary> /// Attempts the task. Returns true if the lesson is finished /// a false return means you should refresh the task. /// </summary> /// <returns><c>true</c>, if task was attempted, /// <c>false</c> otherwise.</returns> /// <param name="command">Command.</param> /// <param name="args">Arguments.</param> public bool attemptTask(string command, string[] args, Interfaces.iModule mod) { cleanOnRun(); string disallowedArg = disallowedCheck(args); if (disallowedArg != null) { throw new ArgumentException ("ERROR: Your command contains a disallowed argument: " + disallowedArg); } if (mod.unsupportedCommand(command, args)) { throw new ArgumentException ("This command is unsupported by the module"); } mod.run(command, args); string comparison = mod.standardOutput(); lastStandardOutput = mod.standardOutput(); lastErrorOutput = mod.errorOutput(); lastResultCode = mod.resultCode(); if (isSandbox) { return(false); } if (activeTask.errorToTask) { comparison = mod.errorOutput(); } if (activeTask.commandToTask) { comparison = command + " "; foreach (string s in args) { comparison += s + " "; } comparison = comparison.TrimEnd(); } if (activeTask.errorToTask && activeTask.commandToTask) { comparison = mod.errorOutput() + Environment.NewLine + Environment.NewLine + command; } if (activeTask.hasPassed(comparison) && isLastTask) { return(true); } if (activeTask.hasPassed(comparison) && isLastTask == false) { activeTask = Tasks [currentTaskNo + 1]; return(false); } if (activeTask.hasPassed(comparison) == false) { return(false); } throw new Exception("An unknown exception ocurred in the lesson flow"); }