public class StudentTest { public List<SelectListItem> files { get; set; } public string currentPath { get; set; } public string inputText { get; set; } public string correctOutput { get; set; } public string studentOutput { get; set; } }
@using (Html.BeginForm("Test", "Development")) { @Html.DropDownListFor(model => model.currentPath, Model.files, "Select test case", new { @class = "dropdown", onchange = "this.form.submit();" }) } <br /> <br /> <div class="CodeMirror cm-s-zenburn cm-error cm-bracket" style="position:absolute;border:solid;top:200px;left:10px;width:500px"> @Html.TextAreaFor(model=>model.inputText,new { id = "inputText"}) </div>
public ActionResult Test() { st = new StudentTest(); var user = UserManager.FindById(((Student)CurrentUser).InstructorID); Instructor Instructor = (Instructor)user; st.files = new List<SelectListItem>(); var files = Directory.GetFiles(Server.MapPath("~/Content/" + Instructor.UserName + "/inputs")); foreach (var file in files){ st.files.Add(new SelectListItem { Text = Path.GetFileName(file), Value= file }); } return View(st); } [HttpPost] public ActionResult Test(string x) { st = new StudentTest(); var user = UserManager.FindById(((Student)CurrentUser).InstructorID); Instructor Instructor = (Instructor)user; st.files = new List<SelectListItem>(); var files = Directory.GetFiles(Server.MapPath("~/Content/" + Instructor.UserName + "/inputs")); foreach (var file in files) { st.files.Add(new SelectListItem { Text = Path.GetFileName(file), Value = file }); } st.inputText = System.IO.File.ReadAllText(x); return View(st); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)