芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/question/type/match/backup/moodle1/lib.php
. /** * @package qtype_match * @copyright 2011 David Mudrak
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Matching question type conversion handler. */ class moodle1_qtype_match_handler extends moodle1_qtype_handler { /** * @return array */ public function get_question_subpaths() { return array( 'MATCHOPTIONS', 'MATCHS/MATCH', ); } /** * Appends the match specific information to the question. */ public function process_question(array $data, array $raw) { global $CFG; // Populate the list of matches first to get their ids. // Note that the field is re-populated on restore anyway but let us // do our best to produce valid backup files. $matchids = array(); if (isset($data['matchs']['match'])) { foreach ($data['matchs']['match'] as $match) { $matchids[] = $match['id']; } } // Convert match options. if (isset($data['matchoptions'])) { $matchoptions = $data['matchoptions'][0]; } else { $matchoptions = array('shuffleanswers' => 1); } $matchoptions['id'] = $this->converter->get_nextid(); $matchoptions['subquestions'] = implode(',', $matchids); $this->write_xml('matchoptions', $matchoptions, array('/matchoptions/id')); // Convert matches. $this->xmlwriter->begin_tag('matches'); if (isset($data['matchs']['match'])) { foreach ($data['matchs']['match'] as $match) { // Replay the upgrade step 2009072100. $match['questiontextformat'] = 0; if ($CFG->texteditors !== 'textarea' and $data['oldquestiontextformat'] == FORMAT_MOODLE) { $match['questiontext'] = text_to_html($match['questiontext'], false, false, true); $match['questiontextformat'] = FORMAT_HTML; } else { $match['questiontextformat'] = $data['oldquestiontextformat']; } $match['questiontext'] = $this->migrate_files( $match['questiontext'], 'qtype_match', 'subquestion', $match['id']); $this->write_xml('match', $match, array('/match/id')); } } $this->xmlwriter->end_tag('matches'); } }