Exemplo n.º 1
0
 private void LoadFileResource()
 {
     using (var helper = new DbHelper.ActAndRes())
     {
         var files = new List <FileResourceEventArgs>();
         var fileR = helper.GetFileResource(FileResourceId);
         if (fileR != null)
         {
             txtName.Text   = fileR.Name;
             CKEditor1.Text = fileR.Description;
             chkDisplayDescription.Checked     = fileR.ShowDescriptionOnCoursePage;
             chkShowSize.Checked               = fileR.ShowSize;
             chkShowType.Checked               = fileR.ShowType;
             chkShowUploadModifiedDate.Checked = fileR.ShowUploadModifiedDate;
             ddlDisplay.SelectedIndex          = fileR.Display;
             var i = 1;
             foreach (var f in fileR.FileResourceFiles)
             {
                 files.Add(new FileResourceEventArgs()
                 {
                     Id              = f.SubFileId,
                     Visible         = true,
                     FileType        = f.SubFile.FileType,
                     IconPath        = f.SubFile.IconPath,
                     FilePath        = f.SubFile.FileDirectory + "/" + f.SubFile.FileName,
                     FileDisplayName = f.SubFile.DisplayName,
                     FileSizeInBytes = f.SubFile.FileSizeInBytes
                     ,
                     LocalId = i.ToString()
                 });
                 i++;
             }
             FilesDisplay1.SetInitialValues(files);
             RestrictionUC.SetActivityResource(false, ((int)Enums.Resources.File) + 1, fileR.Id);
         }
     }
 }
Exemplo n.º 2
0
        private void PopulateSchoolInfo(CustomPrincipal user)
        {
            using (var helper = new DbHelper.Office())
            {
                var sch = helper.GetSchoolOfUser(user.Id);

                if (sch != null)
                {
                    CKEditor1.Text       = sch.Description;
                    hidSchoolId.Value    = sch.Id.ToString();
                    txtAddress.Text      = sch.Address;
                    txtName.Text         = sch.Name;
                    txtEmailGeneral.Text = sch.EmailGeneral;
                    //txtEmailMarketing.Text = sch.EmailMarketing;
                    //txtEmailSupport.Text = sch.EmailSupport;
                    txtPhoneMain.Text = sch.PhoneMain;
                    //txtPhoneAfterHours.Text = sch.PhoneAfterHours;
                    hidImageId.Value = sch.ImageId.ToString();

                    //txtStreet.Text = sch.Street;
                    txtWeb.Text     = sch.Website;
                    hidUserId.Value = sch.UserId.ToString();
                    //cmbSchoolType.SelectedValue = sch.SchoolTypeId.ToString();
                    var f = helper.GetSchoolImage(sch.ImageId);
                    if (f != null)
                    {
                        //var fileName = Path.GetFileName(f.FilePath);
                        var image = new FileResourceEventArgs()
                        {
                            Id = f.Id,
                            //CreatedBy = user.Id
                            //,
                            //CreatedDate = DateTime.Now
                            //,
                            FileDisplayName = f.DisplayName //Path.GetFileName(imageFile.FileName)
                                                            //,
                                                            // FileDirectory = DbHelper.StaticValues.SchoolFileLocation //StaticValue.UserImageDirectory
                                                            // ,
                                                            //FileName = fileName
                            ,
                            FilePath = DbHelper.StaticValues.SchoolFileLocation + f.FileName
                                       //Guid.NewGuid().ToString() + GetExtension(imageFile.FileName, imageFile.ContentType)
                            ,
                            FileSizeInBytes = f.FileSizeInBytes //imageFile.ContentLength
                            ,
                            FileType = f.FileType               //imageFile.ContentType
                            ,
                            IconPath = f.IconPath
                            ,
                            //SubjectId = SubjectId
                        };
                        FilesDisplay1.SetInitialValues(new List <FileResourceEventArgs>()
                        {
                            image
                        });
                    }
                }
                if (SiteMap.CurrentNode != null)
                {
                    var list = new List <IdAndName>()
                    {
                        new IdAndName()
                        {
                            Name    = SiteMap.RootNode.Title
                            , Value = SiteMap.RootNode.Url
                            , Void  = true
                        },
                        new IdAndName()
                        {
                            Name    = sch == null?SiteMap.CurrentNode.ParentNode.Title:sch.Name
                            , Value = SiteMap.CurrentNode.ParentNode.Url
                            , Void  = true
                        },
                        new IdAndName()
                        {
                            Name = "Edit"
                        }
                    };
                    SiteMapUc.SetData(list);
                }
            }
        }
Exemplo n.º 3
0
        void LoadActivity(int assignmentId)
        {
            using (var helper = new DbHelper.ActAndRes())
            {
                var ass = helper.GetAssignment(assignmentId);
                if (ass != null)
                {
                    var submission = ass.Submissions.FirstOrDefault(x => x.UserClassId == UserClassId);
                    if (submission != null)
                    {
                        var files = new List <FileResourceEventArgs>();
                        SubmissionId = submission.Id;
                        if (ass.OnlineText)
                        {
                            CKEditor1.Text = submission.SubmissionText;
                        }
                        if (ass.FileSubmission)
                        {
                            FilesDisplay1.NumberOfFilesToUpload = ass.MaximumNoOfUploadedFiles ?? 0;
                            var i = 1;
                            foreach (var f in submission.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);
                        }
                    }


                    AssignmentId        = assignmentId;
                    lblName.Text        = ass.Name;
                    lblDescription.Text = ass.Description;

                    if (ass.FileSubmission || ass.OnlineText)
                    {
                        if (ass.FileSubmission)
                        {
                            pnlFileSubmit.Visible = true;
                            lblFileLimit.Text     = "(File Limit : " + (ass.MaximumNoOfUploadedFiles ?? 0) + " files, " +
                                                    " Maximum size per file: " + (ass.MaximumSubmissionSize ?? 0) +
                                                    "KB)";
                            //FilesDisplay1.NumberOfFilesToUpload = ass.MaximumNoOfUploadedFiles ?? 0;
                        }
                        else
                        {
                            pnlFileSubmit.Visible = false;
                            pnlFileSubmit.Controls.Clear();
                        }

                        if (ass.OnlineText)
                        {
                            //lblScript.Text = WordLimitScript(ass.WordLimit ?? 0);

                            lblWordLimit.Text = "(Word Limit : " + (ass.WordLimit ?? 0) + " words)";
                            pnlText.Visible   = true;
                        }
                        else
                        {
                            pnlText.Visible = false;
                            pnlText.Controls.Clear();
                        }
                    }
                    else
                    {
                        btnSubmit.Visible = false;
                    }
                }
            }
        }
Exemplo n.º 4
0
        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");
                                }
                            }
                        }
                    }
                }
            }
        }