public function testSerializeUnserializeRecord()
 {
     $test = new TestRecord();
     $test->save();
     $object = new SerializeTest();
     $object->objecttest = $test;
     $object->save();
     $object_before = clone $object;
     $serialized = serialize($object);
     $object_after = unserialize($serialized);
     $this->assertIdentical(get_class($object_after->objecttest), 'TestRecord');
 }
Example #2
0
 protected function executePrepend(PHPTAL $TAL)
 {
     //DbControl::$debug = true;
     try {
         parent::executePrepend($TAL);
         $record = new TestRecord();
         $record->store();
         $TAL->records = new TestRecords();
     } catch (Exception $e) {
         throw $e;
     }
 }
 function testValidation()
 {
     $r = new TestRecord();
     // required rule should fail
     $this->assertFalse($r->save());
     // string rule should fail
     $r->name = array();
     $this->assertFalse($r->save());
     $r->name = 'test';
     $this->assertTrue($r->save());
     $nonUnique = new TestRecord();
     $nonUnique->name = $r->name;
     // unique rule should fail
     $this->assertFalse($nonUnique->save());
     $this->assertIsA($nonUnique->validator(), 'Naf_Validator');
     $this->assertTrue(is_array($nonUnique->getErrorList()));
     $this->assertTrue(count($nonUnique->getErrorList()) > 0);
 }
Example #4
0
    <div class="answer_content form_7">

    <div class="instruction"><b>คำชี้แจง:</b><?php 
echo $answer['session_name'];
?>
</div>
        <ul>
             <?php 
$session_id = $answer['session_id'];
$session_type = $answer['answer_type_id'];
$start = $answer['session_start'];
$end = $answer['session_end'];
$order = $answer['session_order'];
$student_id = Yii::app()->user->id;
$exam_id = $_GET['id'];
$testRecoed = new TestRecord();
$testing = new Testing();
$test_record_id = $testRecoed->getIdByStudentIdExamId($student_id, $exam_id);
for ($i = $start; $i <= $end; $i++) {
    $test = $testing->getAllTestingRecord($test_record_id, $i);
    if (is_array($test)) {
        $ans_1 = substr($test['selected'], 0, 1);
        $ans_2 = substr($test['selected'], 1, 1);
        $ans_3 = substr($test['selected'], 2, 1);
        $ans_4 = substr($test['selected'], 3, 1);
        $ans_5 = substr($test['selected'], 4, 1);
        $ans_6 = substr($test['selected'], 5, 1);
        $ans_7 = substr($test['selected'], 6, 1);
        $ans_8 = substr($test['selected'], 7, 1);
        $ans_9 = substr($test['selected'], 8, 1);
        $ans_10 = substr($test['selected'], 9, 1);
Example #5
0
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['fio'])) {
    $validator = new TestValidation();
    echo $validator->checkTests($_POST);
    $error_div = $validator->showErrors();
    $pd = connectDB();
    if ($_POST["quest1"] == "Leonard Nimoy") {
        $first = 1;
    } else {
        $first = 0;
    }
    if ($_POST['quest2'] == 1) {
        $second = 1;
    } else {
        $second = 0;
    }
    if (isset($_POST['checkboxone']) == true && isset($_POST['checkboxtwo']) == false && isset($_POST['checkboxthree']) == false) {
        $third = 1;
    } else {
        $third = 0;
    }
    $date = date('Y-m-d');
    $fio = $_POST['fio'];
    $test = new TestRecord("tests", $fio, $first, $second, $third, $date);
    $test->save($pd);
}
echo $error_div;
echo "<script>setInterval(function(){\n                history.go(-1);\n                }, 5000);</script>\n                <br><center>Вернетесь обратно через 5 секунд</center>";
?>
</div>
</body>
</html>
Example #6
0
 public function loadTestRecord($id)
 {
     $model = TestRecord::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #7
0
 function generate_record()
 {
     $RecordGenerator = new TestRecord($this);
     $NewRecord = $RecordGenerator->create();
     return $NewRecord;
 }
 public function testFields()
 {
     $fields = TestRecord::getClassFields();
     $this->assertEquals(array_keys($fields), array('ID', 'Class', 'Created', 'CreatorID', 'Field1', 'Field2'));
 }