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);
        }
Ejemplo n.º 2
0
        private QuestionContents CreateContents1()
        {
            QuestionContents qc;

            if (IsEditMode)
            {
                qc = QuestionContents;
            }
            else
            {
                qc = new QuestionContents();
            }
            qc["correctAnswer"] = CorrectIndex(1);
            qc["authorId"]      = PublicUserData.ObjectId;
            qc["questionText"]  = tbQuestion.Text;
            if (cbAnswer5.Checked)
            {
                qc["answers"] = new string[] { tbAnswer1.Text, tbAnswer2.Text, tbAnswer3.Text, tbAnswer4.Text, tbAnswer5.Text }
            }
            ;
            else
            {
                qc["answers"] = new string[] { tbAnswer1.Text, tbAnswer2.Text, tbAnswer3.Text, tbAnswer4.Text }
            };
            qc["explanation"] = tbExplanation.Text;
            if (FileUpload1.HasFile)
            {
                qc["image"] = Upload(FileUpload1);
            }
            qc.ACL = new ParseACL();
            qc.ACL.PublicReadAccess  = true;
            qc.ACL.PublicWriteAccess = false;
            qc.ACL.SetRoleWriteAccess(TutorRole, true);
            return(qc);
        }
 private async Task <QuestionContents[]> GetQuestionContents()
 {
     QuestionContents[] contents = new QuestionContents[Questions.Length];
     for (int i = 0; i < contents.Length; i++)
     {
         contents[i] = Questions[i].Get <QuestionContents>("questionContents");
         await contents[i].FetchIfNeededAsync();
     }
     return(contents);
 }
 private async Task<QuestionContents[]> GetQuestionContents()
 {
     QuestionContents[] contents = new QuestionContents[Questions.Length];
     for (int i = 0; i < contents.Length; i++)
     {
         contents[i] = Questions[i].QuestionContents;
         await contents[i].FetchIfNeededAsync();
     }
     return contents;
 }
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);
        }
 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 QuestionContents CreateContents1()
 {
     QuestionContents qc;
     if (IsEditMode)
         qc = QuestionContents;
     else
         qc = new QuestionContents();
     qc["correctAnswer"] = CorrectIndex(1);
     qc["authorId"] = PublicUserData.ObjectId;
     qc["questionText"] = tbQuestion.Text;
     if (cbAnswer5.Checked) qc["answers"] = new string[] { tbAnswer1.Text, tbAnswer2.Text, tbAnswer3.Text, tbAnswer4.Text, tbAnswer5.Text };
     else qc["answers"] = new string[] { tbAnswer1.Text, tbAnswer2.Text, tbAnswer3.Text, tbAnswer4.Text };
     qc["explanation"] = tbExplanation.Text;
     if (FileUpload1.HasFile)
         qc["image"] = Upload(FileUpload1);
     qc.ACL = new ParseACL();
     qc.ACL.PublicReadAccess = true;
     qc.ACL.PublicWriteAccess = false;
     qc.ACL.SetRoleWriteAccess(TutorRole, true);
     return qc;
 }
 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.º 9
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");
        }