Exemplo n.º 1
0
 /// <summary>
 /// 单个插入,返回影响行数
 /// </summary>
 /// <param name="topicgroups"></param>
 /// <returns></returns>
 public static int Insert(AnswerGroup model)
 {
     using (var db = Databases.Instance)
     {
         return(db.Execute(@"insert into `qp.answergroup`(id,Answer,FromID) values(@id,@Answer,@FromID);", model));
     }
 }
    public void GenerateQuestion()
    {
        if (!active)
        {
            return;
        }

        int index = GetNexQuestionIndex();

        if (index == -1) //if has no questions
        {
            return;
        }
        else if (index == -2) //if finish questions
        {
            GameManager.Instance.OnFinishQuestions();
            HideQuestionAndStop();
            return;
        }

        Question    question    = questions[index];
        AnswerGroup answerGroup = new AnswerGroup(question, answerPrefab);

        answerGroup.SetPosition(spawnPosition.position, answerDistance);
        answerGroup.StartMovement(answerSpeed);

        //set question text
        questionImage.sprite = question.question;
    }
Exemplo n.º 3
0
        public IActionResult DeleteConfirmed(int id)
        {
            AnswerGroup answerGroup = _context.AnswerGroup.Single(m => m.Id == id);

            _context.AnswerGroup.Remove(answerGroup);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        public bool Save(Survey element)
        {
            if (element.Id == 0)
            {
                var surveyTemplate = _surveyTemplateRepo.GetById(element.SurveyTemplateId);
                var customer       = _customerRepo.Find(element.CustomerId);
                foreach (var sectionGroup in surveyTemplate.SectionGroup)
                {
                    var address = new Address()
                    {
                        Recipient = customer.Name, AddressLine1 = customer.Address
                    };
                    var answergroup = new AnswerGroup()
                    {
                        SectionGroupId = sectionGroup.Id,
                        SurveyId       = element.Id,
                        IsUsed         = sectionGroup.IsMandatory ? true : false,
                        Address        = address,
                    };

                    if (answergroup.IsUsed)
                    {
                        foreach (var section in sectionGroup.Section.OrderBy(item => item.SortOrder))
                        {
                            var answerSection = new AnswerSection()
                            {
                                SectionId = section.Id,
                                Order     = element.AnswerGroup.Count + 1
                            };

                            foreach (var question in section.Question.OrderBy(item => item.SortOrder))
                            {
                                var answer = new Answer()
                                {
                                    OptionId      = null,
                                    InHighlighted = false,
                                    IsFinal       = false,
                                    IsValid       = false,
                                    QuestionId    = question.Id,
                                    OptionGroupId = question.OptionGroupId
                                };
                                answerSection.Answer.Add(answer);
                            }
                            answergroup.AnswerSection.Add(answerSection);
                        }
                    }
                    element.AnswerGroup.Add(answergroup);
                }

                element = _surveyRepo.Add(element);
            }
            else
            {
                element = _surveyRepo.Update(element);
            }

            return(true);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="topicgroups"></param>
 /// <returns></returns>
 public static bool Update(AnswerGroup model)
 {
     using (var db = Databases.Instance)
     {
         int updateSet = db.Execute(@"update `qp.answergroup` set Answer=@Answer,FromID=@FromID where id=@id", new { model });
         if (updateSet > 0)
         {
             return(true);
         }
         return(false);
     }
 }
        protected void lbtDelete_Click(object sender, EventArgs e)
        {
            IButtonControl btn   = (IButtonControl)sender;
            AnswerGroup    group = Module.AnswerGroupGetById(Convert.ToInt32(btn.CommandArgument));

            group.AnswerSheet.Deleted = true;
            Module.SaveOrUpdate(group.AnswerSheet);
            //throw new NotImplementedException();

            rptFeedback.DataSource = Module.FeedbackReport(Request.QueryString);
            rptFeedback.DataBind();
        }
Exemplo n.º 7
0
 public IActionResult Create(AnswerGroup answerGroup)
 {
     if (ModelState.IsValid)
     {
         _context.AnswerGroup.Add(answerGroup);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewData["SectionGroupId"] = new SelectList(_context.SectionGroup, "Id", "SectionGroup", answerGroup.SectionGroupId);
     ViewData["SurveyId"]       = new SelectList(_context.Survey, "Id", "Survey", answerGroup.SurveyId);
     return(View(answerGroup));
 }
Exemplo n.º 8
0
        public IActionResult Index(IFormCollection model, List <IFormFile> files)
        {
            //在文件上传的时候, 只能采用表单的提交后台才能够获取到文件?? 而Ajax的方式不行?
            string paths = FileSave(files);
            Dictionary <string, string> keyValuePairs = new Dictionary <string, string>()
            {
            };

            foreach (var item in model)
            {
                // 去掉莫名上传的Cookies防伪标志
                if (item.Key.IndexOf("_") != 0)
                {
                    //前端会上传类型路径的字符串,如果存在就替换成上传路径!
                    if (item.Value.ToString().IndexOf("\\") > -1)
                    {
                        keyValuePairs.Add(item.Key, paths);
                    }
                    else
                    {
                        string Value = item.Value.ToString() == "" ? "..." : item.Value.ToString();
                        //keyValuePairs.Add(item.Key, item.Value);
                        keyValuePairs.Add(item.Key, Value);
                    }
                }
            }
            AnswerGroup InsertModel = new AnswerGroup()
            {
                id     = Guid.NewGuid().ToString(),
                FromID = Seesion.FromIds,
                Answer = JObject.FromObject(new { FormName = keyValuePairs.Keys, Values = keyValuePairs.Values }).ToString()
            };

            try
            {
                int flage = HelpAnswerGroup.Insert(InsertModel);
                if (flage > 0)
                {
                    //RedirectToAction 只能够在本页面跳转
                    return(RedirectToAction("Succeed"));
                }
                return(Json("插入失败"));
            }
            catch (Exception el)
            {
                return(Json(ResultMsg.FormatResult(el)));
            }
        }
Exemplo n.º 9
0
        // GET: AnswerGroups/Details/5
        public IActionResult Details(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            AnswerGroup answerGroup = _context.AnswerGroup.Single(m => m.Id == id);

            if (answerGroup == null)
            {
                return(HttpNotFound());
            }

            return(View(answerGroup));
        }
Exemplo n.º 10
0
 public AnswerGroup Update(AnswerGroup answerGroup)
 {
     using (var dbContextTransaction = _context.Database.BeginTransaction())
     {
         try
         {
             _context.AnswerGroup.Update(answerGroup);
             _context.SaveChanges();
             dbContextTransaction.Commit();
         }
         catch (Exception)
         {
             dbContextTransaction.Rollback();
             throw;
         }
         return(answerGroup);
     }
 }
Exemplo n.º 11
0
        public async Task <Application> GetApplication(int scholarshipId, int profileId, int questionSetId)
        {
            var application = await _context.Application.FirstOrDefaultAsync(app => app.ScholarshipId == scholarshipId && app.ProfileId == profileId);

            if (application == null)
            {
                // First we need to create a default answer set for the user
                var answerSet = new AnswerSet
                {
                    QuestionSetId = questionSetId,
                    ProfileId     = profileId
                };
                _context.AnswerSet.Add(answerSet);
                await _context.SaveChangesAsync();

                // Create an answergroup, which is basically a generic container of answersets
                // Really we only use answerGroups for their unique id
                var answerGroup = new AnswerGroup();

                _context.AnswerGroup.Add(answerGroup);
                await _context.SaveChangesAsync();

                // Next create an answergroupset that will hold our first answerset
                var answerGroupSet = new AnswerGroupSets
                {
                    AnswerGroupId = answerGroup.AnswerGroupId,
                    AnswerSetId   = answerSet.AnswerSetId
                };
                _context.AnswerGroupSets.Add(answerGroupSet);
                await _context.SaveChangesAsync();

                // Last, we need to create an application and attach the answer group
                application = new Application
                {
                    ProfileId     = profileId,
                    ScholarshipId = scholarshipId,
                    AnswerGroupId = answerGroup.AnswerGroupId
                };
                _context.Application.Add(application);
                await _context.SaveChangesAsync();
            }

            return(application);
        }
Exemplo n.º 12
0
 public AnswerGroup Add(AnswerGroup answerGroup)
 {
     using (var dbContextTransaction = _context.Database.BeginTransaction())
     {
         try
         {
             var address = _context.Address.Add(answerGroup.Address);
             answerGroup.AddressId = address.Entity.Id;
             _context.AnswerGroup.Add(answerGroup);
             _context.SaveChanges();
             dbContextTransaction.Commit();
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
         }
         return(answerGroup);
     }
 }
Exemplo n.º 13
0
        public int SeedAnswerOption(int recs, AnswerGroup _answerGroup)
        {
            // default: create 5 options for a group
            for (int i = 1; i <= recs; i++)
            {
                var row = new AnswerOption
                {
                    AnswerVal   = i,
                    AnswerGroup = _answerGroup,
                    AnswerText  = "Group " + Convert.ToString(_answerGroup.Id) + " Choice " + Convert.ToString(i)
                };

                _answerOption.Add(row);
            }

            //verify result
            int count = _answerOption.GetAll().Count();

            return(count);
        }
Exemplo n.º 14
0
        public void VetExercise()
        {
            ClearInitAnswerGroupList();
            failedQuestions = new List <int>();
            foreach (KeyValuePair <int, string> userAnswer in _savedAnswers)
            {
                bool   isCorrect = true;
                string question  = GetQuestion(_exerciseCount, userAnswer.Key);
                if (!isAnswerCorrect(userAnswer.Value, userAnswer.Key))
                {
                    isCorrect = false;
                    _failedQuestionCount++;
                    failedQuestions.Add(userAnswer.Key);//Store the failed question numbers in a list
                }
                //Create an answer group for display in the AnswerDisplayControl.

                AnswerGroup ag = new AnswerGroup(_exerciseCount, userAnswer.Key, question, userAnswer.Value, isCorrect);
                _answersGroupList.Add(ag);
            }
            _savedAnswers.Clear();
        }
Exemplo n.º 15
0
        public int SeedQuestion(int recs, AnswerGroup _answerGroup)
        {
            // default: create 5 questions for a group ... = 5*5 for each survey
            for (int i = 1; i <= recs; i++)
            {
                var row = new Question
                {
                    QGroup       = 1, //default
                    Order        = i,
                    QuestionText = "Question " + Convert.ToString(i),
                    AnswerGroup  = _answerGroup
                };

                _question.Add(row);

                int result = SeedSurveyQuestion(10, row); //rc. 10 surveys * 25 questions each
            }

            //verify result
            int count = _question.GetAll().Count();

            return(count);
        }
Exemplo n.º 16
0
        public int SeedAnswerGroup(int recs)
        {
            // suggested recs: 5 -- specified in TestsController
            for (int i = 1; i <= recs; i++)
            {
                var row = new AnswerGroup
                {
                    Name = "Answer Group " + Convert.ToString(i)
                };

                _answerGroup.Add(row);

                // add 5 options for each group ...
                int result = SeedAnswerOption(5, row);
                // add 5 questions for each group ...
                int res = SeedQuestion(5, row);
            }

            //verify result
            int count = _answerGroup.GetAll().Count();

            return(count);
        }
Exemplo n.º 17
0
 public AnswerGroup Use(AnswerGroup answerGroup)
 {
     using (var dbContextTransaction = _context.Database.BeginTransaction())
     {
         try
         {
             if (!answerGroup.IsUsed)
             {
                 _context.Address.Remove(answerGroup.Address);
                 answerGroup.AddressId = null;
                 _answerSectionRepository.DeleteByAnswerGroupId(answerGroup.Id);
             }
             _context.AnswerGroup.Update(answerGroup);
             _context.SaveChanges();
             dbContextTransaction.Commit();
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
             throw;
         }
         return(answerGroup);
     }
 }
Exemplo n.º 18
0
 public bool Delete(AnswerGroup element)
 {
     return(_answerGroupRepo.Delete(element));
 }
Exemplo n.º 19
0
        public bool Save(AnswerGroup answerGroup)
        {
            if (answerGroup.Id == 0)
            {
                answerGroup = _answerGroupRepo.Add(answerGroup);
            }
            else
            {
                if (answerGroup.IsUsed)
                {
                    if (!answerGroup.AddressId.HasValue)
                    {
                        if (answerGroup.Survey != null)
                        {
                            var customer = _customerRepo.Find(answerGroup.Survey.CustomerId);
                            answerGroup.Address = new Address()
                            {
                                Recipient = customer.Name, AddressLine1 = customer.Address
                            };
                        }
                        else
                        {
                            answerGroup.Address = new Address();
                        }
                    }

                    if (answerGroup.AnswerSection.Count() == 0)
                    {
                        foreach (var section in answerGroup.SectionGroup.Section.OrderBy(item => item.SortOrder))
                        {
                            var answerSection = new AnswerSection()
                            {
                                SectionId = section.Id,
                                Order     = answerGroup.AnswerSection.Count + 1
                            };

                            foreach (var question in section.Question.OrderBy(item => item.SortOrder))
                            {
                                var answer = new Answer()
                                {
                                    OptionId      = null,
                                    InHighlighted = false,
                                    IsFinal       = false,
                                    IsValid       = false,
                                    QuestionId    = question.Id,
                                    OptionGroupId = question.OptionGroupId
                                };
                                answerSection.Answer.Add(answer);
                            }
                            answerGroup.AnswerSection.Add(answerSection);
                        }
                    }
                    answerGroup = _answerGroupRepo.Update(answerGroup);
                }
                else
                {
                    answerGroup = _answerGroupRepo.Use(answerGroup);
                }
            }
            return(true);
        }
Exemplo n.º 20
0
        public bool Extend(AnswerGroup answerGroup)
        {
            if (answerGroup.IsUsed)
            {
                var existingAnswerGroups = _answerGroupRepo.GetBySectionGroupId(answerGroup.SectionGroupId);
                int sortOrder            = existingAnswerGroups.Max(item => item.SortOrder);

                Address address;
                if (answerGroup.Survey != null)
                {
                    var customer = _customerRepo.Find(answerGroup.Survey.CustomerId);
                    address = new Address()
                    {
                        Recipient = customer.Name, AddressLine1 = customer.Address
                    };
                }
                else
                {
                    address = new Address();
                }

                var answerGroupForExtention = new AnswerGroup()
                {
                    Id             = 0,
                    SurveyId       = answerGroup.SurveyId,
                    SectionGroupId = answerGroup.SectionGroupId,
                    IsUsed         = answerGroup.IsUsed,
                    SortOrder      = sortOrder + 1,
                    Address        = address
                };

                foreach (var section in answerGroup.SectionGroup.Section.OrderBy(item => item.SortOrder))
                {
                    if (section.IsRepeatable)
                    {
                        var answerSection = new AnswerSection()
                        {
                            SectionId = section.Id,
                            Order     = answerGroup.AnswerSection.Count + 1
                        };

                        foreach (var question in section.Question.OrderBy(item => item.SortOrder))
                        {
                            var answer = new Answer()
                            {
                                OptionId      = null,
                                InHighlighted = false,
                                IsFinal       = false,
                                IsValid       = false,
                                QuestionId    = question.Id,
                                OptionGroupId = question.OptionGroupId
                            };
                            answerSection.Answer.Add(answer);
                        }
                        answerGroupForExtention.AnswerSection.Add(answerSection);
                    }
                }
                return(this.Save(answerGroupForExtention));
            }
            return(false);
        }
 public bool Delete(AnswerGroup element)
 {
     throw new NotImplementedException();
 }
 public bool Extend(AnswerGroup element)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 23
0
 public AnswerGroup AddFromSurvey(AnswerGroup answerGroup)
 {
     _context.AnswerGroup.Add(answerGroup);
     _context.SaveChanges();
     return(answerGroup);
 }
        protected void rptFeedback_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is AnswerGroup)
            {
                AnswerGroup group = (AnswerGroup)e.Item.DataItem;
                ValueBinder.BindLiteral(e.Item, "litDate", group.AnswerSheet.Date);
                //ValueBinder.BindLiteral(e.Item, "litCruise", group.AnswerSheet.Cruise.Name);
                ValueBinder.BindLiteral(e.Item, "litName", group.AnswerSheet.Name);
                ValueBinder.BindLiteral(e.Item, "litAddress", group.AnswerSheet.Address);
                ValueBinder.BindLiteral(e.Item, "litEmail", group.AnswerSheet.Email);
                ValueBinder.BindLiteral(e.Item, "litNote", group.Comment);
                ValueBinder.BindLiteral(e.Item, "litRoom", group.AnswerSheet.RoomNumber);
                int current = pagerFeedback.CurrentPageIndex;
                if (current < 0)
                {
                    current = 0;
                }
                ValueBinder.BindLiteral(e.Item, "litIndex", e.Item.ItemIndex + current * pagerFeedback.PageSize + 1);
                _currentGroup = group;

                Repeater rptOptions = (Repeater)e.Item.FindControl("rptOptions");
                rptOptions.DataSource = group.Group.Questions;
                rptOptions.DataBind();

                HtmlAnchor anchorFeedback = e.Item.FindControl("anchorFeedback") as HtmlAnchor;
                if (anchorFeedback != null)
                {
                    string url = string.Format("SurveyInput.aspx?NodeId={0}&SectionId={1}&sheetid={2}", Node.Id,
                                               Section.Id, group.AnswerSheet.Id);
                    anchorFeedback.Attributes.Add("onclick",
                                                  CMS.ServerControls.Popup.OpenPopupScript(url, "Survey input", 600, 800));
                }

                HtmlAnchor anchorEmail = e.Item.FindControl("anchorEmail") as HtmlAnchor;
                if (anchorEmail != null)
                {
                    string url = string.Format("FeedbackMail.aspx?NodeId={0}&SectionId={1}&sheetid={2}", Node.Id,
                                               Section.Id, group.AnswerSheet.Id);
                    anchorEmail.Attributes.Add("onclick",
                                               CMS.ServerControls.Popup.OpenPopupScript(url, "Survey input", 600, 800));
                }

                Literal trItem = (Literal)e.Item.FindControl("trItem");
                if (trItem != null)
                {
                    if (group.AnswerSheet.IsSent)
                    {
                        trItem.Text = @"<tr class='sent'>";
                    }
                }

                HyperLink hplBooking = e.Item.FindControl("hplBooking") as HyperLink;
                if (hplBooking != null)
                {
                    if (group.AnswerSheet.Booking != null)
                    {
                        hplBooking.Text        = string.Format(BookingFormat, group.AnswerSheet.Booking.Id);
                        hplBooking.NavigateUrl = string.Format("BookingView.aspx?NodeId={0}&SectionId={1}&bi={2}",
                                                               Node.Id, Section.Id, group.AnswerSheet.Booking.Id);
                        ValueBinder.BindLiteral(e.Item, "litTrip", group.AnswerSheet.Booking.Trip.TripCode);
                    }
                }

                HyperLink hplCruise = e.Item.FindControl("hplCruise") as HyperLink;
                if (hplCruise != null)
                {
                    hplCruise.Text        = group.AnswerSheet.Cruise.Name;
                    hplCruise.NavigateUrl = AddQuery("cruise", group.AnswerSheet.Cruise.Id.ToString());
                }

                HyperLink hplGuide = e.Item.FindControl("hplGuide") as HyperLink;
                if (hplGuide != null)
                {
                    hplGuide.Text        = group.AnswerSheet.Guide;
                    hplGuide.NavigateUrl = AddQuery("guide", HttpUtility.UrlEncode(group.AnswerSheet.Guide));
                }

                HyperLink hplDriver = e.Item.FindControl("hplDriver") as HyperLink;
                if (hplDriver != null)
                {
                    hplDriver.Text        = group.AnswerSheet.Driver;
                    hplDriver.NavigateUrl = AddQuery("driver", HttpUtility.UrlEncode(group.AnswerSheet.Guide));
                }
            }
        }
Exemplo n.º 25
0
 public AnswerController(AnswerGroup answerGroup)
 {
     this.answerGroup = answerGroup;
 }
Exemplo n.º 26
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (ddlBookings.SelectedIndex > 0)
            {
                Booking booking = Module.BookingGetById(Convert.ToInt32(ddlBookings.SelectedValue));
                _currentSheet.Booking = booking;
                _currentSheet.Date    = booking.StartDate;
                _currentSheet.Cruise  = booking.Cruise;
            }
            else
            {
                _currentSheet.Date = DateTime.ParseExact(txtStartDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                //Cruise cruise = Module.CruiseGetById(Convert.ToInt32(ddlCruises.SelectedValue));
                //_currentSheet.Cruise = cruise;
            }

            if (ddlGuide.Visible)
            {
                if (ddlGuide.SelectedIndex > 0)
                {
                    _currentSheet.Guide = ddlGuide.SelectedValue;
                }
                else
                {
                    _currentSheet.Guide = string.Empty;
                }
            }
            else
            {
                _currentSheet.Guide = txtGuide.Text;
            }
            if (ddlDrivers.Visible)
            {
                if (ddlDrivers.SelectedIndex > 0)
                {
                    _currentSheet.Driver = ddlDrivers.SelectedValue;
                }
                else
                {
                    _currentSheet.Driver = string.Empty;
                }
            }
            else
            {
                _currentSheet.Driver = txtDriver.Text;
            }

            _currentSheet.Name       = txtName.Text;
            _currentSheet.Email      = txtEmail.Text;
            _currentSheet.Address    = txtAddress.Text;
            _currentSheet.RoomNumber = txtRoomNumber.Text;
            if (ddlNationalities.SelectedIndex > 0)
            {
                _currentSheet.Nationality = Module.NationalityGetById(Convert.ToInt32(ddlNationalities.SelectedValue));
            }
            Module.SaveOrUpdate(_currentSheet, UserIdentity);

            foreach (RepeaterItem groupItem in rptGroups.Items)
            {
                HiddenField hiddenId     = (HiddenField)groupItem.FindControl("hiddenId");
                TextBox     txtComment   = (TextBox)groupItem.FindControl("txtComment");
                Repeater    rptQuestions = (Repeater)groupItem.FindControl("rptQuestions");

                QuestionGroup grp   = Module.QuestionGroupGetById(Convert.ToInt32(hiddenId.Value));
                AnswerGroup   group = _currentSheet.GetGroup(grp);
                group.AnswerSheet = _currentSheet;
                group.Group       = grp;
                group.Comment     = txtComment.Text;
                Module.SaveOrUpdate(group, UserIdentity);

                foreach (RepeaterItem questionItem in rptQuestions.Items)
                {
                    HiddenField hiddenQId  = (HiddenField)questionItem.FindControl("hiddenId");
                    Question    question   = Module.QuestionGetById(Convert.ToInt32(hiddenQId.Value));
                    Repeater    rptOptions = (Repeater)questionItem.FindControl("rptOptions");

                    AnswerOption option = _currentSheet.GetOption(question);
                    option.Question    = question;
                    option.AnswerSheet = _currentSheet;
                    for (int ii = 0; ii < rptOptions.Items.Count; ii++)
                    {
                        RadioButton radOption = (RadioButton)rptOptions.Items[ii].FindControl("radOption");
                        if (radOption.Checked)
                        {
                            option.Option = ii + 1;
                        }
                    }
                    Module.SaveOrUpdate(option);
                }
            }

            ClientScript.RegisterClientScriptBlock(typeof(SurveyInput), "closure", "window.close();", true);
        }
Exemplo n.º 27
0
 public void SetGroup(AnswerGroup group)
 {
     this.group = group;
 }
Exemplo n.º 28
0
 public void Add(AnswerGroup newAnswerGroup)
 {
     _context.Add(newAnswerGroup);
     _context.SaveChanges();
 }
Exemplo n.º 29
0
 public void Update(AnswerGroup newAnswerGroup)
 {
     throw new NotImplementedException();
 }