From a0e8331441febaaf08bdf73ebf451b0065e1918f Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Wed, 10 Feb 2010 10:16:42 -0500 Subject: [PATCH 1/2] MInor - Needed the a require_once of the file exercise because not find the class answer CT#191 --- main/exercice/export/qti2/qti2_classes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/main/exercice/export/qti2/qti2_classes.php b/main/exercice/export/qti2/qti2_classes.php index 1b374e9429..e7e8f27216 100755 --- a/main/exercice/export/qti2/qti2_classes.php +++ b/main/exercice/export/qti2/qti2_classes.php @@ -22,6 +22,7 @@ define('FREE_ANSWER', 5); define('HOTSPOT', 6); require_once(api_get_path(SYS_CODE_PATH).'/exercice/answer.class.php'); +require_once(api_get_path(SYS_CODE_PATH).'/exercice/exercise.class.php'); require_once(api_get_path(SYS_CODE_PATH).'/exercice/hotspot.class.php'); require_once(api_get_path(SYS_CODE_PATH).'/exercice/unique_answer.class.php'); require_once(api_get_path(SYS_CODE_PATH).'/exercice/multiple_answer.class.php'); From 1bd081bcfde408b66e24c9d8d48c06804c330848 Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Wed, 10 Feb 2010 10:17:35 -0500 Subject: [PATCH 2/2] Added a new file of tests qti2_classes.test.php CT#191 --- .../export/qti2/qti2_classes.test.php | 198 ++++++++++++++++++ tests/main/exercice/hotpotatoes.lib.test.php | 9 - 2 files changed, 198 insertions(+), 9 deletions(-) create mode 100644 tests/main/exercice/export/qti2/qti2_classes.test.php diff --git a/tests/main/exercice/export/qti2/qti2_classes.test.php b/tests/main/exercice/export/qti2/qti2_classes.test.php new file mode 100644 index 0000000000..c6beadac1b --- /dev/null +++ b/tests/main/exercice/export/qti2/qti2_classes.test.php @@ -0,0 +1,198 @@ +UnitTestCase(''); + } + + public function setUp() { + $this->qIms2Question = new Ims2Question(); + $this->qImsAnswerFillInBlanks = new ImsAnswerFillInBlanks(1); + $this->qImsAnswerFree = new ImsAnswerFree(1); + $this->qImsAnswerHotspot = new ImsAnswerHotspot(1); + $this->qImsAnswerMatching = new ImsAnswerMatching(1); + $this->qImsAnswerMultipleChoice = new ImsAnswerMultipleChoice(1); + } + + public function tearDown() { + $this-> qIms2Question = null; + $this-> qImsAnswerFillInBlanks = null; + $this-> qImsAnswerFree = null; + $this-> qImsAnswerHotspot = null; + $this-> qImsAnswerMatching = null; + $this-> qImsAnswerMultipleChoice = null; + } + +//Class qIms2Question + /** + * Include the correct answer class and create answer + */ + + function testsetAnswer() { + $res=Ims2Question::setAnswer(); + if(!is_null){ + $this->assertTrue(is_bool($res)); + } + //var_dump($res); + } + + function testcreateAnswersForm() { + $form = array(1); + $res=Ims2Question::createAnswersForm($form); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + function testprocessAnswersCreation() { + $form = array(1); + $res=Ims2Question::processAnswersCreation($form); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + +//Class qImsAnswerFillInBlanks + + /** + * Export the text with missing words. + * + * + */ + function testimsExportResponses() { + $questionIdent = array(1); + $questionStatment = array(1); + $res=$this->qImsAnswerFillInBlanks->imsExportResponses($questionIdent, $questionStatment); + if(!is_null){ + $this->assertTrue(is_bool($res)); + } + //var_dump($res); + } + + function testimsExportResponsesDeclaration() { + $questionIdent = array(1); + $res=$this->qImsAnswerFillInBlanks->imsExportResponsesDeclaration($questionIdent); + if(!is_null){ + $this->assertTrue(is_bool($res)); + } + //var_dump($res); + } + +//Class qImsAnswerFree + + /** + * TODO implement + * Export the question part as a matrix-choice, with only one possible answer per line. + */ + + function testImsExportResponsesqImsAnswerFree() { + $questionIdent = array(''); + $questionStatment = array(''); + $res=$this->qImsAnswerFree->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia=''); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function testImsExportResponsesDeclarationqImsAnswerFree() { + $questionIdent = array(1); + $res=$this->qImsAnswerFree->imsExportResponsesDeclaration($questionIdent); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + +//Class qImsAnswerHotspot + + /** + * TODO update this to match hotspots instead of copying matching + * Export the question part as a matrix-choice, with only one possible answer per line. + */ + + function testimsExportResponsesqImsAnswerHotspot() { + $questionIdent = array(1); + $questionStatment = array(1); + $res=$this->qImsAnswerHotspot->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia=''); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + + function testimsExportResponsesDeclarationqImsAnswerHotspot() { + $questionIdent = array(1); + $res=$this->qImsAnswerHotspot->imsExportResponsesDeclaration($questionIdent); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + +//Class qImsAnswerMatching + + /** + * Export the question part as a matrix-choice, with only one possible answer per line. + */ + + function testimsExportResponsesqImsAnswerMatching() { + $questionIdent = array(1); + $questionStatment = array(1); + $res=$this->qImsAnswerMatching->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia=''); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + + function testimsExportResponsesDeclarationqImsAnswerMatching() { + $questionIdent = array(1); + $res=$this->qImsAnswerMatching->imsExportResponsesDeclaration($questionIdent); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + +//Class qImsAnswerMultipleChoice + + /** + * Return the XML flow for the possible answers. + * + */ + + function testimsExportResponsesqImsAnswerMultipleChoice() { + $questionIdent = array(1); + $questionStatment = array(1); + $res=$this->qImsAnswerMultipleChoice->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia=''); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + + function testimsExportResponsesDeclarationqImsAnswerMultipleChoice() { + $questionIdent = array(1); + $res=$this->qImsAnswerMultipleChoice->imsExportResponsesDeclaration($questionIdent); + $this->assertTrue(is_string($res)); + //var_dump($res); + } +} +?> diff --git a/tests/main/exercice/hotpotatoes.lib.test.php b/tests/main/exercice/hotpotatoes.lib.test.php index c817dc780e..156c9f99b6 100755 --- a/tests/main/exercice/hotpotatoes.lib.test.php +++ b/tests/main/exercice/hotpotatoes.lib.test.php @@ -119,15 +119,6 @@ class TestHotpotatoes extends UnitTestCase { //var_dump($res); } - function testhotpotatoes_initWithRemoveFolder() { - $base = '/tmp/'; - $baseWorkDir=$base.'test/'; - $res=hotpotatoes_init($baseWorkDir); - $this->assertTrue($res); - rmdir($baseWorkDir); - //var_dump($res); - } - function testHotPotGCt() { $folder='/main/exercice'; $flag=4;