Ejemplo n.º 1
0
        public JsonResult nextQuestion(int i, int type, int id)
        {
            int ix = 0;

            if (Session["nextQ"] != null)
            {
                ix = (int)Session["nextQ"];
                int x = 0;
                if (type == 1)
                {
                    x = ix += i;
                }
                else if (type == 2)
                {
                    x = ix -= i;
                }
                else if (type == 0)
                {
                    x = 1;
                }
                Session["nextQ"] = x;
            }
            else
            {
                Session["nextQ"] = i;
                ix = 1;
            }
            List <string> lsresult = new List <string>();

            TB_Votation_Questions _Questions = new TB_Votation_Questions();

            _Questions.votationId = id;
            _Questions.order      = ix;

            TB_Votation_Questions qRequest = lv.getquestions(DBConnect.open(), _Questions);
            List <TB_Votation_Questions_Answer> lstanswer = lv.getAnswer(DBConnect.open(), qRequest.id);

            lsresult.Add(qRequest.question);

            for (int e = 0; e < lstanswer.Count; e++)
            {
                lsresult.Add(lstanswer[e].answer.ToString());
            }
            Session["votationid"] = id;
            Session["order"]      = ix;
            Session["questionid"] = qRequest.id;


            return(Json(lsresult, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult getQuestions()
        {
            var userVote = (TB_UserVote)Session["UserVote"];

            ListVote      lv       = new ListVote();
            List <string> lsresult = new List <string>();

            int order = lv.getOrderQuestion(DBConnect.open(), userVote.votationid);

            TB_Votation_Questions _Questions = new TB_Votation_Questions();

            _Questions.votationId = userVote.votationid;
            _Questions.order      = order;


            TB_Votation_Questions qRequest = lv.getquestions(DBConnect.open(), _Questions);
            List <TB_Votation_Questions_Answer> lstanswer = lv.getAnswer(DBConnect.opentwo(), qRequest.id);

            lsresult.Add(qRequest.question);

            for (int e = 0; e < lstanswer.Count; e++)
            {
                lsresult.Add(lstanswer[e].answer.ToString());
            }

            return(Json(lsresult, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Report(string key)
        {
            string[] colors  = new string[9];
            string[] graphic = new string[] { };
            string[] options = new string[9];

            int      idf = int.Parse(key);
            ListVote lv  = new ListVote();

            List <ResultOptions> lstro = lv.getOptions(DBConnect.open(), idf);


            int order = lv.getOrderQuestion(DBConnect.open(), idf);

            TB_Votation_Questions _Questions = new TB_Votation_Questions();

            _Questions.votationId = idf;
            _Questions.order      = order;


            TB_Votation_Questions qRequest = lv.getquestions(DBConnect.open(), _Questions);
            List <TB_Vote>        votes    = lv.getListVote("max", idf, qRequest.id, DBConnect.open());

            List <TB_Votation_Questions_Answer> lstanswer = lv.getAnswer(DBConnect.open(), qRequest.id);

            graphic = new string[] { qRequest.question, lstro[0].graphic, lstro[0].height.ToString(), lstro[0].width.ToString(), lstro[0].imagefondo, lstro[0].visible };

            /*
             *          for (int i = 0; i < lstro.Count; i++)
             *          {
             *              colors[i] = lstro[i].color;
             *              options[i] = lstro[i].option;
             *          }
             */
            for (int i = 0; i < lstanswer.Count; i++)
            {
                colors[i]  = lstro[i].color;
                options[i] = lstanswer[i].answer;
            }
            ResultVote rv  = lv.getVote(votes);
            ResultVote rv2 = new ResultVote();

            string[] value   = GetCountOptions(rv, rv2);
            var      Tablero = new[] { graphic, colors, options, value };

            return(Json(Tablero, JsonRequestBehavior.AllowGet));
        }