$where_array = array('tA_S_ID' => $_SESSION['tA_S_ID'], 'tA_id' => $_SESSION['tA_id']);
if (isset($_POST['tA_RepsTowardM']) === TRUE) {
    if ($_POST['tA_RepsTowardM'] === 'Plus1') {
        $value_array['tA_RepsTowardM'] = 'tA_RepsTowardM + 1';
    } else {
        $value_array['tA_RepsTowardM'] = 0;
    }
}
if (isset($_POST['tA_ErrorsMade']) === 'Plus1') {
    $value_array['tA_ErrorsMade'] = 'tA_ErrorsMade + 1';
}
if (isset($_POST['tA_LocalDateTime']) === TRUE) {
    $value_array['tA_LocalDateTime'] = $_POST['tA_LocalDateTime'];
}
$value_array['tA_Post_date'] = time() + 20;
// Add seconds to now.
$sender = $_POST['sender'];
// Sender is not a field in tA and should not be in the query.
// Sender is a good source of info to detect tampering with input data.;
$v = var_export($value_array, true);
$string = __LINE__ . ' $value_array = ' . "{$v}\n\n";
fwrite($logFile, $string);
$v = var_export($where_array, true);
$string = __LINE__ . ' $where_array = ' . "{$v}\n\n";
fwrite($logFile, $string);
$result = $classInstance = new tutor\src\classes\AssignmentsClass();
$result = $classInstance->updateFields($value_array, $where_array);
$v = var_export($result, true);
$string = __LINE__ . ' $result = ' . "{$v}\n\n";
fwrite($logFile, $string);
return $result;
Exemple #2
0
$tA_LastModifiedDateTime = time();
$value_array['tA_Post_date'] = $tA_LastModifiedDateTime + $post_date_time;
$string = "\n" . __LINE__ . '$tA_LastModifiedDateTime = ' . $tA_LastModifiedDateTime;
fwrite($log_file, $string);
$v = var_export($value_array, TRUE);
$string = "\n" . __LINE__ . '$value_array["tA_Post_date"] = ' . $v;
fwrite($log_file, $string);
$value_array["tA_RepsTowardM"] = $tA_RepsTowardM;
// Set at lines 75-85
// $value_array['tA_ErrorsMade'] set at line 145
$value_array['tA_LastModifiedDateTime'] = $tA_LastModifiedDateTime;
$v = var_export($value_array, TRUE);
$string = __LINE__ . ' $value_array = ' . "{$v}\n\n";
fwrite($log_file, $string);
$classInstance = new tutor\src\classes\AssignmentsClass();
$returnedValue = $classInstance->updateFields($value_array, $where_array);
$string = __LINE__ . ' $returnedValue = ' . $returnedValue . "\n\n";
fwrite($log_file, $string);
$string = __LINE__ . ' gettype($returnedValue) = ' . gettype($returnedValue) . "\n\n";
fwrite($log_file, $string);
// Returns count of rows affected.
if ($returnedValue !== 1) {
    // Serious Error..
    $string = "\n" . __LINE__ . " update_tA_TC.php failed to record data in tAssignments.";
    fwrite($log_file, $string);
}
/**
 * Clone and instert a lesson incremented by one in some lessons.
 *
 * Applies to Spelling or typing or some types of math with many parameters.
 */
Exemple #3
0
 /**
  * Test test "normalizePercentTimeTo100Percent()" in Assignments.class.inc
  *
  * A *description*, that can span multiple lines, to go _in-depth_ into the details of this element
  * and to provide some background information or textual references.
  *
  * @return void
  */
 public function testupdateFields()
 {
     $this->testbuildArray();
     // reset myArray to origninal values.
     $classInstance = new tutor\src\classes\AssignmentsClass();
     $this->assertTrue(isset($classInstance));
     $tempStudent = 'bcdefgh';
     // insure no previous lessons for this student.
     $result = $classInstance->delRowsByStudentId($tempStudent);
     $this->assertTrue($result === 0);
     // "No rows should be deleted if all previous methods have cleaned up.");
     $this->myArray['tA_S_ID'] = $tempStudent;
     $result = $classInstance->getCurrentStudentAssignmentsInAnArray($this->myArray['tA_S_ID']);
     $this->assertTrue(count($result) === 0, 'Should return 0 because no assignments have been added.');
     $result = $classInstance->insertRecord($this->myArray);
     $this->assertTrue($result === 1, '1 if insertion succeeded.');
     $results = $classInstance->delRowsByStudentId($this->myArray['tA_S_ID']);
     $this->assertTrue($results === 1, 'Should be 1.');
     // Now create one row with a significant post date.
     $this->myArray['tA_Post_date'] = time() + 1000000000;
     $result = $classInstance->insertRecord($this->myArray);
     $this->assertTrue($result === 1, '1 if insertion succeeded.');
     $whereArray = array('tA_S_ID' => 'bcdefgh', 'tA_ErrorsMade' => '4');
     $valueArray = array('tA_ErrorsMade' => '2', 'tA_StartRec' => '25');
     $result = $classInstance->updateFields($valueArray, $whereArray);
     $this->assertTrue($result === 1);
     // Get the row and check the results.
     $result2 = $classInstance->getNewestDbEntry('bcdefgh');
     $this->assertTrue($result2['tA_StartRec'] === '25');
     $this->assertTrue($result2['tA_ErrorsMade'] === '2');
     $whereArray = array('tA_S_ID' => 'bcdefgh', 'tA_ErrorsMade' => '2');
     $valueArray = array('tA_ErrorsMade' => '6', 'tA_StartRec' => '27');
     $result = $classInstance->updateFields($valueArray, $whereArray);
     $result2 = $classInstance->getNewestDbEntry('bcdefgh');
     $this->assertTrue($result2['tA_StartRec'] === '27');
     $this->assertTrue($result2['tA_ErrorsMade'] === '6');
     // Now delete the rows.
     $classInstance->delRowsByStudentId($this->myArray['tA_S_ID']);
     $classInstance->delRowsByStudentId('bcdefgh');
 }