Song.Site/Ajax/GetResult.ashx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WeiSha.Common;
using Song.ServiceInterfaces;
using System.Xml;

namespace Song.Site.Ajax
{
    /// <summary>
    /// 获取考试的答题信息
    /// </summary>
    public class GetResult : IHttpHandler
    {

        //试卷id,考试id,学生id
        private int tpid = WeiSha.Common.Request.QueryString["tpid"].Int32 ?? 0;
        private int examid = WeiSha.Common.Request.QueryString["examid"].Int32 ?? 0;
        private int stid = WeiSha.Common.Request.QueryString["stid"].Int32 ?? 0;
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //获取答题信息
            Song.Entities.ExamResults exr = Business.Do<IExamination>().ResultSingle(examid, tpid, stid);
            if (exr == null) context.Response.Write("0");
            if (exr != null) context.Response.Write(getResult(exr.Exr_Results));
            context.Response.End();
        }
        /// <summary>
        /// 输出json
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        private string getResult(string result)
        {
            XmlDocument resXml = new XmlDocument();
            resXml.LoadXml(result);
            string json = "[";
            XmlNodeList ques = resXml.GetElementsByTagName("ques");
            for (int i = 0; i < ques.Count; i++)
            {
                XmlNode node = ques[i];
                int type = Convert.ToInt32(node.Attributes["type"].Value);
                for (int n = 0; n < node.ChildNodes.Count; n++)
                {
                    XmlNode q = node.ChildNodes[n];
                    string id = q.Attributes["id"].Value;
                    string cls = q.Attributes["class"].Value;
                    string ans = null;
                    //如果是单选、多选、判断
                    if (type == 1 || type == 2 || type == 3)
                        ans = q.Attributes["ans"].Value;                        
                    if (type == 4 || type == 5) ans = q.InnerText; 
                    json += "{'type':" + type + ",'id':" + id + ",'cls':'" + cls + "','ans':'" + ans + "'},";
                }
            }
            if (json.IndexOf(',') > -1) json = json.Substring(0,json.Length - 1);
            json += "]";
            return json;
后面还有 11 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。