MDL-22164 backup - more cleaning of old questions backup code
authorEloy Lafuente <stronk7@moodle.org>
Tue, 21 Sep 2010 00:08:52 +0000 (00:08 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Tue, 21 Sep 2010 00:08:52 +0000 (00:08 +0000)
question/backuplib.php [deleted file]
question/type/calculated/questiontype.php

diff --git a/question/backuplib.php b/question/backuplib.php
deleted file mode 100644 (file)
index fe8c9d6..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-
-    //This function backups question_numerical_units from different question types
-    function question_backup_numerical_units($bf,$preferences,$question,$level=7) {
-        global $CFG, $DB;
-
-        $status = true;
-
-        $numerical_units = $DB->get_records("question_numerical_units", array("question"=>$question), "id");
-        //If there are numericals_units
-        if ($numerical_units) {
-            $status = $status && fwrite ($bf,start_tag("NUMERICAL_UNITS",$level,true));
-            //Iterate over each numerical_unit
-            foreach ($numerical_units as $numerical_unit) {
-                $status = $status && fwrite ($bf,start_tag("NUMERICAL_UNIT",$level+1,true));
-                //Print numerical_unit contents
-                fwrite ($bf,full_tag("MULTIPLIER",$level+2,false,$numerical_unit->multiplier));
-                fwrite ($bf,full_tag("UNIT",$level+2,false,$numerical_unit->unit));
-                //Now backup numerical_units
-                $status = $status && fwrite ($bf,end_tag("NUMERICAL_UNIT",$level+1,true));
-            }
-            $status = $status && fwrite ($bf,end_tag("NUMERICAL_UNITS",$level,true));
-        }
-
-        return $status;
-
-    }
-
-    //This function backups question_numerical_options from different question types
-    function question_backup_numerical_options($bf,$preferences,$question,$level=7) {
-        global $CFG, $DB;
-
-        $status = true;
-        $numerical_options = $DB->get_records("question_numerical_options",array("questionid" => $question),"id");
-        if ($numerical_options) {
-            //Iterate over each numerical_option
-            foreach ($numerical_options as $numerical_option) {
-                $status = $status && fwrite ($bf,start_tag("NUMERICAL_OPTIONS",$level,true));
-                //Print numerical_option contents
-                fwrite ($bf,full_tag("INSTRUCTIONS",$level+1,false,$numerical_option->instructions));
-                fwrite ($bf,full_tag("SHOWUNITS",$level+1,false,$numerical_option->showunits));
-                fwrite ($bf,full_tag("UNITSLEFT",$level+1,false,$numerical_option->unitsleft));
-                fwrite ($bf,full_tag("UNITGRADINGTYPE",$level+1,false,$numerical_option->unitgradingtype));
-                fwrite ($bf,full_tag("UNITPENALTY",$level+1,false,$numerical_option->unitpenalty));
-                $status = $status && fwrite ($bf,end_tag("NUMERICAL_OPTIONS",$level,true));
-            }
-        }
-
-        return $status;
-
-    }
-
-    //This function backups dataset_definitions (via question_datasets) from different question types
-    function question_backup_datasets($bf,$preferences,$question,$level=7) {
-        global $CFG, $DB;
-
-        $status = true;
-
-        //First, we get the used datasets for this question
-        $question_datasets = $DB->get_records("question_datasets", array("question"=>$question), "id");
-        //If there are question_datasets
-        if ($question_datasets) {
-            $status = $status &&fwrite ($bf,start_tag("DATASET_DEFINITIONS",$level,true));
-            //Iterate over each question_dataset
-            foreach ($question_datasets as $question_dataset) {
-                $def = NULL;
-                //Get dataset_definition
-                if ($def = $DB->get_record("question_dataset_definitions", array("id"=>$question_dataset->datasetdefinition))) {;
-                    $status = $status &&fwrite ($bf,start_tag("DATASET_DEFINITION",$level+1,true));
-                    //Print question_dataset contents
-                    fwrite ($bf,full_tag("CATEGORY",$level+2,false,$def->category));
-                    fwrite ($bf,full_tag("NAME",$level+2,false,$def->name));
-                    fwrite ($bf,full_tag("TYPE",$level+2,false,$def->type));
-                    fwrite ($bf,full_tag("OPTIONS",$level+2,false,$def->options));
-                    fwrite ($bf,full_tag("ITEMCOUNT",$level+2,false,$def->itemcount));
-                    //Now backup dataset_entries
-                    $status = $status && question_backup_dataset_items($bf,$preferences,$def->id,$level+2);
-                    //End dataset definition
-                    $status = $status &&fwrite ($bf,end_tag("DATASET_DEFINITION",$level+1,true));
-                }
-            }
-            $status = $status &&fwrite ($bf,end_tag("DATASET_DEFINITIONS",$level,true));
-        }
-
-        return $status;
-
-    }
-
-    //This function backups datases_items from dataset_definitions
-    function question_backup_dataset_items($bf,$preferences,$datasetdefinition,$level=9) {
-        global $CFG, $DB;
-
-        $status = true;
-
-        //First, we get the datasets_items for this dataset_definition
-        $dataset_items = $DB->get_records("question_dataset_items", array("definition"=>$datasetdefinition), "id");
-        //If there are dataset_items
-        if ($dataset_items) {
-            $status = $status &&fwrite ($bf,start_tag("DATASET_ITEMS",$level,true));
-            //Iterate over each dataset_item
-            foreach ($dataset_items as $dataset_item) {
-                $status = $status &&fwrite ($bf,start_tag("DATASET_ITEM",$level+1,true));
-                //Print question_dataset contents
-                fwrite ($bf,full_tag("NUMBER",$level+2,false,$dataset_item->itemnumber));
-                fwrite ($bf,full_tag("VALUE",$level+2,false,$dataset_item->value));
-                //End dataset definition
-                $status = $status &&fwrite ($bf,end_tag("DATASET_ITEM",$level+1,true));
-            }
-            $status = $status &&fwrite ($bf,end_tag("DATASET_ITEMS",$level,true));
-        }
-
-        return $status;
-
-    }
index 13f9f52..cf9b879 100644 (file)
@@ -2043,59 +2043,6 @@ class question_calculated_qtype extends default_questiontype {
         return $this->virtualqtype;
     }
 
         return $this->virtualqtype;
     }
 
-
-    /// BACKUP FUNCTIONS ////////////////////////////
-
-    /*
-     * Backup the data in the question
-     *
-     * This is used in question/backuplib.php
-     */
-    function backup($bf,$preferences,$question,$level=6) {
-        global $DB;
-        $status = true;
-
-        $calculateds = $DB->get_records("question_calculated",array("question" =>$question,"id"));
-        //If there are calculated-s
-        if ($calculateds) {
-            //Iterate over each calculateds
-            foreach ($calculateds as $calculated) {
-                $status = $status &&fwrite ($bf,start_tag("CALCULATED",$level,true));
-                //Print calculated contents
-                fwrite ($bf,full_tag("ANSWER",$level+1,false,$calculated->answer));
-                fwrite ($bf,full_tag("TOLERANCE",$level+1,false,$calculated->tolerance));
-                fwrite ($bf,full_tag("TOLERANCETYPE",$level+1,false,$calculated->tolerancetype));
-                fwrite ($bf,full_tag("CORRECTANSWERLENGTH",$level+1,false,$calculated->correctanswerlength));
-                fwrite ($bf,full_tag("CORRECTANSWERFORMAT",$level+1,false,$calculated->correctanswerformat));
-                //Now backup numerical_units
-                $status = question_backup_numerical_units($bf,$preferences,$question,7);
-                //Now backup required dataset definitions and items...
-                $status = question_backup_datasets($bf,$preferences,$question,7);
-                //End calculated data
-                $status = $status &&fwrite ($bf,end_tag("CALCULATED",$level,true));
-            }
-            $calculated_options = $DB->get_records("question_calculated_options",array("questionid" => $question),"id");
-            if ($calculated_options) {
-                //Iterate over each calculated_option
-                foreach ($calculated_options as $calculated_option) {
-                    $status = fwrite ($bf,start_tag("CALCULATED_OPTIONS",$level,true));
-                    //Print calculated_option contents
-                    fwrite ($bf,full_tag("SYNCHRONIZE",$level+1,false,$calculated_option->synchronize));
-                    fwrite ($bf,full_tag("SINGLE",$level+1,false,$calculated_option->single));
-                    fwrite ($bf,full_tag("SHUFFLEANSWERS",$level+1,false,$calculated_option->shuffleanswers));
-                    fwrite ($bf,full_tag("CORRECTFEEDBACK",$level+1,false,$calculated_option->correctfeedback));
-                    fwrite ($bf,full_tag("PARTIALLYCORRECTFEEDBACK",$level+1,false,$calculated_option->partiallycorrectfeedback));
-                    fwrite ($bf,full_tag("INCORRECTFEEDBACK",$level+1,false,$calculated_option->incorrectfeedback));
-                    fwrite ($bf,full_tag("ANSWERNUMBERING",$level+1,false,$calculated_option->answernumbering));
-                    $status = fwrite ($bf,end_tag("CALCULATED_OPTIONS",$level,true));
-                }
-            }
-            $status = question_backup_numerical_options($bf,$preferences,$question,$level);
-
-        }
-        return $status;
-    }
-
     /// RESTORE FUNCTIONS /////////////////
 
     /*
     /// RESTORE FUNCTIONS /////////////////
 
     /*