Пример #1
0
 /**
  * Set session variables from Generic assignment..
  *
  * Retrieve a row from tGentericAssignments and set session variables.
  *
  * @param string $tg_assignment_name
  *   From tAssignments.
  */
 public function setSessionVariablesFromTblGenerAssignmentName($tg_assignment_name)
 {
     $log_file = fopen('../logs/', 'a');
     $string = "\n" . __METHOD__ . " inside " . __CLASS__ . "\n";
     fwrite($log_file, $string);
     fwrite($log_file, __LINE__ . ' microtime(TRUE) = ' . microtime(TRUE) . "\n\n");
     $string = "\n" . __LINE__ . ' $tg_assignment_name = ' . $tg_assignment_name . "\n";
     fwrite($log_file, $string);
     // Get the tG_Assignment data based upon lesson selected.
     $next_lesson = new GenericAClass();
     fwrite($log_file, __LINE__ . ' microtime(TRUE) = ' . microtime(TRUE) . "\n\n");
     $lesson = $next_lesson->getRowFromDbAsArray($tg_assignment_name);
     $v = var_export($lesson, TRUE);
     $string = "\n" . __LINE__ . ' $lesson = ' . $v . "\n\n";
     fwrite($log_file, $string . "\n");
     fwrite($log_file, __LINE__ . ' microtime(TRUE) = ' . microtime(TRUE) . "\n\n");
     if ($lesson === NULL) {
         trigger_error($string, E_USER_ERROR);
     }
     $_SESSION['tG_StartStop'] = $lesson['tG_StartStop'];
     $_SESSION['tG_ThreadName'] = $lesson['tG_ThreadName'];
     $_SESSION['tG_AssignmentName'] = $lesson['tG_AssignmentName'];
     $_SESSION['tG_path_to_lesson'] = $lesson['tG_path_to_lesson'];
     $_SESSION['tG_FormName'] = $lesson['tG_FormName'];
     $_SESSION['tG_DataFile'] = $lesson['tG_DataFile'];
     $_SESSION['tG_Parameters'] = $lesson['tG_Parameters'];
     $_SESSION['tG_Consequtive_Reps_OK'] = $lesson['tG_Consequtive_Reps_OK'];
     $_SESSION['tG_Reps_to_master'] = $lesson['tG_Reps_to_master'];
     $_SESSION['tG_Errors_Allowed'] = $lesson['tG_Errors_Allowed'];
     $_SESSION['tG_Minimum_completion_time'] = $lesson['tG_Minimum_completion_time'];
     $_SESSION['tG_Maximum_completion_time'] = $lesson['tG_Maximum_completion_time'];
     $_SESSION['tG_StartRec'] = $lesson['tG_StartRec'];
     $_SESSION['tG_StopRec'] = $lesson['tG_StopRec'];
     $_SESSION['tG_Immediate_Loops'] = $lesson['tG_Immediate_Loops'];
     $_SESSION['tG_RepsPerRecord'] = $lesson['tG_RepsPerRecord'];
     $_SESSION['tG_RecordsPerSet'] = $lesson['tG_RecordsPerSet'];
     $_SESSION['tG_Lesson_if_Correct'] = $lesson['tG_Lesson_if_Correct'];
     $_SESSION['tG_Record_if_Correct'] = $lesson['tG_Record_if_Correct'];
     $_SESSION['tG_Lesson_if_Error'] = $lesson['tG_Lesson_if_Error'];
     $_SESSION['tG_Record_if_Error'] = $lesson['tG_Record_if_Error'];
 }
Пример #2
0
 /**
  * RepairRowIfStartRecIsLlargerThanStopRec.
  *
  * StartRec should be less than or equal to StopRec.
  * Fix it if this is not TRUE.
  *
  * @param string $student_id
  *   The source of the lessons.
  *   The source of the lessons.
  * @param string $tg_assignment_name
  *   The assignment to do.
  * @param int $ta_start_rec
  *   The assignment start position.
  *
  * @return return_array or NULL
  *   Returns null or an array of lessons.
  */
 public function repairRowIfStartRecIsLargerThanStopRec($student_id, $tg_assignment_name, $ta_start_rec)
 {
     $current_row = $this->getSpecificStudentAssignmentFromDbAsArray($student_id, $tg_assignment_name, $ta_start_rec);
     $return_array = array();
     if (array_key_exists('NULL_input', $return_array) === FALSE) {
         if ($ta_start_rec > $current_row['tA_StopRec']) {
             $return_array['tA_StartRecWasGreater'] = TRUE;
             // Update the tAssignment row by adding a new row based upon
             // the gA and deleting the current row.
             // Get tG_Lesson_if_Correct in this assignment's tG_AssignmentName.
             // Get the name of the next lesson which is tG_Lesson_if_Correct
             // column in the current tG_AssignmentName.
             $class_instance = new GenericAClass();
             // Get the row of the current lesson's tG_AssignmentName
             // Then get the name of the new gA.
             // Then get the row of the new gA.
             $this_ga_name = $class_instance->getRowFromDbAsArray($current_row['tG_AssignmentName']);
             $next_ganame = $this_ga_name['tG_Lesson_if_Correct'];
             // This is the name of the next gA.
             $next_ga = $class_instance->getRowFromDbAsArray($next_ganame);
             // Now we replace the current tA row with a new tA row with the new gA.
             $x = $current_row['tA_StudentName'];
             $pram_array = array('tA_S_ID' => $student_id, 'tA_StudentName' => $current_row['tA_StudentName'], 'tG_AssignmentName' => $next_ga['tG_AssignmentName'], 'tA_Consecutive_Reps_OK' => 'tA_Consecutive_Reps_OK', 'tA_StartRec' => $next_ga['tG_StartRec'], 'tA_StopRec' => $next_ga['tG_StopRec'], 'tA_Immediate_Loops' => $next_ga['tG_Immediate_Loops'], 'tG_Reps_to_master' => $next_ga['tG_Reps_to_master'], 'tA_RepsTowardM' => '0', 'tA_ErrorsMade' => '0', 'tA_PercentTime' => $current_row['tA_PercentTime'], 'tA_SumPercent' => '0', 'tA_QueOrder' => $current_row['tA_QueOrder'], 'tA_SavedAssignment' => '', 'tA_SavedStartRec' => '', 'tA_Post_date' => '', 'tA_iterations_to_do' => '', 'tG_Errors_Allowed ' => '');
             $result = $this->insertRecord($pram_array);
             // FALSE for failure or TRUE for success.
             $return_array['tA_subsequentAssignmentInserted'] = TRUE;
             // Now delete the current assignment.
             $row = $this->getSpecificStudentAssignmentFromDbAsArray($student_id, $tg_assignment_name, $ta_start_rec);
             if ($result === 1) {
                 $return_array['tA_ErroneousAssignmentDeleted'] = TRUE;
             } else {
                 $return_array['tA_ErroneousAssignmentDeleted'] = FALSE;
             }
         } else {
             $return_array['tA_StartRecWasGreater'] = FALSE;
         }
         //end if
     }
     //end if
     return $return_array;
 }
Пример #3
0
 /**
  * Deletes row with specified id field.
  */
 public function testdeleteRowById()
 {
     // Reset variables.
     $this->resetMyArray();
     $class_instance = new GenericAClass();
     $this->assertTrue(isset($class_instance));
     // Can't depend on the new record not supplying own id.
     // Can't use line above.
     $my_local_array['tG_AssignmentName'] = 'Test';
     $my_local_array['tG_FormName'] = '537dummy_form.php';
     $results = $class_instance->deleteRowsNamed($my_local_array['tG_AssignmentName']);
     $this->myArray['tG_AssignmentName'] = 'xyx';
     $result = $class_instance->insertRecord($my_local_array);
     // Get record back and use id.
     $row = $class_instance->getLastDbEntryAsArray();
     $this->assertTrue($row['tG_AssignmentName'] === 'Test');
     $this->assertTrue($row['tG_FormName'] === '537dummy_form.php');
     $results = $class_instance->deleteRowById($row['id']);
     $this->assertTrue($results === 1);
     $result = $class_instance->deleteRowsNamed("Test");
     // Clean up.
     // delete the record that was added.
     $r = $class_instance->deleteRowsNamed('Test');
     $this->assertTrue($r === 0);
     // Reset variables.
     $this->resetMyArray();
 }
// Prime session with the existing relevant data.
$_SESSION = $_data;
// Get next assignment to do from the login data.
$next_lesson = new AssignmentsClass();
// Return a single lesson as a tAssignments row.
$lesson = $next_lesson->getNextAssignmentToDo($_data['tA_S_ID'], $_data['tA_id']);
$v = var_export($lesson, TRUE);
$string = "\n" . __LINE__ . ' $lesson = ' . $v . "\n\n";
fwrite($log_file, $string . "\n");
if (is_null($lesson) == TRUE) {
    $msg = $msg . "\n" . __LINE__ . ' No lesson found.';
    trigger_error($msg, E_USER_ERROR);
}
// From the assignment name retrieve the generic assignment and assign
// its variables  to the $_SESSION variable.
$my_next_ga = new GenericAClass();
$the_ga = $my_next_ga->getRowFromDbAsArray($lesson['tG_AssignmentName']);
// Pack all tGenericAssignment data into session varaiable.
foreach ($the_ga as $key => $value) {
    $_SESSION[$key] = $value;
}
$v = var_export($_SESSION, TRUE);
$string = __LINE__ . '  $_SESSION = ' . $v . "\n\n";
fwrite($log_file, $string);
// We should now have the data to prepare the next lesson.
$_SESSION['tG_path_to_lesson'] = trim($_SESSION['tG_path_to_lesson']);
$_SESSION['tG_FormName'] = trim($_SESSION['tG_FormName']);
$file = $_SESSION['tG_path_to_lesson'] . $_SESSION['tG_FormName'];
$string = "\n" . __LINE__ . ' $file = ' . $file;
fwrite($log_file, $string . "\n");
// Build the URL to the next lesson.