Ejemplo n.º 1
0
        private void Submitted(string sid, int assignmentId)
        {
            Submission stdAssignmentSubmission = null;

            stdAssignmentSubmission = SubmissionController.GetItemByStudentAssignment(sid, assignmentId);
            if (stdAssignmentSubmission != null)
            {
                lblFileLocation.Text  = stdAssignmentSubmission.FileLocation;
                lbtnAssignment.Text   = stdAssignmentSubmission.Assignment.ATitle;
                lblSubmittedDate.Text = stdAssignmentSubmission.SubmissionDate.ToLongDateString();
                lblGrade.Text         = stdAssignmentSubmission.Grade.ToString();
            }
        }
Ejemplo n.º 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string sname        = Session["Username"].ToString();
            int    assignmentId = Convert.ToInt32(Request.QueryString["AssignmentID"]);

            Submission studentassignment = new Submission();

            studentassignment.Student.SId             = sname;
            studentassignment.Assignment.AssignmentId = assignmentId;
            studentassignment.SubmissionDate          = DateTime.Now;

            if (fileuploadSubmission.HasFile)
            {
                if (fileuploadSubmission.PostedFile.ContentType.ToLower() == "application/pdf" ||
                    fileuploadSubmission.PostedFile.ContentType.ToLower() == "application/msword")
                {
                    string filename  = sname;
                    string extension = Path.GetExtension(fileuploadSubmission.FileName);
                    string directory = Server.MapPath("~/CourseMaterials/" + Session["courseID"] + "/Assignment/Assignment" + assignmentId);
                    //Create directory if no folder to save the lecture note
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }
                    studentassignment.FileLocation = directory + "/" + filename + extension;
                    fileuploadSubmission.SaveAs(studentassignment.FileLocation);
                    ClientScript.RegisterStartupScript(this.GetType(), "successUpload",
                                                       "alert('Uploaded successfully!!!');", true);
                    SubmissionController.Save(studentassignment);
                    Response.Redirect(String.Format("~/Presentation/formAssignmentDetail.aspx?AssignmentID={0}", assignmentId));
                }
                else  //If the file format is invalid.
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "fileFormatError",
                                                       "alert('File format error: Only pdf or doc files are allowed!!!');",
                                                       true);
                }
            }
            else //If the path doesn't contain any file
            {
                ClientScript.RegisterStartupScript(this.GetType(), "failUpload",
                                                   "alert('Please specify the file to upload.!!!');", true);
            }
        }