⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teststudentwenda.aspx.cs

📁 在线考试系统 主要真对考试 开发的个人项目
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class testStudentWenDa : System.Web.UI.Page
{
    string stuId, stuName, courseName, courseId;
    int score = 0;
    int cont = 0;
    string testId1 = "", testId2 = "", testId3 = "", testId4 = "";
    string tb1 = "", tb2 = "", tb3 = "", tb4 = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["stuId"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            if (!Page.IsCallback)
            {
                courseId = Convert.ToString(Session["courseId"]);
                courseName = Convert.ToString(Session["courseName"]);
                stuId = Convert.ToString(Session["stuId"]);
                stuName = (new projClass()).getUserName(stuId);
                this.Label1.Text = stuName;
                this.Label2.Text = courseName;
                InitData();
            }                       
        }
    }
    public void InitData() {
        DataTable dt=new projClass().getTestWenDa(stuId,courseName); 
        DataRow dr1=dt.Rows[0];
        DataRow dr2=dt.Rows[1];
        DataRow dr3=dt.Rows[2];
        DataRow dr4=dt.Rows[3];
        this.Label3.Text = dr1["testContent"].ToString();
        this.Label9.Text = dr2["testContent"].ToString();
        this.Label13.Text = dr3["testContent"].ToString();
        this.Label17.Text = dr4["testContent"].ToString();        
        this.Label7.Text = dr1["rightAns"].ToString();
        this.Label11.Text = dr2["rightAns"].ToString();
        this.Label15.Text = dr3["rightAns"].ToString();
        this.Label19.Text = dr4["rightAns"].ToString();
        this.Label20.Text = dr1["studentScore"].ToString();
        this.Label21.Text = dr2["studentScore"].ToString();
        this.Label22.Text = dr3["studentScore"].ToString();
        this.Label23.Text = dr4["studentScore"].ToString();
        string str1 = dr1["keyword"].ToString();
        string str2 = dr2["keyword"].ToString();
        string str3 = dr3["keyword"].ToString();
        string str4 = dr4["keyword"].ToString();
        this.Label5.Text = dr1["testScore"].ToString();
        this.Label6.Text = dr2["testScore"].ToString();
        this.Label8.Text = dr3["testScore"].ToString();
        this.Label12.Text = dr4["testScore"].ToString();
        string st1=Key(dr1["studentAns"].ToString(),str1);
        string st2=Key(dr2["studentAns"].ToString(),str2);
        string st3=Key(dr3["studentAns"].ToString(),str3);
        string st4 = Key(dr4["studentAns"].ToString(),str4);
        this.Label4.Text = WrongKey(st1, str1);
        this.Label10.Text = WrongKey(st2,str2);
        this.Label14.Text = WrongKey(st3,str3);
        this.Label18.Text = WrongKey(st4,str4);
        testId1 = dr1["id"].ToString();
        testId2 = dr2["id"].ToString();
        testId3 = dr3["id"].ToString();
        testId4 = dr4["id"].ToString();
        score = Int32.Parse(dr1["studentScore"].ToString()) + Int32.Parse(dr2["studentScore"].ToString()) + Int32.Parse(dr3["studentScore"].ToString()) + Int32.Parse(dr4["studentScore"].ToString());        
    }

    static String Key(string str, string strkey)
    {

        string[] str1 = strkey.Split(',');
        for (int i = 0; i < str1.Length; i++)
        {
            if (str.Contains(str1[i]))
            {
                str = str.Replace(str1[i], "<font color='red'>" + str1[i] + "</font>");
            }
        }
        return str;
    }
    static String WrongKey(string str, string strkey)
    {
        string fou = "not,不是,不,错,错误,不好,否,坏,不会,不对";
        string[] str1 = fou.Split(',');

        for (int i = 0; i < str1.Length; i++)
        {
            if (str.Contains(str1[i]))
            {
                str = str.Replace(str1[i], "<font color='blue'>" + str1[i] + "</font>");
            }
        }
        return str;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox1.Text == "")
        {
            this.TextBox1.Text = this.Label20.Text;            
        }
        if (this.TextBox2.Text == "")
        {
            this.TextBox2.Text = this.Label21.Text;   
        }
        if (this.TextBox3.Text == "")
        {
            this.TextBox3.Text = this.Label22.Text;   
        }
        if (this.TextBox4.Text == "")
        {
            this.TextBox4.Text = this.Label23.Text;   
        }
        cont=Int32.Parse(this.TextBox1.Text)+Int32.Parse(this.TextBox2.Text)+Int32.Parse(this.TextBox3.Text)+Int32.Parse(this.TextBox4.Text);
        int resultScore = (cont - score);
        if (cont < 0)
        {
           this.Label16.Text="你输入的成绩不能小于0分";
        }
        else if (cont > 40)
        {
            this.Label16.Text="输入的成绩不能大于40分";
        }
        else
        {

            int i = (new projClass()).updateScoreByTeacher(Convert.ToString(Session["stuId"]), Convert.ToString(Session["courseId"]), resultScore);
            if (this.TextBox1.Text != "")
            {
                int ii = (new projClass()).updateTestWenDa(testId1, this.TextBox1.Text);
            }
            if (this.TextBox2.Text != ""){
            int iii = (new projClass()).updateTestWenDa(testId2, this.TextBox2.Text);
            }
            if (this.TextBox3.Text != "")
            {
                int iiii = (new projClass()).updateTestWenDa(testId3, this.TextBox3.Text);
            }
            if (this.TextBox4.Text != "")
            {
                int iiiii = (new projClass()).updateTestWenDa(testId4, this.TextBox4.Text);
            }
           
            if (i > 0 )
            {
               Response.Redirect("testResultByTeacher.aspx");
            }
            this.Label16.Text = "保存失败";
        }
    }   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -