protected void initializeFields() { if (Convert.ToBoolean(SharedSupport.GetSetting(AssignmentManager.Constants.AUTOCHECK_SETTING)) == true) { this.rbtnAutoGradeOff.Checked = false; this.rbtnAutoGradeOn.Checked = true; } else { this.rbtnAutoGradeOff.Checked = true; this.rbtnAutoGradeOn.Checked = false; } if (Convert.ToBoolean(SharedSupport.UsingSsl) == true) { this.rbtnSSLOn.Checked = true; this.rbtnSSLOff.Checked = false; } else { this.rbtnSSLOn.Checked = false; this.rbtnSSLOff.Checked = true; } if (Convert.ToBoolean(SharedSupport.UsingSmtp) == true) { this.rbtnSMTPOn.Checked = true; this.rbtnSMTPOff.Checked = false; } else { this.rbtnSMTPOn.Checked = false; this.rbtnSMTPOff.Checked = true; } this.txtProcessingTime.Text = Convert.ToString(SharedSupport.GetSetting(AssignmentManager.Constants.MAX_PROCESS_SETTING)); this.txtProjectSize.Text = Convert.ToString(SharedSupport.GetSetting(AssignmentManager.Constants.MAX_PROJECT_SETTING)); }
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(); } }
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(); } }
public void btnUpdate_Click(object sender, System.EventArgs e) { try { if (!SharedSupport.SecurityIsAllowed(courseId, SecurityAction.SETTING_EDIT)) { throw new Exception(SharedSupport.GetLocalizedString("Global_Unauthorized")); } // AutoBuild/AutoCheck status are tied together and the SetSetting method // will make sure the values remain in synch. Changed after UI freeze. // Determine if the user changed the setting if (SharedSupport.GetSetting(Constants.AUTOBUILD_SETTING) == "True") { // did the user turn it off? if (rbtnAutoGradeOff.Checked) { // turn if off SharedSupport.SetSetting(Constants.AUTOBUILD_SETTING, "False"); // update the UI // rbtnAutoGradeOff.Checked = true; // rbtnAutoGradeOn.Checked = false; } } else { // it was off, did the user turn it back on? if (rbtnAutoGradeOn.Checked) { // turn it on SharedSupport.SetSetting(Constants.AUTOBUILD_SETTING, "True"); // update the UI // rbtnAutoGradeOn.Checked = true; // rbtnAutoGradeOff.Checked = false; } } if (this.txtProcessingTime.Text != "") { try { if (Convert.ToInt32(this.txtProcessingTime.Text) > 0) { if (Convert.ToInt32(txtProcessingTime.Text) <= Constants.MAX_PROCESS_LIMIT) { SharedSupport.SetSetting("MaxProcessTime", txtProcessingTime.Text); } else { string[] limit = new string[] { Constants.MAX_PROCESS_LIMIT.ToString() }; Nav1.Feedback.Text = SharedSupport.GetLocalizedString("Setting_MaxProcessingTime_Limit_Error", limit); } } } catch { Nav1.Feedback.Text = SharedSupport.GetLocalizedString("Setting_MaxProcessingTime_Error"); } } if (this.txtProjectSize.Text != "") { try { if (Convert.ToDouble(this.txtProjectSize.Text) > 0) { if (Convert.ToDouble(txtProjectSize.Text) <= Constants.MAX_PROJECT_SIZE) { SharedSupport.SetSetting("MaxUploadSize", txtProjectSize.Text); } else { string[] limit = new string[] { Constants.MAX_PROJECT_SIZE.ToString() }; Nav1.Feedback.Text = SharedSupport.GetLocalizedString("Setting_MaxProjectSize_Limit_Error", limit); } } } catch { Nav1.Feedback.Text = SharedSupport.GetLocalizedString("Setting_MaxProjectSize_Error"); } } } catch (Exception ex) { Nav1.Feedback.Text = ex.Message; } }