Esempio n. 1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         String givenAnswer = Request.Form["Answer"];
         App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
         manager.SaveQuestionOfTheWeekAnswer(ConfigReader.QuestionOfTheWeekID, 2, givenAnswer);
         String url = String.Format("{0}?{1}={2}&{3}={4}", AppConstants.Pages.ANSWER_OF_THE_WEEK_MESSAGE, AppConstants.QueryString.QUESTION_ID, ConfigReader.QuestionOfTheWeekID, AppConstants.QueryString.ANSWER, givenAnswer);
         Response.Redirect(url, false);
         return;
     }
 }
Esempio n. 2
0
 protected void btnImportLinks_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
         IList<App.Models.Questions.Questions> questions = manager.GetList();
         if (questions != null && questions.Count > 0)
         {
             ImportLinksToCommentTable(questions);
             divMessage.InnerHtml = String.Format("Total {0} Links Imported to the Comments Table.", _TotalImportedLink);
         }
     }
 }
Esempio n. 3
0
 protected void SaveQuestion()
 {
     App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
     App.Models.Questions.Questions question = null;
     if (_QuestionID > 0)
     {
         question = manager.Get(_QuestionID);
     }
     else
     {
         question = new App.Models.Questions.Questions();
     }
     PopulateObject(question);
     manager.SaveOrUpdate(question);
 }
Esempio n. 4
0
 private void BindQuestionData(int questionID)
 {
     App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
     App.Models.Questions.Questions question = null;
     question = manager.Get(_QuestionID);
     if (question != null)
     {
         txtQuestion.Text = question.Question;
         txtAnswerA.Text = question.AnswerA;
         txtAnswerB.Text = question.AnswerB;
         txtAnswerC.Text = question.AnswerC;
         txtAnswerD.Text = question.AnswerD;
         txtExplanation.Text = question.Explanation;
         ddlCorrectAnswer.SelectedValue = question.CorrectAnswer;
         chkIsFunctionalTopics.Checked = question.FunctionalTopics;
         chkIsHistoryTheoryLaw.Checked = question.HistoryTheoryLaw;
         chkIsEthics.Checked = question.Ethics;
         chkIsPlanMaking.Checked = question.PlanMaking;
         chkIsPlanImplementation.Checked = question.PlanImplementation;
     }
 }
    protected void BindQuestionData()
    {
        int.TryParse(Request[AppConstants.QueryString.QUESTION_ID], out _QuestionID);
        App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
        App.Models.Questions.Questions question = manager.Get(_QuestionID);
        if (question != null)
        {
            ucChart.QuestionID = question.QuestionID;
            ucCommenting.QuestionID = question.QuestionID;

            ltrQuestion.Text = question.Question;
            String answer = Request[AppConstants.QueryString.ANSWER];
            if (String.Compare(question.CorrectAnswer, answer, true) == 0)
                ltrAnswer.Text = String.Format("Right, the correct answer is {0}", question.CorrectAnswer);
            else
                ltrAnswer.Text = String.Format("Wrong, the correct answer is {0}", question.CorrectAnswer);

            if (question.CorrectAnswer == "A")
                ltrAnswer.Text = String.Format("{0} ({1})", ltrAnswer.Text, question.AnswerA);
            else if (question.CorrectAnswer == "B")
                ltrAnswer.Text = String.Format("{0} ({1})", ltrAnswer.Text, question.AnswerB);
            else if (question.CorrectAnswer == "C")
                ltrAnswer.Text = String.Format("{0} ({1})", ltrAnswer.Text, question.AnswerC);
            else if (question.CorrectAnswer == "D")
                ltrAnswer.Text = String.Format("{0} ({1})", ltrAnswer.Text, question.AnswerD);

            ltrExplanation.Text = question.Explanation;

            App.Domain.Links.LinkManager linkManager = new App.Domain.Links.LinkManager();
            IList<App.Models.Links.Link> links = linkManager.GetLinksForQuestion(question.QuestionID);
            //BuildHtmlForLinks(links);
        }
        else
        {
            ucChart.Visible = false;
            ucCommenting.Visible = false;
        }
    }
    protected void BindQuestionList(int pageNo)
    {
        Keyword = WebUtil.GetRequestParamValueInString(AppConstants.QueryString.QUESTION_KEYWORD);
        Category = WebUtil.GetRequestParamValueInString(AppConstants.QueryString.QUESTION_CATEGORY);
        if (Category == "None")
        {
            Category = null;
        }

        SessionCache.CurrentQuestionSearchCriteriaForKeyword = null;
        SessionCache.CurrentQuestionSearchCriteriaForCategory = null;

        if (!string.IsNullOrEmpty(Keyword))
        {
            SessionCache.CurrentQuestionSearchCriteriaForKeyword = Keyword;
        }
        else
        {
            SessionCache.CurrentQuestionSearchCriteriaForCategory = Category;
        }

        int pageSize = ConfigReader.AdminQuestionListSize;
        App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
        List<Questions> questions = null;
        int totalRecord = 0;

        if (ShowQuestionsForAnswerMode)
        {
            bool filter = false;
            if (SessionCache.CurrentUser != null)
            {
                if (SessionCache.CurrentUser.Mode == "Filtered")
                {
                    filter = true;
                }
            }
            questions = manager.GetPagedListByKeywordOrCategory(pageNo, pageSize, Keyword, Category,SessionCache.CurrentUser.Author_ID,filter).ToList();
            totalRecord = manager.GetQuestionCountByKeywordOrCategory(Keyword, Category, SessionCache.CurrentUser.Author_ID, filter);
        }
        else
        {
            questions = manager.GetPagedListByKeywordOrCategory(pageNo, pageSize, null, null, SessionCache.CurrentUser.Author_ID, false).ToList();
            totalRecord = manager.GetQuestionCountByKeywordOrCategory(string.Empty, string.Empty, SessionCache.CurrentUser.Author_ID, false);
        }

        SessionCache.CurrentQuestionPageNo = pageNo;
        SessionCache.CurrentQuestionList = questions;

        if (questions == null || questions.Count == 0)
        {
            rptQuestionList.Visible = false;
            ucPager.Visible = false;
            divNoQuestionFound.Visible = true;
        }
        else
        {
            divNoQuestionFound.Visible = false;
            rptQuestionList.DataSource = questions;
            rptQuestionList.DataBind();
            BindPagerControl(pageNo, totalRecord, pageSize);
        }
    }
Esempio n. 7
0
    public static Questions GetNextQuestion(int currentQuestionID)
    {
        IList<Questions> questions = CurrentQuestionList;
        string Keyword = CurrentQuestionSearchCriteriaForKeyword;
        string Category = CurrentQuestionSearchCriteriaForCategory;

        Questions nextQuestion = null;

        if (questions != null)
        {
            for (int i = 0; i < questions.Count; i++)
            {
                if (questions[i].QuestionID == currentQuestionID && i + 1 < questions.Count)
                {
                    nextQuestion = questions[i + 1];
                }
            }
        }

        if (nextQuestion == null)
        {
            //Reload the questions based upon the current criteria
            int pageSize = ConfigReader.AdminQuestionListSize;
            App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
            int pageNo = CurrentQuestionPageNo + 1;
            CurrentQuestionPageNo = pageNo;

            if (string.IsNullOrEmpty(Keyword) && string.IsNullOrEmpty(Category))
            {
                questions = manager.GetPagedList(pageNo, 1000000).ToList();
            }
            else
            {
                bool filter = false;
                if (SessionCache.CurrentUser != null)
                {
                    if (SessionCache.CurrentUser.Mode == "Filtered")
                    {
                        filter = true;
                    }
                }
                questions = manager.GetPagedListByKeywordOrCategory(pageNo, 10000000, Keyword, Category, SessionCache.CurrentUser.Author_ID, filter).ToList();
            }

            CurrentQuestionList = questions;

            if (questions != null)
            {
                for (int i = 0; i < questions.Count; i++)
                {
                    if (questions[i].QuestionID == currentQuestionID && i + 1 < questions.Count)
                    {
                        nextQuestion = questions[i + 1];
                    }
                }
            }
        }

        return nextQuestion;
    }
Esempio n. 8
0
    //private void ValidateFaceBookUser()
    //{
    //    FBConnectAuth.FBConnectAuthentication auth = new FBConnectAuth.FBConnectAuthentication(ConfigReader.FaceBookAPIKey, ConfigReader.FaceBookSecretPhrase);
    //    if (auth.Validate() != FBConnectAuth.ValidationState.Valid)
    //    {
    //        // The request does not contain the details of a valid Facebook connect session - you'll probably want to throw an error here.
    //    }
    //    else
    //    {
    //        FBConnectAuth.FBConnectSession faceBookSession = auth.GetSession();
    //        String userId = faceBookSession.UserID;
    //        String sessionKey = faceBookSession.SessionKey;
    //    }
    //}
    private void SetInitialValues()
    {
        App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
        _NumberOfQuestions = manager.GetPagedList(1, int.MaxValue).Count;
        _LastQuestionDate = manager.LastQuestionDate().ToString(AppConstants.ValueOf.DATE_FROMAT_DISPLAY_WITH_TIME);

        _QuestionOfTheWeek = manager.Get(ConfigReader.QuestionOfTheWeekID);
        if (_QuestionOfTheWeek != null)
        {
            ViewState[QUESTION_OF_THE_WEEK_USERID] = 2;
            ViewState[CORRECT_ANSWER] = _QuestionOfTheWeek.CorrectAnswer;
        }
    }