Exemplo n.º 1
0
        // Обработка нажатия кнопки перехода к следующему вопросу
        private void qNext_Click(object sender, EventArgs e)
        {
            // Проверяем вопросы
            CheckAnswers();
            List <Option> choosen = GetChoosenOptions();
            // Создаём объект ответа на вопрос
            Answer answer = new Answer()
            {
                question = currentQuestion,
                choosen  = choosen,
            };

            // И добавляем в список ответов на вопрос
            QuestionHelper.answers.Add(answer);
            // Создаём запрос, который говорит серверу, что вот
            // Мы ответили на вопрос, сохрани ответ
            Request request = new Request()
            {
                request = "answer",
                client  = QuestionHelper.client,
                body    = JsonConvert.SerializeObject(answer, Formatting.Indented),
            };

            // и отправляем запрос
            new Thread(() => {
                Thread.CurrentThread.IsBackground = true;
                new SocketHelper().DoRequest(request, null);
            }).Start();
            // И получаем новый вопрос
            CurrentQuestion = QuestionHelper.GetNextQuestion();
        }
Exemplo n.º 2
0
    public string BindTask()
    {
        DataTable dt   = ado.ExecuteSqlDataset("select MorePropertys,GoodsId,GoodsName,GoodsSmallPic,GoodsSampleDesc,SalePrice,TotalSaleCount,DataFrom from T_Goods_Info where GoodsToTypeId = '" + this.hid_goodsId.Value + "' and JobType='SubGoods' and IsSale=1 order by Orderby").Tables[0];
        string    html = "";

        foreach (DataRow row in dt.Rows)
        {
            string[] questionInfoArr = QuestionHelper.ComputerQuestionRecord("", row["GoodsId"].ToString(), this.hidMemberId.Value).Split('|');

            if (row["MorePropertys"].ToString() == "外部课程" && row["DataFrom"].ToString() != "")
            {
                html += "<li onclick=\"location.href='YqxkjCourseDetail.aspx?id=" + row["DataFrom"].ToString() + "'\">";
                html += "<b>" + row["GoodsName"].ToString() + "</b>";
                html += "<span><i class=\"icon iconfont icon-jiantou\"></i></span>";
                html += "</li>";
            }
            else
            {
                string freeTest = "";
                string href     = "";
                if (decimal.Parse(row["SalePrice"].ToString()) < 0)
                {
                    freeTest = "icon-jiantou";
                    href     = "onclick=\"location.href='YqxkjCourseFreeTest.aspx?id=" + row["GoodsId"].ToString() + "'\"";
                }

                html += "<li " + href + "\">";
                html += "<b>" + row["GoodsName"].ToString() + "";
                html += "<a>已做<i>" + questionInfoArr[1] + "</i>题,共<i>" + questionInfoArr[0] + "</i>题,正确率<i>" + questionInfoArr[2] + "%</i></a></b>";
                html += "<span><i class=\"icon iconfont " + freeTest + "\"></i></span>";
                html += "</li>";
            }
        }
        return(html);
    }
Exemplo n.º 3
0
        private void btn_query_Click(object sender, EventArgs e)
        {
            var qName = this.tbx_Name.Text;
            var qDate = this.q_date.text;
            var qID   = this.tbx_id.Text;

            string dataName = System.IO.Path.Combine(OSHelper.DataDefaultDirectory, "data.xml");

            qns = QuestionHelper.DeSerializeObject <List <QuestionWorkflow> >(dataName);

            if (null == qns)
            {
                return;
            }

            List <QuestionWorkflow> result = qns.FindAll(o => {
                return(o.user.Name.Equals(string.IsNullOrEmpty(qName) ? o.user.Name : qName) &&
                       o.date.ToShortDateString().Equals((null == qDate || string.IsNullOrEmpty(qDate)) ? o.date.ToShortDateString() : qDate) &&
                       o.user.ID.Equals(string.IsNullOrEmpty(qID) ? o.user.ID : qID));
            });

            this.lv_result.Items.Clear();

            foreach (QuestionWorkflow qwf in result)
            {
                ListViewItem lvItem = new ListViewItem(new string[] { qwf.user.Name, qwf.user.Age.ToString(), qwf.user.Gender, qwf.user.ID, qwf.result, qwf.date.ToShortDateString(), "打印" });
                this.lv_result.Items.Add(lvItem);
            }
        }
Exemplo n.º 4
0
 public ActionResult List(long id, int?p)
 {
     InitIntPage(ref p);
     ViewData["source"] = QuestionHelper.QuestionList(DB, id, p.Value);
     ViewData["group"]  = GroupHelper.GetGroup(DB, id);
     DB.Dispose();
     return(View());
 }
Exemplo n.º 5
0
        public Tuple <bool, string> SaveWorkflow(string _result, string _result_code)
        {
            Tuple <bool, string> tupSaveResult = null;

            if (null == user)
            {
                tupSaveResult = new Tuple <bool, string>(false, string.Format("{0} (用户信息未填写,保存无效)", _result));

                return(tupSaveResult);
            }

            try
            {
                //set ace user
                var ds  = new DirectorySecurity();
                var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
                var ace = new FileSystemAccessRule(sid,
                                                   FileSystemRights.FullControl,
                                                   AccessControlType.Allow);
                ds.AddAccessRule(ace);

                var dataDir = System.IO.Path.Combine(OSHelper.DataDefaultDirectory, "");

                if (!Directory.Exists(dataDir))
                {
                    Directory.CreateDirectory(dataDir, ds);
                }


                result = _result;

                resultCode = _result_code;

                List <QuestionWorkflow> qns = QuestionHelper.DeSerializeObject <List <QuestionWorkflow> >(dataName);

                date = System.DateTime.Now;

                if (null != qns)
                {
                    qns.Add(this);
                }
                else
                {
                    qns = new List <QuestionWorkflow>();
                    qns.Add(this);
                }

                QuestionHelper.SerializeObject <List <QuestionWorkflow> >(qns, dataName);

                tupSaveResult = new Tuple <bool, string>(true, result);
            }
            catch (Exception ex)
            {
                tupSaveResult = new Tuple <bool, string>(false, string.Format("保存异常 {0}", ex.Message));
            }
            return(tupSaveResult);
        }
Exemplo n.º 6
0
 // при загрузке формы
 private void TestingForm_Load(object sender, EventArgs e)
 {
     // Получаем вопрос
     CurrentQuestion          = QuestionHelper.GetNextQuestion();
     QuestionHelper.isTesting = true;
     // И заполняем имя и фамилию студента в верхнем блоке
     clientNameLabel.Text    = QuestionHelper.client.name;
     clientSurnameLabel.Text = QuestionHelper.client.surname;
     totalQuetionsLabel.Text = $"{ QuestionHelper.TotalQuestions }";
 }
Exemplo n.º 7
0
        public ActionResult Index(long id)
        {
            ViewData["comefrom"] = Request.UrlReferrer;
            var d = QuestionHelper.Question(DB, id);

            if (d == null)
            {
                throw new OJException("不能为空");
            }
            DB.Dispose();
            return(View(d));
        }
Exemplo n.º 8
0
    public void BindAllQuestions()
    {
        string    ids = "";
        DataTable dt  = ado.ExecuteSqlDataset("select sysnumber from T_Test_Queston where courseId = '" + this.hidCourseId.Value + "' and shFlag=1 and isnull(isAL,0)=0 order by questionTypeOrderBy,orderBy").Tables[0];

        foreach (DataRow row in dt.Rows)
        {
            ids += row["sysnumber"].ToString() + ",";
        }
        if (ids != "")
        {
            ids = ids.TrimEnd(',');
        }
        this.hidAllQuestions.Value = ids;

        if (this.source == "mnlx")
        {
            //模拟练习
            dt = ado.ExecuteSqlDataset("select Questions from T_Test_day where courseType = '" + this.hidCourseId.Value + "' and shFlag=1 order by Addtime").Tables[0];
            if (dt.Rows.Count > 0)
            {
                ids = "";
                string    sysnumbers = dt.Rows[0]["Questions"].ToString().TrimEnd(',').Replace(",", "','");
                DataTable dt2        = ado.ExecuteSqlDataset("select sysnumber from T_Test_Queston where sysnumber in('" + sysnumbers + "') and shFlag=1 and isnull(isAL,0)=0 order by questionTypeOrderBy,orderBy").Tables[0];
                foreach (DataRow row in dt2.Rows)
                {
                    //first
                    if (this.hidCurId.Value == "")
                    {
                        this.hidCurId.Value = row["sysnumber"].ToString();
                    }

                    ids += row["sysnumber"].ToString() + ",";
                }
                if (ids != "")
                {
                    ids = ids.TrimEnd(',');
                }
                this.hidAllQuestions.Value = ids;
            }
        }

        //first
        if (this.hidCurId.Value == "")
        {
            this.hidCurId.Value = this.hidAllQuestions.Value.Split(',')[0];
        }

        //先创建我的题库记录
        QuestionHelper.CreateMyQuestions(this.hidMemberId.Value, this.hidCourseId.Value, this.hidAllQuestions.Value);
    }
        public ResultMessage SetExamQuestion(ExamQuestion request)
        {
            ExamQuestionHelper eqh    = new ExamQuestionHelper();
            QuestionHelper     qh     = new QuestionHelper();
            QuestionItemHelper qih    = new QuestionItemHelper();
            ResultMessage      result = new ResultMessage();

            result = eqh.Create(request.ExamPaper, request.Byname, request.TotalFullScore, request.LimitTime, request.OwnerType);
            if (!result.State)
            {
                return(result);
            }
            foreach (var q in request.Questions)
            {
                var q_guid = Guid.NewGuid().ToString();
                result = qh.Create(q_guid, request.ExamPaper, q.Code, q.QuestionType, q.QuestionContent, q.FullScore, q.Comment);
                if (!result.State)
                {
                    return(result);
                }

                if (q.Items == null || q.Items.Count == 0)
                {
                    continue;
                }
                foreach (var qi in q.Items)
                {
                    if (string.IsNullOrWhiteSpace(qi.ItemOrder))
                    {
                        continue;
                    }

                    foreach (var qia in q.Answers)
                    {
                        if (qi.ItemOrder == qia.ItemOrder)
                        {
                            qi.Value       = qia.Value;
                            qi.ExpandValue = qia.ExpandValue;
                            break;
                        }
                    }
                    result = qih.Create(Guid.NewGuid().ToString(), q_guid, qi.ItemOrder, qi.ItemAnswer, qi.Value, qi.ExpandValue, qi.IsWrite);
                    if (!result.State)
                    {
                        return(result);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 10
0
        public bool SaveReportSetting()
        {
            try
            {
                QuestionHelper.SerializeObject <Report>(report, dataReportName);
            }
            catch (Exception ex)
            {
                //TOOD

                return(false);
            }

            return(true);
        }
Exemplo n.º 11
0
        private QuestionWorkflow()
        {
            questionnaire = new Questionnaire();

            questionnaires = QuestionHelper.ReadQuestionnairesFromXML(questionnaireFile);

            assesses = QuestionHelper.ReadAssessFromXML(assessesFile);

            report = new Report();

            if (File.Exists(dataReportName))
            {
                report = QuestionHelper.DeSerializeObject <Report>(dataReportName);
            }
        }
Exemplo n.º 12
0
        public List <Questions> GenerateQuestions()
        {
            IPTSE_EXAMEntities     objEntities  = new IPTSE_EXAMEntities();
            Questions              objQuestions = new Questions();
            List <Questions>       lstQuestions = new List <Questions>();
            IQueryable <Questions> questionList = GetQuestions(objEntities, 1, 1);

            lstQuestions.AddRange(QuestionHelper.GetRandom(questionList, 10));
            int index = 0;

            foreach (var quest in lstQuestions)
            {
                quest.QuestNo = ++index;
            }
            return(lstQuestions);
        }
        public ActionResult Create(QuestionProxyModel question)
        {
            AddViewData();
            bool success = false;
            int  id      = 0;

            if (ModelState.IsValid)
            {
                success = QuestionHelper.AddQuestion(db, User.Identity.Name, question, ModelState, out id);
                if (success)
                {
                    if (id != 0)
                    {
                        LogHelper.Log(db, User.Identity.Name, AGPDefine.LogLevelType.Info, AGPDefine.LogEventType.Insert, AGPDefine.LogObjectType.Question, null);
                        return(RedirectToAction("Index"));
                    }
                }
            }

            return(View(question));
        }
        public ExamQuestion GetExamQuestion(RequestGetExamQuestion request)
        {
            ExamQuestionHelper eqh = new ExamQuestionHelper();
            ExamQuestion       eq  = eqh.GetRow(request.ExamPaper);

            QuestionHelper qh = new QuestionHelper();

            eq.Questions = qh.GetRows(request.ExamPaper);

            QuestionItemHelper qih = new QuestionItemHelper();
            var qis = qih.GetRows(request.ExamPaper);

            Dictionary <string, IList <QuestionItem> > items   = new Dictionary <string, IList <QuestionItem> >();
            Dictionary <string, IList <QuestionItem> > answers = new Dictionary <string, IList <QuestionItem> >();

            foreach (var qi in qis)
            {
                if (!items.ContainsKey(qi.Code))
                {
                    items.Add(qi.Code, new List <QuestionItem>());
                }
                if (!answers.ContainsKey(qi.Code))
                {
                    answers.Add(qi.Code, new List <QuestionItem>());
                }
                items[qi.Code].Add(qi);
                if (!string.IsNullOrWhiteSpace(qi.Value))
                {
                    answers[qi.Code].Add(qi);
                }
            }

            foreach (var q in eq.Questions)
            {
                q.Items   = items[q.Code];
                q.Answers = answers[q.Code];
            }

            return(eq);
        }
 public ActionResult Ajax_Edit(int id)
 {
     if (Request.IsAjaxRequest())
     {
         var q = db.Questions.Find(id);
         if (q == null || q.State == (int)AGPDefine.CommitType.Normal)
         {
             LogHelper.Log(db, User.Identity.Name, AGPDefine.LogLevelType.Warning, AGPDefine.LogEventType.NoAccess, AGPDefine.LogObjectType.Question, "越权审阅");
             return(Content("越权操作"));
         }
         if (q.State == (int)AGPDefine.CommitType.Insert)
         {
             q.State = (int)AGPDefine.CommitType.Normal;
         }
         else if (q.State == (int)AGPDefine.CommitType.Delete)
         {
             QuestionHelper.DeleteQuestion(db, id);
         }
         db.SaveChanges();
         return(Content("已审阅"));
     }
     return(new EmptyResult());
 }
Exemplo n.º 16
0
        private void btn_end_Click(object sender, EventArgs e)
        {
            //calculte

            questionWorkflow.result = QuestionHelper.GetCurrentResult();

            MessageBox.Show(questionWorkflow.result);

            //save to file

            if (null == questionWorkflow.user)
            {
                MessageBox.Show("请录入身份信息,方可保存数据");

                return;
            }

            string dataName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "data.xml");

            List <QuestionWorkflow> qns = QuestionHelper.DeSerializeObject <List <QuestionWorkflow> >(dataName);

            questionWorkflow.date = System.DateTime.Now;

            if (null != qns)
            {
                qns.Add(questionWorkflow);
            }
            else
            {
                qns = new List <QuestionWorkflow>();
                qns.Add(questionWorkflow);
            }

            QuestionHelper.SerializeObject <List <QuestionWorkflow> >(qns, dataName);

            this.Close();
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            var questionHelper       = new QuestionHelper();
            var surveyAdressGetter   = new SurveyAdressGetter(questionHelper);
            var surveyLocationGetter = new SurveyLocationGetter(questionHelper, surveyAdressGetter);
            var surveyQuestionGetter = new SurveyQuestionGetter(questionHelper, surveyAdressGetter);

            var surveyCM = new SurveyCampaignMaker(questionHelper, surveyLocationGetter, surveyQuestionGetter);
            var campaign = surveyCM.CreateNewCampaign();

            var serializer = new JsonSerializer();

            using (StreamWriter file = File.CreateText(@"C:\Users\jfont\Source\Repos\SurveyMakerKata\SurveyMakerConsole\output\Survey.json"))
            {
                serializer.Serialize(file, campaign.Survey);
            }

            using (StreamWriter file = File.CreateText(@"C:\Users\jfont\Source\Repos\SurveyMakerKata\SurveyMakerConsole\output\Campaign.json"))
            {
                serializer.Serialize(file, campaign);
            }

            Console.WriteLine("Survey exported to JSON format !");
        }
Exemplo n.º 18
0
 // GET: Questions
 public ActionResult Index()
 {
     return(View(QuestionHelper.GetAllQuestions()));
 }
Exemplo n.º 19
0
        public void Execute(IServiceProvider serviceProvider)
        {
            SqlDataAccess sda = null;

            try
            {
                sda = new SqlDataAccess();
                sda.openConnection(Globals.ConnectionString);

                #region | SERVICE |
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

                #region | Validate Request |
                //Target yoksa veya Entity tipinde değilse, devam etme.
                if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity))
                {
                    return;
                }
                #endregion

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

                #endregion

                Entity entity = (Entity)context.InputParameters["Target"];

                #region | VARIABLES |
                List <ScoreLimit> lstLimits = new List <ScoreLimit>();

                EntityReference portal = null;
                EntityReference user   = null;
                int             point  = 0;

                if (entity.Contains("new_point") && entity["new_point"] != null)
                {
                    point = (int)entity["new_point"];
                }

                if (entity.Contains("new_portalid") && entity["new_portalid"] != null)
                {
                    portal = (EntityReference)entity["new_portalid"];
                }

                if (entity.Contains("new_userid") && entity["new_userid"] != null)
                {
                    user = (EntityReference)entity["new_userid"];
                }
                #endregion

                MsCrmResultObject limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.Question, sda);

                if (limitRes.Success && point != 0)
                {
                    lstLimits = (List <ScoreLimit>)limitRes.ReturnObject;

                    for (int i = 0; i < lstLimits.Count; i++)
                    {
                        int      recCount = 0;
                        DateTime start    = GeneralHelper.GetStartDateByScorePeriod(lstLimits[i].Period);
                        DateTime end      = GeneralHelper.GetEndDateByScorePeriod(lstLimits[i].Period);

                        recCount = QuestionHelper.GetUserAnswerCount(portal.Id, user.Id, start, end, sda);

                        if (lstLimits[i].Frequency >= recCount)
                        {
                            Score sc = new Score()
                            {
                                Point     = point,
                                Portal    = portal,
                                User      = user,
                                ScoreType = ScoreType.Question
                            };

                            MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service);

                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //LOG
                throw new InvalidPluginExecutionException(ex.Message);
            }
            finally
            {
                if (sda != null)
                {
                    sda.closeConnection();
                }
            }
        }
Exemplo n.º 20
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            QuestionHelper.LoadQuestions(".\\Data\\Questions.txt");
        }
Exemplo n.º 21
0
        public string FinishQuestionnaire(object result)
        {
            string ret = string.Empty;

            if (null == (result))
            {
                return(ret);
            }

            Dictionary <string, object> dicResult = (Dictionary <string, object>)result;

            JSResult jsResult = new JSResult();

            List <JSOptions> jsOptions = new List <JSOptions>();

            jsResult.QuestionnaireID = Convert.ToInt32(dicResult["QuestionnaireID"]);

            Questionnaire qn = QuestionWorkflow.Instance().Questionnaire;

            string resultCode = string.Empty;

            object[] objOptions = (object[])dicResult["Options"];

            for (int i = 0; i < objOptions.Length; i++)
            {
                Dictionary <string, object> dicOption = (Dictionary <string, object>)objOptions[i];

                JSOptions jso = new JSOptions()
                {
                    key = dicOption["key"].ToString(), value = Convert.ToInt32(dicOption["val"])
                };

                jsOptions.Add(jso);
            }

            jsResult.Options = jsOptions;



            switch (jsResult.QuestionnaireID)
            {
            case 1:
                ret = QuestionHelper.resultMessage1(qn, jsResult, out resultCode);
                break;

            case 2:
                ret = QuestionHelper.resultMessage2(qn, jsResult, out resultCode);
                break;

            case 3:
                ret = QuestionHelper.resultMessage3(qn, jsResult, out resultCode);
                break;

            case 4:
                ret = QuestionHelper.resultMessage4(qn, jsResult, out resultCode);
                break;

            case 5:
                ret = QuestionHelper.resultMessage5(qn, jsResult, out resultCode);
                break;

            case 6:
                ret = QuestionHelper.resultMessage6(qn, jsResult, out resultCode);
                break;

            case 7:
                ret = QuestionHelper.resultMessage7(qn, jsResult, out resultCode);
                break;

            case 8:
                ret = QuestionHelper.resultMessage8(qn, jsResult, out resultCode);
                break;

            case 9:
                ret = QuestionHelper.resultMessage9(qn, jsResult, out resultCode);
                break;

            case 10:
                ret = QuestionHelper.resultMessage10(qn, jsResult, out resultCode);
                break;

            case 11:

                ret = QuestionHelper.resultMessage11(qn, jsResult, out resultCode);

                break;

            case 12:

                ret = QuestionHelper.resultMessage12(qn, jsResult, out resultCode);

                break;

            case 13:

                ret = QuestionHelper.resultMessage13(qn, jsResult, out resultCode);

                break;

            case 14:

                ret = QuestionHelper.resultMessage14(qn, jsResult, out resultCode);

                break;

            case 15:

                ret = QuestionHelper.resultMessage15(qn, jsResult, out resultCode);

                break;
            }

            Tuple <bool, string> saveResult = QuestionWorkflow.Instance().SaveWorkflow(ret, resultCode);


            return("{\"code\":" + (saveResult.Item1?1:0) + ",\"message\":\"" + (string.IsNullOrEmpty(saveResult.Item2)? "无法确定基本体质": saveResult.Item2) + "\"}");
        }