From: toyomoyo Date: Tue, 29 May 2007 09:00:48 +0000 (+0000) Subject: restore for gradebook, needs testing for grade_history, outcomes, categories, calcula... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=bc1637c73075720a6a073b9d946d0a82b8465fa8;p=moodle.git restore for gradebook, needs testing for grade_history, outcomes, categories, calculations and text --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 457e23d475..d0984674b3 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -1164,92 +1164,261 @@ $status = true; //Check it exists if (!file_exists($xml_file)) { - $status = false; + return false; } - //Get info from xml - if ($status) { - //info will contain the number of record to process - $info = restore_read_xml_gradebook($restore, $xml_file); - - //If we have info, then process preferences, letters & categories - if ($info > 0) { - //Count how many we have - $preferencescount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_preferences'); - $letterscount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_letter'); - $categoriescount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_category'); + + // Get info from xml + // info will contain the number of record to process + $info = restore_read_xml_gradebook($restore, $xml_file); - if ($preferencescount || $letterscount || $categoriescount) { - //Start ul - if (!defined('RESTORE_SILENTLY')) { - echo ''; + } + return $status; } //This function creates all the user, user_students, user_teachers @@ -3372,7 +3474,7 @@ //If we are under a GRADE_PREFERENCE, GRADE_LETTER or GRADE_CATEGORY tag under a GRADEBOOK zone, accumule it if (isset($this->tree[5]) and isset($this->tree[3])) { - if (($this->tree[5] == "GRADE_PREFERENCE" || $this->tree[5] == "GRADE_LETTER" || $this->tree[5] == "GRADE_CATEGORY" ) && ($this->tree[3] == "GRADEBOOK")) { + if (($this->tree[5] == "GRADE_ITEM" || $this->tree[5] == "GRADE_CATEGORY" || $this->tree[5] == "GRADE_OUTCOME") && ($this->tree[3] == "GRADEBOOK")) { if (!isset($this->temp)) { $this->temp = ""; } @@ -4444,13 +4546,13 @@ $this->temp = ""; } $this->temp .= htmlspecialchars(trim($this->content)).""; - //We have finished preferences, letters or categories, reset accumulated - //data because they are close tags + // We have finished outcome, grade_category or grade_item, reset accumulated + // data because they are close tags if ($this->level == 4) { $this->temp = ""; } //If we've finished a message, xmlize it an save to db - if (($this->level == 5) and ($tagName == "GRADE_PREFERENCE")) { + if (($this->level == 5) and ($tagName == "GRADE_ITEM")) { //Prepend XML standard header to info gathered $xml_data = "\n".$this->temp; //Call to xmlize for this portion of xml data (one PREFERENCE) @@ -4462,21 +4564,24 @@ //$GLOBALS['traverse_array']=""; //Debug //Now, save data to db. We'll use it later //Get id and status from data - $preference_id = $data["GRADE_PREFERENCE"]["#"]["ID"]["0"]["#"]; + $item_id = $data["GRADE_ITEM"]["#"]["ID"]["0"]["#"]; $this->counter++; //Save to db - $status = backup_putid($this->preferences->backup_unique_code, 'grade_preferences', $preference_id, + + $status = backup_putid($this->preferences->backup_unique_code, 'grade_items', $item_id, null,$data); //Create returning info $this->info = $this->counter; //Reset temp + unset($this->temp); } - //If we've finished a grade_letter, xmlize it an save to db - if (($this->level == 5) and ($tagName == "GRADE_LETTER")) { + + //If we've finished a grade_category, xmlize it an save to db + if (($this->level == 5) and ($tagName == "GRADE_CATEGORY")) { //Prepend XML standard header to info gathered $xml_data = "\n".$this->temp; - //Call to xmlize for this portion of xml data (one LETTER) + //Call to xmlize for this portion of xml data (one CATECORY) //echo "-XMLIZE: ".strftime ("%X",time()),"-"; //Debug $data = xmlize($xml_data,0); //echo strftime ("%X",time())."

"; //Debug @@ -4485,19 +4590,19 @@ //$GLOBALS['traverse_array']=""; //Debug //Now, save data to db. We'll use it later //Get id and status from data - $letter_id = $data["GRADE_LETTER"]["#"]["ID"]["0"]["#"]; + $category_id = $data["GRADE_CATEGORY"]["#"]["ID"]["0"]["#"]; $this->counter++; //Save to db - $status = backup_putid($this->preferences->backup_unique_code, 'grade_letter' ,$letter_id, + $status = backup_putid($this->preferences->backup_unique_code, 'grade_categories' ,$category_id, null,$data); //Create returning info $this->info = $this->counter; //Reset temp unset($this->temp); } - + //If we've finished a grade_category, xmlize it an save to db - if (($this->level == 5) and ($tagName == "GRADE_CATEGORY")) { + if (($this->level == 5) and ($tagName == "GRADE_OUTCOME")) { //Prepend XML standard header to info gathered $xml_data = "\n".$this->temp; //Call to xmlize for this portion of xml data (one CATECORY) @@ -4509,10 +4614,10 @@ //$GLOBALS['traverse_array']=""; //Debug //Now, save data to db. We'll use it later //Get id and status from data - $category_id = $data["GRADE_CATEGORY"]["#"]["ID"]["0"]["#"]; + $outcome_id = $data["GRADE_OUTCOME"]["#"]["ID"]["0"]["#"]; $this->counter++; //Save to db - $status = backup_putid($this->preferences->backup_unique_code, 'grade_category' ,$category_id, + $status = backup_putid($this->preferences->backup_unique_code, 'grade_outcomes' ,$outcome_id, null,$data); //Create returning info $this->info = $this->counter;