Пример #1
0
        private void Delete()
        {
            QuestionForm frm = new QuestionForm();

            frm.Msg = "Delete this job?";
            if (frm.ShowDialog() == DialogResult.OK)
            {
                DataGridViewRow row = GetSelectedRowFromCell(gridJobs);
                if (row == null)
                {
                    return;
                }
                gridJobs.Rows.Remove(row);
                if (row.Cells[0].Value == null)
                {
                    //RefreshFiles();
                    ClearFiles();
                    return;
                }
                string       name      = row.Cells[0].Value.ToString();
                JobsBO       bo        = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO));
                JobContainer container = bo.FindByName(name);
                if (container != null)
                {
                    bo.Delete(container);
                    bo.Save();
                    //RefreshFiles();
                }
            }
        }
        public StyledQuestionFormControl(QuestionForm form, IEnumerable<PageControl> pages, IEnumerable<QuestionWidget> questionWidgets, OutputWindow outputWindow)
            : this()
        {
            _pages = pages;
            _questionForm = form;
            _questionWidgets = questionWidgets;
            _outputWindow = outputWindow;

            foreach (var pageControl in pages)
            {
                pageControl.NavigateBackwards += PageControl_NavigateBackwards;
                pageControl.NavigateForwards += PageControl_NavigateForwards;
            }

            foreach (var questionWidget in questionWidgets)
            {
                if (!questionWidget.IsReadOnly)
                {
                    questionWidget.QuestionAnswered += QuestionWidget_QuestionAnswered;
                }
            }

            // Paging is not yet supported. Only the first page is shown.
            Controls.Add(pages.First());
            Interpretet();
        }
        private void                Ok()
        {
            try
            {
                if (mPanel.mBmp != null && ReferenceEquals(mPanel.mBmp, mBmp) == false)
                {
                    mPanel.mBmp.Dispose();
                }

                if (mPanel.mImgMemStrm != null && ReferenceEquals(mPanel.mImgMemStrm, mImgMemStrm) == false)
                {
                    mPanel.mImgMemStrm.Close();
                }

                mPanel.mImgMemStrm = mImgMemStrm;
                mPanel.mBmp        = mBmp;
                mPanel.IsContainer = IsContainer;

                if (mPanel.Width != mBmp.Width || mPanel.Height != mBmp.Height)
                {
                    if (QuestionForm.askQuestion("Fit panel to image size?", this) == DialogResult.Yes)
                    {
                        mPanel.fitSize();
                    }
                }

                mPanel.updateProperties();

                DialogResult = DialogResult.OK;
            }
            catch (Exception lExc)
            {
                MessageForm.showMessage(lExc.Message, this);
            }
        }
Пример #4
0
        /// <summary>
        /// Serializes the question form into XML accepted by Mechanical Turk
        /// </summary>
        /// <param name="form">A <see cref="QuestionForm"/> instance to serialize</param>
        /// <returns>XML string</returns>
        public static string SerializeQuestionForm(QuestionForm form)
        {
            if (form == null)
            {
                throw new ArgumentNullException("form", "Can't serialize null form");
            }

            string s1 = XmlUtil.SerializeXML(form);

            int i1 = s1.IndexOf("<Overview>");

            if (i1 == -1)
            {
                i1 = s1.IndexOf("<Question>");
            }

            if (i1 == -1)
            {
                throw new ArgumentException("Cannot serialize question form (contains no questions)");
            }

            s1 = InjectCDataBlocksForFormattedContents(s1);
            s1 = string.Format(TPL_FREE_TEXT_QUESTION_FORM,
                               s1.Substring(i1, s1.IndexOf("</QuestionForm>") - i1));

            return(s1);
        }
Пример #5
0
        public void UpdateQuestionForm(long id, QuestionForm questionForm)
        {
            // If there are no question form with the id throw an expcetion
            if (!QuestionFormExistsById(id))
            {
                throw new QuestionFormDoesntExistsException();
            }

            var existing = _context
                           .QuestionForms
                           .Include(qf => qf.Questions)
                           .SingleOrDefault(qf => qf.Id == id);

            // Remove the old questions
            foreach (var question in existing.Questions.ToList())
            {
                _context.Questions.Remove(question);
            }

            // Save the new date
            existing.Name      = questionForm.Name;
            existing.Active    = questionForm.Active;
            existing.Questions = questionForm.Questions;
            _context.SaveChanges();
        }
Пример #6
0
 public void Visit(QuestionForm questionForm)
 {
     foreach (var statement in questionForm.Statements)
     {
         statement.Accept(this);
     }
 }
Пример #7
0
        /// <summary>
        /// Tests the conversion to Question object of a single question in a form by checking if
        /// the Id and Label match. The question does not contain an initialization
        /// of the value.
        /// </summary>
        public void TestSingleSimpleQuestion()
        {
            int          desiredQuestionCount = 1;
            int          questionCount        = 0;
            QuestionForm form = TestHelper.ParseInputString(TestValues.SingleSimpleQForm);

            questionCount = form.Questions.Count;

            if (questionCount == desiredQuestionCount)
            {
                Question question = form.Questions.ElementAt(0).Value;
                Tuple <bool, List <string> > result = TestQuestion(question, TestValues.SimpleQId, TestValues.SimpleQLabel);
                TestHelper.LogToConsole(result.Item2);
                if (result.Item1)
                {
                    TestHelper.LogToConsole("Test 1 simple question PASSED");
                }
                else
                {
                    TestHelper.LogToConsole("Test 1 simple question FAILED");
                }
            }
            else
            {
                TestHelper.LogQuestionCountFail("1 simple question", questionCount, desiredQuestionCount);
            }
        }
Пример #8
0
        public StyledQuestionFormControl(QuestionForm form, IEnumerable <PageControl> pages, IEnumerable <QuestionWidget> questionWidgets, OutputWindow outputWindow)
            : this()
        {
            _pages           = pages;
            _questionForm    = form;
            _questionWidgets = questionWidgets;
            _outputWindow    = outputWindow;

            foreach (var pageControl in pages)
            {
                pageControl.NavigateBackwards += PageControl_NavigateBackwards;
                pageControl.NavigateForwards  += PageControl_NavigateForwards;
            }

            foreach (var questionWidget in questionWidgets)
            {
                if (!questionWidget.IsReadOnly)
                {
                    questionWidget.QuestionAnswered += QuestionWidget_QuestionAnswered;
                }
            }

            // Paging is not yet supported. Only the first page is shown.
            Controls.Add(pages.First());
            Interpretet();
        }
        private void                    tsButton_Paste_Click(object aSender, EventArgs aEventArgs)
        {
            string[] lNames;
            object[] lValues;

            Clipboard.get(out lNames, out lValues);

            for (int i = 0; i < lNames.Length; i++)
            {
                try
                {
                    mHolder.add(lNames[i], lValues[i], true);
                }
                catch (Exception lExc)
                {
                    var lResult = QuestionForm.askQuestion(lExc.Message + " Continue?", this);
                    if (lResult == DialogResult.No)
                    {
                        break;
                    }
                }
            }

            updateForm();
        }
        private void            tsButton_Delete_Click(object aSender, EventArgs aEventArgs)
        {
            int lCount = dataGridView_Records.SelectedRows.Count;

            if (lCount > 0)
            {
                try
                {
                    if (QuestionForm.askQuestion("Delete " + lCount.ToString() + " record(s)?", this) == DialogResult.Yes)
                    {
                        for (int i = 0; i < lCount; i++)
                        {
                            mSnapshot.deleteRecord(dataGridView_Records.SelectedRows[i].Cells[0].Value.ToString());
                        }
                        updateForm();
                    }
                }
                catch (Exception lExc)
                {
                    Log.Error("Error while user was deleting record(s) from snapshot '"
                              + mSnapshot.Name + "'. " + lExc.Message, lExc.ToString());
                    MessageForm.showMessage(lExc.Message, this);
                }
            }
        }
        public async Task <IActionResult> UpdateQuestion([FromRoute] Guid id, [FromBody] QuestionForm question)
        {
            if (id != question.Id)
            {
                return(BadRequest());
            }

            var userId = await _user.GetUserIdAsync(User);

            if (userId == null)
            {
                return(NotFound());
            }

            try
            {
                await _question.UpdateAsync(question, userId.Value);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await QuestionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #12
0
        public ValidationReport Validate(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null)
            {
                throw new ArgumentNullException("styleSheet");
            }
            if (form == null)
            {
                throw new ArgumentNullException("form");
            }

            var validators = new List <ASTChecker>
            {
                new QuestionReferencingChecker(form.GetAllQuestions()),
                new StyleAttributeChecker(),
                new WidgetTypeChecker(form.GetAllQuestions())
            };

            var report = new ValidationReport();

            foreach (var validator in validators)
            {
                validator.Validate(styleSheet, report);
            }

            return(report);
        }
Пример #13
0
        public ActionResult <QuestionFormDTO> CreateNewQuestionForm(QuestionFormDTO questionFormDTO)
        {
            // Handle error if no data is sent.
            if (questionFormDTO == null)
            {
                return(BadRequest("QuestionForm data must be set!"));
            }

            try
            {
                // Map the DTO to entity and save the entity
                QuestionForm createdEntity = _service.SaveQuestionForm(questionFormDTO.ToEntity());

                // According to the conventions, we have to return a HTTP 201 created repsonse, with field
                // "Location" in the header pointing to the created object
                return(CreatedAtAction(
                           nameof(GetQuestionForm),
                           new { id = createdEntity.Id },
                           new QuestionFormDTO(createdEntity)));
            }
            catch (QuestionFormExistsException)
            {
                return(Conflict("The desired ID for the QuestionForm is already taken!"));
            }
        }
Пример #14
0
        private void            tsButton_UpdateV_Click(object aSender, EventArgs aEventArgs)
        {
            int lCount = dataGridView_Records.SelectedRows.Count;

            if (lCount > 0)
            {
                string lItem;
                object lValue;

                try
                {
                    if (QuestionForm.askQuestion("Update values for " + lCount.ToString() + " record(s)?", this) == DialogResult.Yes)
                    {
                        for (int i = 0; i < lCount; i++)
                        {
                            lItem  = dataGridView_Records.SelectedRows[i].Cells[0].Value.ToString();
                            lValue = mSnapshot.ItemBrowser.readItemOrInitValue(mSnapshot.ItemBrowser.getItemHandleByName(lItem));
                            mSnapshot.changeRecord(lItem, lItem, lValue);
                        }
                        updateForm();
                    }
                }
                catch (Exception lExc)
                {
                    Log.Error("Error while user was updating values for record(s) of snapshot '"
                              + mSnapshot.Name + "'. " + lExc.Message, lExc.ToString());
                    MessageForm.showMessage(lExc.Message, this);
                }
            }
        }
Пример #15
0
        public async Task <ActionResult <QuestionForm> > PostContact(QuestionForm questionForm)
        {
            _vyContext.QuestionForms.Add(questionForm);
            await _vyContext.SaveChangesAsync();

            return(Ok());
        }
Пример #16
0
        public Quiz Get(int id)
        {
            Quiz   quizObj          = new Quiz();
            string connectionstring = "Data Source=localhost;Initial Catalog = quizzie; User ID = sa; Password = Vardhini@98!; MultipleActiveResultSets=True";

            using (SqlConnection connection = new SqlConnection(connectionstring))
            {
                connection.Open();
                string        quizCommand    = "SELECT * FROM quiz where quiz_id=" + id + "";
                SqlCommand    sqlQuizCommand = new SqlCommand(quizCommand, connection);
                SqlDataReader sqlDataReader  = sqlQuizCommand.ExecuteReader();

                while (sqlDataReader.Read())
                {
                    quizObj.quizId         = Convert.ToInt32(sqlDataReader["quiz_id"]);
                    quizObj.userId         = Convert.ToInt32(sqlDataReader["user_id"]);
                    quizObj.quizName       = sqlDataReader["quiz_name"].ToString();
                    quizObj.quizDesc       = sqlDataReader["description"].ToString();
                    quizObj.quizSubject    = sqlDataReader["subject"].ToString();
                    quizObj.isActive       = Convert.ToBoolean(sqlDataReader["inactive"]);
                    quizObj.questionsCount = Convert.ToInt32(sqlDataReader["questions"]);
                    Console.WriteLine(quizObj.quizName, quizObj.questionsCount);
                    string              questionsCommand    = "SELECT * FROM question where quiz_id=" + id + "";
                    SqlCommand          sqlQuestionsCommand = new SqlCommand(questionsCommand, connection);
                    SqlDataReader       sqlDataReader1      = sqlQuestionsCommand.ExecuteReader();
                    List <QuestionForm> questionforms       = new List <QuestionForm>();
                    while (sqlDataReader1.Read())
                    {
                        Console.WriteLine(sqlDataReader1);
                        QuestionForm quesObj = new QuestionForm();
                        quesObj.questionId = Convert.ToInt32(sqlDataReader1["question_id"]);
                        quesObj.question   = sqlDataReader1["question_name"].ToString();

                        Console.WriteLine(quesObj.questionId.ToString(), quesObj.question);
                        quesObj.answertype = sqlDataReader1["answer_type"].ToString();
                        Console.WriteLine(quesObj.answertype);
                        string         answersCommand    = "SELECT * FROM answers where quiz_id=" + id + " and question_id=" + quesObj.questionId + "";
                        SqlCommand     sqlAnswersCommand = new SqlCommand(answersCommand, connection);
                        SqlDataReader  sqlDataReader2    = sqlAnswersCommand.ExecuteReader();
                        List <Answers> answers           = new List <Answers>();

                        while (sqlDataReader2.Read())
                        {
                            Console.WriteLine(sqlDataReader2);
                            Answers ansObj = new Answers();
                            ansObj.ansId     = Convert.ToInt32(sqlDataReader2["answer_id"]);
                            ansObj.ansText   = sqlDataReader2["answer"].ToString();
                            ansObj.iscorrect = Convert.ToBoolean(sqlDataReader2["iscorrect"]);
                            answers.Add(ansObj);
                        }
                        quesObj.answers = answers;

                        questionforms.Add(quesObj);
                    }
                    quizObj.questionforms = questionforms;
                }
            }
            return(quizObj);
        }
Пример #17
0
        public void Move(IGame game)
        {
            var questionResult = new QuestionResultDto();
            var questionForm   = new QuestionForm(questionResult, game.LabelCurrentNode);

            questionForm.ShowDialog();
            game.Play(questionResult.Result);
        }
Пример #18
0
        CheckQuestionReferences(StyleSheet styleSheet, QuestionForm questionForm)
        {
            var checker = new QLSReferenceChecker();

            questionForm.Accept(checker);
            styleSheet.Accept(checker);
            return(checker._messages.ToTuple());
        }
Пример #19
0
 public virtual T Visit(QuestionForm form)
 {
     foreach (var statement in form.Statements)
     {
         statement.Accept <T>(this);
     }
     return(default(T));
 }
        public async Task <ActionResult <Question> > UpdateQuestion(int Id_Question, QuestionForm question)
        {
            //   var accessToken = Request.Headers["Authorization"];

            var UserId = Convert.ToInt32(GetClaim("id"));

            return(Ok(await _questionService.UpdateQuestion(Id_Question, UserId, question)));
        }
Пример #21
0
        public QuestionStyleCollection GetQuestionStyles(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null) { throw new ArgumentNullException("styleSheet"); }
            if (form == null) { throw new ArgumentNullException("form"); }

            var styleEvaluator = new QuestionStyleEvaluator();

            return styleEvaluator.GetQuestionStyles(styleSheet, form.GetAllQuestions());
        }
Пример #22
0
        public Control BuildUI(StyleSheet styleSheet, QuestionStyleCollection questionStyles, QuestionForm questionForm, OutputWindow outputWindow)
        {
            _questionStyles  = questionStyles;
            _questionForm    = questionForm;
            _outputWindow    = outputWindow;
            _questionWidgets = new List <QuestionWidget>();

            return(VisitStyleSheet(styleSheet));
        }
        public ValueTable Interpretet(QuestionForm form, ValueTable context)
        {
            _context = context;
            _results = new ValueTable();

            Visit(form);

            return(_results);
        }
Пример #24
0
        public ValueTable Interpretet(QuestionForm form, ValueTable context)
        {
            if (form == null) { throw new ArgumentNullException("form"); }
            if (context == null) { throw new ArgumentNullException("context"); }

            var interpreter = new Interpreter();

            return interpreter.Interpretet(form, context);
        }
Пример #25
0
        private bool MatchWarn()
        {
            QuestionForm frm = new QuestionForm();

            frm.Msg = "WARNING:  This process can delete files from your backup.  " +
                      "It will remove any files or folders that do not currently exist in your source directory(s).\n\n" +
                      "Are you sure you want to proceed?";
            return(DialogResult.OK == frm.ShowDialog());
        }
Пример #26
0
        public ActionResult DeleteQuestions(QuestionForm form)
        {
            int ret = questionsManagaApp.DeleteQuestions(form);

            if (ret == 1)
            {
                return(Success("操作成功"));
            }
            return(Error("操作失败"));
        }
        public TriviaController(Form mainForm)
        {
            this.mainForm = mainForm;

            db = new QuizContext();


            questionForm        = new QuestionForm(this, mainForm);
            resultsForm         = new ResultsForm(this, mainForm);
            manageQuestionsForm = new ManageQuestionsForm(this, mainForm);
        }
Пример #28
0
        private List <QuestionForm> QSelectToQFormList(List <ChapterQuestionSelect> qselectList)
        {
            List <QuestionForm> qFormList = new List <QuestionForm>();

            foreach (var qselect in qselectList)
            {
                QuestionForm temp = QSelectToQForm(qselect);
                qFormList.Add(temp);
            }
            return(qFormList);
        }
Пример #29
0
        private List <QuestionForm> QTRToQFormList(List <ChapterQuestionTR> qselectList)
        {
            List <QuestionForm> qFormList = new List <QuestionForm>();

            foreach (var qtr in qselectList)
            {
                QuestionForm temp = QTRToQForm(qtr);
                qFormList.Add(temp);
            }
            return(qFormList);
        }
Пример #30
0
 private QuestionFormControl BuildUI(QuestionForm form)
 {
     try
     {
         var uiBuilder = new DefaultUIBuilder();
         return uiBuilder.BuildUI(form, Output);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during creating of the user interface.", ex);
     }
 }
Пример #31
0
 private Control BuildUI(StyleSheet styleSheet, QuestionStyleCollection questionStyles, QuestionForm form)
 {
     try
     {
         var uiBuilder = new StyleSheetUIBuilder();
         return uiBuilder.BuildUI(styleSheet, questionStyles, form, Output);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during creating of the styled user interface.", ex);
     }
 }
Пример #32
0
        private ChapterQuestionTR FormToTR(QuestionForm form)
        {
            ChapterQuestionTR qtr = new ChapterQuestionTR();

            qtr.ID        = form.KeyValue;
            qtr.Answer    = form.TRAnswer;
            qtr.ChapterID = form.ChapterID;
            qtr.CourserID = form.CourseID;
            qtr.Score     = form.Score;
            qtr.QName     = form.QName;
            return(qtr);
        }
Пример #33
0
 private QuestionStyleCollection GetQuestionStyles(StyleSheet styleSheet, QuestionForm form)
 {
     try
     {
         var runtimeController = new QLS.Runtime.RuntimeController();
         return runtimeController.GetQuestionStyles(styleSheet, form);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during the evaluation of the question styles.", ex);
     }
 }
 private QuestionStyleCollection GetQuestionStyles(StyleSheet styleSheet, QuestionForm form)
 {
     try
     {
         var runtimeController = new QLS.Runtime.RuntimeController();
         return(runtimeController.GetQuestionStyles(styleSheet, form));
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during the evaluation of the question styles.", ex);
     }
 }
 private ValidationReport ValidateStyleSheet(StyleSheet styleSheet, QuestionForm form)
 {
     try
     {
         var runtimeController = new QLS.Runtime.RuntimeController();
         return(runtimeController.Validate(styleSheet, form));
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during the validation of the style sheet AST.", ex);
     }
 }
 private QuestionFormControl BuildUI(QuestionForm form)
 {
     try
     {
         var uiBuilder = new DefaultUIBuilder();
         return(uiBuilder.BuildUI(form, Output));
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during creating of the user interface.", ex);
     }
 }
Пример #37
0
        public QuestionFormControl(QuestionForm form, IEnumerable<QuestionWidget> questionWidgets, OutputWindow outputWindow)
            : this()
        {
            _questionForm = form;
            _outputWindow = outputWindow;

            foreach (var questionWidget in questionWidgets)
            {
                if (!questionWidget.IsReadOnly)
                {
                    questionWidget.QuestionAnswered += QuestionWidget_QuestionAnswered;
                }

                QuestionFlowLayout.Controls.Add(questionWidget);
            }

            Interpretet();
        }
Пример #38
0
        public ValidationReport Validate(QuestionForm form)
        {
            if (form == null) { throw new ArgumentNullException("form"); }

            var validators = new List<ASTChecker>
            {
                new DuplicateLabelChecker(),
                new QuestionDeclarationChecker(),
                new TypeChecker(),
                new LiteralChecker(),
            };

            var report = new ValidationReport();

            foreach (var validator in validators)
            {
                validator.Validate(form, report);
            }

            return report;
        }
Пример #39
0
        public ValidationReport Validate(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null) { throw new ArgumentNullException("styleSheet"); }
            if (form == null) { throw new ArgumentNullException("form"); }

            var validators = new List<ASTChecker>
            {
                new QuestionReferencingChecker(form.GetAllQuestions()),
                new StyleAttributeChecker(),
                new WidgetTypeChecker(form.GetAllQuestions())
            };

            var report = new ValidationReport();

            foreach (var validator in validators)
            {
                validator.Validate(styleSheet, report);
            }

            return report;
        }
Пример #40
0
 private ValidationReport ValidateQuestionForm(QuestionForm form)
 {
     try
     {
         var runtimeController = new QL.Runtime.RuntimeController();
         return runtimeController.Validate(form);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during the validation of the questionnaire AST.", ex);
     }
 }
Пример #41
0
 private ValidationReport ValidateStyleSheet(StyleSheet styleSheet, QuestionForm form)
 {
     try
     {
         var runtimeController = new QLS.Runtime.RuntimeController();
         return runtimeController.Validate(styleSheet, form);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during the validation of the style sheet AST.", ex);
     }
 }