private void Start() { this.PopulateLevelEntries(LevelManager.LevelInfo.AutograderLevels, AutograderManager.levelScores.ToArray(), out float totalScore, out float totalTime, out bool requiredTrial); this.texts[(int)Texts.Title].text = $"{LevelManager.LevelInfo.FullName} Autograder"; this.texts[(int)Texts.Total].text = $"{totalScore:F2}/{LevelManager.LevelInfo.AutograderMaxScore:F2}; {totalTime} seconds"; this.texts[(int)Texts.RequiredTrialExplanation].gameObject.SetActive(requiredTrial); this.inputFields[(int)InputFields.Username].text = Settings.Username; this.inputFields[(int)InputFields.ScoreCode].text = this.GenerateScoreCode(LevelManager.LevelInfo, totalScore, Settings.Username); if (AutograderSummary.WasError || AutograderSummary.WasRequiredLevelFailed) { this.cutShortMessage.SetActive(true); Text message = this.cutShortMessage.GetComponentsInChildren <Text>()[0]; if (AutograderSummary.WasError) { message.text = "The autograder was cut short because an error occurred. This may be because your Python program encountered an error."; } else // wasRequiredLevelFailed { AutograderLevelInfo lastLevelInfo = LevelManager.LevelInfo.AutograderLevels[AutograderManager.levelScores.Count - 1]; message.text = $"The autograder was cut short because you did not pass the required trial <b>{AutograderManager.levelScores.Count}. {lastLevelInfo.Title}</b>. To complete the full autograder for this lab, you must pass that trial with full points."; } } AutograderSummary.WasError = false; AutograderSummary.WasRequiredLevelFailed = false; }
/// <summary> /// Initializes the entry with score and time information. /// </summary> /// <param name="levelInfo">Information about the level.</param> /// <param name="bestTimeInfo">Information about the user's performance in the level.</param> public void SetInfo(AutograderLevelInfo levelInfo, AutograderLevelScore levelScore) { this.texts[(int)Texts.Name].text = levelInfo.IsRequired ? $"*{levelInfo.Title}" : levelInfo.Title; if (levelScore != null) { this.texts[(int)Texts.Score].text = $"{levelScore.Score:F2}/{levelInfo.MaxPoints:F2}"; this.texts[(int)Texts.Time].text = levelScore.Time.ToString("F2"); if (levelInfo.MaxPoints > 0 && levelScore.Score == 0) { // No credit this.texts[(int)Texts.Score].color = Color.red; } else if (levelScore.Score > levelInfo.MaxPoints) { // Extra credit this.texts[(int)Texts.Score].color = AutograderUIEntry.extraCreditColor; } else if (levelScore.Score != levelInfo.MaxPoints) { // Partial credit this.texts[(int)Texts.Score].color = AutograderUIEntry.partialCreditColor; } } else { this.texts[(int)Texts.Score].text = $"--/{levelInfo.MaxPoints:F2}"; this.texts[(int)Texts.Score].color = Color.red; this.texts[(int)Texts.Time].text = "--"; } }