123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 |
- <?php
- class TestExercise extends UnitTestCase {
-
- public $eExercise;
-
- public function TestExercise() {
- $this->UnitTestCase('');
- }
-
- public function setUp() {
- $this->eExercise = new Exercise();
- }
-
- public function tearDown() {
- $this->eExercise = null;
- }
-
- /**
- * adds a question into the question list
- * @param - integer $questionId - question ID
- * @return - boolean - true if the question has been added, otherwise false
- */
-
- function testaddToList() {
- $questionId = 1;
- $res = $this->eExercise->addToList($questionId);
- $this->assertTrue(is_bool($res));
- //var_dump($res);
- }
-
- /**
- * Creates the form to create / edit an exercise
- * @param FormValidator $form the formvalidator instance (by reference)
- */
-
- function testcreateForm() {
- global $id;
- $form = new FormValidator('introduction_text');
- $res = $this->eExercise->createForm($form, $type='full');
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
-
- /**
- * disables the exercise
- */
-
- function testdisable() {
- $res = $this->eExercise->disable();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- function testdisable_results() {
- $res = $this->eExercise->disable_results();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * enables the exercise
- */
-
- function testenable() {
- $res = $this->eExercise->enable();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- function testenable_results() {
- $res = $this->eExercise->enable_results();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * Same as isRandom() but has a name applied to values different than 0 or 1
- */
-
- function testgetShuffle() {
- $res = $this->eExercise->getShuffle();
- $this->assertTrue(is_numeric($res));
- //var_dump($res);
- }
-
- /**
- * returns 'true' if the question ID is in the question list
- *
- * @author - Olivier Brouckaert
- * @param - integer $questionId - question ID
- * @return - boolean - true if in the list, otherwise false
- */
-
- function testisInList() {
- $questionId = 1;
- $res = $this->eExercise->isInList($questionId);
- $this->assertTrue(is_bool($res));
- //var_dump($res);
- }
-
- /**
- * tells if questions are selected randomly, and if so returns the draws
- *
- * @author - Olivier Brouckaert
- * @return - integer - 0 if not random, otherwise the draws
- */
-
- function testisRandom() {
- $res = $this->eExercise->isRandom();
- $this->assertTrue(is_bool($res));
- //var_dump($res);
- }
-
- /**
- * moves a question down in the list
- * @param - integer $id - question ID to move down
- */
-
- function testmoveDown() {
- $id=1;
- $res = $this->eExercise->moveDown($id);
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
- //var_dump($res);
- }
-
- /**
- * moves a question up in the list
- * @param - integer $id - question ID to move up
- */
-
- function testmoveUp() {
- $id=1;
- $res = $this->eExercise->moveUp($id);
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
- //var_dump($res);
- }
-
- /**
- * function which process the creation of exercises
- * @param FormValidator $form the formvalidator instance
- */
- /*
- function testprocessCreation() {
- $form = new FormValidator('exerciseTitle');
- $res = $this->eExercise->processCreation($form,$type='');
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
- //var_dump($res);
- }*/
-
- /**
- * reads exercise informations from the data base
- * @param - integer $id - exercise ID
- * @return - boolean - true if exercise exists, otherwise false
- */
-
- function testread() {
- global $_course;
- global $_configuration;
- global $questionList;
- $id=1;
- $res = $this->eExercise->read($id);
- if(!is_null($res)){
- $this->assertTrue(is_bool($res));
- }
- //var_dump($res);
- }
-
- /**
- * removes a question from the question list
- * @param - integer $questionId - question ID
- * @return - boolean - true if the question has been removed, otherwise false
- */
-
- function testremoveFromList() {
- global $_course;
- global $_configuration;
- global $questionList;
- $questionId=1;
- $res = $this->eExercise-> removeFromList($questionId);
- if(!is_null($res)){
- $this->assertTrue(is_bool($res));
- }
- //var_dump($res);
- }
-
- /**
- * updates the exercise in the data base
- */
-
- function testsave() {
- global $_course,$_user;
- $res = $this->eExercise-> save($type_e='');
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- function testsearch_engine_delete() {
- $res = $this->eExercise-> search_engine_delete();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- function testsearch_engine_save() {
- $res = $this->eExercise-> search_engine_save();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * returns the number of attempts setted
- * @return - numeric - exercise attempts
- */
-
- function testselectAttempts() {
- $res = $this->eExercise-> selectAttempts();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * returns the exercise description
- * @return - string - exercise description
- */
-
- function testselectDescription() {
- $res = $this->eExercise-> selectDescription();
- $this->assertTrue(is_string($res));
- //var_dump($res);
- }
-
- /**
- * returns the expired time
- * @return - string - expired time
- */
-
- function testselectExpiredTime() {
- $res = $this->eExercise-> selectExpiredTime();
- $this->assertTrue(is_string($res));
- //var_dump($res);
- }
-
- /** returns the number of FeedbackType *
- * 0=>Feedback , 1=>DirectFeedback, 2=>NoFeedback
- * @return - numeric - exercise attempts
- */
-
- function testselectFeedbackType() {
- $res = $this->eExercise-> selectFeedbackType();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * returns the exercise ID
- * @return - integer - exercise ID
- */
-
- function testselectId() {
- $res = $this->eExercise-> selectId();
- $this->assertTrue(is_numeric($res));
- //var_dump($res);
- }
-
- /**
- * returns the number of questions in this exercise
- * @return - integer - number of questions
- */
-
- function testselectNbrQuestions() {
- $res = $this->eExercise-> selectNbrQuestions();
- $this->assertTrue(is_numeric($res));
- //var_dump($res);
- }
-
- /**
- * returns the array with the question ID list
- * @return - array - question ID list
- */
-
- function testselectQuestionList() {
- $res = $this->eExercise-> selectQuestionList();
- $this->assertTrue(is_array($res));
- //var_dump($res);
- }
-
- /**
- * returns random answers status.
- */
-
- function testselectRandomAnswers() {
- $res = $this->eExercise-> selectRandomAnswers();
- $this->assertTrue(is_numeric($res));
- //var_dump($res);
- }
-
- /**
- * selects questions randomly in the question list
- *
- * @author - Olivier Brouckaert
- * @return - array - if the exercise is not set to take questions randomly, returns the question list
- * without randomizing, otherwise, returns the list with questions selected randomly
- */
-
- function testselectRandomList() {
- $res = $this->eExercise-> selectRandomList();
- $this->assertTrue(is_array($res));
- //var_dump($res);
- }
-
- /**
- * tells if questions are selected randomly, and if so returns the draws
- * @return - integer - results disabled exercise
- */
-
- function testselectResultsDisabled() {
- $res = $this->eExercise-> selectResultsDisabled();
- $this->assertTrue(is_numeric($res));
- //var_dump($res);
- }
-
- /**
- * returns the exercise sound file
- * @return - string - exercise description
- */
-
- function testselectSound() {
- $res = $this->eExercise-> selectSound();
- $this->assertTrue(is_string($res));
- //var_dump($res);
- }
-
- /**
- * returns the exercise status (1 = enabled ; 0 = disabled)
- * @return - int - true if enabled, otherwise false
- */
-
- function testselectStatus() {
- $res = $this->eExercise-> selectStatus();
- $this->assertTrue(is_numeric($res));
- //var_dump($res);
- }
-
- /**
- * returns the time limit
- * @return int
- */
-
- function testselectTimeLimit() {
- $res = $this->eExercise-> selectTimeLimit();
- $this->assertTrue(is_numeric($res));
- //var_dump($res);
- }
-
- /**
- * returns the exercise title
- * @return - string - exercise title
- */
-
- function testselectTitle() {
- $res = $this->eExercise-> selectTitle();
- $this->assertTrue(is_string($res));
- //var_dump($res);
- }
-
- /**
- * returns the exercise type
- * @return - integer - exercise type
- */
-
- function testselectType() {
- $res = $this->eExercise-> selectType();
- $this->assertTrue(is_numeric($res));
- //var_dump($res);
- }
-
- /**
- * sets to 0 if questions are not selected randomly
- * if questions are selected randomly, sets the draws
- * @param - integer $random - 0 if not random, otherwise the draws
- * @return void
- */
-
- function testsetRandom() {
- $random = 1;
- $res = $this->eExercise-> setRandom($random);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * update the table question
- * @return void
- */
- function testupdate_question_positions() {
- $res = $this->eExercise-> update_question_positions();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * changes the exercise max attempts
- * @param - numeric $attempts - exercise max attempts
- * @return void
- */
-
- function testupdateAttempts() {
- $attempts = 1;
- $res = $this->eExercise-> updateAttempts($attempts);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * changes the exercise description
- * @param - string $description - exercise description
- * @return void
- */
-
- function testupdateDescription() {
- $description = 'testdescription';
- $res = $this->eExercise-> updateDescription($description);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * changes the exercise expired_time
- * @param - int The expired time of the quiz
- * @return void
- */
-
- function testupdateExpiredTime() {
- $expired_time = 1;
- $res = $this->eExercise-> updateExpiredTime($expired_time);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * changes the exercise feedback type
- * @param - numeric $attempts - exercise max attempts
- * @return void
- */
-
- function testupdateFeedbackType() {
- $feedback_type = 1;
- $res = $this->eExercise-> updateFeedbackType($feedback_type);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * sets to 0 if answers are not selected randomly
- * if answers are selected randomly
- * @param - integer $random_answers - random answers
- * @return void
- */
-
- function testupdateRandomAnswers() {
- $random_answers = 0;
- $res = $this->eExercise-> updateRandomAnswers($random_answers);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * update the results
- * @return void
- */
- function testupdateResultsDisabled() {
- $results_disabled = 1;
- $res = $this->eExercise->updateResultsDisabled($results_disabled);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * changes the exercise sound file
- * @param - string $sound - exercise sound file
- * @param - string $delete - ask to delete the file
- * @return void
- */
-
- function testupdateSound() {
- global $audioPath, $documentPath,$_course, $_user;
- $sound = 'test';
- $delete = 'test';
- $res = $this->eExercise->updateSound($sound,$delete);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * changes the exercise title
- * @param - string $title - exercise title
- * @return void
- */
-
- function testupdateTitle() {
- $title = 'test';
- $res = $this->eExercise->updateTitle($title);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * changes the exercise type
- * @param - integer $type - exercise type
- */
-
- function testupdateType() {
- $type = 1;
- $res = $this->eExercise->updateType($type);
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
-
- /**
- * deletes the exercise from the database
- * Notice : leaves the question in the data base
- */
-
- function testdelete() {
- global $_course,$_user;
- $res = $this->eExercise->delete();
- $this->assertTrue(is_null($res));
- //var_dump($res);
- }
- }
- ?>
|