コード例 #1
0
        //
        // 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));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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());
        }