Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Teacher")
            {
                Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>");
                return;
            }

            //获取answer信息
            string student = Request.QueryString["student"];
            int problem = int.Parse(Request.QueryString["problem"]);

            //显示学生答案
            oneAnswer = AnswerMan.GetOneAnswer(student,problem);
            AnswerLabel.Text = oneAnswer.content;
            scoreLabel.Text = ProMan.GetProblemScore(problem).ToString();

            Session["oneAnswer"] = oneAnswer;
        }
Ejemplo n.º 2
0
        protected void export_Click(object sender, EventArgs e)
        {
            //Response.Write("<Script Language=JavaScript>alert('请先提交然后再点导出!');</Script>");
            Random rd = new Random();
            string fileName = DateTime.Now.ToString("yyyyMMddhhmm") + rd.Next() + ".doc";
            //存储路径
            string path = Server.MapPath(fileName);
            //创建字符输出流
            StreamWriter sw = new StreamWriter(path, true, System.Text.UnicodeEncoding.UTF8);

            string str = string.Empty;
            int len = Request.Form.GetValues("TA").Length;
            string[] content = Request.Form.GetValues("TA");
            //导出为word文档格式
            for (int i = 0; i < ProblemList.Count; i++)
            {
                str += ProblemList[i].title + "\r\n";
                Answer answer = new Answer();
                //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "myJS3", "content=document.getElementById('TA" + i + "').value", true);
                Response.Write("<Script Language=JavaScript>content=document.getElementById('TA" + i + "').value;</Script>");
                answer.content = content[i];
                AnswerList.Add(answer);
                str += AnswerList[i].content + "\r\n";
            }

            string regexstr = @"<[^>]*>";    //去除所有HTML标签
            str = Regex.Replace(str, regexstr, string.Empty, RegexOptions.IgnoreCase);
            //写入
            sw.Write(str);
            sw.Close();
            Response.Clear();
            Response.Buffer = true;
            this.EnableViewState = false;
            Response.Charset = "utf-8";
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(path);
            Response.Flush();
            Response.Close();
            Response.End();
        }
Ejemplo n.º 3
0
        protected void CheckSaveButton_Click(object sender, EventArgs e)
        {
            if (scoreTextBox.Text == "")
            {
                scoreLabel2.Visible = false;
                scoreLabel1.Visible = true;
            }
            else
            {
                int problem = int.Parse(Request.QueryString["problem"]);
                float actualvalue = float.Parse(scoreTextBox.Text);
                float fullscore = ProMan.GetProblemScore(problem);
                if (actualvalue < 0 || actualvalue > fullscore)
                {
                    scoreLabel1.Visible = false;
                    scoreLabel2.Visible = true;
                }
                else
                {
                    oneAnswer = (Answer)Session["oneAnswer"];
                    oneAnswer.score = float.Parse(scoreTextBox.Text);
                    oneAnswer.comment = commentTextBox.Text;
                    oneAnswer.state = "1";

                    //批改作业
                    answers.Add(oneAnswer);
                    AnswerMan.UpdateAnswer(answers);

                    //获取该问题未批改的所有学生答案
                    List<Answer> nocheckanswers = AnswerMan.GetNoCheckAnswersofApro(int.Parse(Request.QueryString["problem"]));

                    if (nocheckanswers.Count != 0)//若有未批改学生作业,继续批改该题其他学生答案
                        Response.Redirect("Check.aspx?problem=" + nocheckanswers[0].problem + "&student=" + nocheckanswers[0].student);
                    else//若学生作业都批改完成,则跳回该问题查看所有学生成绩
                        Response.Redirect("OneProblem.aspx?problemid=" + Request.QueryString["problem"]);
                }
            }
        }
Ejemplo n.º 4
0
        protected void submit_Click(object sender, EventArgs e)
        {
            string[] content = Request.Form.GetValues("TA");
            for (int i = 0; i < ProblemList.Count; i++)
            {
                Answer answer = new Answer();
                answer.content = content[i];
                answer.student = stu.username;
                answer.problem = ProblemList[i].id;
                answer.score = (float)0.0;
                answer.comment = "no comment";
                answer.major = stu.major;
                answer.state = "2";
                if (AnswerList == null)
                {
                    AnswerList = new List<Answer>();
                }
                AnswerList.Add(answer);
            }

            if (submitFlag)
            {
                AnswerMan.AddAnswer(AnswerList);

                if (accessory == null)
                {
                    accessory = new Accessory();
                }

                try
                {
                    //获取上传文件的路径
                    string filepath = FileUpload2.PostedFile.FileName;
                    //获取后缀名
                    int filepos = filepath.LastIndexOf(".");
                    //截取后缀名
                    String strfilename = filepath.Substring(filepos);
                    //获取时间
                    string time1 = System.DateTime.Now.ToString("yyyyMMddHHmmssffff");
                    //保存到服务器的路径,这是我们网站固定网址
                    string serverpath = Server.MapPath("Accessory") + "\\" + stu.username + "_" + id + "_" + time1 + strfilename;
                    //确定上传文件
                    FileUpload2.PostedFile.SaveAs(serverpath);

                    string DBFilePath = "http://tasksystem.apphb.com/Accessory/" + stu.username + "_" + id + "_" + time1 + strfilename;
                    accessory.adress = DBFilePath;
                    accessory.assignment = System.Int32.Parse(id);
                    accessory.student = stu.username;
                    AccessoryMan.Create(accessory);
                }
                catch (System.Exception error)
                {
                    Response.Write(error.Message.ToString());
                }
            }
            else
            {
                AnswerMan.UpdateAnswer(AnswerList);
                //accessory = AccessoryMan.GetAccessory(stu.username, System.Int32.Parse(id));
            }

            //Response.Redirect("StudentMainForm.aspx");
            Response.Write("<script language=javascript>alert('提交成功!');location='StudentMainForm.aspx'</script>");
        }
Ejemplo n.º 5
0
 partial void DeleteAnswer(Answer instance);
Ejemplo n.º 6
0
 partial void UpdateAnswer(Answer instance);
Ejemplo n.º 7
0
 partial void InsertAnswer(Answer instance);
Ejemplo n.º 8
0
		private void detach_Answer(Answer entity)
		{
			this.SendPropertyChanging();
			entity.Student1 = null;
		}
Ejemplo n.º 9
0
		private void attach_Answer(Answer entity)
		{
			this.SendPropertyChanging();
			entity.Student1 = this;
		}