Example #1
0
        public void btnPreview_Click(object sender, System.EventArgs e)
        {
            try
            {
                Nav1.Feedback.Text = String.Empty;

                // Delete any previous imports that have not been committed.
                //bool clearPreviousImportData = users.CancelPendingImport(courseId);

                DataSet ds = new DataSet();
                //Validate File not blank
                if (txtUploadFile.PostedFile.Equals(null))
                {
                    Nav1.Feedback.Text = SharedSupport.GetLocalizedString("AdminImport_ChooseUploadFile");
                    return;
                }
                //Validate File not blank
                if (txtUploadFile.PostedFile.FileName == String.Empty)
                {
                    Nav1.Feedback.Text = SharedSupport.GetLocalizedString("AdminImport_ChooseUploadFile");
                    return;
                }
                //Validate delimiting character not blank
                if (cboDelimitingCharacter.SelectedItem.Text == String.Empty)
                {
                    Nav1.Feedback.Text = SharedSupport.GetLocalizedString("AdminImport_ChooseDelimitingChar");
                    return;
                }
                string delimiterCharacter = "";
                if (cboDelimitingCharacter.SelectedItem.Text == SharedSupport.GetLocalizedString("AdminImport_Tab"))
                {
                    delimiterCharacter = "\t";
                }
                else
                {
                    delimiterCharacter = cboDelimitingCharacter.SelectedItem.Text;
                }

                string filename = System.Guid.NewGuid().ToString();
                txtUploadFile.PostedFile.SaveAs(SharedSupport.AddBackSlashToDirectory(Server.MapPath(Constants.ASSIGNMENTMANAGER_UPLOAD_DIRECTORY)) + filename);

                Response.Redirect("ImportFormPreview.aspx?" + Request.QueryString + "&File=" + Server.UrlEncode(filename) + "&Char=" + Server.UrlEncode(delimiterCharacter), false);
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions();
                int courseId = func.ValidateNumericQueryStringParameter(this.Request, "CourseID");

                if (!SharedSupport.SecurityIsAllowed(courseId, SecurityAction.ASSIGNMENT_VIEW))
                {
                    // Note that Redirect ends page execution.
                    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_COURSE_MANAGEMENT;
                Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_COURSE_ASSIGNMENTS;
                if (Request.QueryString.Get("Action").ToLower() == "uploadstarter")
                {
                    Nav1.Title = SharedSupport.GetLocalizedString("UploadDownload_Upload_Starter_Title");//"Upload Starter";
                }
                if (Request.QueryString.Get("Action").ToLower() == "downloadsubmission")
                {
                    Nav1.Title = SharedSupport.GetLocalizedString("UploadDownload_Download_Faculty_Title");//"Download Student Submission";
                }
                Nav1.relativeURL = @"../";

                if (Request.QueryString.Get("Action").ToLower() == "uploadstarter")
                {
                    GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vstskUpdatingStarterProject");
                }
                else
                {
                    GoBack1.GoBack_HelpUrl = SharedSupport.HelpRedirect("vsoriUsingAssignmentManager");
                }
                GoBack1.GoBackIncludeBack = true;
                GoBack1.GoBack_left       = "295px";
                GoBack1.GoBack_top        = "22px";
                if (Request.UrlReferrer.ToString() != "")
                {
                    GoBack1.GoBack_BackURL = Request.UrlReferrer.ToString();
                }
                else
                {
                    GoBack1.GoBack_BackURL = "Assignments.aspx?" + Request.QueryString.ToString();
                }
                //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;

                string dir = SharedSupport.AddBackSlashToDirectory(System.Web.HttpContext.Current.Request.MapPath(String.Empty, Constants.ASSIGNMENTMANAGER_DOWNLOAD_DIRECTORY, true));
                if (Directory.Exists(dir))
                {
                    txtDirSize.Value = SharedSupport.GetSetting(AssignmentManager.Constants.MAX_PROJECT_SETTING).ToString();
                }

                int studentID    = func.ValidateNumericQueryStringParameter(this.Request, "StudentID");
                int assignmentId = func.ValidateNumericQueryStringParameter(this.Request, "AssignmentID");
                if (!IsPostBack)
                {
                    //
                    // Evals true first time browser hits the page
                    //
                    if (Request.QueryString.Get("Action").ToLower() == "uploadstarter")
                    {
                        chkRemoveStudentCode.Visible = true;
                        lblRemoveCode.Visible        = true;
                    }
                    else
                    {
                        chkRemoveStudentCode.Visible = false;
                        lblRemoveCode.Visible        = false;
                    }
                    txtExistingStarterProject.Value = "";
                    lblRemoveCode.Text               = UploadDownload_RemoveCode_Text;
                    lblSelectProject.Text            = UploadDownload_SelectProject;
                    lblAssignmentName.Text           = UploadDownload_AssignmentName;
                    lblUploadSubTitle.Text           = UploadDownload_UploadSubTitle;
                    lblUploadDescription.Text        = UploadDownload_UploadDescription;
                    lblDownloadFacultyTitle.Text     = UploadDownload_Download_Faculty_Title;
                    lblDownloadLocationForFiles.Text = UploadDownload_Location_For_Download_Files_Text;
                    lblStudentName.Text              = UploadDownload_StudentName;
                    lblAssignmentNameDownload.Text   = UploadDownload_AssignmentName;
                    if (!assignmentId.Equals(0))
                    {
                        AssignmentM assign = AssignmentM.Load(assignmentId);
                        if (assign.IsValid)
                        {
                            if (assign.StarterProjectFlag)
                            {
                                txtExistingStarterProject.Value = "1";
                            }
                            txtAssignmentName.ReadOnly = true;
                            txtAssignmentName.Enabled  = false;
                            txtAssignmentName.Text     = assign.ShortName;
                        }
                    }

                    //Download of student Submission
                    if (Request.QueryString.Get("Action").ToLower() == "downloadsubmission")
                    {
                        AssignmentM assignment = AssignmentM.Load(assignmentId);
                        if (assignment.IsValid)
                        {
                            if (assignment.StarterProjectFlag)
                            {
                                txtExistingStarterProject.Value = "1";
                            }
                            txtAssignmentName.ReadOnly         = true;
                            txtAssignmentName.Enabled          = false;
                            txtAssignmentName.Text             = assignment.ShortName;
                            txtAssignmentNameDownload.ReadOnly = true;
                            txtAssignmentNameDownload.Enabled  = false;
                            txtAssignmentNameDownload.Text     = assignment.ShortName;
                        }
                        UserM user = UserM.Load(studentID);
                        if (user.IsValid)
                        {
                            txtStudentName.ReadOnly = true;
                            txtStudentName.Text     = Server.HtmlEncode(user.LastName.Trim() + SharedSupport.GetLocalizedString("UploadDownload_comma") + " " + user.FirstName.Trim() + " " + user.MiddleName.Trim());
                        }

                        txtSolutionName.Value = SharedSupport.AddBackSlashToDirectory(assignment.ShortName);
                        System.Guid        guid          = System.Guid.NewGuid();
                        StudentAssignmentM studentAssign = StudentAssignmentM.Load(studentID, assignmentId);
                        txtDownloadFilesXML.Value = studentAssign.AssignmentFilesXML(guid.ToString(), assignment);
                        txtNewGUID.Value          = guid.ToString();
                    }
                    else
                    {
                        txtNewGUID.Value = System.Guid.NewGuid().ToString();
                    }
                }
                else
                {
                    //If this is coming back from the client see what the action
                    //is on the query string and perform accordingly
                    //Faculty Submitting Starter Project
                    if (Request.QueryString.Get("Action").ToLower() == "uploadstarter")
                    {
                        string      xmlFileList = txtFilesUploadedXML.Value.ToString();
                        AssignmentM assign      = AssignmentM.Load(assignmentId);
                        assign.SubmitStarter(xmlFileList, txtNewGUID.Value.ToString());
                        Response.Redirect("Assignments.aspx?CourseID=" + Request.QueryString.Get("CourseID"), false);
                    }
                }
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Nav1.Feedback.Text = String.Empty;
                Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_COURSE_MANAGEMENT;
                Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_COURSE_INFO;
                Nav1.SubTitle      = " ";
                Nav1.Title         = " ";
                Nav1.relativeURL   = @"../";

                PermissionsID maxUserPermission;
                AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions();
                if (!SharedSupport.SecurityIsAllowed(SecurityAction.COURSE_ADD, out maxUserPermission))
                {
                    // Note that Redirect ends page execution.
                    Response.Redirect(@"../Error.aspx?ErrorDetail=" + "Global_Unauthorized");
                }


                int vsversion = func.ValidateNumericQueryStringParameter(Request, "VSVersion");
                if (vsversion < 7.1)
                {
                    Response.Redirect(@"../Error.aspx?ErrorDetail=" + "AddCourse_WrongVSVersion", false);
                }

                if (!IsPostBack)
                {
                    //
                    // Evals true first time browser hits the page
                    //
                    if (Request["CourseID"] != null && Request["CourseID"] != String.Empty)
                    {
                        if (Request["CourseName"] != null && Request["CourseName"] != String.Empty)
                        {
                            // Load by GUID
                            string CourseID = Request.QueryString.Get("CourseID").ToString();
                            courseGuid          = new System.Guid(CourseID);
                            txtCourseGUID.Value = courseGuid.ToString();

                            CourseM course = CourseM.Load(courseGuid);

                            if (course.IsValid)
                            {
                                // course already exists
                                courseExists(course);
                                return;
                            }
                            else
                            {
                                // check the short name for uniqueness
                                string courseShortName = Request.QueryString.Get("CourseName").ToString().Trim();
                                if (courseShortName == null || courseShortName == String.Empty)
                                {
                                    Response.Redirect(@"../Error.aspx?ErrorDetail=" + "AddCourse_MissingCourseShortName", false);
                                    return;
                                }
                                else
                                {
                                    course = CourseM.Load(courseShortName);
                                    if (course.IsValid)
                                    {
                                        // course short name already exists; prompt: work with? copy?
                                        courseExists(course);
                                        return;
                                    }
                                }

                                // insert bare min. course information
                                course                        = new CourseM();
                                course.Name                   = courseShortName;
                                course.CourseGuid             = courseGuid;
                                course.SendEmailRemindersFlag = false;
                                course.LastUpdatedUserID      = SharedSupport.GetUserIdentity();
                                course.StartDate              = DateTime.Now.AddMonths(1);
                                course.EndDate                = DateTime.Now.AddMonths(1);

                                string fileDir = SharedSupport.RemoveIllegalFilePathCharacters(course.Name).Replace(" ", String.Empty);
                                fileDir = SharedSupport.AddBackSlashToDirectory(Constants.DEFAULT_COURSE_OFFERINGS_ROOT_STORAGE_PATH) + SharedSupport.AddBackSlashToDirectory(fileDir);
                                if (!System.IO.Directory.Exists(fileDir))
                                {
                                    //create directory
                                    System.IO.Directory.CreateDirectory(fileDir);
                                }

                                course.RootStoragePath = SharedSupport.AddBackSlashToDirectory(Constants.DEFAULT_COURSE_OFFERINGS_ROOT_STORAGE_PATH) + SharedSupport.AddBackSlashToDirectory(SharedSupport.RemoveIllegalFilePathCharacters(course.Name).Replace(" ", String.Empty));
                                course.Add();

                                if (!Directory.Exists(course.RootStoragePath))
                                {
                                    Directory.CreateDirectory(course.RootStoragePath);
                                }

                                UserM user = UserM.Load(SharedSupport.GetUserIdentity());
                                user.AddToCourse(course.CourseID, maxUserPermission);
                                // redirect for additional maintenance
                                Response.Redirect("AddEditCourse.aspx?CourseID=" + course.CourseID, false);
                            }
                        }
                        else
                        {
                            //Throw error, there was no ShortName on the query string
                            Response.Redirect(@"../Error.aspx?ErrorDetail=" + "AddCourse_MissingCourseShortName", false);
                        }
                    }
                    else
                    {
                        //Throw error, there was no CourseID on the query string
                        Response.Redirect(@"../Error.aspx?ErrorDetail=" + "AddCourse_MissingCourseID", false);
                    }
                }
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                //display nav bar
                Nav1.Feedback.Text = String.Empty;
                Nav1.SideTabId     = AssignmentManager.Common.constants.SIDE_NAV_COURSE_MANAGEMENT;
                Nav1.TopTabId      = AssignmentManager.Common.constants.TOP_NAV_COURSE_USERS;
                Nav1.Title         = SharedSupport.GetLocalizedString("AdminImport_Title");
                Nav1.SubTitle      = SharedSupport.GetLocalizedString("ImportForm_SubTitle");
                Nav1.relativeURL   = @"../";

                GoBack1.GoBack_HelpUrl    = SharedSupport.HelpRedirect("vstskAddingCourseUsers");
                GoBack1.GoBackIncludeBack = true;
                GoBack1.GoBack_left       = "400px";
                GoBack1.GoBack_top        = "-15px";
                GoBack1.GoBack_BackURL    = "ImportForm.aspx?CourseID=" + Request.QueryString.Get("CourseID");

                AssignmentManager.Common.Functions func = new AssignmentManager.Common.Functions();
                courseId = func.ValidateNumericQueryStringParameter(this.Request, "CourseID");
                if (courseId <= 0)
                {
                    throw(new ArgumentException(SharedSupport.GetLocalizedString("Global_MissingParameter")));
                }

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

                if (!IsPostBack)
                {
                    //clear combos
                    cboEmailAddress.Items.Clear();
                    cboFirstName.Items.Clear();
                    cboLastName.Items.Clear();
                    cboMiddleName.Items.Clear();
                    cboUniversityID.Items.Clear();
                    cboUserName.Items.Clear();
                }
                //Localize all items
                localizeLabels();

                //grab items off of the querystring - DECODE them
                uploadedFilePath    = SharedSupport.AddBackSlashToDirectory(Server.MapPath(Constants.ASSIGNMENTMANAGER_UPLOAD_DIRECTORY)) + Server.UrlDecode(Request.QueryString.Get("File"));
                delimitingCharacter = Server.UrlDecode(Request.QueryString.Get("Char"));

                //Create an instance of the dataset
                System.Data.DataSet ds = new System.Data.DataSet();

                //populate the combo boxes with items from the delimited file
                if (delimitingCharacter != "" && delimitingCharacter.Length < 2)
                {
                    //Parse first line of file into dataset using delimiting character specified.
                    ds = SharedSupport.ParseDelimitedFile(uploadedFilePath, delimitingCharacter, 1);
                    //throw new System.IO.FileNotFoundException(SharedSupport.GetLocalizedString("User_UploadFileNotFound"));
                }
                else
                {
                    throw(new ArgumentException(SharedSupport.GetLocalizedString("Global_MissingParameter")));
                }

                System.Data.DataSet   dsNew = new System.Data.DataSet();
                System.Data.DataTable dtNew = dsNew.Tables.Add();
                dtNew.Columns.Add();
                for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                {
                    System.Data.DataRow drNew = dtNew.NewRow();
                    drNew[0] = ds.Tables[0].Rows[0][i].ToString();
                    dtNew.Rows.Add(drNew);
                }

                //populate combos
                if (!Page.IsPostBack)
                {
                    for (int i = 0; i < dsNew.Tables[0].Rows.Count; i++)
                    {
                        int      dropdownIndex = i + 1;
                        ListItem newListItem   = new ListItem(dsNew.Tables[0].Rows[i][0].ToString(), dropdownIndex.ToString());
                        cboEmailAddress.Items.Add(newListItem);
                        cboFirstName.Items.Add(newListItem);
                        cboLastName.Items.Add(newListItem);
                        cboMiddleName.Items.Add(newListItem);
                        cboUniversityID.Items.Add(newListItem);
                        cboUserName.Items.Add(newListItem);
                    }
                }

                txtImportedFileLocation.Text = uploadedFilePath;
            }
            catch (Exception ex)
            {
                Nav1.Feedback.Text = ex.Message.ToString();
            }
        }