// // GET: /AssignmentWizard/ABET/ public override ActionResult Index() { base.Index(); ModelState.Clear(); // Make a list of departments List <string> depts = new List <string>(); OSBLE.Models.FileSystem.OSBLEDirectory fs = OSBLE.Models.FileSystem.Directories.GetAdmin(); OSBLE.Models.FileSystem.OSBLEFile file = fs.GetFile("departments.txt"); if (null == file) { // Administrator hasn't created the departments list yet. Leave the list // empty so that the option will show up as disabled on the page. } else { depts.AddRange(file.ReadAllLines()); } ViewBag.DepartmentsList = depts; // We want a collection of DIVs on the page that list the outcome options // for each department. We build the HTML for that here. StringBuilder sb = new StringBuilder(); foreach (string dept in depts) { // We're expecting a text file with a name in the format: // [department]_abet_outcomes.txt string fname = System.IO.Path.Combine(fs.GetPath(), dept + "_abet_outcomes.txt"); if (System.IO.File.Exists(fname)) { int i = 0; string[] fileLines = System.IO.File.ReadAllLines(fname); sb.AppendLine( "<div id=\"" + dept + "\" style=\"display: none;\">"); foreach (string line in fileLines) { bool isChecked = ContainsOutcome(Assignment.ABETOutcomes, line); sb.AppendFormat( " <input type=\"checkbox\" id=\"{0}\" name=\"{0}\" value=\"{1}\" {2}/>{1}<br />", "cb" + dept + (i++).ToString(), line, isChecked ? "checked " : string.Empty); } sb.AppendLine("</div>"); } else { // If the file DOESN'T exist then we want something on the page that // will let the user know to contact the admin. sb.AppendLine( "<div id=\"" + dept + "\" style=\"display: none;\">ABET outcomes for this " + "department are not yet available. Please contact your system administrator " + "about this issue.</div>"); } } ViewBag.OptionsDIVsHTML = sb.ToString(); return(View(Assignment)); }
public ActionResult Save() { // For the save we'll be dumping all the text from the text area // into a text file in the root file system. // Get the department from the form data string dept = Request.Form["slctDepartment"]; if (string.IsNullOrEmpty(dept)) { throw new Exception( "Was expecting a valid department from the form data but instead " + "got a null or empty string. Make sure that the department list " + "file does not have blank lines."); } // Get the list of ABET options from the form data string opts = Request.Form["taOptions"]; if (null == opts) { // Empty strings are OK, null strings are not throw new Exception("Form data missing \"taOptions\"."); } // Write the file OSBLE.Models.FileSystem.OSBLEDirectory fs = Models.FileSystem.Directories.GetAdmin(); fs.AddFile(dept + "_abet_outcomes.txt", System.Text.Encoding.UTF8.GetBytes(opts)); // Go back to the main admin page return(RedirectToAction("Index", "Admin")); }
public ActionResult Save() { // Get the list of departments from the form data string allDepts = Request.Form["taDepts"]; if (null != allDepts) { OSBLE.Models.FileSystem.OSBLEDirectory fs = Models.FileSystem.Directories.GetAdmin(); fs.AddFile("departments.txt", System.Text.Encoding.UTF8.GetBytes(allDepts)); } return(RedirectToAction("Index", "Admin")); }
public ActionResult Index() { // Although the administrative link for the ABET outcomes editor // shouldn't even appear if the departments list isn't made, we // check for that here anyway. StringBuilder jsArr = new StringBuilder("var ABET_existing_outcomes = new Array();"); jsArr.AppendLine(); string[] depts = null; Dictionary <string, string> existing = new Dictionary <string, string>(); OSBLE.Models.FileSystem.OSBLEDirectory fs = OSBLE.Models.FileSystem.Directories.GetAdmin(); string path = fs.GetPath(); int i = 0; if (System.IO.Directory.Exists(path)) { path = System.IO.Path.Combine(path, "departments.txt"); if (System.IO.File.Exists(path)) { depts = System.IO.File.ReadAllLines(path); foreach (string dept in depts) { existing[dept] = LoadABETOptions(dept); jsArr.AppendFormat( "ABET_existing_outcomes[{0}] = {1};", i++, MakeJSLinesArray(existing[dept])); jsArr.AppendLine(); } } } // Set the department list and options dictionary so // that the view can use it ViewBag.DepartmentList = depts; ViewBag.OptionsDictionary = existing; ViewBag.JSDeptOpts = jsArr.ToString(); return(View()); }
private string LoadABETOptions(string departmentName) { OSBLE.Models.FileSystem.OSBLEDirectory fs = Models.FileSystem.Directories.GetAdmin(); string path = fs.GetPath(); if (System.IO.Directory.Exists(path)) { // We're expecting a text file with a name in the format: // [department]_abet_outcomes.txt path = System.IO.Path.Combine( path, departmentName + "_abet_outcomes.txt"); if (System.IO.File.Exists(path)) { return(System.IO.File.ReadAllText(path)); } } return(string.Empty); }
public ActionResult Index() { // The list of departments is stored in a plain text file in the // root directory of the file system. string[] depts = null; OSBLE.Models.FileSystem.OSBLEDirectory fs = Models.FileSystem.Directories.GetAdmin(); string path = fs.GetPath(); if (System.IO.Directory.Exists(path)) { path = System.IO.Path.Combine(path, "departments.txt"); if (System.IO.File.Exists(path)) { depts = System.IO.File.ReadAllLines(path); } } ViewBag.DepartmentList = depts; return(View()); }
// // GET: /Admin/ public ViewResult Index() { // We'll check for the existence of the departments list file and // show or hide the ABET outcomes link based on this OSBLE.Models.FileSystem.OSBLEDirectory fs = Models.FileSystem.Directories.GetAdmin(); bool showLink = false; if (fs.File("departments.txt").Count > 0) { showLink = true; } ViewBag.ShowABETOutcomesLink = showLink; // Get list of users (other than current user) ordered by last name, who are not pending List <UserProfile> userprofiles = db.UserProfiles.Where(u => u.ID != CurrentUser.ID && u.UserName != null).OrderBy(u => u.LastName).Include(u => u.School).ToList(); // Add pending users to bottom of list. userprofiles = userprofiles.Concat(db.UserProfiles.Where(u => u.ID != CurrentUser.ID && u.UserName == null).ToList()).ToList(); return(View(userprofiles)); }