Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged from STABLE.

  • Loading branch information...
commit 36e2232e27140e343496d5df85e8e7fe8794c838 1 parent f6a7a35
thepurpleblob authored
View
15 question/editlib.php
@@ -19,10 +19,11 @@
* 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) {
View
3  question/format.php
@@ -238,8 +238,9 @@ function importimagefile( $path, $base64 ) {
return $newfile;
}
+//=================
// Export functions
-
+//=================
function export_file_extension() {
/// return the files extension appropriate for this type
View
33 question/format/gift/format.php
@@ -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;
View
1  question/format/webct/format.php
@@ -660,7 +660,6 @@ function readquestions ($lines) {
}
echo "</ul>";
}
- echo "<pre>"; print_r( $questions ); die;
return $questions;
}
}
View
2  question/format/xhtml/format.php
@@ -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";
View
27 question/format/xml/format.php
@@ -553,24 +553,15 @@ function writequestion( $question ) {
// 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";
Please sign in to comment.
Something went wrong with that request. Please try again.