function _Student::load_test_scores

4.x _Student.php _Student::load_test_scores()
5.x _Student.php _Student::load_test_scores()
1 call to _Student::load_test_scores()

File

classes/_Student.php, line 249

Class

_Student

Code

function load_test_scores() 
 {
  // If the student has any scores (from standardized tests)
  // then load them here.

  $st = null;

  $res = db_query("		          
		          SELECT * FROM student_tests
		          WHERE 
								  student_id = '?' 								
							ORDER BY date_taken DESC ", $this->student_id);
  while ($cur = db_fetch_array($res)) {

    $c++;

    extract($cur, 3, "db");


    // Get the test's description, if available.

    $res2 = db_query("SELECT * FROM standardized_tests
                        WHERE test_id = '?'
                        AND category_id = '?'
                        ORDER BY position", $db_test_id, $db_category_id);
    $cur2 = db_fetch_array($res2);
    $db_test_description = trim($cur2 ["test_description"]);
    $db_category_description = trim($cur2 ["category_description"]);

    // Did we find anything in the table?  If not, just use the codes themselves
    if ($db_test_description == "") {
      $db_test_description = t("Test code:") . " " . $db_test_id;
    }
    if ($db_category_description == "") {
      $db_category_description = $db_category_id;
    }



    if (!(($db_date_taken . $db_test_id) == $old_row)) 
     {
      // We are at a new test.  Add the old test to our list.
      if ($st != null) {
        $this->list_standardized_tests->add($st);

      }

      $st = new StandardizedTest();
      $st->test_id = $db_test_id;
      $st->date_taken = $db_date_taken;
      $st->description = $db_test_description;
      $old_row = $db_date_taken . $db_test_id;

    }

    $st->categories [$db_position . $c]["description"] = $db_category_description;
    $st->categories [$db_position . $c]["category_id"] = $db_category_id;
    $st->categories [$db_position . $c]["score"] = $db_score;

  }

  // Add the last one created.
  if ($st != null) {
    $this->list_standardized_tests->add($st);
  }


}