public IActionResult Delete() { if (!_loginServices.isInAdminRoles(this.GetRoles())) { return(RedirectToAction("Login", "Accounts")); } string idParam = this.RouteData.Values["id"].ToString(); QuestionGroup model = null; if (idParam != null && idParam != string.Empty) { int recordId = Int32.Parse(idParam); model = this._context.QuestionGroups.Where(a => a.ID == recordId).FirstOrDefault(); if (model == null) { ModelState.AddModelError("Error", "ไม่พบข้อมูล"); } else { var questions = this._context.Questions.Where(w => w.QuestionGroupID == model.ID); this._context.Questions.RemoveRange(questions); this._context.QuestionGroups.Remove(model); this._context.SaveChanges(); var i = 1; foreach (var item in this._context.Questions.OrderBy(o => o.Index)) { item.Index = i; i++; } this._context.SaveChanges(); } } return(RedirectToAction("Index")); }
public async Task <object> AddAsync(string name, QuestionGroup @group) { var user = await _context.UserModels.FirstOrDefaultAsync(x => x.Name.ToLower() == name.Trim().ToLower()) ?? new UserModel() { Name = name }; var quiz = new QuizModel() { DateStarted = DateTimeOffset.Now, UserModel = user, QuestionGroup = @group, }; await _context.QuizModels.AddAsync(quiz); var result = await _context.SaveChangesAsync(); if (result == 0) { return(400); } return(new { QuizId = quiz.Id, UserName = user.Name }); }
public async Task <IActionResult> Edit(long id, [Bind("Id,Name")] QuestionGroup questionGroup) { if (id != questionGroup.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.QuestionGroup.Update(questionGroup); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionGroupExists(questionGroup.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(questionGroup)); }
public void Copy(QuestionGroup qg) { foreach (var qi in Questions.Select( q => new QuestionItem( q ) )) { qg.Items.Add(qi); } }
public void SetDefinition(QuestionGroup qGroup) { this.titleParser = qGroup; this.uim = new QGUIMaker(this, this.titleParser); this.uim.OnContentChange += new QGUIMaker.ContentChange(uim_OnContentChange); //this.BackColor = System.Drawing.Color.LightYellow; }
public ActionResult Arbitration(string questionGroupId, Int32 teacherId) { ////查询题组信息 //var testletsStructInfo = // _testletsStructQueryService.FindTestletsStructInfo(new TestletsStructQueryDto(examTestletsId: id)); //var testletsStructTeacherDto = _teacherQueryService.FindTeacherDto(testletsStructInfo.TestletsStructId, OriTeacherId); ////查询教师的评阅份数 //ViewData["DistributionNumber"] = testletsStructTeacherDto.DistributionNumber; ////评分点区域 //ViewData["ScorePoint"] = // _scorePointStructQueryService.QueryScorePointStructDto(testletsStructInfo.TestletsStructId); ////阈值 //ViewData["TestletsStruct"] = testletsStructInfo; ////查询科目信息 //ViewData["Subject"] = _subjectQueryService.FindSubjectInfoDto(testletsStructInfo.SubjectId); ////查询教师信息 //ViewData["Teacher"] = base.Teacher; QuestionGroup questionGroup = OnlineCheckManager.Instance.QuestionGroups.SingleOrDefault(s => s.QuestionGroupId.ToString() == questionGroupId); ViewData["Teacher"] = TeacherInfo; ViewData["QuestionGroup"] = questionGroup; return(View()); }
public bool UpdateQuestionGroup(QuestionGroup group) { StringBuilder queryUpdate = new StringBuilder(); queryUpdate.AppendFormat( @"Update SurveyQuestionGroupMaster set QuestionGroupCode='{0}', Admissions='{1}', Registrar='{2}', FinancialAid='{3}', Placement='{4}', Active='{5}' where QuestionGroupID={6}", group.QuestionGroupCode, group.Admissions == true ? 'Y' : 'N', group.Registrar == true ? 'Y' : 'N', group.FinancialAid == true ? 'Y' : 'N', group.Placement == true ? 'Y' : 'N', group.Active == true ? 'Y' : 'N', group.QuestionGroupID ); this.ExecuteNonQuery(CommandType.Text, queryUpdate.ToString()); return(true); }
public ActionResult QueryCallBack(string id) { //string teacherId = _teacherService.GetTeacherId(id, OriTeacherId); //var data = _testletsReviewQueryService.QueryTestletsReviewListDtos(id, teacherId).Select(x => new //{ // ReviewId=x.ReviewId, // ReviewDate=x.ReviewDate.ToString("hh:mm:ss"), // TotalScore=x.TotalScore, // TestletsId=x.TestletsId //}); //return Json(ActionHandleResult.FromSuccess(data: data), JsonRequestBehavior.AllowGet); QuestionGroup questionGroup = OnlineCheckManager.Instance.QuestionGroups.SingleOrDefault(s => s.QuestionGroupId == id); List <Question> questions = questionGroup.Questions; IEnumerable <dynamic> queuesPressChecks = questionGroup.PressReviewManager.PressReview[TeacherId].Where(s => !s.IsPressed).Select(x => new { ReviewId = x.Id, ReviewDate = x.CreateDateTime.ToString("hh:mm:ss"), TotalScore = x.Score.ToDictionary( k => questions.SingleOrDefault(s => s.QuestionId.ToString() == k.Key).QuestionNo, v => v.Value) }); return(Json(ActionHandleResult.FromSuccess(data: queuesPressChecks), JsonRequestBehavior.AllowGet)); }
public void SetActiveQuestionGroup(QuestionGroup group) { switch (group) { case QuestionGroup.MCQ: MCQQuestion.SetActive(true); PokedexNumberQuestion.SetActive(false); FillInTheBlankQuestion.SetActive(false); ScoreDisplay.SetActive(false); break; case QuestionGroup.PokedexNum: MCQQuestion.SetActive(false); PokedexNumberQuestion.SetActive(true); FillInTheBlankQuestion.SetActive(false); ScoreDisplay.SetActive(false); break; case QuestionGroup.FillInBlank: MCQQuestion.SetActive(false); PokedexNumberQuestion.SetActive(false); ScoreDisplay.SetActive(false); FillInTheBlankQuestion.SetActive(true); break; case QuestionGroup.ScoreDisplay: MCQQuestion.SetActive(false); PokedexNumberQuestion.SetActive(false); FillInTheBlankQuestion.SetActive(false); ScoreDisplay.SetActive(true); break; } }
// GET: Practice public ActionResult Index() { QuestionGroup qg = new QuestionGroup(); //return View(qg.GetQuestionSet(con)); return(View(qg.GetQuestionSetDs(con))); }
protected void btnSave_Click(object sender, EventArgs e) { QuestionGroup group; if (Request.QueryString["groupid"] != null) { group = Module.QuestionGroupGetById(Convert.ToInt32(Request.QueryString["groupid"])); } else { group = new QuestionGroup(); } group.Name = txtSubject.Text; group.Selection1 = txtSelection1.Text; group.Selection2 = txtSelection2.Text; group.Selection3 = txtSelection3.Text; group.Selection4 = txtSelection4.Text; group.Selection5 = txtSelection5.Text; group.Priority = Convert.ToInt32(txtPriority.Text); group.GoodChoice = Convert.ToInt32(ddlGoodChoice.SelectedValue); group.IsInDayboatForm = chkIsInDayboatForm.Checked; Module.SaveOrUpdate(group, UserIdentity); IList <Question> data = RepeaterToList(); foreach (Question q in data) { q.Group = group; Module.SaveOrUpdate(q, UserIdentity); } PageRedirect(string.Format("QuestionView.aspx?NodeId={0}&SectionId={1}", Node.Id, Section.Id)); }
public void AddQuestionGroup() { InputDialog dlg = new InputDialog(); dlg.Title = Resources.InputQuestionGroupName; //Enter the question group name dlg.Owner = Application.Current.MainWindow; dlg.ShowDialog(); if (dlg.DialogResult == true) { QuestionGroup questionGroupModel = new QuestionGroup() { Title = dlg.textBox.Text }; QuestionGroupVM questionGroup = new QuestionGroupVM(questionGroupModel) { Parent = this }; questionGroups.Add(questionGroup); if (SelectedQuestionGroup == null) { SelectedQuestionGroup = questionGroup; } Memorize(); } }
private void OpenQuestionGroup(QuestionGroup parentGroup) { int i; parentGroup.ChildQuestionGroups = new List <QuestionGroup>(databaseController.Select <QuestionGroup>("ParentQuestionGroupId = " + databaseController.GetIdentifier(parentGroup))); for (i = 0; i < parentGroup.ChildQuestionGroups.Count; i++) { parentGroup.ChildQuestionGroups[i].ParentQuestionGroup = parentGroup; OpenQuestionGroup(parentGroup.ChildQuestionGroups[i]); } parentGroup.Questions.Clear(); QuestionData[] datas = databaseController.Select <QuestionData>("QuestionGroupId = " + databaseController.GetIdentifier(parentGroup)); for (i = 0; i < datas.Length; i++) { parentGroup.Questions.Add(datas[i].CreateQuestion()); parentGroup.Questions[i].ParentQuestionGroup = parentGroup; parentGroup.Questions[i].Theme = databaseController.SelectParent <Theme, QuestionData>(datas[i])[0]; datas[i].Theme = parentGroup.Questions[i].Theme; questionDataDictionary.TryAdd(datas[i], parentGroup.Questions[i]); Answer[] answers = databaseController.SelectChild <QuestionData, Answer>(datas[i]); if (answers.Length == 1) { parentGroup.Questions[i].Answer = answers[0]; datas[i].Answer = answers[0]; } } }
public QuestionnaireStoreModel GetStoreModel() { var model = _questionnaireViewModel; // TODO: Check what the view model is and transform to the store model. QuestionnaireStoreModel schema = new QuestionnaireStoreModel(); schema.type = model.type; schema.fieldGroup = new List <QuestionGroup>(); foreach (QuestionGroupViewModel data in model.fieldGroup) { QuestionGroup questionGroup = new QuestionGroup(); questionGroup.fieldGroup = data.fieldGroup; questionGroup.hideExpression = data.hideExpression; questionGroup.templateOptions = data.templateOptions; questionGroup.expressionProperties = new List <ExpressionModel>(); if (data.expressionProperties != null) { foreach (var y in data.expressionProperties) { ExpressionModel epressionModel = new ExpressionModel(); epressionModel.Key = y.Key; epressionModel.Expression = y.Value; questionGroup.expressionProperties.Add(epressionModel); } } schema.fieldGroup.Add(questionGroup); } return(schema); }
public JsonResult GetQuestionGroupInfo(int id) { QuestionGroup group = uow.QuestionGroupRepo.Find(id); string result = "Name:" + group.GroupName + ",Order:" + group.GroupOrder; return(Json(result, JsonRequestBehavior.AllowGet)); }
protected void rptGroups_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.DataItem is QuestionGroup) { QuestionGroup group = (QuestionGroup)e.Item.DataItem; ValueBinder.BindLiteral(e.Item, "litGroupName", group.Name); TextBox txtComment = (TextBox)e.Item.FindControl("txtComment"); Repeater rptQuestions = (Repeater)e.Item.FindControl("rptQuestions"); _currentOptions = group.Selections; rptQuestions.DataSource = group.Questions; rptQuestions.DataBind(); foreach (AnswerGroup grp in _currentSheet.Groups) { if (grp.Group.Id == group.Id) { txtComment.Text = grp.Comment; break; } } if (group.Questions.Count > 0) { _hasQuestion = true; Repeater rptOptions = (Repeater)e.Item.FindControl("rptOptions"); rptOptions.DataSource = _currentOptions; rptOptions.DataBind(); } else { _hasQuestion = false; } } }
public ActionResult CallBack(string testletsStructId, string reviewId) { String questionGroupId = testletsStructId; QuestionGroup questionGroup = OnlineCheckManager.Instance.QuestionGroups.SingleOrDefault( s => s.QuestionGroupId.ToString() == questionGroupId); ViewData["Teacher"] = TeacherInfo; ViewData["QuestionGroup"] = questionGroup; ////查询题组信息 //var testletsStructInfo = // _testletsStructQueryService.FindTestletsStructInfo(new TestletsStructQueryDto(testletsStructId)); //var testletsStructTeacherDto = _teacherQueryService.FindTeacherDto(testletsStructId, OriTeacherId); //ViewData["ScorePoint"] = _scorePointStructQueryService.QueryScorePointStructDto(testletsStructId); //ViewData["TestletsStruct"] = testletsStructInfo; ////查询教师的评阅份数 //ViewData["DistributionNumber"] = testletsStructTeacherDto.DistributionNumber; ////查询科目信息 //ViewData["Subject"] = _subjectQueryService.FindSubjectInfoDto(testletsStructInfo.SubjectId); ////查询教师信息 //ViewData["Teacher"] = base.Teacher; //var testlets = // _testletsQueryService.QueryTestletsDtos(new TestletsQueryDto(testletsStructId)).FirstOrDefault(); //ViewData["Testlets"] = testlets; return(View()); }
async Task LoadQuestions(EQuestionGroupStatus status) { if (IsBusy) { return; } IsBusy = true; _questionGroups.Clear(); var address = StateService.CurrentAddress; var customer = StateService.CurrentCustomer; var surveyType = await new DbService().FindSurveyType(address.Type, customer.CustomerSurveyID); if (surveyType != null) { var questions = await new DbService().GetQuestions(surveyType.Value, customer.CustomerSurveyID); var groupped = questions.GroupBy(x => x.Main_Element).ToList(); foreach (var g in groupped) { if (g.Key == "SECONDARY") { continue; } var gr = new QuestionGroup() { Name = g.Key, Questions = new List <Question>(g) }; gr.IsCompleted = await new DbService().FindIfQuestionGroupIsCompleted(address.Id, gr.Name); _questionGroups.Add(gr); } _questionGroups = _questionGroups.OrderBy(x => x.Questions.First().Question_Order).ToList(); if (status == EQuestionGroupStatus.All) { lstGroupss.ItemsSource = _questionGroups; } else { lstGroupss.ItemsSource = _questionGroups.Where(x => x.IsCompleted == (status == EQuestionGroupStatus.Complete)).ToList(); } Task.Factory.StartNew(() => { UpdateAddressStatus(_questionGroups); }); } else { IsBusy = false; } }
public int CheckOrderExists(int order, int?id) { QuestionGroup group = _context.Set <QuestionGroup>() .FirstOrDefault( b => b.GroupOrder == order && (id == null || b.ID != id)); return(group == null ? 0 : 1); }
public int CheckNameExists(string GroupName, int?id) { QuestionGroup group = _context.Set <QuestionGroup>() .FirstOrDefault( b => b.GroupName == GroupName.Trim() && (id == null || b.ID != id)); return(group == null ? 0 : 1); }
public static void UpdateQuestionGroup(this QuestionGroup qGroup, QuestionGroupViewModel qGroupVm) { qGroup.ID = qGroupVm.ID; qGroup.Index = qGroupVm.Index; qGroup.IsKeyword = qGroupVm.IsKeyWord; qGroup.FormQuestionAnswerID = qGroupVm.FormQuestionAnswerID; qGroup.BotID = qGroupVm.BotID; qGroup.CreatedDate = DateTime.Now; }
public List <QuestionGroup> GetQuestionGroupList(int multi = 1) { var list = new List <QuestionGroup>(); _application = new Microsoft.Office.Interop.Excel.Application(); // application.Workbooks.Open(Level1FileName); _application.Visible = false; switch (multi) { case 1: _application.Workbooks.Open(_folder + Level1FileName); break; case 2: _application.Workbooks.Open(_folder + Level2FileName); break; case 3: _application.Workbooks.Open(_folder + Level3FileName); break; } foreach (Microsoft.Office.Interop.Excel.Worksheet sheet in _application.Workbooks[1].Worksheets) { var i = 1; var questions = new List <Question>(); var columns = (Microsoft.Office.Interop.Excel.Range)sheet.Rows[i]; while (((Microsoft.Office.Interop.Excel.Range)columns.Columns[1]).Value2 != null && !string.IsNullOrEmpty(((Microsoft.Office.Interop.Excel.Range)columns.Columns[1]).Value2.ToString())) { questions.Add(new Question { Id = _random.Next(int.MaxValue), Text = ((Microsoft.Office.Interop.Excel.Range)columns.Columns[1]).Value2.ToString(), TextImage = ((Microsoft.Office.Interop.Excel.Range)columns.Columns[2]).Value2 == null ? null : File.ReadAllBytes(_folder + ((Microsoft.Office.Interop.Excel.Range)columns.Columns[2]).Value2), Answer = ((Microsoft.Office.Interop.Excel.Range)columns.Columns[3]).Value2.ToString(), AnswerImage = ((Microsoft.Office.Interop.Excel.Range)columns.Columns[4]).Value2 == null ? null : File.ReadAllBytes(_folder + ((Microsoft.Office.Interop.Excel.Range)columns.Columns[4]).Value2), Cost = int.Parse(((Microsoft.Office.Interop.Excel.Range)columns.Columns[5]).Value2.ToString()) }); i++; columns = (Microsoft.Office.Interop.Excel.Range)sheet.Rows[i]; } var group = new QuestionGroup(_random.Next(int.MaxValue), GetRandomQuestionsByPrice(questions)); group.Name = sheet.Name; list.Add(group); } _application.Workbooks[1].Close(); Marshal.ReleaseComObject(_application); return(GetRandomGroups(list).ToList()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region -- Search and data -- ddlGroups.DataSource = Module.QuestionGroupGetAll(); ddlGroups.DataTextField = "Name"; ddlGroups.DataValueField = "Id"; ddlGroups.DataBind(); rptGroups.DataSource = Module.QuestionGroupGetAll(); rptGroups.DataBind(); ddlCruises.DataSource = Module.CruiseGetAll(); ddlCruises.DataTextField = "Name"; ddlCruises.DataValueField = "Id"; ddlCruises.DataBind(); ddlCruises.Items.Insert(0, "-- All cruises --"); rptFeedback.DataSource = Module.FeedbackReport(Request.QueryString); rptFeedback.DataBind(); if (Request.QueryString["group"] != null) { QuestionGroup group = Module.QuestionGroupGetById(Convert.ToInt32(Request.QueryString["group"])); rptQuestions.DataSource = group.Questions; rptQuestions.DataBind(); ddlGroups.SelectedValue = group.Id.ToString(); #region -- Summarized -- if (Request.QueryString["group"] != null) { rptAnswers.DataSource = group.Selections; rptAnswers.DataBind(); rptQuestionsReport.DataSource = group.Questions; rptQuestionsReport.DataBind(); } #endregion } if (Request.QueryString["cruise"] != null) { ddlCruises.SelectedValue = Request.QueryString["cruise"]; } if (Request.QueryString["from"] != null) { DateTime from = DateTime.FromOADate(Convert.ToDouble(Request.QueryString["from"])); txtFrom.Text = from.ToString("dd/MM/yyyy"); } if (Request.QueryString["to"] != null) { DateTime to = DateTime.FromOADate(Convert.ToDouble(Request.QueryString["to"])); txtTo.Text = to.ToString("dd/MM/yyyy"); } #endregion } }
public QuestionData(Question question) { QuestionNumber = question.QuestionNumber; Points = question.Points; Content = question.Content; QuestionTypeName = question.GetType().ToString(); Answer = question.Answer; Theme = question.Theme; ParentQuestionGroup = question.ParentQuestionGroup; }
public ActionResult ViewQuestionAll(int QGid) { QuestionMaster Qm = new QuestionMaster(); QuestionGroup Qg = new QuestionGroup(); QuestionTestModel model = new QuestionTestModel(); model.Questions = Qm.GetByGroup(QGid, con); model.Name = Qg.GetById(con, QGid).QuestionGroupName; return(View(model)); }
public ActionResult AddNewTest() { if (Session["uid"] == null) { return(Redirect("../Account/Login?ReturnUrl=/Practice/AddNewTest")); } QuestionGroup model = new QuestionGroup(); return(View(model)); }
public IActionResult Create([FromBody] QuestionGroup questionGroup) { // проставляем индекс для группы if (questionGroup.QuestId.HasValue && questionGroup.QuestId.Value != Guid.Empty) { questionGroup.Index = _QuestionGroupRepository.GetNextIndex(questionGroup.QuestId.Value); } _QuestionGroupRepository.Create(questionGroup); return(Ok(ServiceResponse.Ok())); }
public void TestWhenCreatedThenLoadQuestionCommandContainsCorrectGroupId() { //Assign QuestionGroup group = new QuestionGroup(10); //Act QuestionGroupViewModel viewModel = new QuestionGroupViewModel(group); //Assert Assert.True(((LoadQuestionCommand)viewModel.LoadQuestionCommand).GroupId == group.Id); }
public void TestWhenCreatedThenLoadQuestionCommandContainsCorrectGroupId() { //Assign QuestionGroup group = new QuestionGroup(10); //Act QuestionGroupViewModel viewModel = new QuestionGroupViewModel(group); //Assert Assert.True(((LoadQuestionCommand)viewModel.LoadQuestionCommand).GroupId == group.Id); }
public IActionResult Create() { if (!_loginServices.isInAdminRoles(this.GetRoles())) { return(RedirectToAction("Login", "Accounts")); } var model = new QuestionGroup(); model.Status = StatusType.Active; return(View("QuestionGroupInfo", model)); }
public async Task <IActionResult> Create([Bind("Id,Name")] QuestionGroup questionGroup) { if (ModelState.IsValid) { _context.QuestionGroup.Add(questionGroup); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(questionGroup)); }
public QuestionGroupViewModel(QuestionGroup questionGroup) { _model = questionGroup; LoadQuestionCommand = new LoadQuestionCommand(this, _model.Id); MessengerInstance.Register<CancelQuestionMessage>(this, OnCancelQuestion); MessengerInstance.Register<UnloadQuestionMessage>(this, msg => { IsFinished = _questions.All(rec => rec.IsAnswered); }); }
public QuestionGroupBuilder AddQuestionGroup(QuestionGroup questionGroup) { if (questionGroup == null) { throw new ArgumentNullException(nameof(questionGroup)); } QuestionGroupBuilder result = new QuestionGroupBuilder((QuestionGroup)questionGroup.Clone(), this); questionGroupBuilders.Add(result); RegisterQuestionGroup(result); return(result); }
public static void Copy(StackExchangeQuestions response, string groupId, string groupName) { try { QuestionGroup qg = APIMASH_StackExchangeCollection.GetGroupByTitle(groupName); if (qg != null) qg.Items.Clear(); else qg = new QuestionGroup(groupId, groupName ); response.Copy(qg); _questionData._allGroups.Add(qg); } catch (Exception e) { throw (e); } }
private void InitializeSuperRound() { Messenger.Default.Unregister<UnloadQuestionMessage>(ViewModelLocator.QuestionTable); Messenger.Default.Unregister<CancelQuestionMessage>(ViewModelLocator.QuestionTable); foreach (var groupViewModel in ViewModelLocator.QuestionTable.QuestionGroupList) { Messenger.Default.Unregister<UnloadQuestionMessage>(groupViewModel); Messenger.Default.Unregister<CancelQuestionMessage>(groupViewModel); } //unregister MainVindow Messenger.Default.Unregister<LoadQuestionMessage>(Application.Current.MainWindow); Messenger.Default.Unregister<UnloadQuestionMessage>(Application.Current.MainWindow); Messenger.Default.Register<UnloadQuestionMessage>(this, OnUnloadQuestion); _superRoundQuestionGroup = ViewModelLocator.QuestionService.GetQuestionGroupList(3).First(); foreach (var question in _superRoundQuestionGroup.Questions) question.Cost = 0; OnUnloadQuestion(null); Messenger.Default.Send(new SupperRoundStartedMessage()); }