diff -Nur Desktop/sojunit 2008_08_27/config.php Workspace/moodle_19/question/type/sojunit/config.php --- Desktop/sojunit 2008_08_27/config.php 1970-01-01 08:00:00.000000000 +0800 +++ Workspace/moodle_19/question/type/sojunit/config.php 2008-08-29 11:54:49.000000000 +0800 @@ -0,0 +1,7 @@ + \ No newline at end of file Binary files Desktop/sojunit 2008_08_27/.DS_Store and Workspace/moodle_19/question/type/sojunit/.DS_Store differ diff -Nur Desktop/sojunit 2008_08_27/questiontype.php Workspace/moodle_19/question/type/sojunit/questiontype.php --- Desktop/sojunit 2008_08_27/questiontype.php 2008-08-29 12:25:19.000000000 +0800 +++ Workspace/moodle_19/question/type/sojunit/questiontype.php 2008-08-29 13:16:42.000000000 +0800 @@ -8,18 +8,7 @@ * @package so_questiontypes */ -global $CFG; -$cfg_dirroot_backslashes = $CFG->dirroot; -$cfg_dirroot = str_replace("\\", "/", $cfg_dirroot_backslashes); // replace \\ with / (in order to use in windows and linux os) - -//define('PATH_TO_JAVAC', 'PathNotSet'); //TODO use this for module-package //set the proper javac-path e.g. "/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/bin/javac" -define('PATH_TO_JAVAC', '/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/bin/javac'); //TODO delete for module-package - -//define('PATH_TO_JAVA', 'PathNotSet'); //TODO use this for module-package //set the proper java-path e.g. "C:/Program Files/Java/jdk1.5.0_01/bin/javac.exe" -define('PATH_TO_JAVA', '/usr/lib/jvm/java-1.5.0-sun-1.5.0.14/bin/java'); //set the proper java-path e.g. "C:/Program Files/Java/jdk1.5.0_01/bin/java.exe" - -define('PATH_TO_JUNIT', $cfg_dirroot.'/question/type/sojunit/junit.jar'); -define('PATH_TO_POLICY', $cfg_dirroot.'/question/type/sojunit/polfile'); +require_once(dirname(__FILE__) . '/config.php'); /** * The SourceCode JUnit question class @@ -71,7 +60,7 @@ // new fields for this questin type as new options $options->givencode = trim($question->givencode); $options->testclassname = trim($question->testclassname); - $options->useeditor_genfeedb = trim($question->useeditor_genfeedb); + $options->useeditor_genfeedb = !empty($question->useeditor_genfeedb); $options->sourcecode = $question->sourcecode; if ($update) { @@ -289,11 +278,16 @@ // Get the student's code. // Deal with special case: no responses at all. - if (empty($state->responses) || empty($state->responses[''])) { + if (empty($state->responses)) { $state->responses == array(); - return true; } - $studentscode = stripslashes($state->responses['']); + + // Prepare the students response. + if (!empty($state->responses[''])) { + $studentscode = stripslashes($state->responses['']); + } else { + $studentscode = $question->options->givencode; + } // Try to find the class name they used. $matches = array(); @@ -366,9 +360,9 @@ $state->event = ($state->event == QUESTION_EVENTCLOSE) ? QUESTION_EVENTCLOSEANDGRADE : QUESTION_EVENTGRADE; //remove the temporarily created directory with its contents (class, log and temp files) - $del_temp_folder = $cfg_dataroot . '/so_junit_temp/' . $state->attempt; +// $del_temp_folder = $cfg_dataroot . '/so_junit_temp/' . $state->attempt; //print_object('del_temp_folder: '.$del_temp_folder); //debug - remove_dir($del_temp_folder); +// remove_dir($temp_folder); return true; }