/** * Prepares questions for quiz export * * The questions are changed as follows: * - the question answers atached to the questions * - image set to an http reference instead of a file path * - qti specific info added * - exporttext added, which contains an xml-formatted qti assesmentItem * * @param array $questions - an array of question objects * @param int $quizid * @return an array of question arrays */ function quiz_export_prepare_questions($questions, $quizid, $courseid, $shuffleanswers = null) { global $CFG; // add the answers to the questions and format the image property foreach ($questions as $key => $question) { $questions[$key] = get_question_data($question); $questions[$key]->courseid = $courseid; $questions[$key]->quizid = $quizid; if ($question->image) { if (empty($question->mediamimetype)) { $questions[$key]->mediamimetype = mimeinfo('type', $question->image); } $localfile = substr(strtolower($question->image), 0, 7) == 'http://' ? false : true; if ($localfile) { // create the http url that the player will need to access the file if ($CFG->slasharguments) { // Use this method if possible for better caching $questions[$key]->mediaurl = "{$CFG->wwwroot}/file.php/{$question->image}"; } else { $questions[$key]->mediaurl = "{$CFG->wwwroot}/file.php?file={$question->image}"; } } else { $questions[$key]->mediaurl = $question->image; } } } $this->add_qti_info($questions); $questions = $this->questions_with_export_info($questions, $shuffleanswers); $questions = $this->objects_to_array($questions); return $questions; }
/** * Prepares questions for quiz export * * The questions are changed as follows: * - the question answers atached to the questions * - image set to an http reference instead of a file path * - qti specific info added * - exporttext added, which contains an xml-formatted qti assesmentItem * * @param array $questions - an array of question objects * @param int $quizid * @return an array of question arrays */ public function quiz_export_prepare_questions($questions, $quizid, $courseid, $shuffleanswers = null) { global $CFG; // Add the answers to the questions and format the image property. foreach ($questions as $key => $question) { $questions[$key] = get_question_data($question); $questions[$key]->courseid = $courseid; $questions[$key]->quizid = $quizid; } $this->add_qti_info($questions); $questions = $this->questions_with_export_info($questions, $shuffleanswers); $questions = $this->objects_to_array($questions); return $questions; }
return $base; } } return false; } $config_path = seu_get_wp_config_path(); //load WP features include_once $config_path . '/wp-config.php'; include_once $config_path . '/wp-load.php'; include_once $config_path . '/wp-includes/wp-db.php'; switch ($_POST['function']) { case 'get_dept_data': echo get_dept_data(); break; case 'get_question_data': echo get_question_data(); break; case 'get_evaluations': echo get_evaluations(); break; } function get_dept_data() { $depts = get_depts(); foreach ($depts as &$dept) { $dept->eval_sections = get_sections($dept->id); foreach ($dept->eval_sections as &$section) { $section->questions = get_questions($section->id); } } return serialize($depts);
/** * Prepares questions for quiz export * * The questions are changed as follows: * - the question answers atached to the questions * - image set to an http reference instead of a file path * - qti specific info added * - exporttext added, which contains an xml-formatted qti assesmentItem * * @param array $questions - an array of question objects * @param int $quizid * @return an array of question arrays */ function quiz_export_prepare_questions($questions, $quizid, $courseid, $shuffleanswers = null) { global $CFG; // add the answers to the questions and format the image property require_once $CFG->libdir . '/filelib.php'; foreach ($questions as $key => $question) { $questions[$key] = get_question_data($question); $questions[$key]->courseid = $courseid; $questions[$key]->quizid = $quizid; if ($question->image) { if (empty($question->mediamimetype)) { $questions[$key]->mediamimetype = mimeinfo('type', $question->image); } $localfile = substr(strtolower($question->image), 0, 7) == 'http://' ? false : true; if ($localfile) { // create the http url that the player will need to access the file $questions[$key]->mediaurl = get_file_url($question->image); } else { $questions[$key]->mediaurl = $question->image; } } } $this->add_qti_info($questions); $questions = $this->questions_with_export_info($questions, $shuffleanswers); $questions = $this->objects_to_array($questions); return $questions; }