Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blocks/quiz_results/backup/moodle2/restore_quiz_results_block_task.class.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00026 defined('MOODLE_INTERNAL') || die();
00027 
00028 
00038 class restore_quiz_results_block_task extends restore_block_task {
00039 
00040     protected function define_my_settings() {
00041     }
00042 
00043     protected function define_my_steps() {
00044     }
00045 
00046     public function get_fileareas() {
00047         return array(); // No associated fileareas
00048     }
00049 
00050     public function get_configdata_encoded_attributes() {
00051         return array(); // No special handling of configdata
00052     }
00053 
00061     public function after_restore() {
00062         global $DB;
00063 
00064         // Get the blockid
00065         $blockid = $this->get_blockid();
00066 
00067         // Extract block configdata and update it to point to the new quiz
00068         if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
00069             $config = unserialize(base64_decode($configdata));
00070             if (!empty($config->quizid)) {
00071                 // Get quiz mapping and replace it in config
00072                 if ($quizmap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'quiz', $config->quizid)) {
00073                     $config->quizid = $quizmap->newitemid;
00074                     $configdata = base64_encode(serialize($config));
00075                     $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
00076                 }
00077             }
00078         }
00079     }
00080 
00081     static public function define_decode_contents() {
00082         return array();
00083     }
00084 
00085     static public function define_decode_rules() {
00086         return array();
00087     }
00088 }
 All Data Structures Namespaces Files Functions Variables Enumerations