$questions = array();
- process_tf($xml, $questions);
- process_mc($xml, $questions);
- process_ma($xml, $questions);
- process_fib($xml, $questions);
- process_matching($xml, $questions);
+ $defaultq = $this->defaultquestion();
+
+ process_tf($xml, $questions, $defaultq);
+ process_mc($xml, $questions, $defaultq);
+ process_ma($xml, $questions, $defaultq);
+ process_fib($xml, $questions, $defaultq);
+ process_matching($xml, $questions, $defaultq);
return $questions;
}
//----------------------------------------
// Process True / False Questions
//----------------------------------------
-function process_tf($xml, &$questions) {
+function process_tf($xml, &$questions, $defaultq) {
- $tfquestions = $xml["POOL"]["#"]["QUESTION_TRUEFALSE"];
+ if (isset($xml["POOL"]["#"]["QUESTION_TRUEFALSE"])) {
+ $tfquestions = $xml["POOL"]["#"]["QUESTION_TRUEFALSE"];
+ }
+ else {
+ return;
+ }
for ($i = 0; $i < sizeof ($tfquestions); $i++) {
- $question = $this->defaultquestion();
+ $question = $defaultq;
$question->qtype = TRUEFALSE;
$question->single = 1; // Only one answer is allowed
//----------------------------------------
// Process Multiple Choice Questions
//----------------------------------------
-function process_mc($xml, &$questions) {
+function process_mc($xml, &$questions, $defaultq) {
- $mcquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"];
+ if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"])) {
+ $mcquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLECHOICE"];
+ }
+ else {
+ return;
+ }
for ($i = 0; $i < sizeof ($mcquestions); $i++) {
- $question = $this->defaultquestion();
+ $question = $defaultq;
$question->qtype = MULTICHOICE;
$question->single = 1; // Only one answer is allowed
//----------------------------------------
// Process Multiple Choice Questions With Multiple Answers
//----------------------------------------
-function process_ma($xml, &$questions) {
+function process_ma($xml, &$questions, $defaultq) {
- $maquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"];
+ if (isset($xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"])) {
+ $maquestions = $xml["POOL"]["#"]["QUESTION_MULTIPLEANSWER"];
+ }
+ else {
+ return;
+ }
for ($i = 0; $i < sizeof ($maquestions); $i++) {
- $question = $this->defaultquestion();
+ $question = $defaultq;
$question->qtype = MULTICHOICE;
$question->defaultgrade = 1;
//----------------------------------------
// Process Fill in the Blank Questions
//----------------------------------------
-function process_fib($xml, &$questions) {
+function process_fib($xml, &$questions, $defaultq) {
+
+ if (isset($xml["POOL"]["#"]["QUESTION_FILLINBLANK"])) {
+ $fibquestions = $xml["POOL"]["#"]["QUESTION_FILLINBLANK"];
+ }
+ else {
+ return;
+ }
- $fibquestions = $xml["POOL"]["#"]["QUESTION_FILLINBLANK"];
for ($i = 0; $i < sizeof ($fibquestions); $i++) {
- $question = $this->defaultquestion();
+ $question = $defaultq;
$question->qtype = SHORTANSWER;
$question->usecase = 0; // Ignore case
//----------------------------------------
// Process Matching Questions
//----------------------------------------
-function process_matching($xml, &$questions) {
+function process_matching($xml, &$questions, $defaultq) {
+
+ if (isset($xml["POOL"]["#"]["QUESTION_MATCH"])) {
+ $matchquestions = $xml["POOL"]["#"]["QUESTION_MATCH"];
+ }
+ else {
+ return;
+ }
- $matchquestions = $xml["POOL"]["#"]["QUESTION_MATCH"];
for ($i = 0; $i < sizeof ($matchquestions); $i++) {
- $question = $this->defaultquestion();
+ $question = $defaultq;
$question->qtype = MATCH;