parent
99049d8c2e
commit
8588ab9e4a
@ -0,0 +1,145 @@ |
||||
<?php |
||||
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php'; |
||||
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/abstractlink.class.php'; |
||||
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evallink.class.php'; |
||||
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php'; |
||||
|
||||
class TestExerciseLink extends UnitTestCase { |
||||
|
||||
public function TestExerciseLink() { |
||||
$this->UnitTestCase('Test Exercise Link'); |
||||
} |
||||
|
||||
public function __construct() { |
||||
// The constructor acts like a global setUp for the class |
||||
require_once api_get_path(SYS_TEST_PATH).'setup.inc.php'; |
||||
$this->exerciselink = new ExerciseLink(); |
||||
$this->exerciselink->set_course_code('COURSETEST'); |
||||
} |
||||
|
||||
/** |
||||
* Get the score of this exercise. Only the first attempts are taken into account. |
||||
* @param $stud_id student id (default: all students who have results - then the average is returned) |
||||
* @return array (score, max) if student is given |
||||
* array (sum of scores, number of scores) otherwise |
||||
* or null if no scores available |
||||
*/ |
||||
|
||||
public function testcalc_score() { |
||||
$res = $this->exerciselink->calc_score($stud_id = null); |
||||
$this->assertTrue(is_null($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Generate an array of all exercises available. |
||||
* @return array 2-dimensional array - every element contains 2 subelements (id, name) |
||||
*/ |
||||
|
||||
public function testget_all_links() { |
||||
$res = $this->exerciselink->get_all_links(); |
||||
$this->assertTrue(is_array($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Get description to display: same as exercise description |
||||
*/ |
||||
|
||||
public function testget_description() { |
||||
$res = $this->exerciselink->get_description(); |
||||
$this->assertTrue(is_null($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Get URL where to go to if the user clicks on the link. |
||||
* First we go to exercise_jump.php and then to the result page. |
||||
* Check this php file for more info. |
||||
*/ |
||||
|
||||
public function testget_link() { |
||||
$res = $this->exerciselink->get_link(); |
||||
$this->assertTrue(is_string($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Get name to display: same as exercise title |
||||
*/ |
||||
|
||||
public function testget_name() { |
||||
$res = $this->exerciselink->get_name(); |
||||
$this->assertTrue(is_null($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Generate an array of exercises that a teacher hasn't created a link for. |
||||
* @return array 2-dimensional array - every element contains 2 subelements (id, name) |
||||
*/ |
||||
|
||||
public function testget_not_created_links() { |
||||
$_SESSION['id_session'] = 1; |
||||
$res = $this->exerciselink->get_not_created_links(); |
||||
$this->assertTrue(is_array($res)); |
||||
$_SESSION['id_session'] = null; |
||||
//var_dump($res); |
||||
} |
||||
|
||||
public function testget_type_name() { |
||||
$res = $this->exerciselink->get_type_name(); |
||||
$this->assertTrue(is_string($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Has anyone done this exercise yet ? |
||||
*/ |
||||
|
||||
public function testhas_results() { |
||||
$res = $this->exerciselink->has_results(); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
public function testis_allowed_to_change_name() { |
||||
$res = $this->exerciselink->is_allowed_to_change_name(); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Check if this still links to an exercise |
||||
*/ |
||||
|
||||
public function testis_valid_link() { |
||||
$res = $this->exerciselink->is_valid_link(); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
public function testneeds_max() { |
||||
$res = $this->exerciselink->needs_max(); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
public function testneeds_name_and_description() { |
||||
$res = $this->exerciselink->needs_name_and_description(); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
public function testneeds_results() { |
||||
$res = $this->exerciselink->needs_results(); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
public function __destruct() { |
||||
// The destructor acts like a global tearDown for the class |
||||
//require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php'; |
||||
} |
||||
} |
||||
?> |
Loading…
Reference in new issue