Exemple #1
0
 /**
  * Test "insertTaSplitIntoTa()" in Assignments.class.inc
  *
  * Insert a split assignment into tA.
  * Insert into tSplits two assignments.
  * Read the tA and process it and put the newly assigned assignments in tA.
  *
  * @return void
  */
 public function testinsertTaSplitIntoTa()
 {
     // Should also add the tSplits entries to make function stand alone.
     // Pack array with new values to make the assignment a split.
     // Then insert the split into the db.
     $this->testbuildArray();
     // Reset myArray to original values.
     // Add one split.
     $myArray1['tSp_id'] = '1113';
     $myArray1['tS_Name'] = 'tS_Add_Subtract';
     $myArray1['tSplit_gA'] = 'tG_1';
     $myArray1['tSplit_PercentTime'] = '10';
     $this->assertTrue(count($myArray1) === 4);
     // Add another split.
     $myArray2['tSp_id'] = '1114';
     $myArray2['tS_Name'] = 'tS_Add_Subtract';
     $myArray2['tSplit_gA'] = 'tG_2';
     $myArray2['tSplit_PercentTime'] = '20';
     $this->assertTrue(count($myArray2) === 4);
     // Prepare to insert split records into db.
     $splitInstance = new tutor\src\classes\SplitsClass();
     // Make sure no splits with these ids already exist in the db.
     $splitInstance->deleteRowId($myArray1['tSp_id']);
     $splitInstance->deleteRowId($myArray2['tSp_id']);
     // Next insert into db.
     // temp disable
     //$splitInstance->insertRow($myArray1);
     //$splitInstance->insertRow($myArray2);
     // end temp disable
     // Next insert an assignment to use the splits
     // Reset the array.  First store the standard test values.
     $tempStudentID = 'gbcdefg';
     $tempStudentName = 'zxcvbn';
     $this->myArray['tA_S_ID'] = $tempStudentID;
     $this->myArray['tA_StudentName'] = $tempStudentName;
     // Now create a new student assignment to use the splits inserted above.
     $classInstance = new tutor\src\classes\AssignmentsClass();
     // Make sure this assignment does not already exist.
     // Next insure no previous lessons for this student.
     $rowsDeleted = $classInstance->delRowsByStudentId('gbcdefg');
     // Insert the tA.
     $this->myArray['tG_AssignmentName'] = 'tS_Add_Subtract';
     // These tS records were inserted above.
     $classInstance->insertRecord($this->myArray);
     $result = $classInstance->getCurrentStudentAssignmentsInAnArray($tempStudentID);
     $numRows = count($result);
     $this->assertTrue($numRows === 1);
     // Now convert the split to regular assignments.
     $assignmentArray = $result;
     $this->assertTrue(count($assignmentArray) === 1);
     $resultAfterInsert = $classInstance->insertTaSplitIntoTa($assignmentArray);
     //        $this->assertTrue($resultAfterInsert === 1);
     // Now check to see if the split was converted to assignments.
     // Clean up.
     $result = $classInstance->delRowsByStudentId($tempStudentID);
     $this->assertTrue($result === 1);
     // Deleted the two split rows. Original assignment was deleted upon
     // insertion of splits.
     //        $result = $splitInstance->deleteRowId($myArray1['tA_id']);
     //        $this->assertTrue($result === 1);
     //        $result = $splitInstance->deleteRowId($myArray2['tA_id']);
     //        $this->assertTrue($result === 1);
     // Clean Up.
     $classInstance->delRowsByStudentId($this->myArray['tA_S_ID']);
 }