Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void DoSave()
        {
            string SurveyTypeId   = RequestData.Get("SurveyTypeId") + "";
            string SurveyTypeName = RequestData.Get("SurveyTypeName") + "";

            ent = this.GetMergedData <SurveyQuestion>();
            ent.SurveyTypeId   = SurveyTypeId;
            ent.SurveyTypeName = SurveyTypeName;
            ent.State          = "1"; //1 启用
            ent.IsFixed        = "2"; //2 固定问卷
            ent.DoUpdate();

            if (!string.IsNullOrEmpty(SurveyId))
            {
                IList <string> DataList = RequestData.GetList <string>("data");
                if (DataList.Count > 0)
                {
                    IList <QuestionItem> qiEnts = DataList.Select(tent => JsonHelper.GetObject <QuestionItem>(tent) as QuestionItem).ToArray();
                    foreach (QuestionItem itms in qiEnts)
                    {
                        itms.Content = HttpUtility.UrlDecode(itms.Content);
                        itms.DoSave();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void SingleVarNameVarLabel()
        {
            SurveyReport SR = new SurveyReport();

            ReportSurvey   s = new ReportSurvey("TT1");
            SurveyQuestion q = new SurveyQuestion("AA000", "001");

            s.AddQuestion(q);
            s.VarLabelCol = true;
            SR.AddSurvey(s);

            SR.GenerateReport();

            DataTable dt = SR.ReportTable;

            bool hasQnumCol     = dt.Columns[0].ColumnName.Equals("Qnum");
            bool hasVarNameCol  = dt.Columns[1].ColumnName.Equals("VarName");
            bool hasQuestionCol = dt.Columns[2].ColumnName.Equals(s.SurveyCode);
            bool hasVarLabelCol = dt.Columns[3].ColumnName.Equals(s.SurveyCode + " VarLabel");
            bool hasRows        = dt.Rows.Count == s.Questions.Count;

            bool hasAllColumns = hasQnumCol && hasVarNameCol && hasQuestionCol && hasVarLabelCol;

            Assert.IsTrue(hasAllColumns && hasRows);
        }
Ejemplo n.º 3
0
        public void SingleVarNameSingleTranslation()
        {
            SurveyReport SR = new SurveyReport();

            ReportSurvey   s = new ReportSurvey("TT1");
            SurveyQuestion q = new SurveyQuestion("AA000", "001");

            q.Translations.Add(new Translation()
            {
                Language        = "TestLang",
                TranslationText = "Translation Text"
            });
            s.AddQuestion(q);
            s.TransFields.Add("TestLang");
            SR.AddSurvey(s);

            SR.GenerateReport();

            DataTable dt = SR.ReportTable;

            bool hasQnumCol        = dt.Columns[0].ColumnName.Equals("Qnum");
            bool hasVarNameCol     = dt.Columns[1].ColumnName.Equals("VarName");
            bool hasQuestionCol    = dt.Columns[2].ColumnName.Equals(s.SurveyCode);
            bool hasTranslationCol = dt.Columns[3].ColumnName.Equals(s.SurveyCode + " " + s.TransFields[0]);
            bool hasRows           = dt.Rows.Count == s.Questions.Count;

            bool hasAllColumns = hasQnumCol && hasVarNameCol && hasQuestionCol && hasTranslationCol;

            Assert.IsTrue(hasAllColumns && hasRows);
        }
Ejemplo n.º 4
0
        public List <UserTable> GetAllUsers()
        {
            List <UserTable> lists = new List <UserTable>();

            lists = SurveyQuestion.GetUsers();
            return(lists);
        }
Ejemplo n.º 5
0
        public void Save(int SurveyID, bool isActive, bool isMain, string SurveyQuestion, DataTable dtSurveyChoices)
        {
            int IdentityQuestion = 0;

            BINROTA.DAL.SurveyQuestion objSurveyQuestion;
            BINROTA.DAL.SurveyChoice   objSurveyChoice;

            // Soruyu Kaydet
            objSurveyQuestion = new SurveyQuestion();
            if (SurveyID == 0)
            {
                DeleteSurveyChoices(SurveyID);
                objSurveyQuestion.Load(SurveyID);
            }
            objSurveyQuestion.isActive       = isActive;
            objSurveyQuestion.isMain         = isMain;
            objSurveyQuestion.SurveyQuestion = SurveyQuestion;
            IdentityQuestion = objSurveyQuestion.Save();

            //Seçenekleri Kaydet
            foreach (DataRow dr in dtSurveyChoices.Rows)
            {
                objSurveyChoice = new SurveyChoice();
                objSurveyChoice.SurveyChoice     = dr["SurveyChoice"].ToString();
                objSurveyChoice.SurveyVoteNumber = Convert.ToInt32(dr["SurveyVoteNumber"]);
                objSurveyChoice.SurveyQuestionID = IdentityQuestion;
                objSurveyChoice.Save();
            }
        }
Ejemplo n.º 6
0
        private void DoSelect()
        {
            CommPowerSplit ps = new CommPowerSplit();

            if (ps.IsSurveyRole(UserInfo.UserID, UserInfo.LoginName))
            {
                SearchCriterion.SetSearch("IsFixed", "2");  //固定问卷
                SurveyQuestion[] Ents = SurveyQuestion.FindAll(SearchCriterion);
                this.PageState.Add("DataList", Ents);
            }
            else
            {
                SearchCriterion.SetSearch("IsFixed", "2");  //固定问卷
                string CompanyId = string.Empty;            //公司ID

                //first depend login corpid
                var             Ent = SysUser.Find(UserInfo.UserID);
                UserContextInfo UC  = new UserContextInfo();
                CompanyId = UC.GetUserCurrentCorpId(UserInfo.UserID);

                SearchCriterion.AddSearch("CompanyId", CompanyId);
                SurveyQuestion[] Ents = SurveyQuestion.FindAll(SearchCriterion);
                this.PageState.Add("DataList", Ents);
            }
        }
Ejemplo n.º 7
0
        // adds a question to the underlying survey's list of questions
        private void AddQuestion(string varname)
        {
            SurveyQuestion newQ = new SurveyQuestion();
            VariableName   newVar;
            string         newQnum = CurrentQuestion.Qnum;

            // get varname
            newQ.VarName.FullVarName = varname;
            // determine qnum
            if (CurrentQuestion.Qnum.Contains("!"))
            {
                newQnum += "00";
            }
            else
            {
                newQnum += "z";
            }

            if (newQnum.Length > 10)
            {
                MessageBox.Show("The Qnum for this new question is too long. Please limit the Qnum to 10 digits (including suffix). You may need to renumber the survey first.");
                return;
            }

            newQ.Qnum = newQnum;

            newVar = DBAction.GetVariable(newQ.VarName.FullVarName);
            if (newVar == null)
            {
                // if VarName does not exist, check refVarNames
                if (DBAction.RefVarNameExists(Utilities.ChangeCC(varname)))
                {
                    // display all the sets of the labels for this refVarName
                    VariableLabelSelector selector = new VariableLabelSelector(Utilities.ChangeCC(varname));
                    selector.frmParent = this;
                    selector.ShowDialog();
                }
            }
            else
            {
                // if VarName already exists, use those labels
                newQ.VarName.VarLabel = newVar.VarLabel;
                newQ.VarName.Domain   = new DomainLabel(newVar.Domain);
                newQ.VarName.Topic    = new TopicLabel(newVar.Topic);
                newQ.VarName.Content  = new ContentLabel(newVar.Content);
                newQ.VarName.Product  = new ProductLabel(newVar.Product);
            }

            // add to the list of questions, but after the current question
            CurrentSurvey.AddQuestion(newQ, bs.Position + 1);

            // go to the new question
            GoToQnum(newQ.Qnum);

            SaveRecord();

            Renumber = true;

            // TODO check for wave comments
        }
Ejemplo n.º 8
0
        public void SingleSurveyMultiQuestionReportTable()
        {
            SurveyReport SR = new SurveyReport();
            ReportSurvey s  = new ReportSurvey("Test");

            SR.AddSurvey(s);

            for (int i = 0; i < 10; i++)
            {
                SurveyQuestion sq = new SurveyQuestion();
                sq.VarName.FullVarName = "AA" + i.ToString("000");
                sq.Qnum = i.ToString("000");
                sq.PreP = "Test PreP" + i;
                sq.LitQ = "Test LitQ" + i;
                for (int j = 1; j <= i; j++)
                {
                    sq.RespOptions += j + "   Response Option " + j;
                }

                s.AddQuestion(sq);
            }

            int result = SR.GenerateReport();

            Assert.IsTrue(result == 0);

            Assert.IsTrue(SR.ReportTable.Rows.Count == 10);
        }
        public async Task <IHttpActionResult> PutSurveyQuestion(int id, SurveyQuestion surveyQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != surveyQuestion.SurveyQuestionId)
            {
                return(BadRequest());
            }

            db.Entry(surveyQuestion).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SurveyQuestionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 10
0
        //
        // GET: /SurveyQuestionOption/Create/surveyquestionid

        public ActionResult Create(int id)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                {
                    return(RedirectToAction("Validate", "Login"));
                }
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                {
                    ViewData["txtIsAdmin"] = "true";
                }
                else
                {
                    ViewData["txtIsAdmin"] = "false";
                }

                // Get the survey id for redirection
                ISurveyQuestionRepository qrep           = new EntitySurveyQuestionRepository();
                SurveyQuestion            surveyquestion = qrep.GetSurveyQuestion(id);
                ViewData["SurveyID"] = surveyquestion.SurveyID;

                ViewData["ValidationMessage"] = String.Empty;

                return(View(CreateNewSurveyQuestionOption(id)));
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("SurveyQuestionOption", "Create", ex.Message);
                return(RedirectToAction("Index", "ApplicationError"));
            }
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id = RequestData.Get("id") + "";
            op = RequestData.Get("op") + "";
            string SurveyTypeId   = RequestData.Get("SurveyTypeId") + "";
            string SurveyTypeName = RequestData.Get("SurveyTypeName") + "";

            switch (RequestAction)
            {
            case RequestActionEnum.Update:

                ent = this.GetMergedData <SurveyQuestion>();
                if (string.IsNullOrEmpty(ent.State))
                {
                    ent.State = "0";                                       //"0" 表示创建
                }
                ent.SurveyTypeId   = SurveyTypeId;
                ent.SurveyTypeName = SurveyTypeName;
                ent.DoUpdate();
                this.SetFormData(ent);
                break;

            default:
                if (RequestActionString == "GetTypeInfo")
                {
                    GetAddFiles();
                }
                else
                {
                    DoSelect();
                }
                break;
            }
        }
Ejemplo n.º 12
0
        public IHttpActionResult PostSurveyQuestion(SurveyQuestion surveyQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SurveyQuestions.Add(surveyQuestion);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SurveyQuestionExists(surveyQuestion.SurveyQuestionId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = surveyQuestion.SurveyQuestionId }, surveyQuestion));
        }
Ejemplo n.º 13
0
        private void DoSelect()
        {
            if (!string.IsNullOrEmpty(SurveyId))
            {
                ent = SurveyQuestion.Find(SurveyId);
                this.SetFormData(ent);

                string QsItem = @"select * from  FL_Culture..QuestionItem where SurveyId='{0}' order by SortIndex ";
                QsItem = string.Format(QsItem, SurveyId);

                if (string.IsNullOrEmpty(ent.TypeCode))
                {
                    string code = "HR_W" + DateTime.Now.ToString("yyyMMddHHmm");
                    this.SetFormData(new { TypeCode = code });
                }
                this.PageState.Add("DataList", DataHelper.QueryDictList(QsItem));
            }
            else
            {
                string code = "GDWJ" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Minute;
                this.SetFormData(new { TypeCode = code });
            }

            GetTemplate();
            GetTypeEnum();
        }
        private void Create()
        {
            string QcId = string.Empty;   //QuestionContent_ID
            string SqId = string.Empty;   //SurveyQuestionId

            if (string.IsNullOrEmpty(id)) //创建状态
            {
                SurveyQuestion sq = new SurveyQuestion();
                sq.State = "0"; // 已生成
                sq.DoCreate();
                SqId = sq.Id;

                QuestionContent qc = new QuestionContent();
                qc.SurveyQuestionId = SqId;
                qc.DoCreate();
                QcId = qc.Id;

                this.PageState.Add("date", qc.CreateTime);
                this.PageState.Add("SurveyQuestionId", SqId);
                this.PageState.Add("Id", QcId); //QuestionContent ID
            }
            else  //修改状态
            {
                QuestionContent qc = new QuestionContent();
                qc.SurveyQuestionId = id;
                qc.DoCreate();
                QcId = qc.Id;
                this.PageState.Add("date", qc.CreateTime);
                this.PageState.Add("Id", QcId); //QuestionContent  ID
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Updates subforms to match the current record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Bs_PositionChanged(object sender, EventArgs e)
        {
            CurrentQuestion = (SurveyQuestion)bs.Current;

            if (frmBrown != null && !frmBrown.IsDisposed)
            {
                frmBrown.UpdateForm(CurrentQuestion.VarName.RefVarName);
            }

            if (frmTranslations != null && !frmTranslations.IsDisposed)
            {
                frmTranslations.UpdateForm(CurrentQuestion.ID);
            }

            for (int i = 0; i < lstQuestionList.Items.Count; i++)

            {
                lstQuestionList.Items[i].Selected = false;
            }

            for (int i = 0; i < lstQuestionList.Items.Count; i++)
            {
                if (lstQuestionList.Items[i].SubItems[2].Text.Equals(CurrentQuestion.VarName.FullVarName))
                {
                    lstQuestionList.Items[i].Selected = true;
                    lstQuestionList.Items[i].EnsureVisible();


                    break;
                }
            }
            LoadQuestion();
        }
Ejemplo n.º 16
0
        private void SurveyEntry_Load(object sender, EventArgs e)
        {
            CurrentQuestion = (SurveyQuestion)bs.Current;
            //bs.Position = frmParent.currentUser.positions[index]; // TODO add position property to user

            LoadQuestion();
        }
Ejemplo n.º 17
0
        public void GetNextTestPage()
        {
            if (Session["QNum"] == null)
            {
                Session["QNum"] = 0;
            }
            QNumber.Text = Session["QNum"].ToString();
            int qNum = 0;

            int.TryParse(QNumber.Text, out qNum);
            if (qNum != 0)
            {
                lblPreamble.Visible = false;
            }

            var ds = SurveyQuestion.GetSurveyPage(int.Parse(SID.Text), int.Parse(QNumber.Text));

            SurveyQLst.DataSource = ds;
            SurveyQLst.DataBind();

            if (ds.Tables[0].Rows.Count > 0)
            {
                QNumber.Text = ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["QNumber"].ToString();
            }
        }
        public T1 GetView(ApplicationDbContext db)
        {
            SurveyUserData       model = Parameters as SurveyUserData;
            SurveyUserDataReturn surveyUserDataReturn = new SurveyUserDataReturn();

            SurveyPart     surveyPart     = new SurveyPart();
            SurveyQuestion surveyQuestion = new SurveyQuestion();

            SurveyPartTemplate     surveyPartTemplate     = db.T_SurveyPartTemplate.Find(surveyPart.SurveyPartTemplateId);
            SurveyQuestionTemplate surveyQuestionTemplate = db.T_SurveyQuestionTemplate.Find(surveyQuestion.SurveyQuestionTemplateId);

            int id = StringToValue.ParseInt(model.Id);

            surveyPart     = db.T_SurveyPart.Where(sp => sp.SurveyId == id).FirstOrDefault();
            surveyQuestion = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id).FirstOrDefault();

            surveyUserDataReturn.TotalSections  = db.T_SurveyPart.Where(sp => sp.SurveyId == id).Count();
            surveyUserDataReturn.TotalQuestions = db.T_SurveyPart
                                                  .Join(db.T_SurveyQuestion,
                                                        sp => sp.Id, sq => sq.SurveyPartId,
                                                        (sp, sq) => sp).Where(sp => sp.SurveyId == id).Count();
            surveyUserDataReturn.TotalSectionQuestions = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id).Count();



            return(surveyUserDataReturn as T1);
        }
Ejemplo n.º 19
0
        private void LoadQuestion(SurveyQuestion lq)
        {
            rtbQuestionText.Rtf = "";
            rtbQuestionText.Rtf = lq.GetQuestionTextRich();

            cboResponse.DataSource = lq.GetRespNumbers();
        }
 public IList <SurveyAnswer> GetSurveyAnswers(SurveyQuestion question)
 {
     return(Surveys.Where(x => x.IsCompleted)
            .SelectMany(x => x.SurveyResponses)
            .Where(x => x.SurveyQuestionId.Equals(question.Id) && x.Question.CourseClassId.Equals(Assignment.CourseClassId))
            .Select(x => x.Answer).ToList());
 }
Ejemplo n.º 21
0
        public QuestionPreview(SurveyQuestion sq)
        {
            InitializeComponent();

            CurrentQuestion   = sq;
            FormattedQuestion = sq.Copy();

            bs = new BindingSource
            {
                DataSource = CurrentQuestion
            };

            StandardFields = new List <string>();
            StandardFields.Add("PreP");
            StandardFields.Add("PreI");
            StandardFields.Add("PreA");
            StandardFields.Add("LitQ");
            StandardFields.Add("PstI");
            StandardFields.Add("PstP");
            StandardFields.Add("RespOptions");
            StandardFields.Add("NRCodes");

            lstStandardFields.DataSource = StandardFields;
            for (int i = 0; i < lstStandardFields.Items.Count; i++)
            {
                lstStandardFields.SetSelected(i, true);
            }
            txtBaseQuestion.Rtf = Utilities.FormatText(CurrentQuestion.GetQuestionText(StandardFields, false, "<br>"), true);
            LoadQuestion();
        }
Ejemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SurveyId = RequestData.Get <string>("id") + "";

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                DoSave();
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <SurveyQuestion>();
                ent.DoDelete();
                return;

            default:
                if (RequestActionString == "GetId")
                {
                    QuestionItem qItem = new QuestionItem();
                    qItem.SubItemId = Guid.NewGuid().ToString();
                    qItem.DoCreate();
                    this.PageState.Add("SubItemId", qItem.Id + "|" + qItem.SubItemId);
                }
                else if (RequestActionString == "Close")
                {
                    DoClose();
                }
                else
                {
                    DoSelect();
                }
                break;
            }
        }
Ejemplo n.º 23
0
        public IActionResult AddQuestion(string Question, int F_N, int Category)
        {
            if (Question == null)
            {
                return(RedirectToAction(nameof(NewSurvey)));
            }
            if (Category == 0)
            {
                return(RedirectToAction(nameof(NewSurvey)));
            }
            var CreateQuestion = new Question {
                GroupId = 1, CategoryId = Category, Text = Question, Type = F_N
            };

            SurveyID = getSurveyID();

            if (ModelState.IsValid)
            {
                context.Add(CreateQuestion);
                context.SaveChanges();

                QuestionID = getQuestionID();
                var CreateLink = new SurveyQuestion {
                    QuestionId = QuestionID, SurveyId = SurveyID
                };

                context.Add(CreateLink);
                context.SaveChanges();

                return(RedirectToAction(nameof(NewSurvey)));
            }
            return(View());
        }
Ejemplo n.º 24
0
        public T1 GetView(ApplicationDbContext db)
        {
            SurveyUserData       model = Parameters as SurveyUserData;
            SurveyUserDataReturn surveyUserDataReturn = new SurveyUserDataReturn();

            int id = StringToValue.ParseInt(model.Id);

            SurveyPart             surveyPart             = db.T_SurveyPart.Where(sp => sp.SurveyId == id).FirstOrDefault();
            SurveyQuestion         surveyQuestion         = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id).FirstOrDefault();
            SurveyPartTemplate     surveyPartTemplate     = db.T_SurveyPartTemplate.Find(surveyPart.SurveyPartTemplateId);
            SurveyQuestionTemplate surveyQuestionTemplate = db.T_SurveyQuestionTemplate.Find(surveyQuestion.SurveyQuestionTemplateId);

            surveyUserDataReturn.TotalSections  = db.T_SurveyPart.Where(sp => sp.SurveyId == id).Count();
            surveyUserDataReturn.TotalQuestions = db.T_SurveyPart
                                                  .Join(db.T_SurveyQuestion,
                                                        sp => sp.Id, sq => sq.SurveyPartId,
                                                        (sp, sq) => sp).Where(sp => sp.SurveyId == id).Count();
            surveyUserDataReturn.TotalSectionQuestions   = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id).Count();
            surveyUserDataReturn.QuestionSectionNo       = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id && sq.Id <= surveyQuestion.Id).Count();
            surveyUserDataReturn.SectionName             = surveyPartTemplate.Name;
            surveyUserDataReturn.SectionTitle            = surveyPartTemplate.SummaryTitle;
            surveyUserDataReturn.SectionId               = surveyPart.Id;
            surveyUserDataReturn.QuestionId              = surveyQuestion.Id;
            surveyUserDataReturn.QuestionName            = surveyQuestionTemplate.Name;
            surveyUserDataReturn.QuestionDescription     = surveyQuestionTemplate.Definition;
            surveyUserDataReturn.QuestionType            = surveyQuestionTemplate.QuestionType;
            surveyUserDataReturn.QuestionEmployeeScore   = surveyQuestion.EmployeeScore;
            surveyUserDataReturn.QuestionEmployeeComment = surveyQuestion.EmployeeComment;
            surveyUserDataReturn.SectionNo               = db.T_SurveyPart.Where(sp => sp.SurveyId == id && sp.Id <= surveyPart.Id).Count();

            return(surveyUserDataReturn as T1);
        }
Ejemplo n.º 25
0
        public async Task <SurveyQuestion> Update(SurveyQuestion item)
        {
            var result = context.SurveyQuestions.Update(item);
            await context.SaveChangesAsync();

            return(result.Entity);
        }
Ejemplo n.º 26
0
        private string?GenerateAnswer(SurveyQuestion question)
        {
            switch (question.TypeOfQuestion)
            {
            case QuestionType.YesNo:
                int n = randomGenerator.Next(-1, 2);

                return((n == -1) ? default : (n == 0) ? "No" : "Yes");

            case QuestionType.Number:
                n = randomGenerator.Next(-30, 101);

                return((n < 0) ? default : n.ToString());

            default:
                switch (randomGenerator.Next(0, 5))
                {
                case 0:
                    return(default);

                case 1:
                    return("Red");

                case 2:
                    return("Green");

                case 3:
                    return("Blue");
                }
                return("Red. No, Green. Wait.. Blue... AAARGGGGGHHH!");
            }
        }
        private void SaveDetail(SurveyQuestion isEnt)
        {
            string         temp       = string.Empty;
            IList <string> entStrList = RequestData.GetList <string>("data");

            if (entStrList != null && entStrList.Count > 0)
            {
                IList <QuestionContent> Ents = entStrList.Select(tent => JsonHelper.GetObject <QuestionContent>(tent) as QuestionContent).ToList();
                foreach (QuestionContent subItem in Ents)
                {
                    subItem.DoUpdate();
                }
            }

            string deptId    = RequestData["Dept"] + "";
            string PersonId  = RequestData["PersonId"] + "";
            string PowerType = RequestData["PowerType"] + "";

            if (!string.IsNullOrEmpty(PowerType) || deptId != "" || PersonId != "")
            {
                isEnt.ScanPower       = deptId;
                isEnt.StatisticsPower = PersonId;
                isEnt.PowerType       = PowerType;
                isEnt.DoUpdate();
            }
        }
Ejemplo n.º 28
0
        public SurveyEntryBrown(string refVarName, string surveyGlob)
        {
            InitializeComponent();

            // hide translation panel


            Questions  = new BindingList <SurveyQuestion>();
            SurveyGlob = surveyGlob;
            bs         = new BindingSource()
            {
                DataSource = Questions
            };
            bs.PositionChanged        += Bs_PositionChanged;
            navQuestions.BindingSource = bs;

            bsTranslations = new BindingSource()
            {
                DataSource = bs.Current,
                DataMember = "Translations"
            };
            navTranslations.BindingSource = bsTranslations;

            BindProperties();

            ColorForm();

            UpdateRefVarName(refVarName);
            CurrentQuestion         = (SurveyQuestion)bs.Current;
            translationPanel.Height = 0;
            this.Height            -= 260;
        }
Ejemplo n.º 29
0
        public ActionResult AddQuestionToSurvey(int id, QuestionDto questionDto)
        {
            if (questionDto == null)
            {
                return(BadRequest());
            }

            var surveyInDb = _context.Surveys.SingleOrDefault(s => s.Id == id);

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

            var surveyQuestion = new SurveyQuestion
            {
                Survey   = surveyInDb,
                Question = _mapper.Map <Question>(questionDto)
            };

            _context.SurveyQuestions.Add(surveyQuestion);
            _context.SaveChanges();

            var displayUrl = (Request != null) ? Request.GetDisplayUrl() : "http://localhost/survey/" + id;

            return(Created(new Uri(displayUrl + "/" + surveyQuestion.Id), surveyQuestion));
        }
Ejemplo n.º 30
0
        public void BindModel(SurveyEntryViewModel vm, SurveyQuestion model)
        {
            Log.Information("Cell manual bind");
            this.ContentView.ClearsContextBeforeDrawing = true;
            this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;

            AnswerSlider.SetThumbImage(UIImage.FromFile("SliderButton.png"), UIControlState.Normal);

            QuestionLabel.Text = model.Question;
            MinLabel.Text      = model.MinText;
            MaxLabel.Text      = model.MaxText;

            AnswerSlider.MinValue = (float)model.MinValue;
            AnswerSlider.MaxValue = (float)model.MaxValue;
            AnswerSlider.Value    = model.Answered ? (float)model.AnswerValue : (float)model.DefaultValue;

            ProgressView.Progress = AnswerSlider.Value / AnswerSlider.MaxValue;

            // Render the change continuously and not just when released
            //AnswerSlider.Continuous = true;
            //ProgressView.ProgressTintColor = AnswerSlider.MinimumTrackTintColor;
            //ProgressView.Hidden = true;

            AnswerSlider.ValueChanged += (sender, e) =>
            {
                Log.Information($"Setting value for {model.QuestionVariable} to {AnswerSlider.Value}");
                model.Answered        = true;
                model.AnswerValue     = AnswerSlider.Value;
                ProgressView.Progress = (AnswerSlider.Value / AnswerSlider.MaxValue);
            };
            this.SetNeedsDisplay();
        }
 public override void Add(SurveyQuestion entity)
 {
     using (var scope = new TransactionScope(TransactionScopeOption.Suppress)) {
         base.Add(entity);
         scope.Complete();
     }
     
 }
 public void AddSurveyQuestion(SurveyQuestion question, Survey survey)
 {
     var indexOfSurvey = this.SurveysPage.Map.KendoGrid.IndexOfGridRowContainingText(survey.Name);
     this.SurveysPage.Map.AllEpandForQuestionsButtons[indexOfSurvey].MouseClick();
     Manager.Current.ActiveBrowser.WaitForElement(3000, "class=k-detail-cell");
     ExecutionDelayProvider.SleepFor(5000);
     Manager.Current.ActiveBrowser.RefreshDomTree();
     this.SurveysPage.Map.AddQuestionButtons[1].MouseClick();
     Manager.Current.ActiveBrowser.RefreshDomTree();
     ExecutionDelayProvider.SleepFor(2000);
     this.SurveysPage.Map.QuestionTypeLabel.MouseClick();
     Manager.Current.ActiveBrowser.RefreshDomTree();
     ExecutionDelayProvider.SleepFor(2000);
     this.SurveysPage.Map.AllQuestionTypeList[question.TypeIndex].MouseClick();
     Manager.Current.ActiveBrowser.RefreshDomTree();
     ExecutionDelayProvider.SleepFor(2000);
     this.SurveysPage.Map.QuestionText.MouseClick();
     Manager.Current.ActiveBrowser.Desktop.KeyBoard.TypeText(question.Text);
     this.SurveysPage.Map.QuestionUpdateButton.MouseClick();
     Manager.Current.ActiveBrowser.RefreshDomTree();
     ExecutionDelayProvider.SleepFor(2000);
 }
 public void EditSurveyQuestion(SurveyQuestion questionToEdit, SurveyQuestion editingQuestion)
 {
     var rowIndexOfItemToEdit =
         this.SurveysPage.Map.QuestionKendoGrid.IndexOfGridRowContainingText(questionToEdit.Text);
     this.SurveysPage.Map.AllEditEntryButtons[rowIndexOfItemToEdit + 1].ScrollToVisible();
     this.SurveysPage.Map.AllEditEntryButtons[rowIndexOfItemToEdit + 1].MouseClick();
     Manager.Current.ActiveBrowser.RefreshDomTree();
     ExecutionDelayProvider.SleepFor(2000);
     this.SurveysPage.Map.QuestionTypeLabel.MouseClick();
     Manager.Current.ActiveBrowser.RefreshDomTree();
     ExecutionDelayProvider.SleepFor(2000);
     this.SurveysPage.Map.AllQuestionTypeList[editingQuestion.TypeIndex].MouseClick();
     Manager.Current.ActiveBrowser.RefreshDomTree();
     ExecutionDelayProvider.SleepFor(2000);
     this.SurveysPage.Map.QuestionText.MouseClick();
     Manager.Current.ActiveBrowser.Desktop.KeyBoard.KeyPress(Keys.Back, 1000, 18);
     Manager.Current.ActiveBrowser.Desktop.KeyBoard.TypeText(editingQuestion.Text);
     this.SurveysPage.Map.QuestionUpdateButton.MouseClick();
     Manager.Current.ActiveBrowser.RefreshDomTree();
     ExecutionDelayProvider.SleepFor(2000);
 }
 public void DeleteSurveyQuestion(SurveyQuestion question)
 {
     var rowIndexOfItemToDelete =
         this.SurveysPage.Map.QuestionKendoGrid.IndexOfGridRowContainingText(question.Text);
     this.SurveysPage.Map.AllDeleteEntryButtons[rowIndexOfItemToDelete + 1].ScrollToVisible();
     this.SurveysPage.Map.AllDeleteEntryButtons[rowIndexOfItemToDelete + 1].MouseClick();
     ExecutionDelayProvider.SleepFor(2000);
     Manager.Current.ActiveBrowser.Desktop.KeyBoard.KeyPress(Keys.Enter);
     ExecutionDelayProvider.SleepFor(2000);
 }
Ejemplo n.º 35
0
        /// <summary>
        /// Creates a new survey using a json object containing necessary survey fields.
        /// </summary>
        /// <param name="cs"> The consumer survey service used to send the HTTP requests.</param>
        /// <param name="owners"> The list of owners that will be in the newly created survey.</param>
        /// <returns>
        /// A Survey object containing information about the survey.
        /// </returns>

        private static Survey CreateSurvey(ConsumersurveysService cs, List<String> owners)
        {
            SurveyAudience audience = new SurveyAudience()
            {
                Country = "US"
            };
            List<SurveyQuestion> questions = new List<SurveyQuestion>();
            SurveyQuestion question = new SurveyQuestion()
            {
                UnitsPosition = "before",
                Type = "openNumericQuestion",
                Question = "How much did you pay for your last phone?",
                LowValueLabel = "1",
                UnitOfMeasurementLabel = "$",
                SingleLineResponse = true,
                OpenTextPlaceholder = "enter amount here",
            };
            questions.Add(question);

            Survey survey = new Survey()
            {
                Owners = owners,
                Description = "What phones do people buy and how much do they pay?",
                Title = "Phone purchase survey",
                WantedResponseCount = 110,
                Audience = audience,
                Questions = questions,
            };
            Survey createdSurvey = cs.Surveys.Insert(survey).Execute();
            return createdSurvey;
        }