/** * * * @return bool * @access public */ public function do_test() { if ('' == trim($this->sanskey)) { $this->aterror = stack_string('TEST_FAILED', array('errors' => stack_string("AT_EmptySA"))); $this->atfeedback = stack_string('TEST_FAILED', array('errors' => stack_string("AT_EmptySA"))); $this->atansnote = $this->casfunction . 'TEST_FAILED:Empty SA.'; $this->atmark = 0; $this->atvalid = false; return null; } if ('' == trim($this->tanskey)) { $this->aterror = stack_string('TEST_FAILED', array('errors' => stack_string("AT_EmptyTA"))); $this->atfeedback = stack_string('TEST_FAILED', array('errors' => stack_string("AT_EmptyTA"))); $this->atansnote = $this->casfunction . 'TEST_FAILED:Empty TA.'; $this->atmark = 0; $this->atvalid = false; return null; } if ($this->processcasoptions) { if (null == $this->atoption or '' == $this->atoption) { $this->aterror = 'TEST_FAILED'; $this->atfeedback = stack_string('TEST_FAILED', array('errors' => stack_string("AT_MissingOptions"))); $this->atansnote = 'STACKERROR_OPTION.'; $this->atmark = 0; $this->atvalid = false; return null; } else { // Validate with teacher privileges, strict syntax & no automatically adding stars. $ct = new stack_cas_casstring($this->atoption); if (!$ct->get_valid('t', true, 1)) { $this->aterror = 'TEST_FAILED'; $this->atfeedback = stack_string('TEST_FAILED', array('errors' => '')); $this->atfeedback .= stack_string('AT_InvalidOptions', array('errors' => $ct->get_errors())); $this->atansnote = 'STACKERROR_OPTION.'; $this->atmark = 0; $this->atvalid = false; return null; } } $atopt = $this->atoption; $ta = "[{$this->tanskey},{$atopt}]"; } else { $ta = $this->tanskey; } // Sort out options. if (null === $this->options) { $this->options = new stack_options(); } if (!(null === $this->simp)) { $this->options->set_option('simplify', $this->simp); } $cascommands = array(); $cascommands[] = "STACKSA:{$this->sanskey}"; $cascommands[] = "STACKTA:{$ta}"; $cascommands[] = "result:StackReturn({$this->casfunction}(STACKSA,STACKTA))"; $cts = array(); foreach ($cascommands as $com) { $cs = new stack_cas_casstring($com); $cs->get_valid('t', true, 0); $cts[] = $cs; } $session = new stack_cas_session($cts, $this->options, 0); $session->instantiate(); $this->debuginfo = $session->get_debuginfo(); if ('' != $session->get_errors_key('STACKSA')) { $this->aterror = 'TEST_FAILED'; $this->atfeedback = stack_string('TEST_FAILED', array('errors' => $session->get_errors_key('STACKSA'))); $this->atansnote = $this->casfunction . '_STACKERROR_SAns.'; $this->atmark = 0; $this->atvalid = false; return null; } if ('' != $session->get_errors_key('STACKTA')) { $this->aterror = 'TEST_FAILED'; $this->atfeedback = stack_string('TEST_FAILED', array('errors' => $session->get_errors_key('STACKTA'))); $this->atansnote = $this->casfunction . '_STACKERROR_TAns.'; $this->atmark = 0; $this->atvalid = false; return null; } $sessionvars = $session->get_session(); $result = $sessionvars[2]; if ('' != $result->get_errors()) { $this->aterror = 'TEST_FAILED'; if ('' != trim($result->get_feedback())) { $this->atfeedback = $result->get_feedback(); } else { $this->atfeedback = stack_string('TEST_FAILED', array('errors' => $result->get_errors())); } $this->atansnote = trim($result->get_answernote()); $this->atmark = 0; $this->atvalid = false; return null; } $this->atansnote = trim($result->get_answernote()); // Convert the Maxima string 'true' to PHP true. if ('true' == $result->get_value()) { $this->atmark = 1; } else { $this->atmark = 0; } $this->atfeedback = $result->get_feedback(); $this->atvalid = $result->get_valid(); if ($this->atmark) { return true; } else { return false; } }
public function test_remove_comment_fail() { $at1 = new stack_cas_keyval("a:1\n /* This is a comment \n b:2\n */\n c:3", null, 123, 's', true, 0); $this->assertTrue($at1->get_valid()); $a3 = array('a:1', 'c:4'); $s3 = array(); foreach ($a3 as $s) { $s3[] = new stack_cas_casstring($s); } $cs3 = new stack_cas_session($s3, null, 123); $cs3->instantiate(); $at1->instantiate(); // This looks strange, but the cache layer gives inconsistent results if the first // of these populates the cache, and the second one uses it. $this->assertNotEquals($cs3->get_session(), $at1->get_session()->get_session()); }