private void Reload()
        {
            try
            {
                txtAttribute.Text        = string.Empty;
                cboAttribute.ItemsSource = null;
                switch (mode)
                {
                case Mode.Answer:
                    answers = AnswerManager.Load();
                    cboAttribute.ItemsSource = answers;
                    break;

                case Mode.Question:
                    questions = QuestionManager.Load();
                    cboAttribute.ItemsSource = questions;
                    break;
                }

                cboAttribute.DisplayMemberPath = "Text";
                cboAttribute.SelectedValuePath = "Id";
            }


            catch (Exception ex)
            {
                throw ex;
            }
        }
    // Use this for initialization
    void Start()
    {
        // Singleton pattern
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        thereIsQuestion = false;
        //questionFinished = false;
        timer = new Timer();
        disableTimerText();

        // Subscribes to OnSecondNoteChange (from IntervalPlayer script) to receive the second note when a new interval is set
        IntervalPlayer.OnSecondNoteChange += receiveExpectedNote;
        // Subscribes to OnFirstNoteChange (from IntervalPlayer script) to receive the first note when a new interval is set
        IntervalPlayer.OnFirstNoteChange += setFirstNote;
        // Subscribes to OnPlayedSecondNote (from IntervalPlayer script) to check when the second note of an interval is being played
        IntervalPlayer.OnPlayedSecondNote += resetTimer;
        IntervalPlayer.OnPlayedSecondNote += enableTimerText;
        // Subscribes to OnPressedKey (from PressKey script) to check when a key is pressed in the piano object
        PressKey.OnPressedKeyIdentify += processAnswer;
    }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (mode)
                {
                case Mode.Answer:
                    AnswerManager.Insert(new Answer {
                        Text = txtAttribute.Text
                    });
                    break;

                case Mode.Question:
                    QuestionManager.Insert(new Question {
                        Text = txtAttribute.Text
                    });
                    break;
                }

                Reload();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        /// <summary>
        /// Votes for answers
        /// </summary>
        /// <param name="answerid">Answer Id</param>
        /// <param name="vote">Vote</param>
        /// <returns></returns>
        public ActionResult VoteForAnswer(int answerid, int vote)
        {
            if (!Request.IsAuthenticated)
            {
                //Check if the user logged in
                return(Json(Resources.Global.YouHaveToLoginBeforeVote));
            }
            else
            {
                //Check if the user already voted for this answer
                bool isVoted = VoteManager.IsVotedForAnswer(answerid, WebSecurity.GetUserId(User.Identity.Name));
                if (isVoted)
                {
                    return(Json(Resources.Global.YouAlreadyVotedForThisAnswer));
                }


                //Check if the user want to vote for his own question
                if (AnswerManager.GetAnswer(answerid).UserId == WebSecurity.GetUserId(User.Identity.Name))
                {
                    return(Json(Resources.Global.YouCantVoteForYourOwnAnswer));
                }
                //Store the vote
                VoteManager.VoteAnswer(answerid, WebSecurity.GetUserId(User.Identity.Name), vote);

                return(Json(AnswerManager.GetVote(answerid)));
            }
        }
Example #5
0
        /// <summary>
        /// Add Answer.
        /// </summary>
        /// <returns></returns>
        public void AddAnswer(AnswerViewModel answerentry)
        {
            try
            {
                Answer _answer = ObjectMapper.Map <AnswerViewModel, Model.Entities.Answer>(answerentry);
                //Add Answer
                _answer.Question_Id = answerentry.Question_Id;
                _answer.QuizEntryId = answerentry.QuizEntryId;
                Answer newanswer = AnswerManager.Add(_answer);
                int    answerId  = newanswer.Id;

                //add Answer Questions Choices
                if (answerentry.Answers.Count() > 0)
                {
                    foreach (var item in answerentry.Answers)
                    {
                        AnswerQuestionChoice _answerquestion = ObjectMapper.Map <AnswerQuestionChoiceViewModel, Model.Entities.AnswerQuestionChoice>(item);
                        _answerquestion.AnswerId         = answerId;
                        _answerquestion.QuestionChoiceId = item.QuestionChoiceId;
                        AnswerQuestionChoiceManager.Add(_answerquestion);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
        }
Example #6
0
 /// <summary>
 /// Constructor, initializing Lists as well as setting the ItemsSource for the dataGrid
 /// </summary>
 public CreateQuestionWindow()
 {
     InitializeComponent();
     Answers       = new ObservableCollection <Answer>();
     AnswerManager = new AnswerManager();
     AnswersDataGrid.ItemsSource = Answers;
 }
Example #7
0
        /// <summary>
        /// Get the point results for Unique questions in a quizEntry
        /// </summary>
        /// <param name="quizId">The quiz Id</param>
        /// <param name="quizEntryID">Teh Quiz Entry ID</param>
        /// <returns>Points Result for unique questions in a quizEntry</returns>
        private int GetResultsForUniqueQuestions(int quizId, int quizEntryID)
        {
            int result = 0;

            try
            {
                //AnswerQuestionChoices
                List <AnswerQuestionChoice> answerquestionList = AnswerQuestionChoiceManager.GetAll();

                //answer
                List <Answer> answerList = AnswerManager.GetAnswersByQuizEntryId(quizEntryID);

                //Questionchoices for unique answer
                List <QuestionChoice> questionschoicesUniqueList = QuestionChoiceManager.GetCorrectQuestionForUnique();

                //Question
                List <Question> questionlist = QuestionManager.GetQuestionsByQuizId(quizId);

                //Get the Results for UNIQUE CHOICE QUESTION
                result =
                    (from Aq in answerquestionList
                     join a in answerList on Aq.AnswerId equals a.Id
                     join qc in questionschoicesUniqueList on Aq.QuestionChoiceId equals qc.Id
                     join q in questionlist on a.Question_Id equals q.Id
                     select qc).Sum(x => x.PointsValue);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
            return(result);
        }
Example #8
0
    void Start()
    {
        screenSaver   = GetComponent <ScreenSaver>();
        touchInput    = GetComponent <TouchInput>();
        answerManager = GetComponent <AnswerManager>();

        for (int i = 0; i < topicButtons.Length; i++)
        {
            int j = i;
            topicButtons[j].GetComponent <Button>().onClick.AddListener(delegate { SwitchTopic(j); });
            topicButtons[j].GetComponent <ButtonHighlighter>().Init();
        }
        currentTopic = -1;
        SwitchTopic(currentTopic);

        for (int i = 0; i < Enum.GetNames(typeof(Category)).Length; i++)
        {
            int      j        = i;
            Category category = (Category)j;
            var      button   = Instantiate(categoryButtonPrefab, categoryRoot);
            button.GetComponent <Button>().onClick.AddListener(delegate { SwitchCategory((int)category); });
            string name = "";
            switch (category)
            {
            case Category.Categorie1:
                name = "Versicherungs-\nunternehmen";
                break;

            case Category.Categorie2:
                name = "Pensionskassen\n";
                break;

            case Category.Categorie3:
                name = "Betriebliche\nVorsorgekassen  ";
                break;

            case Category.Categorie4:
                name = "Kreditinstitute\n ";
                break;

            case Category.Categorie5:
                name = "Wertpapier-\ndienstleister";
                break;

            case Category.Categorie6:
                name = "Fondsindustrie\n ";
                break;
            }
            button.GetComponentInChildren <Text>().text = name;
            button.name = name;
            button.GetComponent <ButtonHighlighter>().Init();
            categoryButtons.Add(button);
        }
        currentCategory = -1;
        SwitchCategory(currentCategory);
        okButton.GetComponent <ButtonAnimator>().onAnimationFinished.AddListener(delegate { OnOkButtonClicked(); });
        answerSlider.GetComponent <Slider>().onValueChanged.AddListener(OnAnswerSliderValueChanged);
        answerSlider.GetComponent <FadeObject>().Init();
        ActivateOKButton(false);
    }
Example #9
0
 void Awake()
 {
     questionManager = GameObject.Find("questionManager").GetComponent <QuestionManager>();
     answerManager   = GameObject.Find("answerManager").GetComponent <AnswerManager>();
     Name            = gameObject.name;
     storePoint      = GameObject.Find("LeftDown").transform.FindChild("ShopingCart").FindChild("storePosition");
 }
Example #10
0
        public static string UpdateAnswer(int ansId, string answer)
        {
            Answers ans = new Answers();

            ans.Id     = ansId;
            ans.Answer = answer;
            return(AnswerManager.IsAnswerUpdated(ans));
        }
Example #11
0
 public QuestionsController(ILogger <QuestionsController> logger, IConfiguration config,
                            QuestionManager questionManager, AnswerManager answerManager)
 {
     this.config          = config;
     this.logger          = logger;
     this.questionManager = questionManager;
     this.answerManager   = answerManager;
 }
Example #12
0
 public void Awake()
 {
     //AÑADIMOS LOS DIALOGOS CARGADOS DEL XML
     dialogueClass_Class    = dialogueClass.GetComponent <LoadXml>().DClass;
     AnswerManager          = new AnswerManager();
     DictionaryE            = goDictionary.GetComponent <DictionaryEvent>();
     CameraCenterController = Camera.main.GetComponent <CameraCenterController>();
 }
Example #13
0
 public AnswersController(ILogger <AnswersController> logger, IConfiguration config,
                          AnswerManager answerManager, ResponseManager responseManager)
 {
     this.config          = config;
     this.logger          = logger;
     this.answerManager   = answerManager;
     this.responseManager = responseManager;
 }
Example #14
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     Invoke("GetOnPlayerSelected", 0.2f);
 }
Example #15
0
        public void DeleteTest()
        {
            List <Answer> answers = AnswerManager.Load();
            Answer        answer  = answers.FirstOrDefault(a => a.Text == "Waffles");

            int results = AnswerManager.Delete(answer.Id, true);

            Assert.IsTrue(results > 0);
        }
Example #16
0
 public void Reload()
 {
     cboAnswers.ItemsSource = null;
     answers = AnswerManager.Load();
     cboAnswers.ItemsSource       = answers;
     cboAnswers.DisplayMemberPath = "Text";
     cboAnswers.SelectedValuePath = "Id";
     cboAnswers.SelectedIndex     = 0;
 }
Example #17
0
        public static string InsertAnswer(string ans, int qId, int uId)
        {
            Answers answer = new Answers();

            answer.Answer     = ans;
            answer.QuestionId = qId;
            answer.UserId     = uId;

            return(AnswerManager.IsAnswerInserted(answer));
        }
Example #18
0
 public ActionResult EditAnswer(Answer data, string AnsId)
 {
     data.Id     = Int32.Parse(AnsId);
     data.UserId = WebSecurity.CurrentUserId;
     if (ModelState.IsValid)
     {
         AnswerManager.EditAnswer(data);
     }
     return(RedirectToAction("Index"));
 }
Example #19
0
        private bool mUserWasDisconnected; // User was disconnected due to server/network crash

        #endregion Fields

        #region Constructors

        public Network(UserManager prUserManager, QuestionManager prQuestionManager, 
            AnswerManager prAnswerManager, IOProcessor prIOProcessor, ChatManager prChatManager)
        {
            mIOProcessor = prIOProcessor;
            mQuestionManager = prQuestionManager;
            mUserManager = prUserManager;
            mAnswerManager = prAnswerManager;
            mChatManager = prChatManager;
            mTutor = new User();
        }
Example #20
0
        public void InsertTest()
        {
            Answer answer = new Answer();

            answer.Id        = Guid.NewGuid();
            answer.Text      = "Test";
            answer.IsCorrect = false;
            bool results = AnswerManager.Insert(answer, true);

            Assert.IsTrue(results);
        }
Example #21
0
        public HomeController()
        {
            _manager = new HomeManager();
            var unitOfWork = new NhibernateUnitOfWork();

            _courseManager    = new CourseManager(new NHibernateRepository <Course>(unitOfWork), unitOfWork);
            _subscribeManager = new SubscribeManager(new NHibernateRepository <Subscription>(unitOfWork), unitOfWork);
            _answerManager    = new AnswerManager(new NHibernateRepository <Answer>(unitOfWork), unitOfWork);
            _questionManager  = new QuestionManager(new NHibernateRepository <Question>(unitOfWork), unitOfWork);
            _userManager      = new UserManager(new NHibernateRepository <User>(unitOfWork), unitOfWork);
        }
Example #22
0
 private void Awake()
 {
     StartCoroutine(wordDictionary.LoadWordData());
     wordDictionary.ChooseRandomWord();
     currentBacktrackingWords = wordDictionary.backtrackingWords;
     for (int d = 0; d < wordDictionary.backtrackingWords.Count; d++)
     {
         AnswerManager answerManager = Instantiate(answerdObject, playGroundGameObject.transform, false).GetComponent <AnswerManager>();
         answerManager.MyWord = wordDictionary.backtrackingWords[d];
     }
 }
Example #23
0
        public static string InsertAnsDownVote(int ansId, int userId)
        {
            AnswerVote answerVote = new AnswerVote();

            answerVote.DownVote   = 1;
            answerVote.AnswerId   = ansId;
            answerVote.UserId     = userId;
            answerVote.IsDownVote = 1;

            return(AnswerManager.IsAnsDownVoteInsert(answerVote));
        }
Example #24
0
        public void UpdateTest()
        {
            List <Answer> answers = AnswerManager.Load();
            Answer        answer  = answers.FirstOrDefault(a => a.Text == "Waffles");

            answer.Text      = "test";
            answer.IsCorrect = false;
            int results = AnswerManager.Update(answer, true);

            Assert.IsTrue(results > 0);
        }
Example #25
0
 protected virtual void Start()
 {
     answerManager      = GameObject.Find("answerManager").GetComponent <AnswerManager>();
     questionManager    = GameObject.Find("questionManager").GetComponent <QuestionManager>();
     child              = transform.GetChild(0).gameObject;
     leftCreatePosition = questionManager.leftCreatePoint.GetComponent <RectTransform>().position;
     size             = transform.GetComponent <RectTransform>().sizeDelta;
     childSize        = child.GetComponent <RectTransform>().sizeDelta;
     audioSource      = transform.GetComponent <AudioSource>();
     audioSource.clip = cryVoice;
     audioSource.Play();
 }
Example #26
0
        /// <summary>
        /// Returns a collection of Assessment objects that are connected to the specified user.
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public IEnumerable <Assessment> GetAssessmentsForUser(int userId)
        {
            List <Assessment> list = new List <Assessment>();

            using (var db = new CSET_Context())
            {
                var query = (from uu in db.USERS
                             join ac in db.ASSESSMENT_CONTACTS on uu.UserId equals ac.UserId
                             join aa in db.ASSESSMENTS on ac.Assessment_Id equals aa.Assessment_Id
                             join ii in db.INFORMATION on aa.Assessment_Id equals ii.Id
                             join cc in db.USERS on aa.AssessmentCreatorId equals cc.UserId
                             where uu.UserId == userId

                             select new
                {
                    ID = aa.Assessment_Id,
                    AssessmentName = ii.Assessment_Name,
                    StartDate = aa.AssessmentCreatedDate,
                    CreatorName = cc.FirstName + " " + cc.LastName,
                    LastModifiedDate = aa.LastAccessedDate
                });

                var hits = query.ToList();
                foreach (var h in hits)
                {
                    Assessment a = new Assessment
                    {
                        AssessmentId          = h.ID,
                        AssessmentName        = h.AssessmentName,
                        AssessmentCreatedDate = Utilities.UtcToLocal(h.StartDate),
                        CreatorName           = h.CreatorName
                    };

                    if (h.LastModifiedDate != null)
                    {
                        a.LastModifiedDate = Utilities.UtcToLocal((DateTime)h.LastModifiedDate);
                    }

                    // See if any of the assessment's active answers are marked for review
                    AnswerManager ansMan      = new AnswerManager(a.AssessmentId);
                    List <int>    myAnswerIds = ansMan.ActiveAnswerIds();
                    a.MarkedForReview = db.ANSWER.Where(ans => myAnswerIds.Contains(ans.Answer_Id) && (ans.Mark_For_Review ?? false)).Count() > 0;

                    list.Add(a);
                }
            }

            return(list);
        }
Example #27
0
        public ActionResult EditAnswer(string actId)
        {
            int actualId = Int32.Parse(actId);

            var model = AnswerManager.GetAnswer(actualId);

            //If the user is authorized to edit this answer, it returns the edit page
            if (model.UserId == WebSecurity.CurrentUserId)
            {
                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Example #28
0
        public static AnswerVoteRetrive[] GetAnswers(int id)
        {
            List <AnswerVoteRetrive> answerList = new List <AnswerVoteRetrive>();

            foreach (DataRow dtr in AnswerManager.RetriveAnswer(id).Rows)
            {
                AnswerVoteRetrive answer = new AnswerVoteRetrive();
                answer.Id            = int.Parse(dtr["Id"].ToString());
                answer.Answer        = dtr["Answer"].ToString();
                answer.DateTime      = dtr["DateTime"].ToString();
                answer.Name          = dtr["Name"].ToString();
                answer.UpVoteCount   = int.Parse(dtr["PostiveCount"].ToString());
                answer.DownVoteCount = int.Parse(dtr["NegativeCount"].ToString());
                answerList.Add(answer);
            }
            return(answerList.ToArray());
        }
Example #29
0
        public void InsertTest()
        {
            List <Question> questions = QuestionManager.Load();
            Question        question  = questions.FirstOrDefault(a => a.Text == "What color is #51DFFF");
            List <Answer>   answers   = AnswerManager.Load();
            Answer          answer    = answers.FirstOrDefault(a => a.Text == "Waffles");

            Response response = new Response();

            response.Id           = Guid.NewGuid();
            response.AnswerId     = answer.Id;
            response.QuestionId   = question.Id;
            response.ResponseDate = DateTime.Now;
            bool results = ResponseManager.Insert(response, true);

            Assert.IsTrue(results);
        }
Example #30
0
    /// <summary>
    /// 初始化
    /// </summary>
    void InitAnswerUI()
    {
        this.m_answerManager = DataManager.Manager <AnswerManager>();

        if (m_answerManager.InAnswerCopy == true)
        {
            m_trans_AnswerRoot.gameObject.SetActive(true);

            this.m_answerState = m_answerManager.AnswerState;

            InitAnswerStateUI(this.m_answerState);
        }
        else
        {
            m_trans_AnswerRoot.gameObject.SetActive(false);
        }
    }
Example #31
0
    void Awake()
    {
        if(TransitionData.CurrentLevel.answer != null)
        {
            answer = TransitionData.CurrentLevel.answer;
            image.texture = Resources.Load(TransitionData.CurrentLevel.image) as Texture;
        }

        _answerManager = new AnswerManager(answer, OnWon);
        _answerManager.ListenTo(_answerSlotPool);

        _slotFactory = new SlotFactory(tilePrefab, slotPrefab, _slotPool, _answerSlotPool);
        _tileLayoutCreator = new TileLayoutCreator(tileWidth, tilesPerRow, tilesY, _slotFactory);
        _answerSlotLayoutCreator = new AnswerSlotLayoutCreator(tileWidth, tilesPerRow, slotsY, _slotFactory);

        _tileLayoutCreator.CreateTileLayout(GenerateTileLettersFromAnswer());
        _answerSlotLayoutCreator.CreateAnswerSlotLayout(answer.Length);
    }
Example #32
0
        /// <summary>
        /// From list of the question make a QuestionIndexModel list to index page
        /// </summary>
        /// <param name="questions">Question list</param>
        /// <returns></returns>
        public static List <QuestionIndexModel> ToQuestionIndexModel(IEnumerable <Question> questions)
        {
            List <QuestionIndexModel> qim = new List <QuestionIndexModel>();

            foreach (var item in questions)
            {
                var add = new QuestionIndexModel();
                add.Question     = item;
                add.Answers      = AnswerManager.GetAllAnswerToOneQuestion(item.Id).Count;
                add.Vote         = QuestionManager.GetVote(item.Id);
                add.Tags         = TagManager.GetAllTagToOneQuestion(item.Id);
                add.QuestionUser = UserManager.GetUserById(item.UserId);

                qim.Add(add);
            }

            return(qim);
        }
Example #33
0
 void Awake()
 {
     instance = this;
 }