Example #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // grab CourseID parameter from the querystring
                AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions();
                courseId = func.ValidateNumericQueryStringParameter(this.Request, "CourseID");

                UserM user = UserM.Load(SharedSupport.GetUserIdentity());
                if (!user.IsInCourse(courseId))
                {
                    Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized");
                }

                Nav1.Feedback.Text = String.Empty;
                Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_STUDENT_CHANGE_PASSWORD;
                Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_STUDENT_CHANGE_PASSWORD;
                Nav1.Title         = SharedSupport.GetLocalizedString("ChangePassword_Title1");
                Nav1.SubTitle      = SharedSupport.GetLocalizedString("ChangePassword_SubTitle1");
                Nav1.relativeURL   = @"../";

                //GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vstskChangingYourUserPassword");
                GoBack1.GoBack_HelpUrl    = SharedSupport.HelpRedirect("tskChangingYourUserPasswordForAssignmentManager");
                GoBack1.GoBack_left       = "275px";
                GoBack1.GoBack_top        = "-15px";
                GoBack1.GoBackIncludeBack = false;

                if (courseId <= 0)
                {
                    throw(new ArgumentException(SharedSupport.GetLocalizedString("Global_MissingParameter")));
                }

                // if using SSL and the page isn't using a secure connection, redirect to https
                if (SharedSupport.UsingSsl == true && Request.IsSecureConnection == false)
                {
                    // Note that Redirect ends page execution.
                    Response.Redirect("https://" + SharedSupport.BaseUrl + "/faculty/ChangePassword.aspx?CourseID=" + courseId.ToString());
                }

                if (!IsPostBack)
                {
                    // Evals true first time browser hits the page
                    LocalizeLabels();
                }

                Response.Cache.SetNoStore();
                if (user.IsValid)
                {
                    this.lblUserName.Text = Server.HtmlEncode(user.FirstName + " " + user.LastName);
                }
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Do not cache this page
                Response.Cache.SetNoStore();

                AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions();
                // Look for UserId parameter in the query string.
                userId = func.ValidateNumericQueryStringParameter(this.Request, "UserID");

                if (userId == -1 || userId == SharedSupport.GetUserIdentity())
                {
                    //Editing self
                    Nav1.Feedback.Text = String.Empty;
                    Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_SERVER_ADMIN;
                    Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_SERVER_MYACCOUNT;
                    Nav1.Title         = " ";
                    Nav1.SubTitle      = SharedSupport.GetLocalizedString("MyAccountEdit_SubTitle");
                    Nav1.relativeURL   = @"../";

                    lblUserDetails.Visible      = false;
                    lblDescription.Visible      = false;
                    lblPasswordText.Visible     = false;
                    lblFindInstructions.Visible = false;
                    btnFind.Enabled             = false;
                    btnFind.Visible             = false;
                }
                else
                {
                    Nav1.Feedback.Text = "&nbsp;";
                    Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_COURSE_MANAGEMENT;
                    Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_COURSE_USERS;
                    Nav1.relativeURL   = @"../";
                }

                GoBack1.GoBack_left = "400px";
                GoBack1.GoBack_top  = "-2px";
                if (userId == 0)
                {
                    // Set help link to AddUser help topic.
                    GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vstskAddingCourseUsers");
                }
                else if (userId == -1)
                {
                    userId = SharedSupport.GetUserIdentity();
                    GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vstskAccessingYourAccount");
                }
                else
                {
                    // Set help link to EditUser help topic.
                    GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vstskAccessingYourAccount");
                }

                GoBack1.GoBackIncludeBack = true;
                if (Request.UrlReferrer != null && Request.UrlReferrer.ToString() != "")
                {
                    if (Request.UrlReferrer.ToString().IndexOf("UserRoles") > 0)
                    {
                        GoBack1.GoBack_BackURL = "Users.aspx?" + Request.QueryString.ToString();
                    }
                    else
                    {
                        GoBack1.GoBack_BackURL = Request.UrlReferrer.ToString();
                    }
                }
                else
                {
                    GoBack1.GoBack_BackURL = "Users.aspx?" + Request.QueryString.ToString();
                }

                // grab CourseID parameter from the querystring
                courseId = func.ValidateNumericQueryStringParameter(this.Request, "CourseID");

                if (userId == 0)
                {
                    if (!SharedSupport.SecurityIsAllowed(courseId, SecurityAction.USER_ADD))
                    {
                        // Note that Redirect ends page execution.
                        Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized");
                    }
                }
                else
                {
                    if (!SharedSupport.SecurityIsAllowed(courseId, SecurityAction.USER_EDIT))
                    {
                        // Note that Redirect ends page execution.
                        Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized");
                    }
                }


                //Check Security to see if we should disable roles
                if (!SharedSupport.SecurityIsAllowed(courseId, SecurityAction.SECURITY_EDIT))
                {
                    UserRolesList.Enabled = false;
                }

                //Check Security to see if we should hide roles
                if (!SharedSupport.SecurityIsAllowed(courseId, SecurityAction.SECURITY_VIEW))
                {
                    lblUserRoles.Visible  = false;
                    UserRolesList.Visible = false;
                }

                showLinks();

                if (!IsPostBack)
                {
                    //
                    // Evals true first time browser hits the page
                    //

                    LocalizeLabels();

                    SetupRoleButtons();

                    btnUpdate.Visible  = true;
                    Nav1.Feedback.Text = String.Empty;

                    // was userId passed in on querystring?
                    if (userId != 0)
                    {
                        this.lblDescription.Visible  = false;
                        this.lblPasswordText.Visible = false;
                        //Load existing User
                        UserM user = UserM.Load(userId);
                        if (user.IsValid)
                        {
                            // is user a member of the course? change button to 'add' if not
                            if (user.IsInCourse(courseId))
                            {
                                //User is already added to the course, so show delete button
                                this.btnDelete.Visible = true;
                                btnUpdate.Text         = SharedSupport.GetLocalizedString("AddEditUser_Update");
                            }
                            else
                            {
                                btnUpdate.Text = SharedSupport.GetLocalizedString("AddEditUser_Insert");
                            }

                            populateFields(user);
                            this.lblUserDetails.Text = SharedSupport.GetLocalizedString("AddEditUser_UserDetails");
                        }
                        else
                        {
                            clearFields();
                        }
                    }
                    else
                    {
                        // Insert
                        //Prep for inserting a new user
                        btnUpdate.Text           = SharedSupport.GetLocalizedString("AddEditUser_Insert");
                        this.lblUserDetails.Text = SharedSupport.GetLocalizedString("AddEditUser_AddLookUpUsers");
                    }
                }
                else
                {
                    if (txtAction.Value == "DeleteUser")
                    {
                        if (SharedSupport.SecurityIsAllowed(courseId, SecurityAction.USER_EDIT))
                        {
                            UserM.RemoveFromCourse(userId, courseId);
                            Response.Redirect("Users.aspx?UserID=" + userId.ToString() + "&" + Request.QueryString.ToString(), false);
                        }
                        else
                        {
                            Nav1.Feedback.Text = SharedSupport.GetLocalizedString("Global_Unauthorized");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
                btnUpdate.Visible  = false;
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        public void btnUpdate_Click(object sender, System.EventArgs e)
        {
            try
            {
                //reset error handling label
                Nav1.Feedback.Text = String.Empty;
                checkErrorCases();

                UserM user = null;
                //Save Updated or New User - check for UserID on query string
                if (userId != 0)
                {
                    if (!SharedSupport.SecurityIsAllowed(courseId, SecurityAction.USER_EDIT))
                    {
                        throw new Exception(SharedSupport.GetLocalizedString("Global_Unauthorized"));
                    }

                    //Update
                    user = UserM.Load(userId);

                    if (user.IsValid)
                    {
                        //Save updated user
                        user.EmailAddress      = txtEMailAddress.Text.ToString();
                        user.FirstName         = txtFirstName.Text.ToString();
                        user.LastName          = txtLastName.Text.ToString();
                        user.LastUpdatedDate   = DateTime.Now;
                        user.LastUpdatedUserID = SharedSupport.GetUserIdentity();
                        user.MiddleName        = txtMiddleName.Text.ToString();
                        user.UniversityID      = txtUniversityIdentifier.Text.ToString();
                        user.UserName          = txtUserName.Text.ToString();

                        user.Update();

                        if (user.IsInCourse(courseId))
                        {
                            if (SharedSupport.SecurityIsAllowed(courseId, SecurityAction.SECURITY_EDIT))
                            {
                                int   roleid           = Convert.ToInt32(UserRolesList.SelectedItem.Value);
                                RoleM currentUsersRole = RoleM.GetUsersRoleInCourse(SharedSupport.GetUserIdentity(), courseId);

                                // The lower role => greater permissions
                                if ((currentUsersRole.ID == (int)PermissionsID.Admin) || (currentUsersRole.ID < roleid))
                                {
                                    user.SetRoleInCourse(courseId, roleid);
                                }
                                else
                                {
                                    throw new Exception(SharedSupport.GetLocalizedString("AddEditUser_ErrorRolePermissionDenied"));
                                }
                            }
                        }
                        else
                        {
                            // Add user to Course
                            PermissionsID permission = PermissionsID.Student;
                            if (SharedSupport.SecurityIsAllowed(courseId, SecurityAction.SECURITY_EDIT))
                            {
                                int   roleid           = Convert.ToInt32(UserRolesList.SelectedItem.Value);
                                RoleM currentUsersRole = RoleM.GetUsersRoleInCourse(SharedSupport.GetUserIdentity(), courseId);

                                // The lower role => greater permissions
                                // Note: Cannot change the permission of someone at your level.
                                if ((currentUsersRole.ID == (int)PermissionsID.Admin) || (currentUsersRole.ID < roleid))
                                {
                                    permission = (PermissionsID)roleid;
                                    user.AddToCourse(courseId, permission);
                                }
                                else
                                {
                                    throw new Exception(SharedSupport.GetLocalizedString("AddEditUser_ErrorRolePermissionDenied"));
                                }
                            }
                        }
                        btnUpdate.Text     = SharedSupport.GetLocalizedString("AddEditUser_Update");
                        Nav1.Feedback.Text = SharedSupport.GetLocalizedString("AddEditUser_UserUpdated");                          //"User has been Updated.";
                    }
                    else
                    {
                        throw new Exception(NO_USER_FOR_USERID_ERROR);
                    }
                }
                else
                {
                    if (!SharedSupport.SecurityIsAllowed(courseId, SecurityAction.USER_ADD))
                    {
                        throw new Exception(SharedSupport.GetLocalizedString("Global_Unauthorized"));
                    }

                    //Insert
                    user = new UserM();

                    user.EmailAddress      = txtEMailAddress.Text.ToString();
                    user.FirstName         = txtFirstName.Text.ToString();
                    user.LastName          = txtLastName.Text.ToString();
                    user.LastUpdatedDate   = DateTime.Now;
                    user.LastUpdatedUserID = SharedSupport.GetUserIdentity();
                    user.MiddleName        = txtMiddleName.Text.ToString();
                    user.UniversityID      = txtUniversityIdentifier.Text.ToString();
                    user.UserName          = txtUserName.Text.ToString();
                    user.ChangedPassword   = false;

                    // Does the user already exist?
                    UserM userByName = UserM.LoadByUserName(user.UserName);
                    if (!userByName.IsValid)
                    {
                        userId = user.Create();

                        btnUpdate.Text     = SharedSupport.GetLocalizedString("AddEditUser_Update");
                        Nav1.Feedback.Text = SharedSupport.GetLocalizedString("AddEditUser_UserInserted");                          //"User has been inserted.";

                        PermissionsID permission = PermissionsID.Student;
                        if (SharedSupport.SecurityIsAllowed(courseId, SecurityAction.SECURITY_EDIT))
                        {
                            int   roleid           = Convert.ToInt32(UserRolesList.SelectedItem.Value);
                            RoleM currentUsersRole = RoleM.GetUsersRoleInCourse(SharedSupport.GetUserIdentity(), courseId);

                            // The lower role = greater permissions
                            // Note: Can't change permissions of someone equal in level to you.
                            if ((currentUsersRole.ID == (int)PermissionsID.Admin) || (currentUsersRole.ID < roleid))
                            {
                                permission = (PermissionsID)roleid;
                            }
                            else
                            {
                                throw new Exception(SharedSupport.GetLocalizedString("AddEditUser_ErrorRolePermissionDenied"));
                            }
                        }
                        user.AddToCourse(courseId, permission);
                    }
                    else
                    {
                        throw new Exception(SharedSupport.GetLocalizedString("User_UserNameMustBeUnique"));
                    }
                }

                Response.Redirect("Users.aspx?UserID=" + userId.ToString() + "&" + Request.QueryString.ToString(), false);
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }
Example #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // grab CourseID parameter from the querystring
                AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions();
                courseId = func.ValidateNumericQueryStringParameter(this.Request, "CourseID");

                UserM user = UserM.Load(SharedSupport.GetUserIdentity());
                if (!user.IsInCourse(courseId))
                {
                    Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized");
                }

                Nav1.Feedback.Text = String.Empty;
                Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_STUDENT_COURSE;
                Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_STUDENT_COURSE_ASSIGNMENTS;
                Nav1.relativeURL   = @"../";

                GoBack1.GoBack_HelpUrl    = SharedSupport.HelpRedirect("vstskCheckingAssignmentStatus");
                GoBack1.GoBack_HelpUrl    = SharedSupport.HelpRedirect("tskUsingAssignmentManagerToCheckAssignmentStatus");
                GoBack1.GoBack_top        = "-5px";
                GoBack1.GoBack_left       = "60px";
                GoBack1.GoBackIncludeBack = false;

                if (courseId <= 0)
                {
                    Nav1.Feedback.Text = SharedSupport.GetLocalizedString("Global_MissingParameter");
                }

                CourseM course = CourseM.Load(courseId);
                string  title  = course.Name.Trim();
                if (title.Length > 45)
                {
                    title = title.Substring(0, 45) + SharedSupport.GetLocalizedString("UserControl_Faculty_DotDotDot");
                }
                Nav1.Title = Server.HtmlEncode(title);

                if (course.IsValid)
                {
                    Nav1.SubTitle = Server.HtmlEncode(SharedSupport.GetLocalizedString("Assignments_Subtitle") + " " + course.Name);
                }


                if (!IsPostBack)
                {
                    // Evals true first time browser hits the page
                }

                Response.Cache.SetNoStore();
                int userID = SharedSupport.GetUserIdentity();
                //throws an error if either the courseID or userID are empty
                if (courseId.Equals(null) || userID.Equals(null))
                {
                    Nav1.Feedback.Text = SharedSupport.GetLocalizedString("Assignments_CourseIDError");
                }
                else
                {
                    try
                    {
                        //calls a function to return all the assignments for the course
                        BrowseAssignments(course);
                    }
                    catch (System.Exception ex)
                    {
                        Nav1.Feedback.Text = ex.Message;
                    }
                }

                localizeLabels();
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }
Example #5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // grab CourseID parameter from the querystring
                AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions();
                courseId = func.ValidateNumericQueryStringParameter(this.Request, "CourseID");

                UserM user = UserM.Load(SharedSupport.GetUserIdentity());
                if (!user.IsInCourse(courseId))
                {
                    Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized");
                }

                //display nav bar
                Nav1.Feedback.Text = String.Empty;
                Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_STUDENT_COURSE;
                Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_STUDENT_COURSE_INFO;
                Nav1.relativeURL   = @"../";

                GoBack1.GoBack_left       = "450px";
                GoBack1.GoBack_top        = "5px";
                GoBack1.GoBack_HelpUrl    = SharedSupport.HelpRedirect("tskViewingCourseInformationWithAssignmentManager");
                GoBack1.GoBackIncludeBack = false;

                if (courseId.Equals(null))
                {
                    throw(new ArgumentException(SharedSupport.GetLocalizedString("Global_MissingParameter")));
                }

                CourseM course = CourseM.Load(courseId);
                if (course.IsValid)
                {
                    Nav1.SubTitle = SharedSupport.GetLocalizedString("Assignments_Subtitle") + " " + Server.HtmlEncode(course.Name);
                }


                if (!IsPostBack)
                {
                    //
                    // Evals true first time browser hits the page
                    //

                    LocalizeLabels();

                    if (course.IsValid)
                    {
                        this.txtDescriptionText.Text = course.Description;
                        this.lblShortNameValue.Text  = Server.HtmlEncode(course.Name);
                        if (course.HomepageURL.Trim() != "")
                        {
                            this.linkHomePageURLText.Text        = Server.HtmlEncode(course.HomepageURL);
                            this.linkHomePageURLText.NavigateUrl = course.HomepageURL;
                        }
                        else
                        {
                            this.lblHomePageURL.Text = "";
                        }

                        string title = course.Name.Trim();
                        if (title.Length > 45)
                        {
                            title = title.Substring(0, 45) + SharedSupport.GetLocalizedString("UserControl_Faculty_DotDotDot");
                        }
                        Nav1.Title = Server.HtmlEncode(title);
                        CourseResources(course);
                    }
                    else
                    {
                        // throw error - can't use this page without CourseID int passed in
                        Nav1.Feedback.Text = SharedSupport.GetLocalizedString("AddEditCourse_MissingCourseID");
                    }
                }
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }
Example #6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // grab CourseID parameter from the querystring
                AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions();
                courseId = func.ValidateNumericQueryStringParameter(this.Request, "CourseID");

                UserM user = UserM.Load(SharedSupport.GetUserIdentity());
                if (!user.IsInCourse(courseId))
                {
                    Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized");
                }

                // Do not cache this page
                Response.Cache.SetNoStore();

                Nav1.Feedback.Text = String.Empty;
                Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_STUDENT_COURSE;
                Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_STUDENT_COURSE_ASSIGNMENTS;
                Nav1.relativeURL   = @"../";

                //GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vstskCheckingAssignmentStatus");
                GoBack1.GoBack_HelpUrl    = SharedSupport.HelpRedirect("tskUsingAssignmentManagerToCheckAssignmentStatus");
                GoBack1.GoBackIncludeBack = true;
                GoBack1.GoBack_BackURL    = "Assignments.aspx?" + Request.QueryString.ToString();
                GoBack1.GoBack_left       = "-105px";
                if (Request.QueryString.Get("Exp") == "1")
                {
                    txtDescription.CssClass = "infoTextDisabled";
                }
                else
                {
                    txtDescription.CssClass = "invisible";
                }

                if (courseId > 0)
                {
                    //returns the course name to be displayed in the Nav bar title
                    CourseM course = CourseM.Load(courseId);
                    Nav1.Title = Server.HtmlEncode(course.Name);
                }
                else
                {
                    Nav1.Feedback.Text = SharedSupport.GetLocalizedString("Global_MissingParameter");
                }
                // grab assignmentId from querystring
                assignmentId = func.ValidateNumericQueryStringParameter(this.Request, "assignmentId");

                if (!IsPostBack)
                {
                    //
                    // Evals true first time browser hits the page
                    //
                }
                int userID = SharedSupport.GetUserIdentity();

                LocalizeLabels();

                //checks that assignmentId is not empty then loops through
                if (assignmentId.Equals(null))
                {
                    Nav1.Feedback.Text = SharedSupport.GetLocalizedString("GradeDetail_InvalidassignmentIdError");
                }
                else
                {
                    AssignmentM assign = AssignmentM.Load(assignmentId);
                    if (assign.IsValid)
                    {
                        txtDescription.Text             = assign.Description;
                        lblAssignment.Text              = Server.HtmlEncode(assign.ShortName);
                        lblDueDateValue.Text            = assign.DueDate.ToShortDateString();
                        hlAssignmentWebPage.NavigateUrl = assign.AssignmentURL;
                        hlAssignmentWebPage.Text        = Server.HtmlEncode(assign.AssignmentURL);
                    }

                    StudentAssignmentM stuAssign = StudentAssignmentM.Load(userID, assignmentId);
                    if (stuAssign == null)
                    {
                        this.lblAssignment.Text = SharedSupport.GetLocalizedString("GradeDetail_NoDetailsAvailable");
                    }
                    else
                    {
                        //if data is returned, regardless of the Detail Type the LocalizeGeneralLabels
                        //generates text for the header labels.
                        LocalizeGeneralLabels(stuAssign);
                        LocalizeAutoBuildLabels(stuAssign);
                        LocalizeAutoGradeLabels(stuAssign);
                    }
                }
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }
        private void btnImportRecords_Click(object sender, System.EventArgs e)
        {
            try
            {
                Nav1.Feedback.Text = String.Empty;
                //Validate delimiting character not blank
                if (delimitingCharacter == String.Empty)
                {
                    Nav1.Feedback.Text = SharedSupport.GetLocalizedString("AdminImport_ChooseDelimitingChar");
                    return;
                }

                System.Data.DataSet dsuser = SharedSupport.ParseDelimitedFile(uploadedFilePath, delimitingCharacter);
                //Grab the column order from the drop downs and put into string array

                int[] columns = new int[6];

                if (!cboLastName.SelectedIndex.Equals(0) && !cboLastName.SelectedIndex.Equals(-1))
                {
                    if (!checkMultipleColumn(columns, cboLastName.SelectedIndex))
                    {
                        columns[0] = cboLastName.SelectedIndex;
                    }
                    else
                    {
                        throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_ColumnOnce"));
                    }
                }
                else
                {
                    //throw required field error.
                    throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_MissingLastName"));
                }
                if (!cboFirstName.SelectedIndex.Equals(0) && !cboFirstName.SelectedIndex.Equals(-1))
                {
                    if (!checkMultipleColumn(columns, cboFirstName.SelectedIndex))
                    {
                        columns[1] = cboFirstName.SelectedIndex;
                    }
                    else
                    {
                        throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_ColumnOnce"));
                    }
                }
                else
                {
                    //throw required field error.
                    throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_MissingFirstName"));
                }
                if (!cboMiddleName.SelectedIndex.Equals(0) && !cboMiddleName.SelectedIndex.Equals(-1))
                {
                    if (!checkMultipleColumn(columns, cboMiddleName.SelectedIndex))
                    {
                        columns[2] = cboMiddleName.SelectedIndex;
                    }
                    else
                    {
                        throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_ColumnOnce"));
                    }
                }
                else
                {
                    columns[2] = -1;
                }
                if (!cboEmailAddress.SelectedIndex.Equals(0) && !cboEmailAddress.SelectedIndex.Equals(-1))
                {
                    if (!checkMultipleColumn(columns, cboEmailAddress.SelectedIndex))
                    {
                        columns[3] = cboEmailAddress.SelectedIndex;
                    }
                    else
                    {
                        throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_ColumnOnce"));
                    }
                }
                else
                {
                    //throw required field error.
                    throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_MissingEmail"));
                }
                if (!cboUniversityID.SelectedIndex.Equals(0) && !cboUniversityID.SelectedIndex.Equals(-1))
                {
                    if (!checkMultipleColumn(columns, cboUniversityID.SelectedIndex))
                    {
                        columns[4] = cboUniversityID.SelectedIndex;
                    }
                    else
                    {
                        throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_ColumnOnce"));
                    }
                }
                else
                {
                    //throw required field error.
                    throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_MissingID"));
                }
                if (!cboUserName.SelectedIndex.Equals(0) && !cboUserName.SelectedIndex.Equals(-1))
                {
                    if (!checkMultipleColumn(columns, cboUserName.SelectedIndex))
                    {
                        columns[5] = cboUserName.SelectedIndex;
                    }
                    else
                    {
                        throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_ColumnOnce"));
                    }
                }
                else
                {
                    //throw required field error.
                    throw new ApplicationException(SharedSupport.GetLocalizedString("AdminImport_MissingUserName"));
                }

                //Make sure that each column is only choosen once.
                //Grab the userId from the cookie
                int    UserID        = SharedSupport.GetUserIdentity();
                int    importErrors  = 0;
                int    importSuccess = 0;
                string importID      = System.Guid.NewGuid().ToString();
                for (int i = 0; i < dsuser.Tables[0].Rows.Count; i++)
                {
                    try
                    {
                        string userName = dsuser.Tables[0].Rows[i][columns[5] - 1].ToString();
                        // Does the user already exist?
                        UserM userByName = UserM.LoadByUserName(userName);
                        if (userByName.IsValid)
                        {
                            throw new Exception(SharedSupport.GetLocalizedString("User_UserNameMustBeUnique"));
                        }
                        UserM user = new UserM();
                        user.LastName  = dsuser.Tables[0].Rows[i][columns[0] - 1].ToString();
                        user.FirstName = dsuser.Tables[0].Rows[i][columns[1] - 1].ToString();
                        if (!columns[2].Equals(-1))
                        {
                            user.MiddleName = dsuser.Tables[0].Rows[i][columns[2] - 1].ToString();
                        }
                        user.EmailAddress      = dsuser.Tables[0].Rows[i][columns[3] - 1].ToString();
                        user.UniversityID      = dsuser.Tables[0].Rows[i][columns[4] - 1].ToString();
                        user.UserName          = userName;
                        user.LastUpdatedUserID = UserID;
                        user.LastUpdatedDate   = DateTime.Now;
                        user.ChangedPassword   = false;
                        // create but do not mail out password.
                        user.Create(false);
                        if (!user.IsInCourse(courseId))
                        {
                            user.ImportToCourse(courseId, importID);
                        }
                        importSuccess++;
                    }
                    catch
                    {
                        importErrors++;
                    }
                }

                //Delete imported file
                System.IO.File.Delete(uploadedFilePath);
                //Redirect to Results page.
                Response.Redirect("Results.aspx?CourseID=" + courseId.ToString() + "&ImportID=" + importID + "&Success=" + importSuccess + "&Errors=" + importErrors + "&Expected=" + dsuser.Tables[0].Rows.Count, false);
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = SharedSupport.GetLocalizedString("AdminImport_GenericError");
            }
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // grab CourseID parameter from the querystring
                AssignmentManager.Common.Functions f = new AssignmentManager.Common.Functions();
                int courseId = f.ValidateNumericQueryStringParameter(this.Request, "CourseID");

                UserM user = UserM.Load(SharedSupport.GetUserIdentity());
                if (!user.IsInCourse(courseId))
                {
                    Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized");
                }

                //Cleanup temporary files after project downloads. Page does not need to load.
                if (Request.QueryString.Get("Action").ToLower() == "cleanupdirectory")
                {
                    CleanupTempDirectory();
                }

                Nav1.Feedback.Text = String.Empty;
                Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_STUDENT_COURSE;
                Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_STUDENT_COURSE_ASSIGNMENTS;
                Nav1.relativeURL   = @"../";

                //GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vstskAddingAssignment");
                GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("tskSubmittingAssignmentUsingAssignmentManager");

                GoBack1.GoBackIncludeBack = true;
                GoBack1.GoBack_top        = "24px";
                //GoBack1.GoBack_left = "-10px";

                switch (Request.QueryString.Get("Action").ToLower())
                {
                case "uploadsubmission":
                    Nav1.Title = SharedSupport.GetLocalizedString("UploadDownload_StudentUploadTitle");
                    break;

                case "downloadstarter":
                    Nav1.Title = SharedSupport.GetLocalizedString("UploadDownload_StudentDownloadTitle");
                    break;

                default:
                    throw new ApplicationException(SharedSupport.GetLocalizedString("UploadDownload_StudentTitleError"));
                }



                int assignmentId = f.ValidateNumericQueryStringParameter(this.Request, "AssignmentID");
                if (!IsPostBack)
                {
                    //
                    // Evals true first time browser hits the page
                    //
                    //Give the client the upload and download locations
                    if (SharedSupport.UsingSsl)
                    {
                        txtUploadLocation.Value         = "https://" + Request.ServerVariables.Get("HTTP_HOST") + Constants.ASSIGNMENTMANAGER_UPLOAD_DIRECTORY;
                        txtDownloadFolderLocation.Value = "https://" + Request.ServerVariables.Get("HTTP_HOST") + Constants.ASSIGNMENTMANAGER_DOWNLOAD_DIRECTORY;
                    }
                    else
                    {
                        txtUploadLocation.Value         = "http://" + Request.ServerVariables.Get("HTTP_HOST") + Constants.ASSIGNMENTMANAGER_UPLOAD_DIRECTORY;
                        txtDownloadFolderLocation.Value = "http://" + Request.ServerVariables.Get("HTTP_HOST") + Constants.ASSIGNMENTMANAGER_DOWNLOAD_DIRECTORY;
                    }
                    txtMaxUploadSize.Value = SharedSupport.GetSetting(AssignmentManager.Constants.MAX_PROJECT_SETTING).ToString();
                    btnDownload.Value      = UploadDownload_Download_Text;

                    lblSelectProject.Text            = UploadDownload_SelectProject;
                    lblAssignmentName.Text           = UploadDownload_AssignmentName;
                    lblUploadSubTitle.Text           = SharedSupport.GetLocalizedString("UploadDownload_StudentUploadTitle");
                    lblUploadDescription.Text        = UploadDownload_UploadDescription;
                    lblDownloadStudentTitle.Text     = UploadDownload_Download_Student_Title;
                    lblDownloadLocationForFiles.Text = UploadDownload_Location_For_Download_Files_Text;
                    if (!assignmentId.Equals(0))
                    {
                        AssignmentM assign = AssignmentM.Load(assignmentId);
                        if (assign.IsValid)
                        {
                            txtAssignmentName.Enabled = false;
                            txtAssignmentName.Text    = assign.ShortName;
                        }
                    }
                    txtNewGUID.Value = System.Guid.NewGuid().ToString();
                    txtCancel.Value  = "0";
                    txtDirSize.Value = SharedSupport.GetSetting(Constants.MAX_PROJECT_SETTING);
                    //Download assignment starter project
                    if (Request.QueryString.Get("Action").ToLower() == "downloadstarter")
                    {
                        //Check to make sure that you got an AssignmentID and a CourseID
                        if (!courseId.Equals(null) && !assignmentId.Equals(null))
                        {
                            //Call browse starter to get all files to appropriate location
                            AssignmentM assign = AssignmentM.Load(assignmentId);
                            if (assign.IsValid)
                            {
                                if (assign.AssignmentURL.Trim() != String.Empty)
                                {
                                    UploadDownload_DownloadRedirectUrl = Server.HtmlEncode(assign.AssignmentURL);
                                }
                                else
                                {
                                    UploadDownload_DownloadRedirectUrl = "AssignmentGrade.aspx?AssignmentID=" + assignmentId.ToString() + "&CourseID=" + courseId.ToString() + "&Exp=1";
                                }
                                System.Guid guid = System.Guid.NewGuid();
                                txtSolutionName.Value     = assign.ShortName;
                                txtDownloadFilesXML.Value = assign.StarterFilesXML(guid);
                                txtNewGUID.Value          = guid.ToString();
                            }
                            else
                            {
                                throw new ApplicationException(SharedSupport.GetLocalizedString("UploadDownload_AssignmentError"));
                            }
                        }
                        else
                        {
                            throw new ApplicationException(SharedSupport.GetLocalizedString("UploadDownload_AssignmentIDCourseIDError"));
                        }
                    }
                }
                else
                {
                    //If this is coming back from the client see what the action
                    //is on the query string and perform accordingly

                    //make sure that the we or the user didn't cancel the upload
                    if (txtCancel.Value != "1")
                    {
                        //Student Submitting an assignment
                        if (Request.QueryString.Get("Action").ToLower() == "uploadsubmission")
                        {
                            StudentAssignmentM sa       = new StudentAssignmentM();
                            string             xmlFiles = txtFilesUploadedXML.Value.ToString();
                            string             pathGUID = txtNewGUID.Value.ToString();
                            sa.Submit(assignmentId, courseId, xmlFiles, pathGUID);
                            Response.Redirect("Assignments.aspx?" + Request.QueryString.ToString(), false);
                        }
                        //Cleanup temporary files after project downloads.
                        if (Request.QueryString.Get("Action").ToLower() == "cleanupdirectory")
                        {
                            // Grab the querystring parameters.
                            string tempGUID       = Request.QueryString.Get("GUID");
                            bool   addQuerystring = Convert.ToBoolean(Request.QueryString.Get("AddQS"));
                            string targetUrl      = Request.QueryString.Get("TargetURL");

                            // Test whether the GUID that identifies the directory to be deleted exists.
                            if (tempGUID == "" || tempGUID == string.Empty)
                            {
                                // The GUID is missing, try and continue the redirect without deleting the directory.
                            }
                            else
                            {
                                // Delete the temporary download directory from the AMWeb virtual directory.
                                string downloadRoot = Request.MapPath(Request.ApplicationPath.ToString());
                                //string downloadRoot = Request.MapPath(Constants.ASSIGNMENTMANAGER_DOWNLOAD_DIRECTORY);
                                DeleteTempDirectory(tempGUID);
                            }
                            if (addQuerystring == true)
                            {
                                // Remove the QueryString parameters used for this action then pass the leftovers on the redirect.
                                string tempQuerystring = Request.Url.Query.ToString();
                                tempQuerystring = tempQuerystring.Substring(0, tempQuerystring.IndexOf("&GUID"));
                                Response.Redirect(targetUrl + tempQuerystring);
                            }
                            else
                            {
                                Response.Redirect(targetUrl);
                            }
                        }
                    }
                    else
                    {
                        //reset the cancel flag so the user can fix the problem and resubmit
                        txtCancel.Value = "0";
                    }
                }
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }