Ejemplo n.º 1
0
        /// <summary>
        /// 返回学生电子学档
        /// </summary>
        /// <param name="courseid"></param>
        /// <param name="moduleTag"></param>
        /// <returns></returns>
        public ActionResult WorksDetail(int courseid, string moduleTag)
        {
            ViewBag.courseid = courseid;
            //-------------------------------------------返回学生的最后得分-------------------------------------------------
            int      mTag   = 1;//如果是第一次其他页面请求过来,mTag的值为1,则默认显示该课程的第一个模块
            CouScore cScore = null;

            if (!string.IsNullOrEmpty(moduleTag))
            {
                mTag = Convert.ToInt32(moduleTag);
            }
            cScore         = db.CouScore.Where(cs => cs.CourseId == courseid && cs.ModuleTag == mTag).FirstOrDefault();
            ViewBag.cScore = cScore;
            //--------------------------------------返回课程某一模块的详细----------------------------------------------------------
            Module module = db.Module.Where(m => m.CourseId == courseid && m.ModuleTag == mTag).FirstOrDefault();

            ViewBag.module = module;

            //----------------------------------------------返回学生对某一模块的作业----------------------------------------------------
            StudentWork sWork = db.StudentWork.Where(sw => sw.CourseId == courseid && sw.StudentId == studentId && sw.ModuleTag == mTag).FirstOrDefault();

            ViewBag.sWork = sWork;
            //---------------------------------------返回某一模块的考试题目 学生的答案 及评分-------------------------------------
            if (module != null)
            {
                List <Erecord> listErecord = mHelp.SqlQuery <Erecord>("select pq.QTitle,psa.Answer,psa.AnswerScore from PaperStudentAnswers as psa join PaperQuestions as pq on psa.QuestionId=pq.Id where psa.MouduleTag=@mTag and StudentId=@studentId", new SqlParameter[] { new SqlParameter("@mTag", mTag), new SqlParameter("@studentId", studentId) }).ToList();
                ViewBag.listErecord = listErecord;
            }
            //--------------------------------------------------------------------------------------------------------------------
            return(View());
        }
Ejemplo n.º 2
0
 private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         StudentWork studentWork = dataGridView1.SelectedRows[0].DataBoundItem as StudentWork;
         student.StudentWorks.Remove(studentWork);
         DBController.Instance.Remove(studentWork);
         UpdateGrid();
     }
 }
Ejemplo n.º 3
0
        private ActionResult Save(StudentWork model, string newStatus, HttpPostedFileBase upload)
        {
            try
            {
                string oldStatus = model.WorkStatus;
                model.WorkStatus = newStatus;
                string msg = model.Validate();
                if (!string.IsNullOrEmpty(msg))
                {
                    model.WorkStatus = oldStatus;
                    throw new Exception(msg);
                }
                using (DataContext ctx = new DataContext())
                {
                    if (model.Id != 0)
                    {
                        var item = ctx.StudentWork.FirstOrDefault(t => t.Id == model.Id);
                        item.TeacherId       = model.TeacherId;
                        item.StudentId       = model.StudentId;
                        item.WorkTypeId      = model.WorkTypeId;
                        item.WorkStatus      = model.WorkStatus;
                        item.TeacherComments = model.TeacherComments;
                        item.PredmetId       = model.PredmetId;

                        if (upload != null)
                        {
                            item.WorkFileName = System.IO.Path.GetFileName(upload.FileName);
                            item.WorkFile     = new byte[upload.InputStream.Length];
                            upload.InputStream.Read(item.WorkFile, 0, item.WorkFile.Length);
                        }
                    }
                    else
                    {
                        if (upload != null)
                        {
                            model.WorkFileName = System.IO.Path.GetFileName(upload.FileName);
                            model.WorkFile     = new byte[upload.InputStream.Length];
                            upload.InputStream.Read(model.WorkFile, 0, model.WorkFile.Length);
                        }

                        ctx.StudentWork.Add(model);
                    }

                    ctx.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                PrepareViewBag();
                FillModelForeignKeys(model);
                return(View("Edit", model));
            }
        }
Ejemplo n.º 4
0
        private void OpenStudentWork()
        {
            int course = int.Parse(comboBox1.Text);

            if (dataGridView1.SelectedRows.Count > 0)
            {
                StudentWork studentWork = dataGridView1.SelectedRows[0].DataBoundItem as StudentWork;

                NewStudentWorkForm form = new NewStudentWorkForm(student, course, studentWork);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    UpdateGrid();
                }
            }
        }
Ejemplo n.º 5
0
 public ActionResult Create()
 {
     try
     {
         StudentWork model = new StudentWork();
         model.InitNewObject();
         model.Student = Authentication.User;
         PrepareViewBag();
         return(View("Edit", model));
     }
     catch (Exception ex)
     {
         ViewBag.Message = ex.Message;
         return(Index(null));
     }
 }
Ejemplo n.º 6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (studentWork == null)
            {
                studentWork = new StudentWork();
            }

            studentWork.Name     = txtBxTheme.Text;
            studentWork.Subject  = comboBox1.SelectedItem as Subject;
            studentWork.Teacher  = comboBox2.SelectedItem as Teacher;
            studentWork.Mark     = (int)numericUpDown1.Value;
            studentWork.Student  = student;
            studentWork.Course   = course;
            studentWork.TypeWork = (TypeWork)comboBox3.SelectedIndex;

            DBController.Instance.Update(studentWork);

            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获得学生的上传作业的情况
        /// </summary>
        /// <returns></returns>
        public ActionResult GetStudentWork(string moduleTag)
        {
            Guid studentId = new Guid(Request.QueryString["SId"]);
            int  courseId  = Convert.ToInt32(Request.QueryString["CId"]);

            //前台界面上需要显示如下:模块名称,作业下载,学生作业内容,题目及学生答案

            ViewBag.courseid = courseId;
            //返回学生的最后得分
            int mTag = 1;//如果是第一次其他页面请求过来,mTag的值为1,则默认显示该课程的第一个模块

            if (!string.IsNullOrEmpty(moduleTag))
            {
                mTag = Convert.ToInt32(moduleTag);
            }
            //返回模块详情
            Module module = db.Module.Where(m => m.CourseId == courseId && m.ModuleTag == mTag).FirstOrDefault();

            ViewBag.module = module;
            //返回学生作业
            StudentWork sWork = db.StudentWork.Where(sw => sw.CourseId == courseId && sw.StudentId == studentId && sw.ModuleTag == mTag).FirstOrDefault();

            ViewBag.sWork = sWork;
            //返回学生问题及答案和评分
            if (module != null)
            {
                List <Erecord> listErecord = mHelp.SqlQuery <Erecord>("select pq.QTitle,psa.Answer,psa.AnswerScore from PaperStudentAnswers as psa join PaperQuestions as pq on psa.QuestionId=pq.Id where psa.MouduleTag=@mTag and StudentId=@studentId", new SqlParameter[] { new SqlParameter("@mTag", mTag), new SqlParameter("@studentId", studentId) }).ToList();
                ViewBag.listErecord = listErecord;
            }
            //todo---查询评价量表的题目
            List <EvaluateTable> EvTableList = db.EvaluateTable.Where(c => c.TableId == 1).ToList();

            ViewBag.EvTableList = EvTableList;

            List <StudentWork> listStudentWork = db.StudentWork.Where(sw => sw.CourseId == courseId && sw.StudentId == studentId).ToList();

            ViewBag.listStudentWork = listStudentWork;


            return(View());
        }
Ejemplo n.º 8
0
        public NewStudentWorkForm(Student student, int course, StudentWork studentWork = null)
        {
            InitializeComponent();

            comboBox1.DataSource = DBController.Instance.Subjects;
            comboBox2.DataSource = DBController.Instance.Teachers;

            this.student = student;
            this.course  = course;

            if (studentWork != null)
            {
                txtBxTheme.Text         = studentWork.Name;
                comboBox1.SelectedItem  = studentWork.Subject;
                numericUpDown1.Value    = studentWork.Mark;
                comboBox2.SelectedItem  = studentWork.Teacher;
                comboBox3.SelectedIndex = (int)studentWork.TypeWork;

                this.studentWork = studentWork;
            }
        }
Ejemplo n.º 9
0
 private void FillModelForeignKeys(StudentWork model)
 {
     using (DataContext ctx = new DataContext())
     {
         if (model.Predmet == null)
         {
             model.Predmet = ctx.Predmet.FirstOrDefault(t => t.Id == model.PredmetId);
         }
         if (model.WorkType == null)
         {
             model.WorkType = ctx.WorkType.FirstOrDefault(t => t.Id == model.WorkTypeId);
         }
         if (model.Student == null)
         {
             model.Student = ctx.User.Include(t => t.StudentGroup).FirstOrDefault(t => t.UserId == model.StudentId);
         }
         if (model.Teacher == null)
         {
             model.Teacher = ctx.User.FirstOrDefault(t => t.UserId == model.TeacherId);
         }
     }
 }
Ejemplo n.º 10
0
 public static int Question2(int number1, int number2)
 {
     return(StudentWork.MinusTwoNumber(number1, number2));
 }
Ejemplo n.º 11
0
 public static int Question1(int number1, int number2)
 {
     return(StudentWork.AddTwoNumber(number1, number2));
 }
Ejemplo n.º 12
0
 public ActionResult SaveAsRejected(StudentWork model)
 {
     return(Save(model, StudentWorkStatus.REJECTED, null));
 }
Ejemplo n.º 13
0
 public ActionResult SaveAsApprooved(StudentWork model)
 {
     return(Save(model, StudentWorkStatus.APPROOVED, null));
 }
Ejemplo n.º 14
0
 public ActionResult SaveAsChecking(StudentWork model, HttpPostedFileBase upload)
 {
     return(Save(model, StudentWorkStatus.CHECKING, upload));
 }
Ejemplo n.º 15
0
 public ActionResult SaveAsDraft(StudentWork model, HttpPostedFileBase upload)
 {
     return(Save(model, StudentWorkStatus.DRAFT, upload));
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 显示各个模块的内容,传递的参数是模块的id和标志显示不同的页面,
        /// 5个页面
        /// </summary>
        /// <param name="ModuleId"></param>
        /// <param name="ModuleTag"></param>
        /// <returns></returns>
        public ActionResult ModuleView()
        {
            //if()
            string CId      = Request.QueryString["CId"]; ///属于哪一门课程
            int    CourseId = Convert.ToInt32(CId);

            if (db.Stu_Course.Where(c => c.StudentId == new Guid(studentId) && c.CourseId == CourseId).FirstOrDefault() != null)
            {
                if (CId != null && CId != "")
                {
                    ViewBag.CId = CId; //保存
                }

                string id = Request.QueryString["id"]; ///查看的是模块的id
                if (id != null)
                {
                    int    ModuleId = Convert.ToInt32(id);//获得模块的id
                    Module module   = db.Module.Where(m => m.Id == ModuleId).FirstOrDefault();
                    ViewBag.Pagemodule = module;
                }
                string moduleTag = Request.QueryString["flag"];
                int    tag       = Convert.ToInt32(moduleTag);

                StudentWork work = db.StudentWork.Where(w => w.CourseId == CourseId && w.ModuleTag == tag).FirstOrDefault();
                //查询选择题目---------todo   单选多选要分开,因为checkbox和radio不同
                List <PaperQuestion> selectQuestions = db.PaperQuestion.Where(t => t.CourseId == CourseId && t.ModuleTag == tag && t.QuestionType != 2).ToList();
                //查询填空题目
                List <PaperQuestion> blankQuestions = db.PaperQuestion.Where(t => t.CourseId == CourseId && t.ModuleTag == tag && t.QuestionType == 2).ToList();
                if (selectQuestions.Count() != 0)
                {
                    ViewBag.selectQuestions = selectQuestions;
                }
                if (blankQuestions.Count() != 0)
                {
                    ViewBag.blankQuestions = blankQuestions;
                }
                if (work != null)
                {
                    ViewBag.PageWork = work;
                }
                if (moduleTag.Equals("1"))
                {
                    return(View("ModuleView1"));
                }
                else
                if (moduleTag.Equals("2"))
                {
                    return(View("ModuleView2"));
                }
                else
                if (moduleTag.Equals("3"))
                {
                    return(View("ModuleView3"));
                }
                else
                if (moduleTag.Equals("4"))
                {
                    return(View("ModuleView4"));
                }
                else
                {
                    return(View("ModuleView5"));
                }
            }
            else
            {
                return(RedirectToAction("StudentEnterCourse", new { id = Convert.ToInt32(CId) }));
            }
        }
Ejemplo n.º 17
0
        public ActionResult FinishModule(FormCollection form)
        {
            int    moduleTag = Convert.ToInt32(Request.QueryString["moduleTag"]);
            string CId       = form["CourseId"].Trim();

            HttpPostedFileBase hpfb     = Request.Files["studentPath"];
            string             filePath = "";

            if (hpfb.ContentLength > 0)
            {
                Common.UpLoad upLoad = new Common.UpLoad();
                filePath = upLoad.StudentSaveFile(hpfb);
            }

            int CourseId = 0;

            if (CId != null && CId != "")
            {
                CourseId = Convert.ToInt32(CId);
            }

            //完成课后习题答案的提交和成绩

            //先查询出当前模块的所有题目ID
            List <PaperQuestion> pQuestionList = db.PaperQuestion.Where(c => c.CourseId == CourseId && c.ModuleTag == moduleTag).ToList();
            //再根据所有questionId查找所有提交过来的form,如果是单选就直接查值,如果是多选就split那个form值
            PaperStudentAnswer pAnswer = null;

            foreach (PaperQuestion p in pQuestionList)
            {
                pAnswer = new PaperStudentAnswer()
                {
                    StudentId  = new Guid(studentId),
                    CourseId   = CourseId,
                    MouduleTag = moduleTag,
                };
                string Answer;           //传来的form值
                if (p.QuestionType == 0) //单选
                {
                    Answer = Request.Form[p.Id + "&Answer"].ToString();
                    if (p.Answer == Answer)
                    {
                        pAnswer.AnswerScore = 4;
                    }
                    else
                    {
                        pAnswer.AnswerScore = 0;
                    }
                }
                else if (p.QuestionType == 1)//多选
                {
                    Answer = Request.Form[p.Id + "&Answer"].ToString();
                    //--todo split需要完成
                    if (p.Answer == Answer)
                    {
                        pAnswer.AnswerScore = 4;
                    }
                    else
                    {
                        pAnswer.AnswerScore = 0;
                    }
                }
                else //填空
                {
                    Answer = Request.Form[p.Id + "&Answer"].ToString();
                    if (p.Answer == Answer)
                    {
                        pAnswer.AnswerScore = 4;
                    }
                    else
                    {
                        pAnswer.AnswerScore = 0;
                    }
                }
                pAnswer.MouduleId  = p.MouduleId;
                pAnswer.QuestionId = p.Id;
                pAnswer.Answer     = Answer;
                db.PaperStudentAnswer.Add(pAnswer);
            }



            //List<PaperStudentAnswer> pAnswerList = db.PaperStudentAnswer.Where(c=>c.StudentId==new Guid(studentId)&&c.CourseId==CourseId&&c.==).ToList();

            StudentWork work  = null;
            StudentInfo sInfo = db.StudentInfo.Where(s => s.Id == new Guid(studentId)).FirstOrDefault();

            work = new StudentWork()
            {
                CourseId       = Convert.ToInt32(form["CourseId"]),
                ModuleTag      = Convert.ToInt32(Request.QueryString["moduleTag"]),
                WorkContent    = form["WorkContent"],
                WorkTime       = DateTime.Now.ToString(),
                StudentId      = new Guid(studentId),
                StudentAccount = sInfo.Account,
                WorkFilePath   = filePath
            };
            db.StudentWork.Add(work);
            db.SaveChanges();

            return(RedirectToAction("StudentEnterCourse", new { id = CourseId }));
        }
Ejemplo n.º 18
0
        public ActionResult FinishModule(FormCollection form)
        {
            int moduleTag = Convert.ToInt32(Request.QueryString["moduleTag"]);
            string CId = form["CourseId"].Trim();

            HttpPostedFileBase hpfb = Request.Files["studentPath"];
            string filePath = "";
            if (hpfb.ContentLength > 0)
            {
                Common.UpLoad upLoad = new Common.UpLoad();
                filePath = upLoad.StudentSaveFile(hpfb);
            }

            int CourseId = 0;
            if (CId != null && CId != "")
            {
                CourseId = Convert.ToInt32(CId);
            }

            //完成课后习题答案的提交和成绩

            //先查询出当前模块的所有题目ID
            List<PaperQuestion> pQuestionList = db.PaperQuestion.Where(c => c.CourseId == CourseId && c.ModuleTag == moduleTag).ToList();
            //再根据所有questionId查找所有提交过来的form,如果是单选就直接查值,如果是多选就split那个form值
            PaperStudentAnswer pAnswer = null;

            foreach (PaperQuestion p in pQuestionList)
            {
                pAnswer = new PaperStudentAnswer()
                {
                    StudentId = new Guid(studentId),
                    CourseId = CourseId,
                    MouduleTag = moduleTag,
                };
                string Answer;//传来的form值
                if (p.QuestionType == 0)//单选
                {
                    Answer = Request.Form[p.Id + "&Answer"].ToString();
                    if (p.Answer == Answer)
                    {
                        pAnswer.AnswerScore = 4;
                    }
                    else
                        pAnswer.AnswerScore = 0;
                }
                else if (p.QuestionType == 1)//多选
                {
                    Answer = Request.Form[p.Id + "&Answer"].ToString();
                    //--todo split需要完成
                    if (p.Answer == Answer)
                    {
                        pAnswer.AnswerScore = 4;
                    }
                    else
                        pAnswer.AnswerScore = 0;
                }
                else //填空
                {
                    Answer = Request.Form[p.Id+"&Answer"].ToString();
                    if (p.Answer == Answer)
                    {
                        pAnswer.AnswerScore = 4;
                    }
                    else
                        pAnswer.AnswerScore = 0;
                }
                pAnswer.MouduleId = p.MouduleId;
                pAnswer.QuestionId = p.Id;
                pAnswer.Answer = Answer;
                db.PaperStudentAnswer.Add(pAnswer);
            }

            //List<PaperStudentAnswer> pAnswerList = db.PaperStudentAnswer.Where(c=>c.StudentId==new Guid(studentId)&&c.CourseId==CourseId&&c.==).ToList();

            StudentWork work = null;
            StudentInfo sInfo = db.StudentInfo.Where(s => s.Id == new Guid(studentId)).FirstOrDefault();
            work = new StudentWork()
            {
                CourseId = Convert.ToInt32(form["CourseId"]),
                ModuleTag = Convert.ToInt32(Request.QueryString["moduleTag"]),
                WorkContent = form["WorkContent"],
                WorkTime = DateTime.Now.ToString(),
                StudentId = new Guid(studentId),
                StudentAccount = sInfo.Account,
                WorkFilePath = filePath

            };
            db.StudentWork.Add(work);
            db.SaveChanges();

            return RedirectToAction("StudentEnterCourse", new { id = CourseId });
        }