public function testCompletePaperPartialAnswers()
 {
     do_student_login($this, 'teststudent14', 'mon~61Qt');
     $this->open("/paper/user_index.php?id=21355414508102");
     $this->click("id=start");
     $this->waitForPopUp("paper", "30000");
     $this->selectWindow("name=paper");
     $this->click("id=q1_1");
     $this->click("id=q2_1");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("id=q1_2");
     $this->click("id=q2_2");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("id=q1_1");
     $this->click("id=q2_4");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("id=q1_2");
     $this->click("id=q2_3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("id=q1_1");
     $this->click("id=q2_3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("id=q1_4");
     $this->click("id=q2_2");
     $this->click("id=finish");
     $this->assertEquals("Are you sure you wish to finish. After clicking 'OK' you will not be able to go back.", $this->getConfirmation());
     $this->waitForPageToLoad("30000");
     $this->assertLocation($this->page_root . '/paper/finish.php?id=21355414508102&dont_record=true');
     // Individual Question Marks
     $this->assertElementContainsText('//table[2]/tbody/tr[2]/td[2]/p[2]/span', '1 out of 2');
     $this->assertElementContainsText('//table[2]/tbody/tr[4]/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[3]/tbody/tr/td[2]/p/span', '0 out of 4');
     $this->assertElementContainsText('//table[3]/tbody/tr[3]/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[4]/tbody/tr/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[4]/tbody/tr[3]/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[5]/tbody/tr[2]/td[2]/p[2]/span', '-2 out of 2');
     $this->assertElementContainsText('//table[5]/tbody/tr[4]/td[2]/p/span', '1 out of 4');
     $this->assertElementContainsText('//table[6]/tbody/tr/td[2]/p/span', '0.5 out of 2');
     $this->assertElementContainsText('//table[6]/tbody/tr[3]/td[2]/p/span', '-1 out of 2');
     $this->assertElementContainsText('//table[7]/tbody/tr/td[2]/p/span', '-1 out of 1');
     $this->assertElementContainsText('//table[7]/tbody/tr[3]/td[2]/p/span', '-2 out of 3');
     // Overall Marks
     $this->assertElementContainsText('//div[7]/table/tbody/tr[2]/td[2]', '-3.5 out of 27');
     $this->assertElementContainsText('//div[7]/table/tbody/tr[3]/td[2]', '40%');
     $this->assertElementContainsText('//div[7]/table/tbody/tr[4]/td[2]', '-12.96%');
 }
 public function testQuestionFeedbackNotAllowed()
 {
     do_student_login($this, 'teststudent2', 'nrt%52YQ');
     $this->open("paper/feedback.php?id=71377089276102&userid=104");
     $this->assertTextPresent('Access Denied');
 }
 public function testCompletePaperMixed()
 {
     do_student_login($this, 'teststudent13', 'hii.420R');
     $this->open("/paper/user_index.php?id=11355244387102");
     $this->click("id=start");
     $this->waitForPopUp("paper", "30000");
     $this->selectWindow("name=paper");
     $this->click("name=q1");
     $this->click("xpath=(//input[@name='q2'])[1]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->select("name=q1", "label=Option Three");
     $this->click("xpath=(//input[@name='q2'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1");
     $this->select("name=q2", "label=Option M");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1' and @value='2'])");
     $this->click("xpath=(//input[@name='q2' and @value='2'])");
     $this->select("name=q3", "label=Option Three");
     $this->click("id=finish");
     $this->assertEquals("Are you sure you wish to finish. After clicking 'OK' you will not be able to go back.", $this->getConfirmation());
     $this->waitForPageToLoad("30000");
     $this->assertLocation($this->page_root . '/paper/finish.php?id=11355244387102&dont_record=true');
     // Individual Question Marks
     $this->assertElementContainsText('//table[2]/tbody/tr/td[2]/p/span', '1 out of 1');
     $this->assertElementContainsText('//table[2]/tbody/tr[4]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[3]/tbody/tr/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[3]/tbody/tr[3]/td[2]/p/span', '1 out of 1');
     $this->assertElementContainsText('//table[4]/tbody/tr/td[2]/p/span', '1 out of 1');
     $this->assertElementContainsText('//table[4]/tbody/tr[3]/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[5]/tbody/tr/td[2]/p/span', '-1 out of 1');
     $this->assertElementContainsText('//table[5]/tbody/tr[3]/td[2]/p/span', '1 out of 1');
     $this->assertElementContainsText('//table[5]/tbody/tr[5]/td[2]/p/span', '2 out of 2');
     // Overall Marks
     $this->assertElementContainsText('//div[5]/table/tbody/tr[2]/td[2]', '5 out of 12');
     $this->assertElementContainsText('//div[5]/table/tbody/tr[3]/td[2]', '40%');
     $this->assertElementContainsText('//div[5]/table/tbody/tr[4]/td[2]', '41.67%');
 }
 public function testCompletePaperPartialAnswers()
 {
     do_student_login($this, 'teststudent14', 'mon~61Qt');
     $this->open("/paper/user_index.php?id=31357211657102");
     $this->click("id=start");
     $this->waitForPopUp("paper", "30000");
     $this->selectWindow("name=paper");
     $this->select("name=q1_2", "label=E. Option Five");
     $this->select("name=q1_3", "label=B. Option Two");
     $this->select("name=q2_1", "label=A. Option B");
     $this->select("name=q2_3", "label=E. Option X");
     $this->select("name=q2_4", "label=C. Option M");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->select("name=q1_1", "value=3");
     $this->select("name=q1_2", "value=3");
     $this->select("name=q2_1", "label=B. Option Two");
     $this->select("name=q2_3", "label=A. Option One");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->select("name=q1_1", "label=A. Option B");
     $this->select("name=q1_2", "label=E. Option X");
     $this->select("name=q1_3", "label=B. Option C");
     $this->select("name=q2_2", "value=4");
     $this->select("name=q2_3", "value=2");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->select("name=q1_1", "label=A. Option One");
     $this->select("name=q1_3", "label=E. Option Five");
     $this->select("name=q2_1", "label=C. Option M");
     $this->select("name=q2_2", "label=B. Option C");
     $this->select("name=q2_4", "label=D. Option P");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->select("name=q1_2", "value=3");
     $this->select("name=q1_3", "value=3");
     $this->select("name=q2_1", "label=A. Option One");
     $this->select("name=q2_3", "label=B. Option Two");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->select("name=q1_2", "label=B. Option C");
     $this->select("name=q1_3", "label=B. Option C");
     $this->select("name=q1_4", "label=B. Option C");
     $this->select("name=q2_1", "value=2");
     $this->select("name=q2_2", "value=2");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "label=A. Option One");
     $this->addSelection("id=q1_1", "label=C. Option Three");
     $this->select("name=q1_3", "label=B. Option Two");
     $this->select("name=q2_2", "label=A. Option B");
     $this->addSelection("id=q2_3", "label=C. Option M");
     $this->addSelection("id=q2_3", "label=D. Option P");
     $this->addSelection("id=q2_4", "label=A. Option B");
     $this->addSelection("id=q2_4", "label=B. Option C");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->select("name=q1_1", "value=5");
     $this->addSelection("id=q1_2", "value=1");
     $this->addSelection("id=q1_2", "value=4");
     $this->addSelection("id=q2_2", "label=B. Option Two");
     $this->addSelection("id=q2_2", "label=C. Option Three");
     $this->select("name=q2_3", "label=E. Option Five");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "label=C. Option M");
     $this->addSelection("id=q1_1", "label=E. Option X");
     $this->addSelection("id=q1_2", "label=D. Option P");
     $this->addSelection("id=q1_2", "label=E. Option X");
     $this->select("name=q1_4", "label=D. Option P");
     $this->select("name=q2_2", "value=4");
     $this->addSelection("id=q2_3", "value=2");
     $this->addSelection("id=q2_3", "value=3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "label=A. Option One");
     $this->addSelection("id=q1_1", "label=C. Option Three");
     $this->select("name=q1_3", "label=A. Option One");
     $this->select("name=q2_1", "label=C. Option M");
     $this->addSelection("id=q2_2", "label=B. Option C");
     $this->addSelection("id=q2_2", "label=C. Option M");
     $this->addSelection("id=q2_4", "label=D. Option P");
     $this->addSelection("id=q2_4", "label=E. Option X");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_2", "value=2");
     $this->addSelection("id=q1_2", "value=3");
     $this->select("name=q1_3", "value=3");
     $this->addSelection("id=q2_1", "label=A. Option One");
     $this->addSelection("id=q2_1", "label=C. Option Three");
     $this->select("name=q2_2", "label=E. Option Five");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "label=B. Option C");
     $this->addSelection("id=q1_1", "label=C. Option M");
     $this->select("name=q1_3", "label=A. Option B");
     $this->addSelection("id=q1_4", "label=D. Option P");
     $this->addSelection("id=q1_4", "label=E. Option X");
     $this->addSelection("id=q2_2", "value=2");
     $this->addSelection("id=q2_2", "value=5");
     $this->select("name=q2_3", "value=3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "label=A. Option One");
     $this->addSelection("id=q1_2", "label=E. Option Five");
     $this->addSelection("id=q1_3", "label=B. Option Two");
     $this->addSelection("id=q1_3", "label=E. Option Five");
     $this->addSelection("id=q2_1", "label=A. Option B");
     $this->addSelection("id=q2_1", "label=B. Option C");
     $this->addSelection("id=q2_2", "label=D. Option P");
     $this->addSelection("id=q2_3", "label=B. Option C");
     $this->addSelection("id=q2_3", "label=D. Option P");
     $this->addSelection("id=q2_4", "label=A. Option B");
     $this->addSelection("id=q2_4", "label=B. Option C");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "value=2");
     $this->addSelection("id=q1_2", "value=3");
     $this->addSelection("id=q1_3", "value=4");
     $this->addSelection("id=q1_3", "value=2");
     $this->addSelection("id=q2_1", "label=B. Option Two");
     $this->addSelection("id=q2_1", "label=E. Option Five");
     $this->addSelection("id=q2_2", "label=C. Option Three");
     $this->addSelection("id=q2_3", "label=C. Option Three");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "label=C. Option M");
     $this->addSelection("id=q1_2", "label=B. Option C");
     $this->addSelection("id=q1_3", "label=E. Option X");
     $this->addSelection("id=q1_4", "label=B. Option C");
     $this->addSelection("id=q2_1", "value=3");
     $this->addSelection("id=q2_1", "value=5");
     $this->addSelection("id=q2_2", "value=5");
     $this->addSelection("id=q2_3", "value=3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "label=A. Option One");
     $this->addSelection("id=q1_2", "label=A. Option One");
     $this->addSelection("id=q1_2", "label=B. Option Two");
     $this->addSelection("id=q1_3", "label=C. Option Three");
     $this->addSelection("id=q2_1", "label=E. Option X");
     $this->addSelection("id=q2_2", "label=B. Option C");
     $this->addSelection("id=q2_2", "label=C. Option M");
     $this->addSelection("id=q2_3", "label=A. Option B");
     $this->addSelection("id=q2_4", "label=D. Option P");
     $this->addSelection("id=q2_4", "label=E. Option X");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "value=1");
     $this->addSelection("id=q1_2", "value=1");
     $this->addSelection("id=q1_3", "value=1");
     $this->addSelection("id=q2_1", "label=A. Option One");
     $this->addSelection("id=q2_2", "label=D. Option Four");
     $this->addSelection("id=q2_3", "label=A. Option One");
     $this->addSelection("id=q2_3", "label=B. Option Two");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->addSelection("id=q1_1", "label=B. Option C");
     $this->addSelection("id=q1_2", "label=C. Option M");
     $this->addSelection("id=q1_3", "label=B. Option C");
     $this->addSelection("id=q1_3", "label=D. Option P");
     $this->addSelection("id=q1_4", "label=D. Option P");
     $this->addSelection("id=q2_1", "value=4");
     $this->addSelection("id=q2_2", "value=2");
     $this->addSelection("id=q2_2", "value=3");
     $this->addSelection("id=q2_3", "value=4");
     $this->addSelection("id=q2_3", "value=5");
     $this->click("id=finish");
     $this->assertEquals("Are you sure you wish to finish. After clicking 'OK' you will not be able to go back.", $this->getConfirmation());
     $this->waitForPageToLoad("30000");
     $this->assertLocation($this->page_root . '/paper/finish.php?id=31357211657102&dont_record=true');
     // Individual Question Marks
     $this->assertElementContainsText("//table[2]/tbody/tr[2]/td[2]/p[2]/span", '2 out of 3');
     $this->assertElementContainsText("//table[2]/tbody/tr[4]/td[2]/p/span", '0 out of 8');
     $this->assertElementContainsText("//table[3]/tbody/tr/td[2]/p/span", '1 out of 3');
     $this->assertElementContainsText("//table[3]/tbody/tr[4]/td[2]/p/span", '-1 out of 3');
     $this->assertElementContainsText("//table[4]/tbody/tr/td[2]/p/span", '-3 out of 8');
     $this->assertElementContainsText("//table[4]/tbody/tr[3]/td[2]/p/span", '2 out of 3');
     $this->assertElementContainsText("//table[5]/tbody/tr[2]/td[2]/p[2]/span", '0 out of 1');
     $this->assertElementContainsText("//table[5]/tbody/tr[4]/td[2]/p/span", '0 out of 2');
     $this->assertElementContainsText("//table[6]/tbody/tr/td[2]/p/span", '0 out of 3');
     $this->assertElementContainsText("//table[6]/tbody/tr[4]/td[2]/p/span", '-0.5 out of 1');
     $this->assertElementContainsText("//table[7]/tbody/tr/td[2]/p/span", '-1 out of 2');
     $this->assertElementContainsText("//table[7]/tbody/tr[3]/td[2]/p/span", '-1 out of 1');
     $this->assertElementContainsText("//table[8]/tbody/tr[2]/td[2]/p[2]/span", '3 out of 5');
     $this->assertElementContainsText("//table[8]/tbody/tr[4]/td[2]/p/span", '0 out of 14');
     $this->assertElementContainsText("//table[9]/tbody/tr/td[2]/p/span", '2 out of 5');
     $this->assertElementContainsText("//table[9]/tbody/tr[4]/td[2]/p/span", '-1.5 out of 5');
     $this->assertElementContainsText("//table[10]/tbody/tr/td[2]/p/span", '4 out of 14');
     $this->assertElementContainsText("//table[10]/tbody/tr[3]/td[2]/p/span", '3 out of 5');
     $this->assertElementContainsText("//table[11]/tbody/tr[2]/td[2]/p[2]/span", '0 out of 1');
     $this->assertElementContainsText("//table[11]/tbody/tr[4]/td[2]/p/span", '0 out of 2');
     $this->assertElementContainsText("//table[12]/tbody/tr/td[2]/p/span", '0 out of 3');
     $this->assertElementContainsText("//table[12]/tbody/tr[4]/td[2]/p/span", '-0.5 out of 1');
     $this->assertElementContainsText("//table[13]/tbody/tr/td[2]/p/span", '-1 out of 2');
     $this->assertElementContainsText("//table[13]/tbody/tr[3]/td[2]/p/span", '-1 out of 1');
     $this->assertElementContainsText("//table[14]/tbody/tr[2]/td[2]/p[2]/span", '4 out of 6');
     $this->assertElementContainsText("//table[14]/tbody/tr[4]/td[2]/p/span", '0 out of 16');
     $this->assertElementContainsText("//table[15]/tbody/tr/td[2]/p/span", '2 out of 6');
     $this->assertElementContainsText("//table[15]/tbody/tr[4]/td[2]/p/span", '-2 out of 6');
     $this->assertElementContainsText("//table[16]/tbody/tr/td[2]/p/span", '2 out of 16');
     $this->assertElementContainsText("//table[16]/tbody/tr[3]/td[2]/p/span", '4 out of 6');
     $this->assertElementContainsText("//table[17]/tbody/tr[2]/td[2]/p[2]/span", '0 out of 1');
     $this->assertElementContainsText("//table[17]/tbody/tr[4]/td[2]/p/span", '0 out of 2');
     $this->assertElementContainsText("//table[18]/tbody/tr/td[2]/p/span", '0 out of 3');
     $this->assertElementContainsText("//table[18]/tbody/tr[4]/td[2]/p/span", '-0.5 out of 1');
     $this->assertElementContainsText("//table[19]/tbody/tr/td[2]/p/span", '-1 out of 2');
     $this->assertElementContainsText("//table[19]/tbody/tr[3]/td[2]/p/span", '-1 out of 1');
     // Overall Marks
     $this->assertElementContainsText("//div[19]/table/tbody/tr[2]/td[2]", '14 out of 162');
     $this->assertElementContainsText('//div[19]/table/tbody/tr[3]/td[2]', '40%');
     $this->assertElementContainsText("//div[19]/table/tbody/tr[4]/td[2]", '8.64%');
 }
 public function testCompletePaperMixed2()
 {
     do_student_login($this, 'teststudent14', 'mon~61Qt');
     $this->open("/paper/user_index.php?id=51357812182102");
     $this->click("id=start");
     $this->waitForPopUp("paper", "30000");
     $this->selectWindow("name=paper");
     $this->select("name=q1_1", "label=colour");
     $this->select("name=q1_2", "label=country");
     $this->select("name=q2_1", "label=texture");
     $this->select("name=q2_2", "label=continent");
     $this->select("name=q2_3", "label=Video Display Unit");
     $this->select("name=q3_1", "label=colour");
     $this->select("name=q3_2", "label=country");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->select("name=q1_1", "label=country");
     $this->select("name=q1_2", "label=city");
     $this->select("name=q1_3", "label=Video Display Unit");
     $this->type("name=q2_1", "colour");
     $this->type("name=q2_2", "country");
     $this->type("name=q3_1", "texture");
     $this->type("name=q3_2", "city");
     $this->type("name=q3_3", "Video Display Unit");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->type("name=q1_1", "colour");
     $this->type("name=q1_2", "country");
     $this->type("name=q2_1", "texture");
     $this->type("name=q2_2", "continent");
     $this->type("name=q2_3", "Vibrant Display Unit");
     $this->click("id=finish");
     $this->assertEquals("Are you sure you wish to finish. After clicking 'OK' you will not be able to go back.", $this->getConfirmation());
     $this->waitForPageToLoad("30000");
     $this->assertLocation($this->page_root . '/paper/finish.php?id=51357812182102&dont_record=true');
     // Individual Question Marks
     $this->assertElementContainsText('//table[2]/tbody/tr[2]/td[2]/p[4]/span', '2 out of 2');
     $this->assertElementContainsText('//table[2]/tbody/tr[5]/td[2]/p[3]/span', '-3 out of 6');
     $this->assertElementContainsText('//table[2]/tbody/tr[8]/td[2]/p[3]/span', '2 out of 2');
     $this->assertElementContainsText('//table[3]/tbody/tr[2]/td[2]/p[3]/span', '-1 out of 3');
     $this->assertElementContainsText('//table[3]/tbody/tr[5]/td[2]/p[4]/span', '2 out of 2');
     $this->assertElementContainsText('//table[3]/tbody/tr[8]/td[2]/p[3]/span', '-3 out of 6');
     $this->assertElementContainsText('//table[4]/tbody/tr[2]/td[2]/p[3]/span', '2 out of 2');
     $this->assertElementContainsText('//table[4]/tbody/tr[5]/td[2]/p[3]/span', '-1 out of 3');
     // Overall Marks
     $this->assertElementContainsText('//div[4]/table/tbody/tr[2]/td[2]', '0 out of 26');
     $this->assertElementContainsText('//div[4]/table/tbody/tr[3]/td[2]', '40%');
     $this->assertElementContainsText('//div[4]/table/tbody/tr[4]/td[2]', '0.00%');
 }
 public function testPaperFinishNonExistent()
 {
     do_student_login($this, 'teststudent10', 'jgl!34Z^');
     $this->open("paper/finish.php?id=6184135298420215248&previous=20121125233045&log_type=1");
     $this->assertTextPresent('Page not Found');
 }
 public function testCompletePaperPartialAnswers()
 {
     do_student_login($this, 'teststudent15', 'scd=50AH');
     $this->open("/paper/user_index.php?id=41357635970102");
     $this->click("id=start");
     $this->waitForPopUp("paper", "30000");
     $this->selectWindow("name=paper");
     $this->click("name=q1_1");
     $this->click("xpath=(//input[@name='q1_2'])[2]");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("name=q2_4");
     $this->click("name=q2_3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("name=q1_3");
     $this->click("name=q1_4");
     $this->click("name=q1_5");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("name=q2_2");
     $this->click("name=q2_3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_2'])[2]");
     $this->click("name=q1_3");
     $this->click("name=q2_1");
     $this->click("xpath=(//input[@name='q2_2'])[2]");
     $this->click("xpath=(//input[@name='q2_3'])[2]");
     $this->click("xpath=(//input[@name='q2_5'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("xpath=(//input[@name='q1_2'])[2]");
     $this->click("name=q1_3");
     $this->click("name=q2_1");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("xpath=(//input[@name='q2_3'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_1'])[2]");
     $this->click("name=q1_2");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("name=q1_5");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("name=q2_3");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("xpath=(//input[@name='q2_2'])[2]");
     $this->click("xpath=(//input[@name='q2_3'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("name=q1_4");
     $this->click("name=q2_2");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("name=q2_4");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("name=q1_5");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("name=q2_2");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_2'])[2]");
     $this->click("xpath=(//input[@name='q1_1'])[2]");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("xpath=(//input[@name='q2_2'])[2]");
     $this->click("xpath=(//input[@name='q2_3'])[2]");
     $this->click("name=q2_4");
     $this->click("xpath=(//input[@name='q2_5'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("name=q1_2");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("xpath=(//input[@name='q2_2'])[2]");
     $this->click("name=q2_1");
     $this->click("xpath=(//input[@name='q2_3'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_1'])[2]");
     $this->click("name=q1_2");
     $this->click("name=q1_3");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_2'])[2]");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("name=q2_1");
     $this->click("xpath=(//input[@name='q2_2'])[2]");
     $this->click("name=q2_5");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_2'])[2]");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("name=q1_4");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("name=q2_4");
     $this->click("name=q2_3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("name=q1_3");
     $this->click("name=q1_2");
     $this->click("name=q2_3");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_2'])[2]");
     $this->click("xpath=(//input[@name='q1_1'])[2]");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("xpath=(//input[@name='q2_3'])[2]");
     $this->click("name=q2_4");
     $this->click("xpath=(//input[@name='q2_5'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("name=q1_2");
     $this->click("name=q1_4");
     $this->click("name=q2_1");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_1'])[2]");
     $this->click("name=q1_2");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("name=q1_5");
     $this->click("name=q2_2");
     $this->click("name=q2_3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("name=q2_4");
     $this->click("name=q2_5");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("name=q1_4");
     $this->click("name=q2_2");
     $this->click("xpath=(//input[@name='q2_1'])[2]");
     $this->click("name=q2_3");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("name=q1_3");
     $this->click("name=q1_4");
     $this->click("name=q2_2");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_2");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("xpath=(//input[@name='q2_2'])[2]");
     $this->click("xpath=(//input[@name='q2_3'])[2]");
     $this->click("name=q2_4");
     $this->click("xpath=(//input[@name='q2_5'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_2");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("xpath=(//input[@name='q1_4'])[2]");
     $this->click("name=q2_1");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("xpath=(//input[@name='q1_1'])[2]");
     $this->click("name=q1_3");
     $this->click("name=q1_5");
     $this->click("name=q2_2");
     $this->click("name=q2_3");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     $this->click("name=q1_1");
     $this->click("xpath=(//input[@name='q1_3'])[2]");
     $this->click("name=q2_1");
     $this->click("xpath=(//input[@name='q2_4'])[2]");
     $this->click("name=q2_5");
     $this->click("id=finish");
     $this->assertEquals("Are you sure you wish to finish. After clicking 'OK' you will not be able to go back.", $this->getConfirmation());
     $this->waitForPageToLoad("30000");
     $this->assertLocation($this->page_root . '/paper/finish.php?id=41357635970102&dont_record=true');
     // Individual Question Marks
     $this->assertElementContainsText('//table[2]/tbody/tr[2]/td[2]/p[2]/span', '3 out of 4');
     $this->assertElementContainsText('//table[2]/tbody/tr[4]/td[2]/p/span', '0 out of 8');
     $this->assertElementContainsText('//table[3]/tbody/tr/td[2]/p/span', '2 out of 5');
     $this->assertElementContainsText('//table[3]/tbody/tr[4]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[4]/tbody/tr/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[4]/tbody/tr[3]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[5]/tbody/tr[2]/td[2]/p/span', '1.5 out of 4');
     $this->assertElementContainsText('//table[5]/tbody/tr[4]/td[2]/p/span', '6 out of 8');
     $this->assertElementContainsText('//table[6]/tbody/tr/td[2]/p/span', '-4 out of 5');
     $this->assertElementContainsText('//table[6]/tbody/tr[4]/td[2]/p/span', '-0.5 out of 1');
     $this->assertElementContainsText('//table[7]/tbody/tr/td[2]/p/span', '-1 out of 2');
     $this->assertElementContainsText('//table[7]/tbody/tr[3]/td[2]/p/span', '-1 out of 1');
     $this->assertElementContainsText('//table[8]/tbody/tr[2]/td[2]/p[2]/span', '3 out of 4');
     $this->assertElementContainsText('//table[8]/tbody/tr[4]/td[2]/p/span', '0 out of 8');
     $this->assertElementContainsText('//table[9]/tbody/tr/td[2]/p/span', '2 out of 5');
     $this->assertElementContainsText('//table[9]/tbody/tr[4]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[10]/tbody/tr/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[10]/tbody/tr[3]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[11]/tbody/tr[2]/td[2]/p/span', '1.5 out of 4');
     $this->assertElementContainsText('//table[11]/tbody/tr[4]/td[2]/p/span', '6 out of 8');
     $this->assertElementContainsText('//table[12]/tbody/tr/td[2]/p/span', '-4 out of 5');
     $this->assertElementContainsText('//table[12]/tbody/tr[4]/td[2]/p/span', '-0.5 out of 1');
     $this->assertElementContainsText('//table[13]/tbody/tr/td[2]/p/span', '-1 out of 2');
     $this->assertElementContainsText('//table[13]/tbody/tr[3]/td[2]/p/span', '-1 out of 1');
     $this->assertElementContainsText('//table[14]/tbody/tr[2]/td[2]/p[2]/span', '3 out of 4');
     $this->assertElementContainsText('//table[14]/tbody/tr[4]/td[2]/p/span', '0 out of 8');
     $this->assertElementContainsText('//table[15]/tbody/tr/td[2]/p/span', '1 out of 5');
     $this->assertElementContainsText('//table[15]/tbody/tr[4]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[16]/tbody/tr/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[16]/tbody/tr[3]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[17]/tbody/tr[2]/td[2]/p/span', '1.5 out of 4');
     $this->assertElementContainsText('//table[17]/tbody/tr[4]/td[2]/p/span', '4 out of 8');
     $this->assertElementContainsText('//table[18]/tbody/tr/td[2]/p/span', '-4 out of 5');
     $this->assertElementContainsText('//table[18]/tbody/tr[4]/td[2]/p/span', '-0.5 out of 1');
     $this->assertElementContainsText('//table[19]/tbody/tr/td[2]/p/span', '-1 out of 2');
     $this->assertElementContainsText('//table[19]/tbody/tr[3]/td[2]/p/span', '-1 out of 1');
     $this->assertElementContainsText('//table[20]/tbody/tr[2]/td[2]/p[2]/span', '2 out of 4');
     $this->assertElementContainsText('//table[20]/tbody/tr[4]/td[2]/p/span', '0 out of 8');
     $this->assertElementContainsText('//table[21]/tbody/tr/td[2]/p/span', '2 out of 5');
     $this->assertElementContainsText('//table[21]/tbody/tr[4]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[22]/tbody/tr/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[22]/tbody/tr[3]/td[2]/p/span', '0 out of 1');
     $this->assertElementContainsText('//table[23]/tbody/tr[2]/td[2]/p/span', '0 out of 4');
     $this->assertElementContainsText('//table[23]/tbody/tr[4]/td[2]/p/span', '4 out of 8');
     $this->assertElementContainsText('//table[24]/tbody/tr/td[2]/p/span', '-3 out of 5');
     $this->assertElementContainsText('//table[24]/tbody/tr[4]/td[2]/p/span', '-0.5 out of 1');
     $this->assertElementContainsText('//table[25]/tbody/tr/td[2]/p/span', '-1 out of 2');
     $this->assertElementContainsText('//table[25]/tbody/tr[3]/td[2]/p/span', '-1 out of 1');
     // Overall Marks
     $this->assertElementContainsText('//div[25]/table/tbody/tr[2]/td[2]', '17.5 out of 168');
     $this->assertElementContainsText('//div[25]/table/tbody/tr[3]/td[2]', '40%');
     $this->assertElementContainsText('//div[25]/table/tbody/tr[4]/td[2]', '10.42%');
 }
 public function testCompletePaperMixed()
 {
     do_student_login($this, 'teststudent15', 'scd=50AH');
     $this->open("/paper/user_index.php?id=61357920091102");
     $this->click("id=start");
     $this->waitForPopUp("paper", "30000");
     $this->selectWindow("name=paper");
     // Calculate correct answers and input them
     $qn_text = $this->getText('id=calc1_q');
     $matches = array();
     preg_match('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1];
     $answer = pow($A, 2) * pi();
     $answer = round($answer, 2);
     $this->type("id=q1", $answer);
     $qn_text = $this->getText('id=calc2_q');
     preg_match_all('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1][0];
     $B = $matches[1][1];
     $answer = sqrt(pow($A, 2) + pow($B, 2));
     $answer = round($answer, 1);
     $this->type("id=q2", $answer - 2);
     $qn_text = $this->getText('id=calc3_q');
     $matches = array();
     preg_match('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1];
     $answer = pow($A, 2) * pi();
     $answer = round($answer, 2);
     $this->type("id=q3", $answer + 2);
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     // Calculate correct answers and input them
     $qn_text = $this->getText('id=calc4_q');
     preg_match_all('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1][0];
     $B = $matches[1][1];
     $answer = sqrt(pow($A, 2) + pow($B, 2));
     $answer = round($answer, 1);
     $this->type("id=q1", $answer - 1);
     $qn_text = $this->getText('id=calc5_q');
     $matches = array();
     preg_match('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1];
     $answer = pow($A, 2) * pi();
     $answer = round($answer, 2);
     $this->type("id=q2", $answer + 1);
     $qn_text = $this->getText('id=calc6_q');
     preg_match_all('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1][0];
     $B = $matches[1][1];
     $answer = sqrt(pow($A, 2) + pow($B, 2));
     $answer = round($answer, 1);
     $this->type("id=q3", $answer - 2);
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     // Calculate correct answers and input them
     $qn_text = $this->getText('id=calc7_q');
     $matches = array();
     preg_match('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1];
     $answer = pow($A, 2) * pi();
     $answer = round($answer, 2);
     $this->type("id=q1", $answer);
     $qn_text = $this->getText('id=calc8_q');
     preg_match_all('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1][0];
     $B = $matches[1][1];
     $answer = sqrt(pow($A, 2) + pow($B, 2));
     $answer = round($answer, 1);
     $this->type("id=q2", $answer - 1);
     $qn_text = $this->getText('id=calc9_q');
     $matches = array();
     preg_match('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1];
     $answer = pow($A, 2) * pi();
     $answer = round($answer, 2);
     $answer = $this->get_answer_with_tolerance($answer, 6);
     $this->type("id=q3", $answer);
     $this->click("id=next");
     $this->waitForPageToLoad("30000");
     // Calculate correct answers and input them
     $qn_text = $this->getText('id=calc10_q');
     preg_match_all('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1][0];
     $B = $matches[1][1];
     $answer = sqrt(pow($A, 2) + pow($B, 2));
     $answer = round($answer, 1);
     // Store answer and tolerance for comparison later
     $t_vals = array('10' => array($answer, 0.08, 1));
     $answer = $this->get_answer_with_tolerance($answer, 8);
     $this->type("id=q1", $answer);
     $qn_text = $this->getText('id=calc11_q');
     $matches = array();
     preg_match('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1];
     $answer = pow($A, 2) * pi();
     $answer = round($answer, 2);
     $this->type("id=q2", $answer);
     $qn_text = $this->getText('id=calc12_q');
     preg_match_all('/\\|\\|([0-9\\.]*?)\\|\\|/', $qn_text, $matches);
     $A = $matches[1][0];
     $B = $matches[1][1];
     $answer = sqrt(pow($A, 2) + pow($B, 2));
     $answer = round($answer, 1);
     // Store tolerance min/max for comparison later
     $t_vals['12'] = array($answer, 0.08, 1);
     $answer = $this->get_answer_with_tolerance($answer, 8, false);
     $this->type("id=q3", $answer);
     $this->click("id=finish");
     $this->assertEquals("Are you sure you wish to finish. After clicking 'OK' you will not be able to go back.", $this->getConfirmation());
     $this->waitForPageToLoad("30000");
     $this->assertLocation($this->page_root . '/paper/finish.php?id=61357920091102&dont_record=true');
     // Individual Question Marks
     $this->assertElementContainsText('//table[2]/tbody/tr[2]/td[2]/p[4]/span', '1 out of 1');
     $this->assertElementContainsText('//table[2]/tbody/tr[4]/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[2]/tbody/tr[7]/td[2]/p[4]/span', '-0.5 out of 1');
     $this->assertElementContainsText('//table[3]/tbody/tr/td[2]/p/span', '2 out of 2');
     $text = $this->getText('//table[3]/tbody/tr/td[2]/table/tbody/tr/td[2]');
     $this->assertRegExp('/^cm/', $text);
     $this->assertRegExp('/with a tolerance of 1$/', $text);
     $this->assertElementContainsText('//table[3]/tbody/tr[4]/td[2]/p[4]/span', '0.5 out of 1');
     $text = $this->getText('//table[3]/tbody/tr[4]/td[2]/table/tbody/tr/td[2]');
     $this->assertRegExp('/with a tolerance of 1$/', $text);
     $this->assertElementContainsText('//table[3]/tbody/tr[6]/td[2]/p/span', '0 out of 2');
     $this->assertElementContainsText('//table[4]/tbody/tr[2]/td[2]/p[4]/span', '1 out of 1');
     $this->assertElementContainsText('//table[4]/tbody/tr[4]/td[2]/p/span', '2 out of 2');
     $text = $this->getText('//table[4]/tbody/tr[4]/td[2]/table/tbody/tr/td[2]');
     $this->assertRegExp('/^cm/', $text);
     $this->assertRegExp('/with a tolerance of 1$/', $text);
     $this->assertElementContainsText('//table[4]/tbody/tr[7]/td[2]/p[4]/span', '0 out of 1');
     $this->assertElementContainsText('//table[5]/tbody/tr/td[2]/p/span', '1 out of 2');
     $this->assertElementContainsText('//table[5]/tbody/tr/td[2]/table/tbody/tr/td[2]', $this->make_perc_tolerance_text('cm', $t_vals['10'][0], $t_vals['10'][1], $t_vals['10'][2]));
     $this->assertElementContainsText('//table[5]/tbody/tr[4]/td[2]/p[4]/span', '1 out of 1');
     $this->assertElementContainsText('//table[5]/tbody/tr[6]/td[2]/p/span', '1 out of 2');
     $this->assertElementContainsText('//table[5]/tbody/tr[6]/td[2]/table/tbody/tr/td[2]', $this->make_perc_tolerance_text('cm', $t_vals['12'][0], $t_vals['12'][1], $t_vals['12'][2]));
     // Overall Marks
     $this->assertElementContainsText('//div[5]/table/tbody/tr[2]/td[2]', '9 out of 18');
     $this->assertElementContainsText('//div[5]/table/tbody/tr[3]/td[2]', '40%');
     $this->assertElementContainsText('//div[5]/table/tbody/tr[4]/td[2]', '50.00%');
 }