示例#1
0
        public StatisticsModule(Questionnaire q, FilledQuestionnaire fq, string culture)
		{
			this._q = q;
            this._fq = fq;
            this.culture = culture;
			_rList = new List<string>();
		}
示例#2
0
 public void StoreQuestionnaire(string userName, Questionnaire questionnaire)
 {
     HandleDb4o.StoreQuestionnaire(userName, questionnaire);
 }
示例#3
0
        // gets admin email
        /* 
        internal static string GetUserMail(string userName)
        {
            var loggedInUserMail =
                (from User user in Database
                 where user.userName == userName
                 select user.Email).FirstOrDefault();
            return loggedInUserMail;
        }*/

        /// <summary>
        /// Creates some test data
        /// </summary>
        /// <param name="dbFileName"></param>
        public static void LoadTestData(string dbFileName)
        {
            var questionnaire1 = new Questionnaire("Q1", "Test questionnaire");
            
            var choiceOpt1 = new TextChoice("Yes", 1);
            var choiceOpt2 = new TextChoice("No", 2);
            var choiceOpt3 = new TextChoice("Maybe", 3);
            var choiceList1 = new List<Choice>();
            choiceList1.Add(choiceOpt1);
            choiceList1.Add(choiceOpt2);
            choiceList1.Add(choiceOpt3);

            var question1 = new ChoiceQuestion("Is this a test?", choiceList1);
            question1.QuestionId = Guid.NewGuid();
            
            questionnaire1.Questions.Add(question1);

            var choiceOpt4 = new NumberChoice(1, 1);
            var choiceOpt5 = new NumberChoice(2, 2);
            var choiceOpt6 = new NumberChoice(100, 3);

            var choiceList2 = new List<Choice>();
            choiceList2.Add(choiceOpt4);
            choiceList2.Add(choiceOpt5);
            choiceList2.Add(choiceOpt6);

            var question2 = new ChoiceQuestion("How many tests are there in this application?", choiceList2);
            question2.QuestionId = Guid.NewGuid();
            questionnaire1.Questions.Add(question2);

            var questionnaire2 = new Questionnaire("Q2", "Public opinion on Statis testing");

            var question3 = new TextQuestion("What do you think about testing?");
            question3.QuestionId = Guid.NewGuid();
            questionnaire2.Questions.Add(question3);

            var question4 = new TextQuestion("Do you think Statis should have a logo?");
            question4.QuestionId = Guid.NewGuid();
            questionnaire2.Questions.Add(question4);

            var img = new object();
            img = null;
            
            var choiceOpt7 = new TextChoice("Yes, why not", 1);
            var choiceOpt8 = new TextChoice("I don't care", 2);
            var choiceOpt9 = new TextChoice("No, it looks ugly", 3);

            var choiceList3 = new List<Choice>();
            choiceList3.Add(choiceOpt7);
            choiceList3.Add(choiceOpt8);
            choiceList3.Add(choiceOpt9);

            var question5 = new ImgChoiceQuestion("Should it be this logo?", img, choiceList3);
            question5.QuestionId = Guid.NewGuid();

            questionnaire2.Questions.Add(question5);

            var filledQuestionnaire1 = new FilledQuestionnaire(questionnaire1);
            var answer1 = new SingleChoiceAnswer
                              {
                                  Choice = 1
                              };
            var answer2 = new SingleChoiceAnswer
                              {
                                  Choice = 3
                              };
            filledQuestionnaire1.Answers.Add(answer1);
            filledQuestionnaire1.Answers.Add(answer2);

            var filledQuestionnaire2 = new FilledQuestionnaire(questionnaire2);
            var answer3 = new TextAnswer("I love testing");
            var answer4 = new TextAnswer("Definitely");
            var answer5 = new SingleChoiceAnswer
                              {
                                  Choice = 3
                              };

            filledQuestionnaire2.Answers.Add(answer3);
            filledQuestionnaire2.Answers.Add(answer4);
            filledQuestionnaire2.Answers.Add(answer5);

            var admin = new Administrator("jb", "Jānis", "Bērziņš", "*****@*****.**", "go");
            var questionnaires = new List<Questionnaire>();
            questionnaires.Add(questionnaire1);
            questionnaires.Add(questionnaire2);
            admin.Questionnaires = questionnaires;


            var user2 = new Analyst("SysAnal", "A", "B", "*****@*****.**", "go");

            admin.TrustedAnalysts = new List<Analyst>();
            admin.TrustedAnalysts.Add(user2);

            admin.Respondents = new List<User>();
            
            var db = GetDb(dbFileName);
            db.Store(admin);
            db.Store(user2);
            //db.Store(questionnaire1);
            //db.Store(questionnaire2);
            //db.Store(filledQuestionnaire1);
            //db.Store(filledQuestionnaire2);
            db.Close();
        }
示例#4
0
        public static void StoreQuestionnaire(string userName, Questionnaire questionnaireToStore)
        {
            var db = Database;
            
            var loggedInUser =
                (from Analyst user in db
                 where user.UserName == userName
                 select user).FirstOrDefault();

            if (loggedInUser != null)
            {
                var q = GetQuestionnaire(questionnaireToStore.Name);
                loggedInUser.Questionnaires.Remove(q);
                DeleteQuestionnaire(db, questionnaireToStore.Name);
                loggedInUser.Questionnaires.Add(questionnaireToStore);
                db.Store(loggedInUser);
                db.Commit();
            }
        }
示例#5
0
        public void TestStatisServiceMethodDeleteQuestionnaire()
        {
            var config = Db4oEmbedded.NewConfiguration();
            config.Common.ObjectClass(typeof(Questionnaire)).CascadeOnDelete(true);
            var db = Db4oEmbedded.OpenFile(config, TestDbFile);

            int noOfObjectsBefore;
            var questionnaireExample = new Questionnaire();
            noOfObjectsBefore = db.QueryByExample(questionnaireExample).Count;

            var questionnaire = new Questionnaire("Q99", "Clean test database");
            IObjectSet set = db.QueryByExample(questionnaire);

            var questionnaireVerify = new Questionnaire();
            questionnaireVerify = (Questionnaire)set[0];
            db.Delete(questionnaireVerify);

            int noOfObjectsAfter = db.QueryByExample(questionnaireExample).Count;

            Assert.AreNotEqual(noOfObjectsBefore, noOfObjectsAfter, "Test database not deleted");
            Assert.IsFalse(db.QueryByExample(questionnaireExample).Contains(questionnaire), "Test database not deleted");
        }
示例#6
0
        public void TestStatisServiceMethodStoreQuestionnaire()
        {
            var config = Db4oEmbedded.NewConfiguration();
            config.Common.ObjectClass(typeof(Questionnaire)).CascadeOnDelete(true);
            var db = Db4oEmbedded.OpenFile(config, TestDbFile);

            int noOfObjectsBefore;
            var questionnaireExample = new Questionnaire();
            noOfObjectsBefore = db.QueryByExample(questionnaireExample).Count;
            
            var questionnaire = new Questionnaire("Q99", "Clean test database");
            db.Store(questionnaire);

            int noOfObjectsAfter = db.QueryByExample(questionnaireExample).Count;

            Assert.AreNotEqual(noOfObjectsBefore, noOfObjectsAfter, "No new database stored");
            Assert.IsTrue(db.QueryByExample(questionnaireExample).Contains(questionnaire), "Test database not stored");

            /*using(var proxy = new QuestionnaireAdministrativeServiceClient())
            {
                proxy.Open();
                proxy.StoreQuestionnaire(questionnaire);
                
                //commpare db and service returned questionnaires
                Assert.IsNotNull(serviceQuestionnaire, "Service does not return any data.");
                Assert.AreEqual(questionnaire.Name, serviceQuestionnaire.Name, "Service and db contain questionnaires with different names.");
                Assert.AreEqual(questionnaire.Description, serviceQuestionnaire.Description, "Service and db contains questionnaires with different descriptions.");
                Assert.AreEqual(questionnaire.Questions.Count, serviceQuestionnaire.Questions.Count, "Service and db questionnaires contains different number of questions.");
            }*/
        }