private void BindData()
        {
            Users userda = new Users(Globals.CurrentIdentity);
            Courses courseda = new Courses(Globals.CurrentIdentity);
            int courseID = GetCourseID();

            User user = userda.GetInfo(GetUsername(), null);
            txtFirst.Text = user.FirstName; txtLast.Text = user.LastName;
            txtEmail.Text = user.Email;

            double total = courseda.GetTotalPoints(courseID);
            double userp = userda.GetCoursePoints(user.UserName, courseID);
            lblTotal.Text = String.Format("{0} / {1} ({2}%)",
                userp, total, Math.Round((userp/total)*100.0, 2));

            dgReport.DataSource = courseda.GetAssignments(courseID);
            dgReport.DataBind();

            CourseRole.CourseRoleList roles = courseda.GetRoles(courseID, null);
            CourseRole urole = courseda.GetRole(user.UserName, courseID, null);
            ddlRoles.Items.Clear();
            foreach (CourseRole role in roles) {
                ListItem item = new ListItem(role.Name, role.PrincipalID.ToString());
                if (role.PrincipalID == urole.PrincipalID)
                    item.Selected = true;
                ddlRoles.Items.Add(item);
            }
        }
Пример #2
0
        public string Backup(int asstID)
        {
            string zfile, wzfile;

            Assignment asst = GetInfo(asstID);

            //Check permission
            Authorize(asst.CourseID, "createbackup", asstID, null);

            //Create our external sink file
            IExternalSink extsink =
                ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IExternalSink;

            zfile = Globals.PurifyString(asst.Description)+
                DateTime.Now.Hour+DateTime.Now.Minute+DateTime.Now.Second+".zip";
            wzfile = Globals.BackupDirectoryName + "/" + zfile;
            zfile = Path.Combine(Globals.BackupDirectory, zfile);
            extsink.CreateSink(zfile);

            //Backup Info
            //Backup Results

            //Back up submissions
            Users users = new Users(m_ident);
            User.UserList mems = new Courses(m_ident).GetMembers(asst.CourseID, null);

            foreach (User mem in mems)
                users.Backup(mem.UserName, asst.CourseID, asstID, extsink);

            extsink.CloseSink();

            new Backups(m_ident).Create(asst.Description, wzfile, asst.CourseID);

            return zfile;
        }
Пример #3
0
        private void Page_Load(object sender, EventArgs e)
        {
            int courseID = Convert.ToInt32(Request.Params["CourseID"]);
            CourseRole role =
                new Courses(Globals.CurrentIdentity).GetRole(Globals.CurrentUserName, courseID, null);

            if (role == null || !role.Staff)
                Page.Response.Redirect("error.aspx?Code="+
                    Convert.ToInt32(Pages.ErrorPage.Codes.PERMISSION));
        }
Пример #4
0
        protected void CreatePermissions(int entityID, int courseID, string type)
        {
            CourseRole.CourseRoleList roles = new Courses(m_ident).GetRoles(courseID, null);
            Permissions permda = new Permissions(m_ident);

            //Give actor permission power
            CourseRole mrole = new Courses(m_ident).GetRole(m_ident.Name, courseID, null);
            m_dp.AssignPermission(mrole.PrincipalID, "updateperms", type, entityID);
            foreach (CourseRole role in roles) {
                if (role.Staff) {
                    //Do the rest of the perms
                    Permission.PermissionList perms = permda.GetTypePermissions(type);
                    foreach (Permission perm in perms)
                        permda.Assign(role, type, perm.Name, entityID, courseID);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Check to see if principal ID has permission
        /// </summary>
        public Permission.GrantType CheckPermission(int principalID, int courseID, string etype, 
            string perm, int entityID)
        {
            //Check ID directly
            if (m_dp.CheckPermission(principalID, courseID, perm, entityID, etype, null))
                return Permission.GrantType.DIRECT;

            Principal prin = new Principals(m_ident).GetInfo(principalID);
            if (prin.Type == Principal.USER) {
                CourseRole role = new Courses(m_ident).GetRole(
                    prin.Name, courseID, null);
                if (m_dp.CheckPermission(role.PrincipalID, courseID, perm, entityID, etype, null))
                    return Permission.GrantType.INHERIT;
            }

            return Permission.GrantType.DENY;
        }
Пример #6
0
        public void dgCourseList_Update(object sender, DataGridCommandEventArgs e)
        {
            Course course = new Course();
            Courses courseda = new Courses(Globals.CurrentIdentity);

            course = courseda.GetInfo((int) dgCourseList.DataKeys[e.Item.ItemIndex]);
            course.Name = ((TextBox)(e.Item.Cells[1].Controls[1])).Text;
            course.Number = (e.Item.Cells[2].Controls[1] as TextBox).Text;

            try {
                courseda.Update(course);
            } catch (CustomException er) {
                PageError(er.Message);
            }

            dgCourseList.EditItemIndex = -1;
            BindData();
        }
Пример #7
0
        private void BindPrincipals()
        {
            int courseID = Convert.ToInt32(Request.Params["CourseID"]);
            Courses courseda = new Courses(Globals.CurrentIdentity);
            User.UserList users = courseda.GetMembers(courseID, null);
            CourseRole.CourseRoleList roles = courseda.GetRoles(courseID, null);

            ddlPrins.Items.Clear();
            //Add roles
            foreach (CourseRole role in roles) {
                ListItem item = new ListItem("Role: " + role.Name, role.PrincipalID.ToString());
                ddlPrins.Items.Add(item);
            }

            //Add users
            foreach (User user in users) {
                ListItem item = new ListItem(user.FullName + " (" + user.UserName + ")", user.PrincipalID.ToString());
                ddlPrins.Items.Add(item);
            }
        }
Пример #8
0
        private void BindData()
        {
            Sections sectda = new Sections(Globals.CurrentIdentity);
            Section sect = sectda.GetInfo(GetSectionID());

            User.UserList secs = sectda.GetMembers(sect.ID);
            lstSectionUsers.Items.Clear();
            foreach (User user in secs)
                lstSectionUsers.Items.Add(
                    new ListItem(user.FullName + " (" + user.UserName + ")", user.UserName));

            User.UserList mems =
                new Courses(Globals.CurrentIdentity).GetMembers(sect.CourseID, null);
            lstAllUsers.Items.Clear();
            foreach (User user in mems)
                lstAllUsers.Items.Add(
                    new ListItem(user.FullName + " (" + user.UserName + ")", user.UserName));

            lnkSecExpl.Attributes.Add("onClick",
                @"window.open('sectionexpl.aspx?CourseID=" + sect.CourseID +
                @"', '"+sect.CourseID+@"', 'width=430, height=530')");
        }
Пример #9
0
        private void BindData()
        {
            int i;
            int courseID = GetCourseID();
            Courses courseda = new Courses(Globals.CurrentIdentity);
            User.UserList users =  courseda.GetStaff(courseID, null);
            CourseRole.CourseRoleList roles = courseda.GetRoles(courseID, null);

            Principal.PrincipalList prins = new Principal.PrincipalList();
            prins.AddRange(roles); prins.AddRange(users);

            dgRoles.DataSource = prins;
            dgRoles.DataBind();

            for (i = 0; i < roles.Count; i++) {
                if (roles[i].Staff) {
                    dgRoles.SelectedIndex = i;
                    BindPermissions();
                    break;
                }
            }
        }
Пример #10
0
        private void BindData()
        {
            Courses courseda = new Courses(Globals.CurrentIdentity);
            Assignment asst = new Assignments(Globals.CurrentIdentity).GetInfo(GetAsstID());
            Course course = courseda.GetInfo(asst.CourseID);

            Section.SectionList sections = courseda.GetSections(course.ID);
            CourseMember.CourseMemberList mems = courseda.GetMembers(course.ID, null);

            ArrayList secmems = sections;
            secmems.AddRange(mems);

            dgUsers.DataSource = secmems;
            dgUsers.DataBind();

            cmdEvaluate.Enabled = asst.ResultRelease;
            lblEvaluate.Visible = !asst.ResultRelease;

            lnkSecExpl.Attributes.Add("onClick",
                @"window.open('sectionexpl.aspx?CourseID=" + course.ID +
                @"', '"+ course.ID+@"', 'width=430, height=530')");
        }
Пример #11
0
        private void BindUserGrid()
        {
            int courseID = Convert.ToInt32(Request.Params["CourseID"]);
            User.UserList users =
                new Courses(Globals.CurrentIdentity).GetMembers(courseID, null);

            dgUsers.DataSource = users;
            dgUsers.DataBind();
        }
Пример #12
0
        private void tvSection_Check(object sender, TreeViewClickEventArgs e)
        {
            TreeNode node = tvSection.GetNodeFromIndex(e.Node);
            Users users = new Users(Globals.CurrentIdentity);
            int courseID = Convert.ToInt32(HttpContext.Current.Request.Params["CourseID"]);
            string[] tokens;

            if (node.NodeData.IndexOf("Uname") == 0) {
                tokens = node.NodeData.Split(" ".ToCharArray());
                int pid = users.GetInfo(tokens[1], null).PrincipalID;
                ArrayList prins = Principals;
                if (node.Checked)
                    prins.Add(pid);
                else
                    prins.Remove(pid);

                Principals = prins;
            }
            else if (node.NodeData.IndexOf("Group") == 0) {
                tokens = node.NodeData.Split(" ".ToCharArray());
                int pid = Convert.ToInt32(tokens[1]);
                ArrayList prins = Principals;
                if (node.Checked)
                    prins.Add(pid);
                else
                    prins.Remove(pid);

                Principals = prins;
            }
            else if (node.NodeData.IndexOf("Uallusers") == 0) {
                User.UserList mems = new Courses(Globals.CurrentIdentity).GetMembers(courseID, null);
                ArrayList prins = Principals;

                foreach (TreeNode cnode in node.Nodes)
                    cnode.Checked = node.Checked;

                foreach (User mem in mems) {
                    if (node.Checked)
                        prins.Add(mem.PrincipalID);
                    else
                        prins.Remove(mem.PrincipalID);
                }

                node.Expanded = true;
                Principals = prins;
            }
            else if (node.NodeData.IndexOf("Section") == 0) {
                tokens = node.NodeData.Split(" ".ToCharArray());
                User.UserList susers = (new Sections(Globals.CurrentIdentity)).GetMembers(
                    Convert.ToInt32(tokens[1]));

                if (node.Nodes.Count == 0)
                    AddSectionMembers(node);

                foreach (TreeNode cnode in node.Nodes)
                    cnode.Checked = node.Checked;

                ArrayList prins = Principals;
                foreach (User user in susers) {
                    if (node.Checked)
                        prins.Add(user.PrincipalID);
                    else
                        prins.Remove(user.PrincipalID);
                }

                node.Expanded = true;
                Principals = prins;
            }
        }
Пример #13
0
        private void AddAllUsers(int courseID)
        {
            TreeNode courses = AddNode(tvSection.Nodes, true, "All Users", "attributes/group.jpg",
                                       "Uallusers");
            User.UserList mems = new Courses(Globals.CurrentIdentity).GetMembers(courseID, null);
            foreach (User mem in mems) {
                TreeNode root = AddNode(courses.Nodes, true,
                    mem.FullName + " (Username: "******")" ,
                    "attributes/user.jpg", "Uname " + mem.UserName);

                AddNode(root.Nodes, false, "Sections", "attributes/folder.gif", "attributes/folderopen.gif",
                    "USects " + mem.UserName);
                AddNode(root.Nodes, false, "Submission Groups", "attributes/folder.gif", "attributes/folderopen.gif",
                    "UGrous " + mem.UserName);
            }
        }
Пример #14
0
        private void dgCourseList_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Backup") {
                int courseID = (int) dgCourseList.DataKeys[e.Item.ItemIndex];
                try {
                    string fname = new Courses(Globals.CurrentIdentity).Backup(courseID);
                    BackupPageError("Backup completed successfully. Visit the Backups " +
                        "tab to download the file: " + fname);
                } catch (CustomException er) {
                    PageError(er.Message);
                }
            } else if (e.CommandName == "Available") {
                int courseID = (int) dgCourseList.DataKeys[e.Item.ItemIndex];
                Courses courseda = new Courses(Globals.CurrentIdentity);
                Course course = courseda.GetInfo(courseID);
                course.Available = !course.Available;
                try {
                    courseda.Update(course);
                } catch (CustomException er) {
                    PageError(er.Message);
                }

                BindData();
            }
        }
Пример #15
0
        /// <summary>
        /// Get the export heading for a course export
        /// </summary>
        public ExportRow GetCourseExportHeading(int courseID)
        {
            ExportRow row = new ExportRow();
            Assignment.AssignmentList assts = new Courses(m_ident).GetAssignments(courseID);

            //User
            row.Fields.Add("Username");
            //Course Total
            row.Fields.Add("Course Total");
            foreach (Assignment asst in assts)
                row.Fields.AddRange(GetAsstExportHeading(asst.ID).Fields);

            return row;
        }
Пример #16
0
        private int CommitTestSource(AutoEvaluation eval, IExternalSource zone)
        {
            FileSystem fs = new FileSystem(m_ident);

            //Make sure toplevel zone directory exists
            CFile zonedir = fs.GetFile(@"c:\zones");
            if (null == zonedir)
                zonedir = fs.CreateDirectory(@"c:\zones", true, null);

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(eval.CourseID, true, null);
            foreach (CourseRole role in staff)
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));

            //Create zone directory
            string zpath = @"c:\zones\" + eval.ID;
            CFile ezonedir;
            if (null == (ezonedir = fs.GetFile(zpath))) {
                ezonedir = fs.CreateDirectory(zpath, false, perms);
                ezonedir.Alias = eval.Name; ezonedir.SpecType = CFile.SpecialType.TEST;
                fs.UpdateFileInfo(ezonedir, false);
            }
            fs.ImportData(zpath, zone, false, true); //Import the data

            return ezonedir.ID;
        }
Пример #17
0
        /// <summary>
        /// Load submission directory with new files, updates time
        /// </summary>
        public bool Update(Submission sub, IExternalSource files)
        {
            FileSystem fs = new FileSystem(m_ident);
            bool       markcmp, unmarkcmp, defunct;

            //Get old sub
            Components.Submission oldsub = GetInfo(sub.ID);
            markcmp = (oldsub.Status == Components.Submission.UNGRADED &&
                       sub.Status == Components.Submission.GRADED);
            unmarkcmp = (oldsub.Status == Components.Submission.GRADED &&
                         sub.Status == Components.Submission.UNGRADED);
            defunct = (oldsub.Status != Components.Submission.DEFUNCT &&
                       sub.Status == Components.Submission.DEFUNCT);

            //Make sure toplevel zone directory exists
            CFile subdir = fs.GetFile(@"c:\subs");

            if (null == subdir)
            {
                subdir = fs.CreateDirectory(@"c:\subs", true, null, false);
            }

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            int courseID = new Assignments(m_ident).GetInfo(sub.AsstID).CourseID;

            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(courseID, true, null);
            foreach (CourseRole role in staff)
            {
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
            }
            perms.AddRange(CFilePermission.CreateOprFullAccess(sub.PrincipalID));

            //Create zone directory
            CFile  esubdir;
            string zpath = @"c:\subs\" + sub.ID;

            if (null == (esubdir = fs.GetFile(zpath)))
            {
                esubdir          = fs.CreateDirectory(zpath, false, perms, false);
                esubdir.SpecType = CFile.SpecialType.SUBMISSION;
                string name = new Principals(m_ident).GetInfo(sub.PrincipalID).Name;
                esubdir.Alias = String.Format("{0}: {1}",
                                              name, GetNextSubmission(sub.AsstID, sub.PrincipalID));
                fs.UpdateFileInfo(esubdir, false);
            }
            //Update sub entry
            sub.LocationID = esubdir.ID;
            m_dp.UpdateSubmission(sub);


            //Load files
            try {
                fs.ImportData(zpath, files, false, false);                 //Import the data
            } catch (Exception) {
                throw new DataAccessException("Invalid external file source. This means the system does " +
                                              "not understand how to extract files from the source. Please create a valid source");
            }

            //Verify submission structure
            VerifyFormat(sub.AsstID, zpath);

            //Log
            if (markcmp)
            {
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " completed", sub.ID);
            }
            else if (unmarkcmp)
            {
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " incomplete", sub.ID);
            }
            else if (defunct)
            {
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " defunct", sub.ID);
            }

            return(true);
        }
Пример #18
0
        public void SynchronizePoints()
        {
            Courses courseda = new Courses(m_ident);
            Assignments asstda = new Assignments(m_ident);
            int total=0;

            Course.CourseList courses = courseda.GetAll();
            foreach (Course course in courses) {
                Assignment.AssignmentList assts = courseda.GetAssignments(course.ID);
                foreach (Assignment asst in assts) {
                    Rubric arub = asstda.GetRubric(asst.ID);
                    Rubric.RubricList rubs = Flatten(arub);
                    Components.Submission.SubmissionList subs = asstda.GetSubmissions(asst.ID);
                    foreach (Rubric rub in rubs) {
                        foreach (Components.Submission sub in subs) {
                            m_dp.UpdateRubricSubPoints(rub.ID, sub.ID);
                            total++;
                        }
                    }
                }
            }

            System.Diagnostics.Trace.WriteLine(total);
        }
Пример #19
0
        protected string ConvertXmlToText(string xmloutput, int courseID, int asstID)
        {
            DataSet dsres = new DataSet();
            string textoutput="This is an auto-generated message, please do not reply.\n\n";

            //Read Xml
            try {
                MemoryStream memstream =
                    new MemoryStream(System.Text.Encoding.ASCII.GetBytes(xmloutput));
                dsres.ReadXml(memstream);
            } catch (Exception) { return xmloutput; }

            DataTable restbl = dsres.Tables["Result"];
            DataTable errortbl = dsres.Tables["Error"];
            DataTable failtbl = dsres.Tables["Failure"];

            //Course and assignment
            Course course = new Courses(m_ident).GetInfo(courseID);
            Assignment asst = new Assignments(m_ident).GetInfo(asstID);
            textoutput += "Course: " + course.Name + "\n";
            textoutput += "Assignment: " + asst.Description + "\n\n";

            //Get success or failure
            string sucstr = (string) restbl.Rows[0]["Success"];
            if (sucstr == "criticallyflawed" || sucstr ==  "flawed")
                textoutput += "There were errors with this evaluation!";
            else if (sucstr == "depfail")
                textoutput += "Dependency failed. Evaluation not run.";
            else if (sucstr == "flawless")
                textoutput += "Evaluation successful!";
            textoutput += "\n\n";

            //Get failures
            if (failtbl != null)
                foreach (DataRow row in failtbl.Rows) {
                    textoutput += "Failure: " + row["Name"] + "\n";
                    textoutput += "\tDetails: " + row["Message"] + "\n\n";
                }

            //Add up error points
            if (errortbl != null)
                foreach (DataRow row in errortbl.Rows) {
                    textoutput += "Error: " + row["Name"] + "\n";
                    textoutput += "\tDetails: " + row["Message"] + "\n\n";
                }

            textoutput += "Messages: " + restbl.Rows[0]["Msg"] + "\n";
            textoutput += "Time: " + restbl.Rows[0]["Time"] + "s\n";
            textoutput += "Test Count: " + restbl.Rows[0]["Count"] + "\n";
            textoutput += "API: " + restbl.Rows[0]["API"] + "\n\n";

            textoutput += "Please contact the course staff if you feel there is a problem " +
                "with your results.";

            return textoutput;
        }
Пример #20
0
        /// <summary>
        /// Create an assignment
        /// </summary>
        public int Create(int courseID, string creator, string desc, DateTime duedate)
        {
            //Check perm
            Authorize(courseID, Permission.COURSE, "createasst", courseID, null);

            Assignment asst = new Assignment();
            asst.CourseID = courseID;
            asst.Creator = creator;
            asst.Description = desc;
            asst.DueDate = duedate;
            asst.Format = Assignment.DEFAULT_FORMAT;

            //Create
            m_dp.CreateAssignment(asst);

            //Setup default permissions
            CreatePermissions(asst.ID, courseID, Permission.ASSIGNMENT);

            //Setup default file permissions
            Courses courseda = new Courses(m_ident);
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            CourseRole.CourseRoleList staff = courseda.GetTypedRoles(courseID, true, null);
            CourseRole.CourseRoleList stu = courseda.GetTypedRoles(courseID, false, null);
            foreach (CourseRole role in staff)
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));

            foreach (CourseRole role in stu)
                perms.Add(new CFilePermission(role.PrincipalID, FileAction.READ, true));

            //Create content area
            FileSystem fs = new FileSystem(m_ident);
            CFile cdir = fs.CreateDirectory(@"c:\acontent\" + asst.ID, false, perms, false);
            asst.ContentID = cdir.ID;
            Update(asst);

            //Log
            Log("Created assignment: " + desc, asst.ID);

            return asst.ID;
        }
Пример #21
0
        /// <summary>
        /// Check to see if submission is available for current user
        /// </summary>
        public bool IsSubmissionAvailable(int asstID)
        {
            Assignment asst = GetInfo(asstID);
            CourseRole role = new Courses(m_ident).GetRole(m_ident.Name, asst.CourseID, null);

            return (role.Staff || asst.StudentSubmit);
        }
Пример #22
0
        /// <summary>
        /// Load submission directory with new files, updates time
        /// </summary>
        public bool Update(Submission sub, IExternalSource files)
        {
            FileSystem fs = new FileSystem(m_ident);
            bool markcmp, unmarkcmp, defunct;

            //Get old sub
            Components.Submission oldsub = GetInfo(sub.ID);
            markcmp = (oldsub.Status == Components.Submission.UNGRADED &&
                      sub.Status == Components.Submission.GRADED);
            unmarkcmp = (oldsub.Status == Components.Submission.GRADED &&
                         sub.Status == Components.Submission.UNGRADED);
            defunct = (oldsub.Status != Components.Submission.DEFUNCT &&
                        sub.Status == Components.Submission.DEFUNCT);

            //Make sure toplevel zone directory exists
            CFile subdir = fs.GetFile(@"c:\subs");
            if (null == subdir)
                subdir = fs.CreateDirectory(@"c:\subs", true, null, false);

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            int courseID = new Assignments(m_ident).GetInfo(sub.AsstID).CourseID;
            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(courseID, true, null);
            foreach (CourseRole role in staff)
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
            perms.AddRange(CFilePermission.CreateOprFullAccess(sub.PrincipalID));

            //Create zone directory
            CFile esubdir;
            string zpath = @"c:\subs\" + sub.ID;
            if (null == (esubdir = fs.GetFile(zpath))) {
                esubdir = fs.CreateDirectory(zpath, false, perms, false);
                esubdir.SpecType = CFile.SpecialType.SUBMISSION;
                string name = new Principals(m_ident).GetInfo(sub.PrincipalID).Name;
                esubdir.Alias = String.Format("{0}: {1}",
                    name, GetNextSubmission(sub.AsstID, sub.PrincipalID));
                fs.UpdateFileInfo(esubdir, false);
            }
            //Update sub entry
            sub.LocationID = esubdir.ID;
            m_dp.UpdateSubmission(sub);

            //Load files
            try {
                fs.ImportData(zpath, files, false, false); //Import the data
            } catch (Exception) {
                throw new DataAccessException("Invalid external file source. This means the system does " +
                    "not understand how to extract files from the source. Please create a valid source");
            }

            //Verify submission structure
            VerifyFormat(sub.AsstID, zpath);

            //Log
            if (markcmp)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " completed", sub.ID);
            else if (unmarkcmp)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " incomplete", sub.ID);
            else if (defunct)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " defunct", sub.ID);

            return true;
        }
        private void dgCourse_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            Label lblStudent, lblPoints;

            if (null != (lblStudent = (Label) e.Item.FindControl("lblStudent"))) {
                lblPoints = (Label) e.Item.FindControl("lblPoints");

                User user = e.Item.DataItem as User;

                int courseID = GetCourseID();
                double total = new Courses(Globals.CurrentIdentity).GetTotalPoints(courseID);
                double userp =
                    new Users(Globals.CurrentIdentity).GetCoursePoints(user.UserName, courseID);

                lblPoints.Text = String.Format("{0} / {1} ({2}%)",
                    userp, total, Math.Round((userp/total)*100.0, 2));

                lblStudent.Text = user.FullName + " (" + user.UserName + ")";
            }
        }
Пример #24
0
        private void dgUserCourses_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            HyperLink hypAdmin, hypStudent, hypStudentAdmin;
            if (null != (hypAdmin = (HyperLink) e.Item.FindControl("hypAdmin"))) {
                Course course = (Course) e.Item.DataItem;
                CourseRole role = new Courses(Globals.CurrentIdentity).GetRole(
                    Globals.CurrentUserName, course.ID, null);

                hypStudent = (HyperLink) e.Item.FindControl("hypStudent");
                hypStudentAdmin = (HyperLink) e.Item.FindControl("hypStudentAdmin");

                hypStudent.Enabled = course.Available;
                hypStudentAdmin.Enabled = course.Available;
                if (!hypStudent.Enabled)
                    hypStudent.Text += " (Unavailable)";

                if (role.Staff) {
                    hypAdmin.NavigateUrl = "../courseadmin.aspx?CourseID="+course.ID;
                    hypAdmin.Visible = true;
                    hypStudentAdmin.NavigateUrl = "../course.aspx?CourseID="+course.ID;
                    hypStudentAdmin.Visible = true;

                } else {
                    hypAdmin.NavigateUrl = "../course.aspx?CourseID="+course.ID;
                    hypAdmin.Visible = false;
                    hypStudentAdmin.Visible = false;
                }
            }
        }
Пример #25
0
        public void Activate(ActivateParams ap)
        {
            ViewState["asstID"] = ap.ID;

            Courses courseda = new Courses(Globals.CurrentIdentity);
            Assignment asst = new Assignments(Globals.CurrentIdentity).GetInfo(ap.ID);

            ViewState["courseID"] = asst.CourseID;

            BindSelectData();
        }
Пример #26
0
        private void BindSections()
        {
            Courses courseda = new Courses(Globals.CurrentIdentity);
            Section.SectionList sections = courseda.GetSections(GetCourseID());

            dgSections.DataSource = sections;
            dgSections.DataBind();
        }
Пример #27
0
        private void BindSelectData()
        {
            //Bind the correct tab
            switch (tsUsers.SelectedIndex) {
            case 0:
                BindSections();
                divSections.Visible = true;
                divUsers.Visible = false;
                break;
            case 1:
                BindGroups(new User.UserList());
                BindSearchData(new User.UserList());
                divSections.Visible = false;
                divUsers.Visible = true;
                divSearch.Visible = true;
                break;
            case 2:
                User.UserList mems = new Courses(Globals.CurrentIdentity).GetMembers(GetCourseID(), null);
                BindGroups(mems);
                BindSearchData(mems);
                divSections.Visible = false;
                divUsers.Visible = true;
                divSearch.Visible = false;
                break;
            }

            int courseID = GetCourseID();
            lnkSecExpl.Attributes.Add("onClick",
                @"window.open('sectionexpl.aspx?CourseID=" + courseID +
                @"', '"+ courseID+@"', 'width=430, height=530')");
        }
Пример #28
0
        /// <summary>
        /// Get a user's grades for a course in "export" format
        /// </summary>
        public ExportRow GetCourseExport(string username, int courseID)
        {
            double totpoints, points;
            ExportRow row = new ExportRow();
            Assignment.AssignmentList assts = new Courses(m_ident).GetAssignments(courseID);

            //User
            row.Fields.Add(username);

            totpoints = 0;
            foreach (Assignment asst in assts) {
                row.Fields.AddRange(GetAsstExport(username, asst.ID, out points).Fields);
                totpoints += points;
            }

            //Course Total
            row.Fields.Insert(1, totpoints.ToString());

            return row;
        }
Пример #29
0
        private void cmdSearch_Click(object sender, EventArgs e)
        {
            User.UserList foundUsers = null;
            //to get the course id, you can use the current assignment
            Assignment asst = new Assignments(Globals.CurrentIdentity).GetInfo(GetAsstID());
            if (drpSearchMethod.SelectedValue == "username")
                foundUsers = new Courses(Globals.CurrentIdentity).GetMembersByUsername(txtSearch.Text, asst.CourseID);
            else if (drpSearchMethod.SelectedValue == "lastname")
                foundUsers = new Courses(Globals.CurrentIdentity).GetMembersByLastname(txtSearch.Text, asst.CourseID);

            //clear the text box and then fill the dialog box
            txtSearch.Text="";
            BindGroups(foundUsers);
            BindSearchData(foundUsers);
        }
Пример #30
0
        /// <summary>
        /// Get total points for a course
        /// </summary>
        public double GetCoursePoints(string username, int courseID)
        {
            Assignment.AssignmentList assts =
                new Courses(Globals.CurrentIdentity).GetAssignments(courseID);
            double points=0;

            foreach (Assignment asst in assts)
                points += GetAsstPoints(username, asst.ID);

            return points;
        }
Пример #31
0
        private void LoadCourseNode(TreeNode par, int courseID)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            Courses courseda = new Courses(Globals.CurrentIdentity);
            Course course = courseda.GetInfo(courseID);

            par.Nodes.Clear();
            //Load announcement folder
            if (!StudentMode)
                AddAnnFolderNode(par.Nodes, courseID);

            //Load content
            CFile.FileList cdir = fs.ListDirectory(fs.GetFile(course.ContentID));
            foreach (CFile file in cdir) {
                if (file.IsDirectory())
                    AddFolderNode(par.Nodes, file);
                else
                    AddDocumentNode(par.Nodes, file);
            }

            //Load assignments
            Assignment.AssignmentList assts;
            if (StudentMode)
                assts = courseda.GetStudentAssignments(courseID);
            else
                assts = courseda.GetAssignments(courseID);
            foreach (Assignment asst in assts)
                AddAsstNode(par.Nodes, asst);

            //Add section folder
            if (!StudentMode) {
                AddBackupsNode(par.Nodes, courseID);
                AddSectionFolderNode(par.Nodes, courseID, "Users and Sections");
                AddPermNode(par.Nodes, courseID);
            }
        }