private void LoadActivityResource() { using (var helper = new DbHelper.ActAndRes()) { var arId = ActivityResourceId; var actRes = helper.GetActivityResource(arId); if (actRes != null) { foreach (var aCls in actRes.ActivityClasses) { var subCls = aCls.SubjectClass; //get a uc , initialize uc var classUc = (ClassGradeDisplayUc) Page.LoadControl("~/Views/ActivityResource/Grading/ClassGradeDisplayUc.ascx"); classUc.SetData(subCls.IsRegular ? subCls.GetName : subCls.Name); var any = false; foreach (var clsUser in subCls.ClassUsers) { //initialize another uc if (clsUser.Role.RoleName == "student" && !(clsUser.Void ?? false)) { var userUc = (UserGradeDisplayUc) Page.LoadControl("~/Views/ActivityResource/Grading/UserGradeDisplayUc.ascx"); userUc.SetData(clsUser, actRes.Id, actRes.ActivityResourceId, actRes.ActivityResourceType); classUc.AddControls(userUc); any = true; } } if (!any) { classUc.AddControlsInsideTable(new Literal() { Text = "<tr>" + "<td>" + "No students found." + "</td>" + "</tr>" }, false); pnlGradeList.Controls.Add(new Literal() { Text = "<br />" }); } pnlGradeList.Controls.Add(classUc); pnlGradeList.Controls.Add(new Literal() { Text = "<br />" }); pnlGradeList.Controls.Add(new Literal() { Text = "<br />" }); } } } }
List <IdAndName> GetForum(DbHelper.ActAndRes helper, string fileName) { var list = new List <IdAndName>(); switch (fileName) { case "DiscussionCreate.aspx": var fId = Request.QueryString["fId"]; var subId = Request.QueryString["SubId"]; var secId = Request.QueryString["secId"]; var frum = helper.GetForumActivity(Convert.ToInt32(fId)); list.Add(new IdAndName() { Name = frum.Name, Value = "~/Views/ActivityResource/Forum/ForumView.aspx?SubId=" + subId + "&arId=" + fId + "&secId=" + secId, Void = true, }); list.Add(new IdAndName() { Name = "Discussion edit", }); break; case "DiscussionView.aspx": var disId = Request.QueryString["disId"]; var discussion = helper.GetForumDiscussion(Convert.ToInt32(disId)); if (discussion != null) { var actres = helper.GetActivityResource(true, (byte)Enums.Activities.Forum + 1, discussion.ForumActivityId); list.Add(new IdAndName() { Name = discussion.ForumActivity.Name, Value = "~/Views/ActivityResource/Forum/ForumView.aspx?SubId=" + actres.SubjectSection.SubjectId + "&arId=" + discussion.ForumActivityId + "&secId=" + actres.SubjectSectionId, Void = true, }); list.Add(new IdAndName() { Name = discussion.Subject, }); } break; case "ForumCreate.aspx": list.Add(new IdAndName() { Name = "Forum edit" }); break; case "ForumView.aspx": var forumId = Request.QueryString["arId"]; var forum = helper.GetForumActivity(Convert.ToInt32(forumId)); if (forum != null) { list.Add(new IdAndName() { Name = forum.Name, }); } break; } return(list); }
private void LoadAssignment() { using (var helper = new DbHelper.ActAndRes()) { var ass = helper.GetAssignment(AssignmentId); if (ass != null) { RestrictionUC.SetActivityResource(true, ((int)Enums.Activities.Assignment) + 1, ass.Id); var actRes = helper.GetActivityResource(true, ((int)Enums.Activities.Assignment) + 1, ass.Id); if (actRes != null) { var classes = new List <IdAndName>(); foreach (var cls in actRes.ActivityClasses.AsEnumerable()) { classes.Add(new IdAndName() { Id = cls.SubjectClassId , Name = cls.SubjectClass.IsRegular ? cls.SubjectClass.GetName : cls.SubjectClass.Name , Void = false }); } txtName.Text = ass.Name; CKEditor1.Text = ass.Description; chkDisplayDesc.Checked = ass.DispalyDescriptionOnPage ?? false; ClassesInActivityChoose1.PopulateClassPanel(classes); GradeInActivityUc1.SetGradeValues(actRes, ass); #region File and online submission if (ass.FileSubmission) { chkFileSubmission.Checked = true; txtMaxFiles.Text = (ass.MaximumNoOfUploadedFiles ?? 0).ToString(); txtMaxSize.Text = (ass.MaximumSubmissionSize ?? 0).ToString(); txtMaxFiles.Enabled = true; txtMaxSize.Enabled = true; } else { chkFileSubmission.Checked = false; txtMaxFiles.Enabled = false; txtMaxSize.Enabled = false; } if (ass.OnlineText) { chkOnlineSubmission.Checked = true; txtWordLimit.Text = ass.WordLimit.ToString(); txtWordLimit.Enabled = true; } else { chkOnlineSubmission.Checked = false; txtWordLimit.Enabled = false; } #endregion #region Date if (ass.CutOffDate != null) { chkCutOff.Checked = true; txtCutOff.Text = ass.CutOffDate.Value.ToShortDateString(); } else { chkCutOff.Checked = false; txtCutOff.Enabled = false; } if (ass.DueDate != null) { chkDue.Checked = true; txtDue.Text = ass.DueDate.Value.ToShortDateString(); txtDue.Enabled = true; } else { chkDue.Checked = false; txtDue.Enabled = false; } if (ass.SubmissionFrom != null) { chkFrom.Checked = true; txtFrom.Text = ass.SubmissionFrom == null ? "" : ass.SubmissionFrom.Value.ToShortDateString(); txtFrom.Enabled = true; } else { chkFrom.Checked = false; txtFrom.Enabled = false; } #endregion //here } } } }
private void LoadCustomText() { try { #region Activity Resource var actResId = Request.QueryString["actResId"]; //var actOrRes = Request.QueryString["actOrRes"]; //var actOrResId = Request.QueryString["actOrResId"]; //var actResType = Request.QueryString["actResType"]; if (actResId != null)//actOrRes != null && actOrResId != null && actResType != null) { var displayType = ""; //var type = Convert.ToByte(actResType); //var aOrRId = Convert.ToInt32(actOrResId); using (var helper = new DbHelper.ActAndRes()) { var actRes = helper.GetActivityResource(Convert.ToInt32(actResId)); if (actRes != null) { if (Convert.ToBoolean(actRes.ActivityOrResource)) //activity { switch (actRes.ActivityResourceType - 1) { case (int)Enums.Activities.Assignment: //Assignment displayType = Enums.Activities.Assignment.ToString().ToLower(); break; case (int)Enums.Activities.Chat: //chat displayType = Enums.Activities.Chat.ToString().ToLower(); break; case (int)Enums.Activities.Forum: //forum displayType = Enums.Activities.Forum.ToString().ToLower(); break; case (int)Enums.Activities.Choice: displayType = Enums.Activities.Choice.ToString().ToLower(); break; case (int)Enums.Activities.Lession: //lession displayType = Enums.Activities.Lession.ToString().ToLower(); break; case (int)Enums.Activities.Wiki: //wiki displayType = Enums.Activities.Wiki.ToString().ToLower(); break; case (int)Enums.Activities.Workshop: //Workshop displayType = Enums.Activities.Workshop.ToString().ToLower(); break; } } else //resource { switch (actRes.ActivityResourceType - 1) { case (int)Enums.Resources.Book: //Book displayType = Enums.Resources.Book.ToString().ToLower(); break; case (int)Enums.Resources.File: //file displayType = Enums.Resources.File.ToString().ToLower(); break; case (int)Enums.Resources.Folder: displayType = Enums.Resources.Folder.ToString().ToLower(); break; case (int)(Enums.Resources.Label): displayType = Enums.Resources.Label.ToString().ToLower(); break; case (int)(Enums.Resources.Page): displayType = Enums.Resources.Page.ToString().ToLower(); break; case (int)(Enums.Resources.Url): displayType = Enums.Resources.Url.ToString().ToLower(); break; } } lblInfoText.Text = ("Are you sure to delete the " + displayType + ", " + actRes.Name + "?"); //DbHelper.StaticValues.Decode } } return; } #endregion #region Book chapter var chapterId = Request.QueryString["bcId"]; if (chapterId != null) { using (var helper = new DbHelper.ActAndRes()) { var chapter = helper.GetChapter(Convert.ToInt32(chapterId)); if (chapter != null) { lblInfoText.Text = "Are you sure to delete the chapter, " + chapter.Title + "?"; } return; } } #endregion #region Grade var gradeId = Request.QueryString["grdId"]; if (gradeId != null) { using (var helper = new DbHelper.Grade()) { var grade = helper.GetGrade(Convert.ToInt32(gradeId)); if (grade != null) { lblInfoText.Text = "Are you sure to delete the grade, " + grade.Name + "?"; } return; } } #endregion #region Notice var noticeId = Request.QueryString["nId"]; if (noticeId != null) { using (var helper = new DbHelper.Notice()) { var notice = helper.GetNotice(Convert.ToInt32(noticeId)); if (notice != null) { lblInfoText.Text = "Are you sure to delete the notice, " + notice.Title + "?"; } } return; } #endregion #region Academic year and SEssion var acaId = Request.QueryString["acaId"]; if (acaId != null) { using (var helper = new DbHelper.AcademicYear()) { var academic = helper.GetAcademicYear(Convert.ToInt32(acaId)); if (academic != null) { lblInfoText.Text = "Are you sure to delete the academic year, " + academic.Name + "?"; } return; } } var sessId = Request.QueryString["sessId"]; if (sessId != null) { using (var helper = new DbHelper.AcademicYear()) { var session = helper.GetSession(Convert.ToInt32(sessId)); if (session != null) { lblInfoText.Text = "Are you sure to delete the session, " + session.Name + "?"; } return; } } #endregion #region SubjectClass var subclsId = Request.QueryString["subclsId"]; if (subclsId != null) { using (var helper = new DbHelper.Classes()) { var cls = helper.GetSubjectSession(Convert.ToInt32(subclsId)); if (cls != null) { lblInfoText.Text = "Are you sure to delete the class, " + (cls.IsRegular ? cls.GetName : cls.Name) + "?"; } } return; } #endregion #region Course and Category var catId = Request.QueryString["catId"]; var crsId = Request.QueryString["crsId"]; //crsId should be null so it means that its category only if (catId != null && crsId == null) { using (var helper = new DbHelper.Subject()) { var category = helper.GetCategory(Convert.ToInt32(catId)); if (category != null) { lblInfoText.Text = "Are you sure to delete the category, " + category.Name + "?"; } } return; } #endregion } catch { } }
//DbHelper.ActAndRes ahelper, private void PopulateClasses(CustomPrincipal user) { using (var ahelper = new DbHelper.ActAndRes()) { var actres = ahelper.GetActivityResource(true, (byte)(Enums.Activities.Assignment + 1), AssignmentId); if (actres != null) { ahelper.SetActivityResourceView(actres.Id, SubjectId, user.Id); var submitButtonVisiblity = true; var colorChange = false; //Color backColor = Color.White; //Color foreColor = Color.Black; var status = ""; var grade = "N/A"; var remarks = ""; var assignmentId = AssignmentId; #region Restriction and all codes var elligible = false; var roles = user.GetRoles(); if (roles.Contains(DbHelper.StaticValues.Roles.CourseEditor.ToString()) || roles.Contains(DbHelper.StaticValues.Roles.Manager.ToString()) || roles.Contains(DbHelper.StaticValues.Roles.Admin) || roles.Contains("teacher")) { elligible = true; } var canView = elligible; if (!canView) { canView = ahelper.EvaluateRestriction(null, actres.Restriction, user.Id); } //else // submitButtonVisiblity = false; if (canView) { #region Assignment Load var date = DateTime.Now; var ass = ahelper.GetAssignment(assignmentId); if (ass != null) { var timeRemaining = "N/A"; //actres will be used for restriction n class lblName.Text = ass.Name; lblPageTitle.Text = ass.Name; lblDescription.Text = ass.Description; #region Date and time Calculation if (ass.SubmissionFrom != null) { if (ass.SubmissionFrom > date) { var rem = (ass.SubmissionFrom.Value - date); timeRemaining = (rem.Days > 0 ? (rem.Days + " days ") : "") + (rem.Hours > 0 ? (rem.Hours + " hours ") : "") + (rem.Minutes > 0 ? (rem.Minutes + " minutes ") : "") + " for submission start."; submitButtonVisiblity = false; } } if (ass.DueDate != null) { lblDueDate.Text = ass.DueDate.Value.ToString("f"); if (ass.DueDate < date) { var rem = (date - ass.DueDate.Value); timeRemaining = (rem.Days > 0 ? (rem.Days + " days ") : "") + (rem.Hours > 0 ? (rem.Hours + " hours ") : "") + (rem.Minutes > 0 ? (rem.Minutes + " minutes ") : "") + " elapsed since due date."; //timeRemaining = "Due date finished on " + ass.DueDate.Value.ToString("f"); colorChange = true; //backColor = Color.DeepPink; //foreColor = Color.White; } else { var rem = (ass.DueDate.Value - date); timeRemaining = (rem.Days > 0 ? (rem.Days + " days ") : "") + (rem.Hours > 0 ? (rem.Hours + " hours ") : "") + (rem.Minutes > 0 ? (rem.Minutes + " minutes ") : "") + " for submission end."; } } else { lblDueDate.Text = "N/A"; } if (ass.CutOffDate != null && ass.CutOffDate < date) { timeRemaining = "Sumission period end."; submitButtonVisiblity = false; } lblTimeRemaining.Text = timeRemaining; #endregion #endregion foreach (var c in actres.ActivityClasses) { var userclass = c.SubjectClass.ClassUsers.FirstOrDefault(y => y.UserId == user.Id); if (userclass != null) { #region Each class view initialize var subCls = c.SubjectClass; var classUc = (ClassGradeDisplayUc) Page.LoadControl("~/Views/ActivityResource/Grading/ClassGradeDisplayUc.ascx"); classUc.SetData(subCls.IsRegular ? subCls.GetName : subCls.Name); if (subCls.SessionComplete ?? false) { classUc.Enable = false; } pnlGradeList.Controls.Add(classUc); // pnlGradeList.Controls.Add(new Literal() {Text = "<br />"}); //pnlGradeList.Controls.Add(new Literal() {Text = "<br />"}); #endregion if (userclass.Role.RoleName == "student") { #region submit view display classUc.ShowStudentListTableHeading = false; if (!(subCls.SessionComplete ?? false)) { //disable the submit button var stdGradeUc = (StudentGradeDispalyUc) Page.LoadControl( "~/Views/ActivityResource/Grading/StudentGradeDispalyUc.ascx"); //stdGradeUc.RedirectUrl = "~/Views/ActivityResource/Grading/?actResId=" + actres.Id + // "&SubId=" + SubjectId + // "&secId=" + SectionId; stdGradeUc.RedirectUrl = "~/Views/ActivityResource/Assignments/SubmitAssignmentCreate.aspx?arId=" + AssignmentId + "&SubId=" + SubjectId + "&secId=" + SectionId + "&ucId=" + userclass.Id; stdGradeUc.SubmitButtonVisible = ass.FileSubmission || ass.OnlineText; #region Submissions var subm = ass.Submissions.FirstOrDefault(x => x.UserClass.UserId == user.Id); var submissionEnabled = true; if (subm != null) { status = "Submitted on : " + ((subm.ModifiedDate == null) ? subm.SubmittedDate.ToString("f") : subm.ModifiedDate.Value.ToString("f")); stdGradeUc.SubmitButtonText = "Edit Submission"; var obtgrade = actres.ActivityGradings.FirstOrDefault( x => x.UserClassId == subm.UserClassId); if (obtgrade != null) { if (obtgrade.ObtainedGradeId != null) { grade = obtgrade.ObtainedGrade.Value; } else { grade = (obtgrade.ObtainedGradeMarks ?? 0).ToString("F"); } submissionEnabled = false;//since already graded remarks = obtgrade.Remarks; } } else { status = "Not submitted yet"; } #endregion classUc.AddControlsOusideOfTable(stdGradeUc); stdGradeUc.SubmitButtonVisible = submitButtonVisiblity; if (colorChange) { stdGradeUc.SubmitDueIndicator = true; lblTimeRemaining.ForeColor = Color.Red; //lblTimeRemaining.ForeColor = foreColor; //stdGradeUc.SubmitButtonBackColor = backColor; //stdGradeUc.SubmitButtonForeColor = foreColor; } stdGradeUc.SetData(status, grade, remarks, submissionEnabled, ass.ShowGradeToStudents); } #endregion //ucStdRole.Add(userclass); } else if (userclass.Role.RoleName == "teacher" || userclass.Role.RoleName == "manager") { //grade uc display for that class #region Grading view display , start of teacher role classUc.ShowStudentListTableHeading = true; var any = false; foreach (var clsUser in subCls.ClassUsers.Where(x => !(x.Void ?? false))) { //initialize each user uc if (clsUser.Role.RoleName == "student" && !(clsUser.Void ?? false)) { var userUc = (UserGradeDisplayUc) Page.LoadControl( "~/Views/ActivityResource/Grading/UserGradeDisplayUc.ascx"); userUc.SectionId = SectionId; userUc.SubjectId = SubjectId; userUc.SetData(clsUser, actres.Id, ass.Id, actres.ActivityResourceType); classUc.AddControls(userUc); any = true; } } if (!any) { classUc.AddControlsInsideTable(new Literal() { Text = "<tr>" + "<td>" + "No students found." + "</td>" + "</tr>" }, false); } #endregion of teacher role } } } //foreach end } else { Response.Redirect("~/"); } } else { Response.Redirect("~/"); } #endregion } else { Response.Redirect("~/"); } } }
private void LoadSubmission() { using (var helper = new DbHelper.ActAndRes()) { var userClassId = UserClassId; var actres = helper.GetActivityResource(ActivityResourceId); if (actres != null) { var grd = (actres.ActivityGradings.FirstOrDefault(x => x.UserClassId == userClassId)); var ass = helper.GetAssignment(ActivityId); if (ass != null) { var sub = ass.Submissions.FirstOrDefault(x => x.UserClassId == userClassId); lblName.Text = ass.Name; lblDescription.Text = ass.Description; if (sub != null) { if (ass.FileSubmission) { var files = new List <FileResourceEventArgs>(); FilesDisplay1.NumberOfFilesToUpload = ass.MaximumNoOfUploadedFiles ?? 0; var i = 1; foreach (var f in sub.AssignmentSubmissionFiles) { files.Add(new FileResourceEventArgs() { Id = f.UserFileId, Visible = true, FileType = f.UserFile.FileType, IconPath = f.UserFile.IconPath, FilePath = f.UserFile.FileDirectory + "/" + f.UserFile.FileName, FileDisplayName = f.UserFile.DisplayName, FileSizeInBytes = f.UserFile.FileSizeInBytes , LocalId = i.ToString() }); i++; } FilesDisplay1.SetInitialValues(files); } if (grd != null) { var user = grd.UserClass.User; lblStudentName.Text = user.FirstName + (string.IsNullOrEmpty(user.MiddleName)? "": " " + user.MiddleName) + (string.IsNullOrEmpty(user.LastName) ? "" : " " + user.LastName); lblEmail.Text = user.Email; lblClassName.Text = grd.UserClass.SubjectClass.GetName; var std = user.Student.FirstOrDefault(); if (std != null) { lblRoll.Text = std.CRN; } txtRemarks.Text = grd.Remarks; } else { using (var clsHelper = new DbHelper.Classes()) { var uc = clsHelper.GetUserClass(userClassId); if (uc != null) { var user = uc.User; lblStudentName.Text = user.FirstName + (string.IsNullOrEmpty(user.MiddleName) ? "" : " " + user.MiddleName) + (string.IsNullOrEmpty(user.LastName) ? "" : " " + user.LastName); lblEmail.Text = user.Email; lblClassName.Text = uc.SubjectClass.GetName; var std = user.Student.FirstOrDefault(); if (std != null) { lblRoll.Text = std.CRN; } } else { Response.Redirect("~/Views/All_Resusable_Codes/Error/ErrorPage.aspx"); } } } if (ass.OnlineText) { pnlText.Visible = true; txtSubmittedText.Text = sub.SubmissionText; lblWordLimit.Text = "(Word limit : " + (ass.WordLimit ?? 0) + " words)"; } if (ass.FileSubmission) { pnlFileSubmit.Visible = true; lblFileLimit.Text = "(Maximum No. of files allowed : " + (ass.MaximumNoOfUploadedFiles ?? 0) + ", Maximum file size : " + (ass.MaximumSubmissionSize ?? 0) + "KB)"; //each file load } if (ass.GradeType.RangeOrValue) //value { var values = ass.GradeType.GradeValues.ToList(); ddlGrade.Visible = true; var lst = new List <Academic.DbEntities.Grades.GradeValue>(); var maxid = 0; try { maxid = Convert.ToInt32(ass.MaximumGrade); } catch { } var max = values.FirstOrDefault(x => x.Id == maxid); if (max != null) { lblMaximumGrade.Text = max.Value; foreach (var gv in ass.GradeType.GradeValues) { if ((gv.EquivalentPercentOrPostition ?? 0).CompareTo( (max.EquivalentPercentOrPostition ?? 0)) <= 0) { lst.Add(gv); } } } var minid = 0; try { minid = Convert.ToInt32(ass.GradeToPass); } catch { } var min = values.FirstOrDefault(x => x.Id == minid); if (min != null) { lblMinimumGradeToPass.Text = min.Value; } ddlGrade.DataSource = lst; ddlGrade.DataBind(); if (grd != null) { try { if ((grd.ObtainedGradeId ?? 0) > 0) { ddlGrade.SelectedValue = (grd.ObtainedGradeId ?? 0).ToString(); } } catch { } } } else//range { txtGrade.Visible = true; lblMaximumGrade.Text = ass.MaximumGrade; lblMinimumGradeToPass.Text = ass.GradeToPass; if (grd != null) { txtGrade.Text = (grd.ObtainedGradeMarks ?? 0).ToString("F"); } } } } } } }