Пример #1
0
    protected void TextBoxTableau_TextChanged(object sender, EventArgs e)
    {
        Reporter.Trace("TextBoxTableau_TextChanged");
        BloquerQuestionnaire(SessionState.Questionnaire.Bloque);

        TextBox text = ( TextBox )sender;

        if (text.Text.Trim() != "")
        {
            try
            {
                HiddenField hf = new HiddenField();
                hf = ( HiddenField )text.Parent.FindControl("PollQuestionId");
                Guid         pollQuestionId = new Guid(hf.Value);
                PollQuestion question       = SessionState.Questions.FindByPollQuestionID(pollQuestionId);
                question.Tableau = text.Text.Trim();
                int status = PollQuestion.UpdateTableau(question);
            }
            catch
            {
            }
        }

        Response.Redirect(Request.RawUrl);
    }
Пример #2
0
 public void SetUp(PollQuestion _question)
 {
     question        = _question;
     options         = new List <GameObject>();
     headerText.text = question.text;
     AddOptions(question);
 }
Пример #3
0
    protected void ImageButtonInsererTableau_Click(object sender, EventArgs e)
    {
        Reporter.Trace("ImageButtonInsererTableau_Click");

        ImageButton imageButton      = ( ImageButton )sender;
        Panel       panelTableauEdit = ( Panel )imageButton.Parent.FindControl("PanelTableauEdit");
        Panel       panelTableau     = ( Panel )imageButton.Parent.FindControl("PanelTableau");

        panelTableauEdit.Visible = panelTableauEdit.Visible == true ? false : true;

        // Premier coup : panelTableau.Visible == true
        // equivalent a Question possede un Tableau
        if (panelTableau.Visible)
        {
            panelTableau.Visible = false;
        }
        else // Trouver si la Question possede ou non un Tableau si true l'afficher
        {
            HiddenField hf = new HiddenField();
            hf = ( HiddenField )imageButton.Parent.FindControl("PollQuestionId");
            Guid         pollQuestionId = new Guid(hf.Value);
            PollQuestion question       = SessionState.Questions.FindByPollQuestionID(pollQuestionId);
            panelTableau.Visible = !string.IsNullOrEmpty(question.Tableau);
        }
    }
Пример #4
0
    protected void ImageButtonSautPageSupprimer_Click(object sender, EventArgs e)
    {
        Reporter.Trace("ImageButtonSautPageSupprimer_Click");

        ImageButton imageButton = ( ImageButton )sender;

        try
        {
            HiddenField hf = new HiddenField();
            hf = ( HiddenField )imageButton.Parent.FindControl("PollQuestionId");
            Guid         pollQuestionId = new Guid(hf.Value);
            PollQuestion question       = SessionState.Questions.FindByPollQuestionID(pollQuestionId);
            question.SautPage = null;
            int status = PollQuestion.UpdateSautPage(question);
        }
        catch
        {
        }

        Panel panelSautPageEdit = ( Panel )imageButton.Parent.FindControl("PanelSautPageEdit");

        panelSautPageEdit.Visible = false;

        // Rafraichir l'objet modifie
        try
        {
            Panel panelSautPage = ( Panel )imageButton.Parent.FindControl("PanelSautPage");
            Label LabelSautPage = ( Label )panelSautPage.FindControl("LabelSautPage");
            LabelSautPage.Text = string.Empty;
        }
        catch
        {
        }
    }
        public async Task <CreateQuestionViewModel> Handle(CreateQuestionCommand request, CancellationToken cancellationToken)
        {
            var        userId = HttpContextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier);
            Instructor user   = await _context.Instructors.FirstOrDefaultAsync(i => i.Id == userId, cancellationToken);

            if (user == null)
            {
                throw new CustomException(new Error
                {
                    ErrorType = ErrorType.Unauthorized,
                    Message   = Localizer["Unauthorized"]
                });
            }

            var course = await _context.Courses.Include(c => c.Instructor)
                         .Include(c => c.Polls).FirstOrDefaultAsync(c => c.CourseId == request.CourseId
                                                                    , cancellationToken);

            var poll = new PollQuestion
            {
                QuestionDescription = request.QuestionDescription,
                MultiVote           = request.MultiVote,
                Course   = course,
                CourseId = course.CourseId
            };
            await _context.PollQuestions.AddAsync(poll, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            return(new CreateQuestionViewModel
            {
                Poll = _mapper.Map <PollQuestionDto>(poll)
            });
        }
Пример #6
0
    protected void TextBoxMessageUtilisateur_TextChanged(object sender, EventArgs e)
    {
        Reporter.Trace("TextBoxMessageUtilisateur_TextChanged");
        BloquerQuestionnaire(SessionState.Questionnaire.Bloque);

        try
        {
            TextBox textBox = ( TextBox )sender;

            HiddenField hf = new HiddenField();
            hf = ( HiddenField )textBox.Parent.FindControl("PollQuestionId");
            Guid         pollQuestionId = new Guid(hf.Value);
            PollQuestion question       = SessionState.Questions.FindByPollQuestionID(pollQuestionId);
            question.Message = textBox.Text.Trim();
            PollQuestion.Update(question);

            // Pallier a un bug graphique voir List.aspx.cs a <!-- BUG GRAPHIQUE
            if (textBox.Text.Trim() != string.Empty)
            {
                textBox.Width = new Unit("100%");
            }
            else
            {
                textBox.Width = new Unit(180);
            }
        }
        catch
        {
        }
    }
Пример #7
0
    // GridViewQuestion_RowDataBound est appellee pour chaque ligne lors de la construction
    // de la GridView
    // Attention : le fait d'utiliser une deuxieme fois la DDL, introduit un mauvais comportement
    // Valeur est à "" lors du SelectedIndexChanged !
    protected void ComputeAlignementColumn()
    {
        Trace.Warn("ComputeAlignementColumn");

        if (GridViewQuestion.Rows.Count > 0)
        {
            int indexRow = GridViewQuestion.Rows.Count - 1;

            Guid         questionGuid = new Guid(GridViewQuestion.DataKeys[indexRow].Value.ToString());
            PollQuestion question     = PollQuestion.GetQuestion(questionGuid);

            DropDownListGridView ddlQ = ( DropDownListGridView )GridViewQuestion.Rows[indexRow].FindControl("DropDownListGridViewAlignementQuestion");
            ddlQ.DataSource = PollQuestion.TypeAlignement();
            ddlQ.DataBind();
            ddlQ.Valeur = indexRow.ToString();
            if (question.AlignementQuestion != "")
            {
                ddlQ.SelectedValue = question.AlignementQuestion;
            }

            DropDownListGridView ddlR = ( DropDownListGridView )GridViewQuestion.Rows[indexRow].FindControl("DropDownListGridViewAlignementReponse");
            ddlR.DataSource = PollQuestion.TypeAlignement();
            ddlR.DataBind();
            ddlR.Valeur = indexRow.ToString();
            if (question.AlignementQuestion != "")
            {
                ddlR.SelectedValue = question.AlignementReponse;
            }
        }
    }
Пример #8
0
    // Se declenche quand on clique sur les boutons edit/delete/update/cancel
    protected void GridViewQuestion_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        Trace.Warn("GridViewQuestion_RowCommand");

        if (e.CommandName == "Edit")
        {
            // Trouver la Question selectionnee par l'utilisateur pour remplir les colonnes cachees lors du save
            int index = Convert.ToInt32(e.CommandArgument);

            GridView gv = ( GridView )e.CommandSource;
            string   q  = gv.DataKeys[index].Value.ToString();

            PollQuestionCollection questions = PollQuestionCollection.GetByQuestionnaire(SessionState.Questionnaire.QuestionnaireID);
            SessionState.Question = questions.FindByPollQuestionID(new Guid(q));
        }

        if (e.CommandName == "Delete")
        {
            int index = Convert.ToInt32(e.CommandArgument);

            GridView gv = ( GridView )e.CommandSource;

            Guid questionGuid = new Guid(gv.DataKeys[index].Value.ToString());
            int  status       = PollQuestion.Delete(questionGuid);
            SessionState.Limitations.SupprimerQuestion();
        }

        Trace.Warn(string.Format("GridViewQuestion_RowCommand CommandName : {0}", e.CommandName));
    }
Пример #9
0
    protected void ButtonTableauOk_Click(object sender, EventArgs e)
    {
        Reporter.Trace("ButtonTableauOk_Click");

        Button button           = ( Button )sender;
        Panel  panelTableauEdit = ( Panel )button.Parent.FindControl("PanelTableauEdit");
        Panel  panelTableau     = ( Panel )button.Parent.FindControl("PanelTableau");

        panelTableauEdit.Visible = false;

        // Rafraichir l'objet modifie
        try
        {
            HiddenField hf = new HiddenField();
            hf = ( HiddenField )button.Parent.FindControl("PollQuestionId");
            Guid         pollQuestionId = new Guid(hf.Value);
            PollQuestion question       = SessionState.Questions.FindByPollQuestionID(pollQuestionId);

            Label LabelTableau = ( Label )panelTableau.FindControl("LabelTableau");
            LabelTableau.Text    = question.Tableau;
            panelTableau.Visible = string.IsNullOrEmpty(question.Tableau) == false;
        }
        catch
        {
        }
    }
Пример #10
0
        public async Task <Unit> Handle(UpdateQuestionCommand request, CancellationToken cancellationToken)
        {
            var        userId = HttpContextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier);
            Instructor user   = await _context.Instructors.
                                FirstOrDefaultAsync(i => i.Id == userId, cancellationToken);

            if (user == null)
            {
                throw new CustomException(new Error
                {
                    ErrorType = ErrorType.Unauthorized,
                    Message   = Localizer["Unauthorized"]
                });
            }

            var question = new PollQuestion
            {
                QuestionId          = request.QuestionId,
                QuestionDescription = request.QuestionDescription,
                IsOpen    = request.IsOpen,
                MultiVote = request.MultiVote
            };

            _context.PollQuestions.Update(question);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
Пример #11
0
        /// <summary>
        /// Devuelve un objeto modelado con los valores del dataRow que recibe por parámetro.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private PollQuestion ConvertToModel(DataRow data)
        {
            PollQuestion pollQuestion = new PollQuestion();

            pollQuestion.Id       = int.Parse(data["id"].ToString());
            pollQuestion.Question = data["question"].ToString();
            return(pollQuestion);
        }
Пример #12
0
        /// <summary>
        /// Add a Poll question to storage
        /// </summary>
        /// <param name="questionText"></param>
        /// <param name="title"></param>
        /// <returns>The saved Poll Question</returns>
        public PollQuestion AddPollQuestion(string questionText, string title)
        {
            PollQuestion newQuestion = new PollQuestion();

            newQuestion.QuestionText = questionText;
            newQuestion.Title        = title;
            return(this.PollRepository.Save(newQuestion));
        }
Пример #13
0
 public static PollQuestion craftFirstQuestion(int idPoll)
 {
     // Question par défaut pour obtenir la première question du sondage choisi
     PollQuestion firstQuestion = new PollQuestion();
     firstQuestion.PollId = idPoll;
     firstQuestion.QuestionId = -1;
     return firstQuestion;
 }
Пример #14
0
 /// <summary>
 /// Elimina del listado la pregunta de la encuesta persistidas en sesión.
 /// </summary>
 /// <param name="session"></param>
 /// <returns></returns>
 public static void RemovePollQuestion(PollQuestion pollQuestion, HttpSessionState session)
 {
     if (Exist(POLL_QUESTION, session))
     {
         //Se elimina por pregunta porque en caso de ser nuevo el item, no presenta id
         ((List <PollQuestion>)session[POLL_QUESTION]).RemoveAll(x => x.Question == pollQuestion.Question);
         pollQuestionEdited = true;
     }
 }
Пример #15
0
    protected void DropDownListAlignementReponse_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownListGridView ddl  = ( DropDownListGridView )sender;
        int          indexe       = int.Parse(ddl.Valeur);
        Guid         questionGuid = new Guid(GridViewQuestion.DataKeys[indexe].Value.ToString());
        PollQuestion question     = PollQuestion.GetQuestion(questionGuid);

        question.AlignementReponse = ddl.SelectedValue;
        PollQuestion.UpdateAlignementReponse(question);
    }
Пример #16
0
        /// <summary>
        /// Persiste las preguntas de la encuestas en sessión para podes efectuar tareas ABMicas.
        /// </summary>
        /// <param name="pollQuestion"></param>
        /// <param name="session"></param>
        public static void KeepPollQuestion(PollQuestion pollQuestion, HttpSessionState session)
        {
            if (!Exist(POLL_QUESTION, session))
            {
                session[POLL_QUESTION] = new List <PollQuestion>();
            }

            ((List <PollQuestion>)session[POLL_QUESTION]).Add(pollQuestion);
            pollQuestionEdited = true;
        }
Пример #17
0
 private void AddOptions(PollQuestion question)
 {
     foreach (PollOption o in question.options)
     {
         GameObject oo = Instantiate(optionPrefab, transform);
         oo.GetComponent <OptionObject>().Set(o);
         totalVotes            += o.votes;
         oo.transform.position -= new Vector3(0, options.Count * distance, 0);
         options.Add(oo);
     }
 }
Пример #18
0
        public ActionResult Welcome()
        {
            PollWorker   worker   = new PollWorker();
            PollQuestion question = worker.GetActiveQuestion();

            if (question == null)
            {
                //return HttpNotFound;
            }
            return(View(question));
        }
Пример #19
0
        public PollQuestion Post(int pollId, string currentQuestionId, string answer, string username, string test)
        {
            if (ValidateToken(Request.Headers["Authorization"]))
            {
                string a = currentQuestionId;

                if (a == "11" || a == "12" || a == "13" || a == "21" || a == "22" || a == "23")
                {
                    PollQuestion responseQuestion = new PollQuestion();
                    responseQuestion.PollId = pollId;
                    responseQuestion.Text   = answer;

                    int userId = int.Parse(username);

                    new SimpleSondageDAO().SaveAnswer(userId, responseQuestion);

                    int b = int.Parse(currentQuestionId);

                    return(new SimpleSondageDAO().GetNextQuestion(pollId, b));
                }

                int c = int.Parse(currentQuestionId);

                if (currentQuestionId == "-1" && test == "first")
                {
                    return(new SimpleSondageDAO().GetNextQuestion(pollId, c));
                }

                if (currentQuestionId == "-1" && test == "second")
                {
                    int          userId           = int.Parse(username);
                    PollQuestion responseQuestion = new PollQuestion();
                    responseQuestion.PollId = pollId;
                    responseQuestion.Text   = answer;

                    if (pollId == 1)
                    {
                        new SimpleSondageDAO().SaveAnswer(userId, responseQuestion);
                        return(new SimpleSondageDAO().GetNextQuestion(1, 11));
                    }

                    if (pollId == 2)
                    {
                        new SimpleSondageDAO().SaveAnswer(userId, responseQuestion);
                        return(new SimpleSondageDAO().GetNextQuestion(2, 21));
                    }
                }
            }
            else
            {
                return(null);
            }
            return(null);
        }
Пример #20
0
        /// <summary>
        /// Add an answer option to a poll
        /// </summary>
        /// <param name="pollQuestionId"></param>
        /// <param name="optionText"></param>
        /// <returns>The updated Poll Question with the option in it</returns>
        public PollQuestion AddPollOption(int pollQuestionId, string optionText)
        {
            PollQuestion targetQuestion = this.GetById(pollQuestionId);

            if (targetQuestion != null)
            {
                targetQuestion.AddOption(optionText);
                targetQuestion = this.PollRepository.Save(targetQuestion);
            }

            return(targetQuestion);
        }
 public  PollQuestion Add(string question, int pollId, string status)
 {
     PollQuestion pollQuestion = new PollQuestion();
     pollQuestion.Question = question.Trim();
     pollQuestion.PollId = pollId;
     pollQuestion.Status = status.Trim();
     pollQuestion.CreatedDate = DateTime.Now;
     pollQuestion.UpdatedDate = DateTime.Now;
     this.PollQuestions.InsertOnSubmit(pollQuestion);
     Commit();
     return pollQuestion;
 }
Пример #22
0
 public IActionResult PostAnswer([FromBody] PollQuestion answer)
 {
     if (answer != null)
     {
         sondage.SaveAnswer(1, answer);
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
Пример #23
0
        /// <summary>
        /// Add a vote for a poll option
        /// </summary>
        /// <param name="pollOptionId"></param>
        /// <param name="address"></param>
        /// <returns>The poll question with the additional vote</returns>
        public PollQuestion AddOptionVote(int pollOptionId, IPAddress address)
        {
            PollQuestion pollQuestion = this.PollRepository.GetByPollOptionId(pollOptionId);

            if (pollQuestion != null)
            {
                pollQuestion.AddOptionVote(pollOptionId, address);
                pollQuestion = this.PollRepository.Save(pollQuestion);
            }

            return(pollQuestion);
        }
Пример #24
0
        /// <summary>
        /// Elimina de la lista de las preguntas, aquella que se encuentra seleccionada.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DeleteQuestion(object sender, EventArgs e)
        {
            if (pollQuestionList.SelectedItem == null)
            {
                return;
            }
            ListItem     selectedQuestion = pollQuestionList.SelectedItem;
            PollQuestion pollQuestion     = new PollQuestion();

            pollQuestion.Question = selectedQuestion.Text;
            SessionUtilHelper.RemovePollQuestion(pollQuestion, Session);
            RefreshQuestionList(SessionUtilHelper.GetPollQuestions(Session));
        }
Пример #25
0
    protected void ButtonTableauClassementOk_Click(object sender, EventArgs e)
    {
        Reporter.Trace("ButtonTableauClassementOk_Click");

        Button button = ( Button )sender;

        try
        {
            HiddenField hf = new HiddenField();
            hf = ( HiddenField )button.Parent.FindControl("PollQuestionId");
            Guid         pollQuestionId = new Guid(hf.Value);
            PollQuestion question       = SessionState.Questions.FindByPollQuestionID(pollQuestionId);
            if (question.Tableau.Contains(Tableau.Classement))
            {
                question.Tableau = question.Tableau.Substring(0, question.Tableau.Length - Tableau.Classement.Length);
            }
            else
            {
                question.Tableau = question.Tableau + Tableau.Classement;
            }
            int status = PollQuestion.UpdateTableau(question);
        }
        catch
        {
        }

        Panel panelTableauEdit = ( Panel )button.Parent.FindControl("PanelTableauEdit");
        Panel panelTableau     = ( Panel )button.Parent.FindControl("PanelTableau");

        panelTableauEdit.Visible = false;
        panelTableau.Visible     = true;

        // Rafraichir les objets modifies
        try
        {
            HiddenField hf = new HiddenField();
            hf = ( HiddenField )button.Parent.FindControl("PollQuestionId");
            Guid         pollQuestionId = new Guid(hf.Value);
            PollQuestion question       = SessionState.Questions.FindByPollQuestionID(pollQuestionId);

            Label LabelTableau = ( Label )panelTableau.FindControl("LabelTableau");
            LabelTableau.Text = question.Tableau;

            // Et la TextBox car on ne passera pas par TextBoxTableau_TextChanged comme avec ButtonTableauOk_Click
            TextBox TextBox = ( TextBox )panelTableauEdit.FindControl("TextBoxTableauEdit");
            TextBox.Text = question.Tableau;
        }
        catch
        {
        }
    }
Пример #26
0
        //BACKEND
        public ActionResult Create(int videoId)
        {
            var model = new PollQuestion
            {
                VideoId   = videoId,
                Published = true,
                Displayed = true,
                ViewTotal = true,

                FromDate = DateTime.Now.Date,
            };

            return(PartialView("_Create", model));
        }
Пример #27
0
    private Dictionary <int, int> GetVotesByQuestion(PollQuestion question)
    {
        Dictionary <int, int> votes = new Dictionary <int, int>();

        int i = 0;

        foreach (PollOption o in question.options)
        {
            votes.Add(i, o.votes);
            i++;
        }

        return(votes);
    }
Пример #28
0
        public PollQuestion GetNext(int userId, PollQuestion answer)
        {
            try
            {
                if (validateUserActive(userId))
                {
                    if (answer != null)
                    {
                        if (validatePollId(answer.PollId) && validateQuestionId(answer.PollId, answer.QuestionId))
                        {
                            // On veut la premiere question du sondage, donc -1
                            if (answer.QuestionId == -1)
                            {
                                return(_simpleSondageDAO.GetNextQuestion(answer.PollId, -1));
                            }

                            if (answer.Text != null)
                            {
                                // Sanitise la reponse avant d'etre process
                                if (answer.Text.Equals("a") || answer.Text.Equals("b") || answer.Text.Equals("c") || answer.Text.Equals("d"))
                                {
                                    _simpleSondageDAO.SaveAnswer(userId, answer);
                                    return(_simpleSondageDAO.GetNextQuestion(answer.PollId, answer.QuestionId));
                                }
                                else
                                {
                                    //Mauvais data, on recommence la question.
                                    return(_simpleSondageDAO.GetNextQuestion(answer.PollId, answer.QuestionId - 1));
                                }
                            }
                            return(null); // Lance exception car answer.Text ne contient pas une reponse attendue
                        }
                    }
                    return(null); // Lance exception car answer nest pas valide
                }
                return(null);     // Lance Exception que le user n'est pas valide
            }
            catch (Exception e) when(e is PersistenceException)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                return(null);
            }
            catch (Exception e) when(e is InvalidIdException)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                return(null);
            }
        }
Пример #29
0
    protected void TextBoxInstruction_TextChanged(object sender, EventArgs e)
    {
        BloquerQuestionnaire(SessionState.Questionnaire.Bloque);

        try
        {
            TextBox textBox = ( TextBox )sender;

            HiddenField hf = new HiddenField();
            hf = ( HiddenField )textBox.Parent.FindControl("PollQuestionId");
            Guid         pollQuestionId = new Guid(hf.Value);
            PollQuestion question       = SessionState.Questions.FindByPollQuestionID(pollQuestionId);

            if (textBox.Text.Trim() != string.Empty)
            {
                if (Instruction.Valide(textBox.Text.Trim(), question.ChoixMultiple == false))
                {
                    question.Instruction = textBox.Text.Trim();
                    textBox.CssClass     = "TextBoxListUserQuestionInstructionStyle";
                    PollQuestion.Update(question);
                }
                else
                {
                    textBox.CssClass = "TextBoxListUserQuestionInstructionRedStyle";
                    textBox.Text     = "Instruction non valide";
                }
            }
            else
            {
                question.Instruction = string.Empty;
                PollQuestion.Update(question);
            }

            // Pallier a un bug graphique voir List.aspx.cs a <!-- BUG GRAPHIQUE
            if (textBox.Text.Trim() != string.Empty)
            {
                textBox.Width = new Unit("100%");
            }
            else
            {
                textBox.Width = new Unit(130);
            }
        }
        catch
        {
        }
    }
        private Table CreateTableForQuestion(PollQuestion question)
        {
            Table     table = new Table();
            TableCell cell  = new TableCell();
            TableRow  row   = new TableRow();

            string q = CreateHtmlLabel(question.Rank.ToString() + " - " + question.Question, "LabelQuestionStyle");

            if (question.Obligatoire)
            {
                q += "&nbsp;";
                string obligatoire = CreateHtmlLabel("Obligatoire", "LabelListUserQuestionObligatoireStyle");
                q += obligatoire;
            }
            if (question.ChoixMultiple)
            {
                q += "&nbsp;";
                string multiple = CreateHtmlLabel("Multiple", "LabelListUserQuestionChoixMultipleStyle");
                q += multiple;
            }
            if (question.Fin)
            {
                q += "&nbsp;";
                string fin = CreateHtmlLabel("Fin", "LabelListUserQuestionFinStyle");
                q += fin;
            }
            if (question.Instruction != "")
            {
                q += "<br />";
                string inst = CreateHtmlLabel(question.Instruction, "LabelListUserQuestionInstructionStyle");
                q += inst;
            }
            if (question.Message != "")
            {
                q += "<br />";
                string inst = CreateHtmlLabel(question.Message, "LabelListUserQuestionMessageStyle");
                q += inst;
            }

            cell.Text = q;
            //cell.CssClass = cellCssClass;

            row.Cells.Add(cell);
            table.Rows.Add(row);
            return(table);
        }
Пример #31
0
        /// <summary>
        /// Add user answer, by question and answer data.
        /// </summary>
        /// <param name="question"></param>
        /// <param name="answersData"></param>
        /// <returns></returns>
        private async Task <UserAnswer> AddUserAnswerWithSelectAnwerData(PollQuestion question, params UserAnswerSelectData[] answersData)
        {
            var addedUserAnswer = await _dbContext.UserAnswers.AddAsync(new UserAnswer()
            {
                Question = question,
                Date     = DateTime.Now,
            });

            foreach (var answerData in answersData)
            {
                answerData.UserAnswer = addedUserAnswer.Entity;
            }

            await _dbContext.AnswerSelectData.AddRangeAsync(answersData);

            return(addedUserAnswer.Entity);
        }
Пример #32
0
        public IActionResult GetSondageById(int PollId, int QId)
        {
            // Récupération des descriptions

            PollQuestion question = sondage.GetNextQuestion(PollId, QId);
            // Formatage
            string contenu = JsonConvert.SerializeObject(question);

            // Retour de GET
            if (!contenu.Equals("null"))
            {
                return(Ok(contenu));
            }
            else
            {
                return(NotFound());
            }
        }
        public  void Edit(string Question, int PollId, string Status)
        {
            PollQuestion q = new PollQuestion() { 
            PollId = PollId,
            Question = Question,
            Status = Status,
            CreatedDate =DateTime.Now,
            UpdatedDate = DateTime.Now
            };

            PollQuestions.InsertOnSubmit(q);
            Commit();

        }
Пример #34
0
 public void InsertPoll(PollQuestion poll)
 {
     context.Polls.Add(poll);
 }
Пример #35
0
 public void UpdatePoll(PollQuestion poll)
 {
     context.Entry(poll).State = EntityState.Modified;
 }
Пример #36
0
        /// <summary>
        /// Creates a table and inserts the Poll Questions and the
        /// submt button
        /// </summary>
        /// <returns></returns>
        protected bool MkControls()
        {
            HtmlTable				m_Table;
            HtmlTableRow			m_Row;
            HtmlTableCell			m_Cell;
            HtmlInputRadioButton    m_Rdo;
            Button					m_Btn;

            //Set the table properties
            m_Table				=	new HtmlTable();
            m_Table.Border		=	1;
            m_Table.CellPadding	=	1;
            m_Table.CellSpacing	=	0;
            m_Table.BorderColor =	"#000000";
            m_Table.BgColor		=	"#FFFFEE";
            m_Table.Width		=	"160px";

            // Get Poll Question
            pQ = new PollQuestion(m_whichPoll,m_connString);

            // If there isn't a valid Poll then exit
            if (pQ.Found!=true) return false;

            // Get the Question Answers
            alAnswers = pQ.alAnswers;

            // First Table Row for Question
            m_Row  = new HtmlTableRow();
            m_Cell = new HtmlTableCell();
            m_Cell.ColSpan   = 2;
            m_Cell.Align     = "center";
            m_Cell.InnerHtml = "<font size='1' face='arial'><b>"+pQ.Question+"</b></font>";
            m_Row.Cells.Add(m_Cell);
            m_Table.Rows.Add(m_Row);

            // Poll Answers
            RdoValues = new ArrayList();		// New Array for Poll Answers
            for (int i=0;i<pQ.NumberAnswers;i++)
            {
                pA				= (PollAnswer)alAnswers[i];
                m_Row           = new HtmlTableRow();

                // This cell shows the checkbox
                m_Rdo			= new HtmlInputRadioButton();
                m_Rdo.ID		= String.Format("R{0}",i);
                m_Rdo.Name		= "G1"; // Group Name
                RdoValues.Add(m_Rdo);
                m_Cell	        = new HtmlTableCell();
                m_Cell.Align	= "center";
                m_Cell.Controls.Add(m_Rdo);
                m_Row.Cells.Add(m_Cell);

                // This cell shows the Answer
                m_Cell = new HtmlTableCell();
                m_Cell.InnerHtml = "&nbsp<font size='1' face='arial'>"+pA.Answer+"</font>";
                m_Row.Cells.Add(m_Cell);

                // Add the Row to the table
                m_Table.Rows.Add(m_Row);
            }

            // Show Previous Number of Responses
            m_Row			= new HtmlTableRow();
            m_Cell			= new HtmlTableCell();
            m_Cell.ColSpan	= 2;
            m_Cell.Align    = "center";
            m_Label  	    = new Label();
            m_Label.Text   += string.Format("<font size='1' face='arial'>{0} Responses</font>",pQ.TotalAnswers);
            m_Cell.Controls.Add(m_Label);
            m_Row.Cells.Add(m_Cell);
            m_Table.Rows.Add(m_Row);

            // Add the Submit Button
            m_Row			= new HtmlTableRow();
            m_Cell			= new HtmlTableCell();
            m_Cell.ColSpan	= 3;
            m_Cell.Align    = "center";
            m_Btn		    = new Button();
            m_Btn.Click	   += new System.EventHandler (this.Btn_Click);
            m_Btn.Text      = "Submit";
            m_Btn.ForeColor = Color.White;
            m_Btn.BackColor = Color.DarkBlue;
            m_Btn.Font.Bold = true;
            m_Btn.Font.Name = "Arial";
            m_Btn.Font.Size = 8;

            m_Cell.Controls.Add(m_Btn);
            m_Row.Cells.Add(m_Cell);
            m_Table.Rows.Add(m_Row);
            Ph.Controls.Add(m_Table);  // Add the Poll Table
            return true;
        }