Ejemplo n.º 1
0
        private Question CreateQuestion1(QuestionContents qc, QuestionData qd)
        {
            Question q;

            if (IsEditMode)
            {
                q = Question;
            }
            else
            {
                q                       = new Question();
                q["inBundle"]           = false;
                q["questionContents"]   = qc;
                q["questionData"]       = qd;
                q["test"]               = false;
                q["numberInBundle"]     = cbInBundle.Checked ? (int?)1 : null;
                q.ACL                   = new ParseACL();
                q.ACL.PublicReadAccess  = true;
                q.ACL.PublicWriteAccess = false;
                q.ACL.SetRoleWriteAccess(TutorRole, true);
            }
            q["subject"]  = ddlSubject.Text;
            q["category"] = ddlCategory.Text;
            q["isActive"] = false;
            return(q);
        }
 private async Task <QuestionData[]> GetQuestionData()
 {
     QuestionData[] data = new QuestionData[Questions.Length];
     for (int i = 0; i < data.Length; i++)
     {
         data[i] = Questions[i].Get <QuestionData>("questionData");
         await data[i].FetchIfNeededAsync();
     }
     return(data);
 }
 private async Task<QuestionData[]> GetQuestionData()
 {
     QuestionData[] data = new QuestionData[Questions.Length];
     for (int i = 0; i < data.Length; i++)
     {
         data[i] = Questions[i].Get<QuestionData>("questionData");
         await data[i].FetchIfNeededAsync();
     }
     return data;
 }
Ejemplo n.º 4
0
        private QuestionData CreateData2()
        {
            QuestionData qd2 = new QuestionData();;

            qd2["correctResponses"] = 0;
            qd2["totalResponses"]   = 0;
            qd2["reviewStatus"]     = Constants.ReviewStatusType.PENDING;
            qd2["reviews"]          = new List <ParseObject>();
            qd2.ACL = new ParseACL();
            qd2.ACL.PublicReadAccess  = false;
            qd2.ACL.PublicWriteAccess = false;
            qd2.ACL.SetRoleReadAccess(TutorRole, true);
            qd2.ACL.SetRoleWriteAccess(TutorRole, true);
            return(qd2);
        }
Ejemplo n.º 5
0
        private Question CreateQuestion2(QuestionContents qc2, QuestionData qd2, ParseObject bundle)
        {
            Question q2 = new Question();;

            q2["subject"]          = ddlSubject.Text;
            q2["category"]         = ddlCategory.Text;
            q2["inBundle"]         = true;
            q2["questionContents"] = qc2;
            q2["questionData"]     = qd2;
            q2["bundle"]           = bundle;
            q2["isActive"]         = false;
            q2["test"]             = false;
            q2["numberInBundle"]   = 2;
            q2.ACL = new ParseACL();
            q2.ACL.PublicReadAccess  = true;
            q2.ACL.PublicWriteAccess = false;
            q2.ACL.SetRoleWriteAccess(TutorRole, true);
            return(q2);
        }
Ejemplo n.º 6
0
        private QuestionData CreateData1()
        {
            QuestionData qd;

            if (IsEditMode)
            {
                qd = QuestionData;
            }
            else
            {
                qd = new QuestionData();
                qd["correctResponses"] = 0;
                qd["totalResponses"]   = 0;
                qd["reviews"]          = new List <ParseObject>();
                qd.ACL = new ParseACL();
                qd.ACL.PublicReadAccess  = false;
                qd.ACL.PublicWriteAccess = false;
                qd.ACL.SetRoleReadAccess(TutorRole, true);
                qd.ACL.SetRoleWriteAccess(TutorRole, true);
            }
            qd["reviewStatus"] = Constants.ReviewStatusType.PENDING;
            return(qd);
        }
 private Question CreateQuestion1(QuestionContents qc, QuestionData qd)
 {
     Question q;
     if (IsEditMode)
     {
         q = Question;
     }
     else
     {
         q = new Question();
         q["inBundle"] = false;
         q["questionContents"] = qc;
         q["questionData"] = qd;
         q["test"] = false;
         q["numberInBundle"] = cbInBundle.Checked ? (int?)1 : null;
         q.ACL = new ParseACL();
         q.ACL.PublicReadAccess = true;
         q.ACL.PublicWriteAccess = false;
         q.ACL.SetRoleWriteAccess(TutorRole, true);
     }
     q["subject"] = ddlSubject.Text;
     q["category"] = ddlCategory.Text;
     q["isActive"] = false;
     return q;
 }
 private QuestionData CreateData1()
 {
     QuestionData qd;
     if (IsEditMode)
     {
         qd = QuestionData;
     }
     else
     {
         qd = new QuestionData();
         qd["correctResponses"] = 0;
         qd["totalResponses"] = 0;
         qd["reviews"] = new List<ParseObject>();
         qd.ACL = new ParseACL();
         qd.ACL.PublicReadAccess = false;
         qd.ACL.PublicWriteAccess = false;
         qd.ACL.SetRoleReadAccess(TutorRole, true);
         qd.ACL.SetRoleWriteAccess(TutorRole, true);
     }
     qd["reviewStatus"] = Constants.ReviewStatusType.PENDING;
     return qd;
 }
 private Question CreateQuestion2(QuestionContents qc2, QuestionData qd2, ParseObject bundle)
 {
     Question q2 = new Question();;
     q2["subject"] = ddlSubject.Text;
     q2["category"] = ddlCategory.Text;
     q2["inBundle"] = true;
     q2["questionContents"] = qc2;
     q2["questionData"] = qd2;
     q2["bundle"] = bundle;
     q2["isActive"] = false;
     q2["test"] = false;
     q2["numberInBundle"] = 2;
     q2.ACL = new ParseACL();
     q2.ACL.PublicReadAccess = true;
     q2.ACL.PublicWriteAccess = false;
     q2.ACL.SetRoleWriteAccess(TutorRole, true);
     return q2;
 }
 private QuestionData CreateData2()
 {
     QuestionData qd2 = new QuestionData();;
     qd2["correctResponses"] = 0;
     qd2["totalResponses"] = 0;
     qd2["reviewStatus"] = Constants.ReviewStatusType.PENDING;
     qd2["reviews"] = new List<ParseObject>();
     qd2.ACL = new ParseACL();
     qd2.ACL.PublicReadAccess = false;
     qd2.ACL.PublicWriteAccess = false;
     qd2.ACL.SetRoleReadAccess(TutorRole, true);
     qd2.ACL.SetRoleWriteAccess(TutorRole, true);
     return qd2;
 }
Ejemplo n.º 11
0
        protected void btnSubmitQuestion_Click(object sender, EventArgs e)
        {
            if (!ValidateQuestions())
            {
                pnlError.Visible = true;
                return;
            }
            pnlError.Visible = false;

            if (IsEditMode)
            {
                List <Task>      tasks     = new List <Task>();
                QuestionContents contents1 = CreateContents1();
                QuestionData     data1     = CreateData1();
                Question         question1 = CreateQuestion1(contents1, data1);
                if (IsBundle)
                {
                    QuestionBundle bundle = SaveBundle();
                }
                AsyncHelpers.RunSync(contents1.SaveAsync);
                AsyncHelpers.RunSync(data1.SaveAsync);
                AsyncHelpers.RunSync(question1.SaveAsync);
            }
            else
            {
                List <Task>      tasks     = new List <Task>();
                QuestionContents contents1 = CreateContents1();
                QuestionData     data1     = CreateData1();
                Question         question1 = CreateQuestion1(contents1, data1);

                if (IsBundle)
                {
                    QuestionBundle bundle = SaveBundle();
                    question1["inBundle"] = true;
                    question1["bundle"]   = bundle;
                    QuestionContents contents2 = CreateContents2();
                    QuestionData     data2     = CreateData2();
                    Question         question2 = CreateQuestion2(contents2, data2, bundle);
                    QuestionContents contents3 = CreateContents3();
                    QuestionData     data3     = CreateData3();
                    Question         question3 = CreateQuestion3(contents3, data3, bundle);
                    tasks.Add(contents1.SaveAsync());
                    tasks.Add(contents2.SaveAsync());
                    tasks.Add(contents3.SaveAsync());
                    tasks.Add(data1.SaveAsync());
                    tasks.Add(data1.SaveAsync());
                    tasks.Add(data1.SaveAsync());
                    foreach (Task t in tasks)
                    {
                        t.Wait();
                    }
                    Task t1 = question1.SaveAsync();
                    Task t2 = question2.SaveAsync();
                    Task t3 = question3.SaveAsync();
                    t1.Wait(); t2.Wait(); t3.Wait();
                    bundle["questions"] = new ParseObject[] { question1, question2, question3 };
                    Task t4 = bundle.SaveAsync();
                    t4.Wait();
                }
                else
                {
                    Task t1 = contents1.SaveAsync();
                    Task t2 = data1.SaveAsync();
                    t1.Wait(); t2.Wait();
                    Task t3 = question1.SaveAsync();
                    t3.Wait();
                }
            }
            Session["QuestionObjectId"] = null;
            Response.Redirect("UploadQuestion?success=true");
        }