$question = $defaultq;
$question->qtype = TRUEFALSE;
- $question->single = 1; // Only one answer is allowed
+ $question->single = 1; // Only one answer is allowed
- $thisquestion = $tfquestions[$i];
+ $thisquestion = $tfquestions[$i];
// put questiontext in question object
- $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
+ $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
// put name in question object
$question->name = $question->questiontext;
- $choices = $thisquestion["#"]["ANSWER"];
+ $choices = $thisquestion["#"]["ANSWER"];
$correct_answer = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"];
$question = $defaultq;
$question->qtype = MULTICHOICE;
- $question->single = 1; // Only one answer is allowed
+ $question->single = 1; // Only one answer is allowed
- $thisquestion = $mcquestions[$i];
+ $thisquestion = $mcquestions[$i];
// put questiontext in question object
- $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
+ $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
// put name of question in question object
$question->name = $question->questiontext;
- $choices = $thisquestion["#"]["ANSWER"];
- for ($j = 0; $j < sizeof ($choices); $j++) {
+ $choices = $thisquestion["#"]["ANSWER"];
+ for ($j = 0; $j < sizeof ($choices); $j++) {
- $choice = trim($choices[$j]["#"]["TEXT"][0]["#"]);
+ $choice = trim($choices[$j]["#"]["TEXT"][0]["#"]);
// put this choice in the question object.
$question->answer[$j] = addslashes($choice);
- $id = $choices[$j]["@"]["id"];
- $correct_answer_id = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"];
+ $id = $choices[$j]["@"]["id"];
+ $correct_answer_id = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"][0]["@"]["answer_id"];
// if choice is the answer, give 100%, otherwise give 0%
- if (strcmp ($id, $correct_answer_id) == 0) {
- $question->fraction[$j] = 1;
- $question->feedback[$j] = addslashes(trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]));
+ if (strcmp ($id, $correct_answer_id) == 0) {
+ $question->fraction[$j] = 1;
+ $question->feedback[$j] = addslashes(trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]));
} else {
- $question->fraction[$j] = 0;
- $question->feedback[$j] = addslashes(trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]));
+ $question->fraction[$j] = 0;
+ $question->feedback[$j] = addslashes(trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]));
}
}
$questions[] = $question;
$question->qtype = MULTICHOICE;
$question->defaultgrade = 1;
- $question->single = 0; // More than one answers allowed
- $question->image = ""; // No images with this format
+ $question->single = 0; // More than one answers allowed
+ $question->image = ""; // No images with this format
- $thisquestion = $maquestions[$i];
+ $thisquestion = $maquestions[$i];
// put questiontext in question object
- $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
+ $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
// put name of question in question object
$question->name = $question->questiontext;
- $choices = $thisquestion["#"]["ANSWER"];
+ $choices = $thisquestion["#"]["ANSWER"];
$correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"];
- for ($j = 0; $j < sizeof ($choices); $j++) {
+ for ($j = 0; $j < sizeof ($choices); $j++) {
- $choice = trim($choices[$j]["#"]["TEXT"][0]["#"]);
+ $choice = trim($choices[$j]["#"]["TEXT"][0]["#"]);
// put this choice in the question object.
$question->answer[$j] = addslashes($choice);
$question = $defaultq;
$question->qtype = SHORTANSWER;
- $question->usecase = 0; // Ignore case
+ $question->usecase = 0; // Ignore case
- $thisquestion = $fibquestions[$i];
+ $thisquestion = $fibquestions[$i];
// put questiontext in question object
- $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
+ $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
// put name of question in question object
$question->name = $question->questiontext;
- $answer = trim($thisquestion["#"]["ANSWER"][0]["#"]["TEXT"][0]["#"]);
+ $answer = trim($thisquestion["#"]["ANSWER"][0]["#"]["TEXT"][0]["#"]);
$question->answer[] = addslashes($answer);
$question->fraction[] = 1;
$question->qtype = MATCH;
- $thisquestion = $matchquestions[$i];
+ $thisquestion = $matchquestions[$i];
// put questiontext in question object
- $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
+ $question->questiontext = addslashes(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
// put name of question in question object
$question->name = $question->questiontext;
- $choices = $thisquestion["#"]["CHOICE"];
- for ($j = 0; $j < sizeof ($choices); $j++) {
+ $choices = $thisquestion["#"]["CHOICE"];
+ for ($j = 0; $j < sizeof ($choices); $j++) {
$subquestion = NULL;
- $choice = $choices[$j]["#"]["TEXT"][0]["#"];
- $choice_id = $choices[$j]["@"]["id"];
+ $choice = $choices[$j]["#"]["TEXT"][0]["#"];
+ $choice_id = $choices[$j]["@"]["id"];
$question->subanswers[] = addslashes(trim($choice));
- $correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"];
- for ($k = 0; $k < sizeof ($correctanswers); $k++) {
+ $correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"];
+ for ($k = 0; $k < sizeof ($correctanswers); $k++) {
- if (strcmp($choice_id, $correctanswers[$k]["@"]["choice_id"]) == 0) {
+ if (strcmp($choice_id, $correctanswers[$k]["@"]["choice_id"]) == 0) {
- $answer_id = $correctanswers[$k]["@"]["answer_id"];
+ $answer_id = $correctanswers[$k]["@"]["answer_id"];
- $answers = $thisquestion["#"]["ANSWER"];
- for ($m = 0; $m < sizeof ($answers); $m++) {
+ $answers = $thisquestion["#"]["ANSWER"];
+ for ($m = 0; $m < sizeof ($answers); $m++) {
- $answer = $answers[$m];
- $current_ans_id = $answer["@"]["id"];
- if (strcmp ($current_ans_id, $answer_id) == 0) {
+ $answer = $answers[$m];
+ $current_ans_id = $answer["@"]["id"];
+ if (strcmp ($current_ans_id, $answer_id) == 0) {
- $answer = $answer["#"]["TEXT"][0]["#"];
+ $answer = $answer["#"]["TEXT"][0]["#"];
$question->subquestions[] = addslashes(trim($answer));
- break;
+ break;
- }
+ }
- }
+ }
- break;
+ break;
- }
+ }
- }
+ }
- }
+ }
- $questions[] = $question;
+ $questions[] = $question;
- }
+ }
}
?>
$question->qtype = TRUEFALSE;
$question->defaultgrade = 1;
- $question->single = 1; // Only one answer is allowed
- $question->image = ""; // No images with this format
- $question->questiontext = addslashes($quest->QUESTION_BLOCK->text);
+ $question->single = 1; // Only one answer is allowed
+ $question->image = ""; // No images with this format
+ $question->questiontext = addslashes($quest->QUESTION_BLOCK->text);
// put name in question object
$question->name = $question->questiontext;
$question->name = $question->questiontext;
$question->qtype = MULTICHOICE;
$question->defaultgrade = 1;
- $question->single = 0; // More than one answers allowed
- $question->image = ""; // No images with this format
+ $question->single = 0; // More than one answers allowed
+ $question->image = ""; // No images with this format
$answers = $quest->responses;
$correct_answers = array();
// treat as short answer
$question->qtype = ESSAY;
$question->defaultgrade = 1;
- $question->usecase = 0; // Ignore case
- $question->image = ""; // No images with this format
+ $question->usecase = 0; // Ignore case
+ $question->image = ""; // No images with this format
$question->questiontext = addslashes(trim($quest->QUESTION_BLOCK->text));
$question->name = $question->questiontext;
**
** @TODO:
** Take care of odd unicode character mapping (ex: curly quotes)
-** Image and table support
+** Image and table support
** Formatting support
** Support of rejoinders
**
** $Log$
+** Revision 1.4 2006/08/10 18:23:39 tjhunt
+** Convert tabs to spaces.
+**
** Revision 1.3 2006/05/04 11:17:50 thepurpleblob
** Merging from STABLE
**
}
foreach($this->matching_questions as $match_group) {
$question = $this->defaultquestion();
- $htmltext = $this->htmlPrepare($match_group->questiontext);
- $htmltext = addslashes($htmltext);
+ $htmltext = $this->htmlPrepare($match_group->questiontext);
+ $htmltext = addslashes($htmltext);
$question->questiontext = $htmltext;
$question->name = $question->questiontext;
$question->qtype = MATCH;
// No images with this format
- // print($question->questiontext.' '.$question->id."<BR>");
+ // print($question->questiontext.' '.$question->id."<BR>");
$question->subquestions = array();
$question->subanswers = array();
foreach($match_group->subquestions as $key => $value) {
- $htmltext = $this->htmlPrepare($value);
- $htmltext = addslashes($htmltext);
+ $htmltext = $this->htmlPrepare($value);
+ $htmltext = addslashes($htmltext);
$question->subquestions[] = $htmltext;
$htmltext = $this->htmlPrepare($match_group->subanswers[$key]);
- $htmltext = addslashes($htmltext);
+ $htmltext = addslashes($htmltext);
$question->subanswers[] = $htmltext;
}
$questions[] = $question;
}
}
- // cleans unicode characters from string
- // add to the array unicode_array as necessary
- function cleanUnicode($text) {
- //$unicode_array = array( "ߣ" => "'");
- //return strtr($text, $unicode_array);
- return str_replace('’', "'", $text);
- }
-
+ // cleans unicode characters from string
+ // add to the array unicode_array as necessary
+ function cleanUnicode($text) {
+ //$unicode_array = array("ߣ" => "'");
+ //return strtr($text, $unicode_array);
+ return str_replace('’', "'", $text);
+ }
+
function readquestions($lines)
{
/// Parses an array of lines into an array of questions,
$currentquestion = array();
$text = implode($lines, ' ');
- $text = $this->cleanUnicode($text);
+ $text = $this->cleanUnicode($text);
$xml = xmlize($text, 0);
$this->parse_matching_groups($xml['examview']['#']['matching-group']);