Beispiel #1
0
        /// <summary>
        /// calculates the grade of the given pda-constuction-problem attempt
        /// </summary>
        /// <param name="xmlPdaCorrect">the correct pda that defines the language</param>
        /// <param name="xmlPdaAttempt">attempt pda created by the solver</param>
        /// <param name="xmlGiveStackAlphabet">whether the stack-alphabet was given or the solver could define it himself</param>
        /// <param name="xmlMaxGrade">maximum reachable grade</param>
        /// <returns>grade of the problem attempt and a detailed feedback</returns>
        public static XElement GradeConstructionProblem(XElement xmlPdaCorrect, XElement xmlPdaAttempt, XElement xmlGiveStackAlphabet, XElement xmlMaxGrade)
        {
            int timeOut = 10000;

            try
            {
                return(TimeGuard <XElement> .Run(token => TryToGradeConstructionProblem(xmlPdaCorrect, xmlPdaAttempt, xmlGiveStackAlphabet, xmlMaxGrade, token), timeOut));
            }
            catch (TimeoutException)
            {
                return(Grader.CreateXmlFeedback(0, new List <string>()
                {
                    "Timeout - your inputs seem to be too big"
                }));
            }
        }
Beispiel #2
0
        /// <summary>
        /// calculates the grade of the given pda-word-problem attempt
        /// </summary>
        /// <param name="xmlPda">pda in xml-representation</param>
        /// <param name="xmlWordsInLanguage">words in xml-format that should be in the language of the pda</param>
        /// <param name="xmlWordsNotInLanguage">words in xml-format that should not be in the language of the pda</param>
        /// <param name="xmlMaxGrade">maximum reachable grade</param>
        /// <returns>grade of the problem attempt and a detailed feedback</returns>
        public static XElement GradeWordProblemAsync(XElement xmlPda, XElement xmlWordsInLanguage, XElement xmlWordsNotInLanguage, XElement xmlMaxGrade)
        {
            int timeOut = 10000;

            try
            {
                return(TimeGuard <XElement> .Run(token => TryToGradeWordProblem(xmlPda, xmlWordsInLanguage, xmlWordsNotInLanguage, xmlMaxGrade, token), timeOut));
            }
            catch (TimeoutException)
            {
                return(Grader.CreateXmlFeedback(0, new List <string>()
                {
                    "Timeout - your inputs seem to be too big"
                }));
            }
        }
        public static XElement RunSimulationAsync(XElement xmlPda, XElement xmlWord)
        {
            int timeOut = 10000;

            try
            {
                //var task = TimeGuard<XElement>.RunAsync(token => TryToRunSimulation(xmlPda, xmlWord, token), timeOut);
                return(TimeGuard <XElement> .Run(token => TryToRunSimulation(xmlPda, xmlWord, token), timeOut));

                //task.Wait();
                //return task.Result;
            }
            catch (TimeoutException)
            {
                return(Error("Timeout - your inputs seem to be too big"));
            }

            /*catch (AggregateException)
             * {
             *  return Error("Timeout - your inputs seem to be too big");
             * }*/
        }