Exemple #1
0
        public static int AddTestResult(int userid, int testid, DateTime date, int timetaken, int correct, int total, string testname)
        {
            string result;
            string data;
            int    testresultid = -1;
            Dictionary <string, string> postData = new Dictionary <string, string>();
            Dictionary <string, string> dict     = null;

            postData.Add("userid", userid.ToString());
            postData.Add("testid", testid.ToString());
            postData.Add("date", date.ToString());
            postData.Add("timetaken", timetaken.ToString());
            postData.Add("correct", correct.ToString());
            postData.Add("total", total.ToString());
            postData.Add("testname", testname);
            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.AddTestResult, postData, ServiceUtil.ServiceCallType.Post);

            if (result != null)
            {
                dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);
                dict.TryGetValue("d", out data);
                testresultid = JsonConvert.DeserializeObject <int>(data);
            }
            return(testresultid);
        }
        public static int AddQuestionResult(int testid, int questionid, string useranswer, string answer, int correct, int responsetime, int result)
        {
            string Quesryresult;
            string data;
            int    questionresultid = -1;
            Dictionary <string, string> postData = new Dictionary <string, string>();
            Dictionary <string, string> dict     = null;

            postData.Add("testid", testid.ToString());
            postData.Add("questionid", questionid.ToString());
            postData.Add("useranswer", useranswer);
            postData.Add("answer", answer);
            postData.Add("correct", correct.ToString());
            postData.Add("responsetime", responsetime.ToString());
            postData.Add("result", result.ToString());
            Quesryresult = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.AddQuestionResult, postData, ServiceUtil.ServiceCallType.Post);

            if (Quesryresult != null)
            {
                dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(Quesryresult);
                dict.TryGetValue("d", out data);
                questionresultid = JsonConvert.DeserializeObject <int>(data);
            }
            return(questionresultid);
        }
Exemple #3
0
        public static void DeleteTest(int testid)
        {
            string result;
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("testid", testid.ToString());
            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.DeleteTest, postData, ServiceUtil.ServiceCallType.Post);
        }
Exemple #4
0
        public static void SetTestTimelimit(int testid, int timelimit)
        {
            string result;
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("testid", testid.ToString());
            postData.Add("timelimit", timelimit.ToString());
            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.SetTestTimelimit, postData, ServiceUtil.ServiceCallType.Post);
        }
Exemple #5
0
        public static void UpdateQuestion(int questionid, string questionstring, string answer)
        {
            string result;
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("questionid", questionid.ToString());
            postData.Add("questionstring", questionstring);
            postData.Add("answer", answer);
            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.UpdateQuestion, postData,
                                                ServiceUtil.ServiceCallType.Post);
        }
Exemple #6
0
        public static void AddQuestion(int testid, String question, String type, String answer)
        {
            string result;
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("testid", testid.ToString());
            postData.Add("question", question);
            postData.Add("type", type);
            postData.Add("answer", answer);
            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.AddQuestion, postData, ServiceUtil.ServiceCallType.Post);
        }
Exemple #7
0
        public static Question[] GetQuestions()
        {
            string                      result = null;
            string                      data;
            List <Question>             questions = null;
            Dictionary <string, string> dict      = null;
            Dictionary <string, string> postData  = new Dictionary <string, string>();

            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.GetQuestionsAll, postData, ServiceUtil.ServiceCallType.Post);
            if (result != null)
            {
                dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);
                dict.TryGetValue("d", out data);
                questions = JsonConvert.DeserializeObject <List <Question> >(data);
                return(questions.ToArray <Question>());
            }
            else
            {
                return(null);
            }
        }
Exemple #8
0
        public static List <string> GetTestTypes()
        {
            string        result = null;
            string        data;
            List <string> testTypes              = null;
            Dictionary <string, string> dict     = null;
            Dictionary <string, string> postData = new Dictionary <string, string>();

            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.GetTestTypes, postData, ServiceUtil.ServiceCallType.Post);
            if (result != null)
            {
                dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);
                dict.TryGetValue("d", out data);
                testTypes = JsonConvert.DeserializeObject <List <string> >(data);
                return(testTypes);
            }
            else
            {
                return(null);
            }
        }
Exemple #9
0
        public static int AddTest(string name, string type, int timelimit)
        {
            string result;
            string data;
            int    testid = -1;
            Dictionary <string, string> postData = new Dictionary <string, string>();
            Dictionary <string, string> dict     = null;

            postData.Add("name", name);
            postData.Add("type", type);
            postData.Add("timelimit", timelimit.ToString());
            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.AddTest, postData, ServiceUtil.ServiceCallType.Post);

            if (result != null)
            {
                dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);
                dict.TryGetValue("d", out data);
                testid = JsonConvert.DeserializeObject <int>(data);
            }
            return(testid);
        }
Exemple #10
0
        public static Test GetTest(int testid)
        {
            string result = null;
            string data;
            Test   test = null;
            Dictionary <string, string> dict     = null;
            Dictionary <string, string> postData = new Dictionary <string, string> {
                { "testid", testid.ToString() }
            };

            result = RemoteUtil.postSynchronous(ServiceURL, ServiceUtil.ServiceMethods.GetTest, postData, ServiceUtil.ServiceCallType.Post);
            if (result != null)
            {
                dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);
                dict.TryGetValue("d", out data);
                test = JsonConvert.DeserializeObject <Test>(data);
                return(test);
            }
            else
            {
                return(null);
            }
        }