Fixes for bugs #5435 - subcategories were not exported and

#5470 - true/false questions not exported due to internal format
change.
This commit is contained in:
thepurpleblob
2006-05-13 08:47:57 +00:00
parent 672007443c
commit 53b824ef1f
6 changed files with 48 additions and 33 deletions
+12 -3
View File
@@ -19,10 +19,11 @@ require_once($CFG->libdir.'/questionlib.php');
* Function to read all questions for category into big array
*
* @param int $category category number
* @param bool @noparent if true only questions with NO parent will be selected
* @param bool $noparent if true only questions with NO parent will be selected
* @param bool $recurse include subdirectories
* @author added by Howard Miller June 2004
*/
function get_questions_category( $category, $noparent=false ) {
function get_questions_category( $category, $noparent=false, $recurse=true ) {
global $QTYPES;
@@ -35,8 +36,16 @@ function get_questions_category( $category, $noparent=false ) {
$npsql = " and parent='0' ";
}
// get (list) of categories
if ($recurse) {
$categorylist = question_categorylist( $category->id );
}
else {
$categorylist = $category->id;
}
// get the list of questions for the category
if ($questions = get_records_select("question","category={$category->id} $npsql", "qtype, name ASC")) {
if ($questions = get_records_select("question","category IN ($categorylist) $npsql", "qtype, name ASC")) {
// iterate through questions, getting stuff we need
foreach($questions as $question) {
+2 -1
View File
@@ -238,8 +238,9 @@ class qformat_default {
return $newfile;
}
//=================
// Export functions
//=================
function export_file_extension() {
/// return the files extension appropriate for this type
+24 -9
View File
@@ -507,16 +507,31 @@ function writequestion( $question ) {
switch($question->qtype) {
case TRUEFALSE:
$answers = $question->options->answers;
if ($answers['true']->fraction==1) {
$answertext = 'TRUE';
$wrong_feedback = $this->repchar( $answers['false']->feedback );
$right_feedback = $this->repchar( $answers['true']->feedback );
}
else {
$answertext = 'FALSE';
$wrong_feedback = $this->repchar( $answers['true']->feedback );
$right_feedback = $this->repchar( $answers['false']->feedback );
foreach ($answers as $answer) {
if (trim($answer->answer)=='True') {
if ($answer->fraction==1) {
$answertext = 'TRUE';
$right_feedback = $answer->feedback;
}
else {
$answertext = 'FALSE';
$wrong_feedback = $answer->feedback;
}
}
else {
if ($answer->fraction==1) {
$answertext = 'FALSE';
$right_feedback = $answer->feedback;
}
else {
$answertext = 'TRUE';
$wrong_feedback = $answer->feedback;
}
}
}
$wrong_feedback = $this->repchar( $wrong_feedback );
$right_feedback = $this->repchar( $right_feedback );
$expout .= "::".$question->name."::".$tfname.$this->repchar( $question->questiontext,$textformat )."{".$this->repchar( $answertext );
if ($wrong_feedback!="") {
$expout .= "#".$wrong_feedback;
-1
View File
@@ -660,7 +660,6 @@ class qformat_webct extends qformat_default {
}
echo "</ul>";
}
echo "<pre>"; print_r( $questions ); die;
return $questions;
}
}
+1 -1
View File
@@ -114,7 +114,7 @@ function presave_process( $content ) {
global $CFG;
// get css bit
$css_lines = file( "$CFG->dirroot/mod/quiz/format/xhtml/xhtml.css" );
$css_lines = file( "$CFG->dirroot/question/format/xhtml/xhtml.css" );
$css = implode( ' ',$css_lines );
$xp = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
+9 -18
View File
@@ -553,24 +553,15 @@ class qformat_xml extends qformat_default {
// output depends on question type
switch($question->qtype) {
case TRUEFALSE:
$answer = $question->options->answers;
$true_percent = round( $answer['true']->fraction * 100 );
$false_percent = round( $answer['false']->fraction * 100 );
// true answer
$expout .= " <answer fraction=\"$true_percent\">\n";
$expout .= $this->writetext("true",3)."\n";
$expout .= " <feedback>\n";
$expout .= $this->writetext( $answer['true']->feedback,4,false );
$expout .= " </feedback>\n";
$expout .= " </answer>\n";
// false answer
$expout .= " <answer fraction=\"$false_percent\">\n";
$expout .= $this->writetext("false")."\n";
$expout .= " <feedback>\n";
$expout .= $this->writetext( $answer['false']->feedback,4,false );
$expout .= " </feedback>\n";
$expout .= " </answer>\n";
foreach ($question->options->answers as $answer) {
$fraction_pc = round( $answer->fraction * 100 );
$expout .= " <answer fraction=\"$fraction_pc\">\n";
$expout .= $this->writetext(strtolower($answer->answer),3)."\n";
$expout .= " <feedback>\n";
$expout .= $this->writetext( $answer->feedback,4,false );
$expout .= " </feedback>\n";
$expout .= " </answer>\n";
}
break;
case MULTICHOICE:
$expout .= " <single>".$this->get_single($question->options->single)."</single>\n";