private void Form1_Load(object sender, EventArgs e) { string path = ConfigurationSettings.AppSettings["ProjectPath"]; string assemblyName = ConfigurationSettings.AppSettings["AssemblyName"]; try { projectData = XDocument.Load("XML/VsProject3Grader.xml"); string directory = Directory.GetCurrentDirectory(); string assemblyFile = string.Format("{0}\\{1}.DLL", directory, assemblyName); p4Assembly = Assembly.LoadFile(assemblyFile); //path + assemblyName + @".dll"); setup = new Setup(p4Assembly, projectData); grader = new Grader(setup.Name()); List <string> topicNames = setup.TopicNames(); foreach (string topicName in topicNames) { grader.Topics.Add(setup.SetupTopic(topicName)); } ProjectName.Text = grader.Name; PopulateData data = new PopulateData(); setup.GradeTheProject(grader, data); ResultsView.DataSource = grader.Topics; StudentName.Text = grader.Programmer; GradeSummary.Text = String.Format("Grade {0} / {1}", grader.TotalGrade, grader.TotalValue); Percentage.Text = String.Format("{0:0.0%}", grader.GradePercentage); ProgressIndicator.Maximum = grader.TotalValue; ProgressIndicator.Value = grader.TotalGrade; Color color = GetProgressColor(grader.GradePercentage); ProgressIndicator.BackColor = color; ProgressIndicator.ForeColor = color; } catch (System.IO.FileNotFoundException ex) { MessageBox.Show(String.Format("Could not load {0} from {1}. Check the properties in your App.Config file", assemblyName, path), "Could not find file", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ImportScoresFromFile_WithInvalidScore_ThrowsException() { const string FIRST_LINE = "KING, MADISON, 85"; const string SECOND_LINE = "BUNDY, TERESSA, 88"; bool expectedExceptionThrown = false; StringBuilder sb = new StringBuilder(); sb.Append(Environment.NewLine); sb.Append(FIRST_LINE); sb.Append(SECOND_LINE); sb.Append("LASTNAME, FIRSTNAME, INVALIDSCORE"); sb.Append(Environment.NewLine); //creating a streamReader to feed into ImportScoresFromFile using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString()))) { using (var streamReader = new StreamReader(stream)) { var grader = new Grader(); try { grader.ImportScoresFromFile(streamReader); } catch (Exception e) { //exception has been thrown as expected expectedExceptionThrown = true; } if (!expectedExceptionThrown) { Assert.Fail(); } } } }
public void spawnCritic() { Grader g = Instantiate(critics[nextCritic]).GetComponent <Grader>(); if (firstCritic) { g.Tutorial(); firstCritic = false; } int newCrit = nextCritic; while (newCrit == nextCritic && critics.Count > 1) { newCrit = Random.Range(0, critics.Count); } nextCritic = newCrit; GameObject nextText = GameObject.Find("Next Text"); nextText.GetComponent <TextMesh>().text = "Tomorrow's critique:\n" + critics[nextCritic].GetComponent <Grader>().bio.Replace("NLN", "\n"); nextText.GetComponent <MeshRenderer>().enabled = false; }
public double Step() { var mutations = _pool.Select((parent) => { try { var child = parent.Item1.Modify(Temperature); var solution = GenerateSolution(child); var cost = Grader.CostForSolution(solution); return(new Tuple <SolutionParameters, Searchspace, double>(child, solution, cost)); } catch (InvalidOperationException) { } catch (IndexOutOfRangeException) { } return(new Tuple <SolutionParameters, Searchspace, double>(null, new Searchspace(), -1)); }).Where((g) => g.Item1 != null); var additions = Enumerable.Range(0, 2).Select((i) => CreateRandom()); var newPool = _pool.Concat(mutations).Concat(additions).OrderBy((g) => g.Item3); _pool = newPool.Take(10).ToList(); var best = _pool.OrderBy((g) => g.Item3).First(); BestParameters = best.Item1; BestState = best.Item2; LowestCost = best.Item3; var iterBest = additions.Concat(mutations).OrderBy((g) => g.Item3).First(); Temperature *= 0.5; if (Temperature < 0.02) { Temperature = 1; } return(iterBest.Item3); }
public void ImportScoresFromFile_WithBlankLinesInInput_ReturnsGraderWithCorrectScoreList() { const string FIRST_LINE = "KING, MADISON, 85"; const string SECOND_LINE = "BUNDY, TERESSA, 88"; StringBuilder sb = new StringBuilder(); sb.Append(Environment.NewLine); sb.Append(FIRST_LINE); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append(SECOND_LINE); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); //creating a streamReader to feed into ImportScoresFromFile using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString()))) { using (var streamReader = new StreamReader(stream)) { var grader = new Grader(); grader.ImportScoresFromFile(streamReader); //we now need to check that the grader's scorelist matches what we loaded into the stream reader Assert.IsTrue(grader.ScoreList.Count == 2); //first item should be equal to the first line; Assert.That(FIRST_LINE, Is.EqualTo(grader.ScoreList[0].LastName + SEPARATOR + grader.ScoreList[0].FirstName + SEPARATOR + grader.ScoreList[0].Score)); //second item should be equal to the second line Assert.That(SECOND_LINE, Is.EqualTo(grader.ScoreList[1].LastName + SEPARATOR + grader.ScoreList[1].FirstName + SEPARATOR + grader.ScoreList[1].Score)); } } }
void Update() { if (eyesClosing) { eyesTimer += Time.deltaTime; if (eyesTimer >= 2) { dreamBed.Dream(); } return; } mouseOver = false; Ray ray = new Ray(transform.position, transform.forward); RaycastHit rayHit = new RaycastHit(); if (Physics.Raycast(ray, out rayHit)) { Debug.DrawLine(rayHit.point, transform.position); Photograph photo = rayHit.collider.gameObject.GetComponent <Photograph>(); Grader grader = rayHit.collider.gameObject.GetComponentInParent <Grader>(); Bed bed = rayHit.collider.gameObject.GetComponent <Bed>(); if (bed == null) { bed = rayHit.collider.gameObject.GetComponentInParent <Bed>(); } if (photo != null) { mouseOver = true; if (Input.GetButtonDown("Fire1")) { if (grabbedPhoto != null) { grabbedPhoto.transform.position = photo.transform.position; grabbedPhoto.transform.rotation = photo.transform.rotation; grabbedPhoto.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; grabbedPhoto.shrink(); photosToGrade.Remove(grabbedPhoto); } grabbedPhoto = photo; grabbedPhoto.transform.position = new Vector3(0, -10, 0); grabSound.pitch = Random.Range(0.75f, 2f); grabSound.Play(); } photosToGrade.Remove(grabbedPhoto); } else if (grader != null) { if (Input.GetButtonDown("Fire1")) { grader.Click(); } grader.talk(); } else if (bed != null && Input.GetButtonDown("Fire1")) { dreamBed = bed; eyesClosing = true; eyes.gameObject.SetActive(true); eyes.GetComponent <Animator>().SetTrigger("close"); //bed.Dream(); } else if (grabbedPhoto != null && Input.GetButtonDown("Fire1")) { grabbedPhoto.transform.position = rayHit.point + rayHit.normal * .05f; grabbedPhoto.transform.rotation = Quaternion.LookRotation(-rayHit.normal, Vector3.up); if (rayHit.normal.y < .5f) { grabbedPhoto.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; grabbedPhoto.grow(); if (rayHit.transform.name == "Grading Wall") { photosToGrade.Add(grabbedPhoto); } } else { grabbedPhoto.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; grabbedPhoto.shrink(); photosToGrade.Remove(grabbedPhoto); } pinSound.pitch = Random.Range(.75f, 2f); pinSound.Play(); grabbedPhoto = null; } } if (photosToGrade.Count == 3) { tutorialText.SetActive(false); } else { tutorialText.SetActive(true); } }
public bool removeGrader(Grader grader) { return(false); }
public bool addGrader(Grader grader) { return(false); }
public async Task <ActionResult <SubmissionDto> > PostSubmission(int taskId, [FromBody] SubmissionDto submissionDto) { int currentUserId = int.Parse(User.FindFirst(JwtRegisteredClaimNames.Sub).Value); // Get task info Entities.Task task = await _context.Tasks.SingleOrDefaultAsync(t => t.Id == taskId && (t.IsPublic || t.UserId == currentUserId)); if (task == null) { return(BadRequest()); } // Get language info ComputerLanguage lang = await _context.ComputerLanguages.FindAsync(submissionDto.LangId); if (lang == null) { return(BadRequest()); } // Get test cases await _context.Entry(task).Collection(t => t.TestCases).LoadAsync(); Submission submission = new Submission { SourceCode = submissionDto.SourceCode, LangId = submissionDto.LangId, UserId = currentUserId, TimeSubmitted = DateTime.Now, TaskId = taskId, Status = "UD", ExecutionTime = 0, ExecutionMemory = 0, }; // Save initial submission to DB to get a unique id _context.Submissions.Add(submission); await _context.SaveChangesAsync(); string executionRootDir = Grader.GetExecutionRootDir(); string sourceFileName = $"{submission.Id}.{lang.Extension}"; string binaryFileName = submission.Id.ToString(); string sourceFilePath = $"{executionRootDir}{sourceFileName}"; string binaryFilePath = $"{executionRootDir}{binaryFileName}"; // Create file from source code inside rootDir System.IO.File.WriteAllText(sourceFilePath, submissionDto.SourceCode); bool readyToRun = true; // Check if compiled language if (!string.IsNullOrEmpty(lang.CompileCmd)) { // Compile submission CompilationOutputDto co = Grader.Compile(lang, sourceFileName, binaryFileName); if (co.ExitCode != 0) { // Compile error submission.Status = "CE"; // Mark status as Compile Error submissionDto.Message = co.Error; // Set message as compile error message readyToRun = false; } } if (readyToRun) { // Compiled successfully or interpreted language, so we're ready to run the solution submission.Status = "AC"; // Submission status will stay accepted if all test cases pass (or if there aren't any TCs) string fileName = string.IsNullOrEmpty(lang.CompileCmd) ? sourceFileName : binaryFileName; int maxTimeMs = 0; // Track max execution time of test cases int maxMemoryB = 0; // Track max execution memory of test cases bool correctSoFar = true; for (int i = 0; correctSoFar && i < task.TestCases.Count; ++i) { TestCase tc = task.TestCases.ElementAt(i); GradeDto grade = Grader.Grade(lang, fileName, tc.Input, tc.Output, task.TimeLimit, task.MemoryLimit); maxTimeMs = Math.Max(maxTimeMs, grade.ExecutionTime); maxMemoryB = Math.Max(maxMemoryB, grade.ExecutionMemory); submission.Status = grade.Status; correctSoFar = grade.Status.Equals("AC"); } submission.ExecutionTime = maxTimeMs; // Set submission execution time as max out of all test cases submission.ExecutionMemory = maxMemoryB; // Set submission execution memory as max out of all test cases // Delete binary file if compiled if (!string.IsNullOrEmpty(lang.CompileCmd)) { System.IO.File.Delete(binaryFilePath); } } // Edit submission object status and stats await _context.SaveChangesAsync(); // Delete source file System.IO.File.Delete(sourceFilePath); // Prepare response DTO SubmissionDto responseDto = mapper.Map <SubmissionDto>(submission); responseDto.Message = submissionDto.Message; responseDto.Task = null; responseDto.ComputerLanguage = null; responseDto.User = null; return(CreatedAtAction("GetSubmission", new { id = submission.Id }, responseDto)); }
// Start is called before the first frame update void Start() { testGrade = Grader.getGrade(PlayerDataHolder.Current.GeneralRanking.StatFloat); StartCoroutine(startIncrementing(testGrade)); }
public Simulator() { Grader = new Grader(1); }
public void Construct(Grader grader, Settings settings) { mLecture = new Lecture(grader, settings.A, settings.B, settings.C); Debug.LogFormat("Grade : {0}", mLecture.Grade()); }
public bool SetGrader(Grader model) { throw new NotImplementedException(); }