public int Start(StartInput startInput) { var refazerDb = new RefazerDbContext(); //First, create an experiment for this grading section var session = new Session(); refazerDb.Sessions.Add(session); refazerDb.SaveChanges(); //associate the submissions to this experiment and save startInput.Submissions.ForEach(s => s.SessionId = session.ID); foreach (var submission in startInput.Submissions) { refazerDb.Submissions.Add(submission); } refazerDb.SaveChanges(); return(session.ID); }
private IEnumerator Handler() { SetColor(Color.green); StartInput?.Invoke(this); ShowQuad(); while (Input.GetMouseButton(0) || Input.GetMouseButton(1)) { yield return(null); } string input = label.text; int count = input.Length; bool done = false; while (!done) { string current = Input.inputString; if (Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter)) { done = true; } else if (count > 0 && Input.GetKeyDown(KeyCode.Backspace)) { string changed = input.Remove((count--) - 1, 1); input = changed.Trim(); } else if (!string.IsNullOrEmpty(current)) { int parsedInt = -1; char[] chars = current.ToCharArray(); bool isPunctuation = false; for (int i = 0; chars.Length > i && !isPunctuation; i++) { if (chars[i] == '.') { isPunctuation = true; } } bool isNumber = int.TryParse(current, out parsedInt); bool valid = _contentMode == ContentMode.TextAndNumbers || (_contentMode == ContentMode.Text && !isNumber) || (_contentMode == ContentMode.Numbers && (isNumber || isPunctuation)); if (valid) { input = input + current; count += current.Length; } } label.SetText(input); yield return(null); } SetColor(Color.white); EndInput?.Invoke(this); _handler = null; HideQuad(); }