private void BuildDataList()
    {
        if (SessionState.Questionnaire != null)
        {
            PollQuestionCollection pollQuestions = PollQuestionCollection.GetByQuestionnaire(SessionState.Questionnaire.QuestionnaireID);
            QuestionRankMax = pollQuestions.MaxRank();

            DataListQuestion.DataSource = pollQuestions;
            DataListQuestion.DataBind();

            // Trouver les reponses
            foreach (DataListItem dli in DataListQuestion.Items)
            {
                DataList dl = new DataList();
                dl = ( DataList )dli.FindControl("DataListReponse");

                HiddenField hf = new HiddenField();
                hf = ( HiddenField )dli.FindControl("PollQuestionId");
                Guid pollQuestionId          = new Guid(hf.Value);
                PollAnswerCollection answers = PollAnswerCollection.GetByPollQuestionID(pollQuestionId);

                dl.DataSource = answers;
                dl.DataBind();
            }
        }

        Trace.Warn("BuildDataList");
    }
예제 #2
0
    private void BuildDataList()
    {
        Trace.Warn("BuildDataList");

        if (SessionState.Questionnaire != null)
        {
            PollQuestionCollection pollQuestions = PollQuestionCollection.GetByQuestionnaire(SessionState.Questionnaire.QuestionnaireID);
            QuestionRankMax = pollQuestions.MaxRank();

            DropDownListCopierAPartirDe.Items.Clear();
            DropDownListCopierAPartirDe.Items.Add("");
            foreach (PollQuestion pq in pollQuestions)
            {
                DropDownListCopierAPartirDe.Items.Add(pq.Rank.ToString());
            }

            DataListQuestion.DataSource = pollQuestions;
            DataListQuestion.DataBind();

            // Trouver les reponses
            foreach (DataListItem dli in DataListQuestion.Items)
            {
                DataList dl = new DataList();
                dl = ( DataList )dli.FindControl("DataListReponse");

                HiddenField hf = new HiddenField();
                hf = ( HiddenField )dli.FindControl("PollQuestionId");
                Guid pollQuestionId          = new Guid(hf.Value);
                PollAnswerCollection answers = PollAnswerCollection.GetByPollQuestionID(pollQuestionId);

                dl.DataSource = answers;
                dl.DataBind();
            }
        }
    }
예제 #3
0
    private void BindItemsList()
    {
        questionbl = new QuestionBL();
        questions  = new List <QuestionDTO>();

        questions = questionbl.GetAllQuestion(CurrentPage, 20);

        if (questions != null)
        {
            ViewState["TotalPages"] = questions[1].TotalPage.ToString();

            DataListQuestion.DataSource = questions;
            DataListQuestion.DataBind();

            this.lblPageInfo.Text = "Page " + (CurrentPage) + " of " + questions[1].TotalPage.ToString();

            if (CurrentPage - 1 == 0)
            {
                lbtnPrevious.Enabled = false;
            }
            else
            {
                lbtnPrevious.Enabled = true;
            }

            if (CurrentPage == Convert.ToInt32(ViewState["TotalPages"]))
            {
                lbtnNext.Enabled = false;
            }
            else
            {
                lbtnNext.Enabled = true;
            }

            if (CurrentPage == 1)
            {
                lbtnFirst.Enabled = false;
            }
            else
            {
                lbtnFirst.Enabled = true;
            }

            if (CurrentPage == Convert.ToInt32(ViewState["TotalPages"]))
            {
                lbtnLast.Enabled = false;
            }
            else
            {
                lbtnLast.Enabled = true;
            }
        }
    }
예제 #4
0
        private void Populate(string parameterID, string typeofQuestion)
        {
            string constr = ConfigurationManager.ConnectionStrings["AssignmentEntities"].ConnectionString;

            using (SqlConnection _cn = new SqlConnection(constr))
            {
                if (typeofQuestion == "MCQ")
                {
                    using (SqlCommand _cmd = new SqlCommand("SELECT * FROM MCQQuestion WHERE MCQAssessmentID=" + parameterID, _cn))
                    {
                        using (SqlDataAdapter da = new SqlDataAdapter(_cmd))
                        {
                            _cn.Open();
                            DataSet ds = new DataSet();
                            da.Fill(ds);
                            DataListQuestion.DataSource = ds;
                            DataListQuestion.DataBind();
                            _cn.Close();
                        }
                    }
                }
                else if (typeofQuestion == "QNA")
                {
                    using (SqlCommand _cmd = new SqlCommand("SELECT * FROM WrittenQuestion WHERE WrittenID=" + parameterID, _cn))
                    {
                        using (SqlDataAdapter da = new SqlDataAdapter(_cmd))
                        {
                            _cn.Open();
                            DataSet ds = new DataSet();
                            da.Fill(ds);
                            QNADataList.DataSource = ds;
                            QNADataList.DataBind();
                            _cn.Close();
                        }
                    }
                }
                else
                {
                }
            }
        }
    private void BuildDataList()
    {
        DataListQuestion.DataSource = SessionState.QuestionsEnCours;
        DataListQuestion.DataBind();

        // Trouver les Reponses et les Votes
        foreach (DataListItem dli in DataListQuestion.Items)
        {
            DataList dl = new DataList();
            dl = ( DataList )dli.FindControl("DataListReponse");

            HiddenField hf = new HiddenField();
            hf = ( HiddenField )dli.FindControl("PollQuestionId");
            Guid pollQuestionId          = new Guid(hf.Value);
            PollAnswerCollection answers = PollAnswerCollection.GetByPollQuestionID(pollQuestionId);

            dl.DataSource = answers;
            dl.DataBind();

            // Rechercher dans les Votes deja effectues
            if (answers.Count > 0 && SessionState.Votes != null)
            {
                int indexReponse = 0; // Trouver le bon LabelVote dans DataListReponse
                foreach (PollAnswer answer in answers)
                {
                    PollVoteCollection pvc = SessionState.Votes.FindByAnswerID(answer.PollAnswerId);
                    if (pvc.Count >= 1)   // surement un seul mais bon ...
                    {
                        Label lbl = ( Label )dl.Controls[indexReponse].FindControl("LabelVote");
                        lbl.Text     = "X";
                        lbl.CssClass = "LabelQuestionEnCoursVoteDejaFaitStyle";

                        if (TypeReponse.EstTextuelle(answer.TypeReponse))
                        {
                            Label lblVoteTexte = ( Label )dl.Controls[indexReponse].FindControl("LabelVoteTexte");
                            lblVoteTexte.Text = pvc[0].Vote;
                        }
                    }
                    indexReponse += 1;
                }
            }

            // Rechercher dans les Votes en Cours
            if (answers.Count > 0 && SessionState.VotesEnCours != null)
            {
                int indexReponse = 0; // Trouver le bon LabelVote dans DataListReponse
                foreach (PollAnswer answer in answers)
                {
                    PollVoteCollection pvc = SessionState.VotesEnCours.FindByAnswerID(answer.PollAnswerId);
                    if (pvc.Count >= 1)   // surement un seul mais ...
                    {
                        Label lbl = ( Label )dl.Controls[indexReponse].FindControl("LabelVote");
                        lbl.Text = "X";

                        if (TypeReponse.EstTextuelle(answer.TypeReponse))
                        {
                            Label lblVoteTexte = ( Label )dl.Controls[indexReponse].FindControl("LabelVoteTexte");
                            lblVoteTexte.Text = pvc[0].Vote;
                        }
                    }
                    indexReponse += 1;
                }
            }
        }
    }
예제 #6
0
    private void BuildDataList()
    {
        Reporter.Trace("BuildDataList");

        // AME19102010 Mode Pagination - Il y a t-il plusieurs pages ?
        if (modePage())
        {
            // AME19102010 - Mettre ou remettre les boutons des pager en fonction de CurrentPage
            if (CurrentPage == 0)   // premiere page
            {
                ButtonPagePrecedenteHaut.Visible = false;
                ButtonPagePrecedenteBas.Visible  = false;
                ButtonPageSuivanteHaut.Visible   = true;
                ButtonPageSuivanteBas.Visible    = true;
            }
            if (CurrentPage > 0)
            {
                ButtonPagePrecedenteHaut.Visible = true;
                ButtonPagePrecedenteBas.Visible  = true;
                ButtonPageSuivanteHaut.Visible   = true;
                ButtonPageSuivanteBas.Visible    = true;
            }
            if (nombrePage() > 0 && CurrentPage + 1 >= nombrePage()) // derniere page
            {
                CurrentPage = nombrePage() - 1;                      // si on a change la pagination CurrentPage ne peut pas depasser nombrePage() - 1
                ButtonPagePrecedenteHaut.Visible = true;
                ButtonPagePrecedenteBas.Visible  = true;
                ButtonPageSuivanteHaut.Visible   = false;
                ButtonPageSuivanteBas.Visible    = false;
            }

            PagedDataSource pagedDataSource = new PagedDataSource();
            pagedDataSource.AllowPaging      = true;
            pagedDataSource.DataSource       = SessionState.Questions;
            pagedDataSource.PageSize         = int.Parse(SessionState.MemberSettings.TaillePageQuestions);
            pagedDataSource.CurrentPageIndex = CurrentPage;

            LabelPageCouranteHaut.Text    = (CurrentPage + 1).ToString() + "/" + nombrePage().ToString();
            LabelPageCouranteBas.Text     = LabelPageCouranteHaut.Text;
            LabelPageCouranteHaut.ToolTip = "Page courante/Nombre de pages - taille d'une page : " + SessionState.MemberSettings.TaillePageQuestions;
            LabelPageCouranteBas.ToolTip  = LabelPageCouranteHaut.ToolTip;

            PanelPagerHaut.Visible = true;
            PanelPagerBas.Visible  = true;

            DataListQuestion.DataSource = pagedDataSource;
        }
        else
        {
            PanelPagerHaut.Visible      = false;
            PanelPagerBas.Visible       = false;
            DataListQuestion.DataSource = SessionState.Questions;
        }
        DataListQuestion.DataBind();

        // Trouver toutes les reponses
        foreach (DataListItem dli in DataListQuestion.Items)
        {
            DataList dl = new DataList();
            dl = ( DataList )dli.FindControl("DataListReponse");

            HiddenField hf = new HiddenField();
            hf = ( HiddenField )dli.FindControl("PollQuestionId");
            Guid pollQuestionId          = new Guid(hf.Value);
            PollAnswerCollection answers = PollAnswerCollection.GetByPollQuestionID(pollQuestionId);

            dl.DataSource = answers;
            dl.DataBind();

            DropDownList ddlTypReponse = ( DropDownList )dli.FindControl("DropDownListTypeReponse");
            ddlTypReponse.DataSource = TypeReponse.List();
            ddlTypReponse.DataBind();
            ddlTypReponse.Items.Insert(0, new ListItem("Type de Réponse", "-1"));

            // Par defaut on propose toujours le type de reponse "Choix"
            ddlTypReponse.SelectedValue = TypeReponse.Choix;
        }
    }