From d6545aefbcc13d2406fb12f3707d8d25d5ec6399 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 2 May 2003 17:22:18 +0000 Subject: [PATCH] Check page finished (all mods except quiz). --- backup/STATUS.txt | 17 ++-- backup/check.html | 8 +- backup/mod/journal/backuplib.php | 78 ++++++++++++++++ backup/mod/pgassignment/backuplib.php | 125 ++++++++++++++++++++++++++ backup/mod/resource/backuplib.php | 4 +- backup/mod/survey/backuplib.php | 81 +++++++++++++++++ 6 files changed, 301 insertions(+), 12 deletions(-) create mode 100644 backup/mod/journal/backuplib.php create mode 100644 backup/mod/pgassignment/backuplib.php create mode 100644 backup/mod/survey/backuplib.php diff --git a/backup/STATUS.txt b/backup/STATUS.txt index 71ff087feb7..9dff24375d0 100644 --- a/backup/STATUS.txt +++ b/backup/STATUS.txt @@ -50,11 +50,11 @@ Backup Details: + course data..................................NO EXISTS + user data....................................NO EXISTS + files........................................NO EXISTS - x journals........................................NO EXISTS + x journals........................................IN PROGRESS + course data..................................NO EXISTS + user data....................................NO EXISTS + files........................................NO EXISTS - x peer graded assignments.........................NO EXISTS + x peer graded assignments.........................IN PROGRESS + course data..................................NO EXISTS + user data....................................NO EXISTS + files........................................NO EXISTS @@ -62,21 +62,22 @@ Backup Details: + course data..................................NO EXISTS + user data....................................NO EXISTS + files........................................NO EXISTS - x resources.......................................NO EXISTS + x resources.......................................IN PROGRESS + course data..................................NO EXISTS + user data....................................NO EXISTS + files........................................NO EXISTS - x surveys.........................................NO EXISTS + x surveys.........................................IN PROGRESS + course data..................................NO EXISTS + user data....................................NO EXISTS + + files........................................NO EXISTS - Compress the backup (zip)..................................NO EXISTS - XML File................................................NO EXISTS - Course Files............................................NO EXISTS - User Files..............................................NO EXISTS - - Browse backup files........................................NO EXISTS + - Browse backup files........................................DONE. TO FILE MANAGER - Obtain info about backup files.............................NO EXISTS - - Download backup files......................................NO EXISTS - - Delete backup files........................................NO EXISTS + - Download backup files......................................DONE. TO FILE MANAGER + - Delete backup files........................................DONE. TO FILE MANAGER - Program automatic backups..................................NO EXISTS Restore Details: @@ -143,7 +144,7 @@ Restore Details: - Course Files............................................NO EXISTS - User Files..............................................NO EXISTS - Obtain info about backup files.............................NO EXISTS - - Upload backup files........................................NO EXISTS + - Upload backup files........................................DONE. TO FILE MANAGER ========== ========== ========== =========== =========== =========== === diff --git a/backup/check.html b/backup/check.html index c43609f2b19..9a4f371b8dc 100644 --- a/backup/check.html +++ b/backup/check.html @@ -72,17 +72,21 @@ } //Calculate the format string $backup_name_format = get_string("backupnameformat"); - //If non-translated, use "%%Y%%m%%d-%%H%%M" + //If non-translated, use "%Y%m%d-%H%M" if (substr($backup_name_format,0,1) == "[") { $backup_name_format = "%%Y%%m%%d-%%H%%M"; } - $backup_name .= "-".userdate(time(),$backup_name_format,99,false).".zip"; echo $backup_name; //Add as hidden name echo ""; echo ""; + //Calculate the temp dir name to do all the work + $tempdir_name = userdate(time(),"%Y%m%d%H%M",99,false); + //Add as hidden name + echo ""; + //Line echo "
"; diff --git a/backup/mod/journal/backuplib.php b/backup/mod/journal/backuplib.php new file mode 100644 index 00000000000..ae22a46ac53 --- /dev/null +++ b/backup/mod/journal/backuplib.php @@ -0,0 +1,78 @@ +id) + // | + // | + // | + // journal_entries + // (UL,pk->id, fk->journal) + // + // Meaning: pk->primary key field of the table + // fk->foreign key to link with parent + // nt->nested field (recursive data) + // CL->course level info + // UL->user level info + // files->table may have files) + // + //----------------------------------------------------------- + + function journal_backup_mods($course,$user_data=false) { + print "hola"; + } + + ////Return an array of info (name,value) + function journal_check_backup_mods($course,$user_data=false) { + //First the course data + $info[0][0] = get_string("modulenameplural","journal"); + if ($ids = journal_ids ($course)) { + $info[0][1] = count($ids); + } else { + $info[0][1] = 0; + } + + //Now, if requested, the user_data + if ($user_data) { + $info[1][0] = get_string("entries","journal"); + if ($ids = journal_entry_ids_by_course ($course)) { + $info[1][1] = count($ids); + } else { + $info[1][1] = 0; + } + } + return $info; + } + + + + + + + // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE + + //Returns an array of journals id + function journal_ids ($course) { + + global $CFG; + + return get_records_sql ("SELECT a.id, a.course + FROM {$CFG->prefix}journal a + WHERE a.course = '$course'"); + } + + //Returns an array of journal entries id + function journal_entry_ids_by_course ($course) { + + global $CFG; + + return get_records_sql ("SELECT s.id , s.journal + FROM {$CFG->prefix}journal_entries s, + {$CFG->prefix}journal a + WHERE a.course = '$course' AND + s.journal = a.id"); + } +?> diff --git a/backup/mod/pgassignment/backuplib.php b/backup/mod/pgassignment/backuplib.php new file mode 100644 index 00000000000..267ce4735d0 --- /dev/null +++ b/backup/mod/pgassignment/backuplib.php @@ -0,0 +1,125 @@ +id) + // | + // ----------------------------------- + // | | + // pgassignment_elements pgassignment_submissions + // (CL,pk->id, fk->pgassignment) (UL,pk->id, fk->pgassignment,files) + // | + // | + // | + // pgasignments_grades + // (UL,pk->id,fk->submission) + // + // Meaning: pk->primary key field of the table + // fk->foreign key to link with parent + // nt->nested field (recursive data) + // CL->course level info + // UL->user level info + // files->table may have files) + // + //----------------------------------------------------------- + + function pgassignment_backup_mods($course,$user_data=false) { + print "hola"; + } + + ////Return an array of info (name,value) + function pgassignment_check_backup_mods($course,$user_data=false) { + //First the course data + $info[0][0] = get_string("modulenameplural","pgassignment"); + if ($ids = pgassignment_ids ($course)) { + $info[0][1] = count($ids); + } else { + $info[0][1] = 0; + } + //Elements + $info[1][0] = get_string("elements","pgassignment"); + if ($ids = pgassignment_element_ids_by_course ($course)) { + $info[1][1] = count($ids); + } else { + $info[1][1] = 0; + } + + //Now, if requested, the user_data + if ($user_data) { + //Submissions + $info[2][0] = get_string("submissions","pgassignment"); + if ($ids = pgassignment_submission_ids_by_course ($course)) { + $info[2][1] = count($ids); + } else { + $info[2][1] = 0; + } + //Grades + $info[3][0] = get_string("grades","pgassignment"); + if ($ids = pgassignment_grade_ids_by_course ($course)) { + $info[3][1] = count($ids); + } else { + $info[3][1] = 0; + } + } + return $info; + } + + + + + + + // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE + + //Returns an array of pgassignments id + function pgassignment_ids ($course) { + + global $CFG; + + return get_records_sql ("SELECT a.id, a.course + FROM {$CFG->prefix}pgassignment a + WHERE a.course = '$course'"); + } + + //Returns an array of pgassignment elements id + function pgassignment_element_ids_by_course ($course) { + + global $CFG; + + return get_records_sql ("SELECT s.id , s.pgassignment + FROM {$CFG->prefix}pgassignment_elements s, + {$CFG->prefix}pgassignment a + WHERE a.course = '$course' AND + s.pgassignment = a.id"); + } + + //Returns an array of pgassignment submissions id + function pgassignment_submission_ids_by_course ($course) { + + global $CFG; + + return get_records_sql ("SELECT s.id , s.pgassignment + FROM {$CFG->prefix}pgassignment_submissions s, + {$CFG->prefix}pgassignment a + WHERE a.course = '$course' AND + s.pgassignment = a.id"); + } + + //Returns an array of pgassignment grades id + function pgassignment_grade_ids_by_course ($course) { + + global $CFG; + + return get_records_sql ("SELECT g.id , g.submission, s.pgassignment + FROM {$CFG->prefix}pgassignment_grades g, + {$CFG->prefix}pgassignment_submissions s, + {$CFG->prefix}pgassignment a + WHERE a.course = '$course' AND + s.pgassignment = a.id AND + g.submission = s.id"); + } + +?> diff --git a/backup/mod/resource/backuplib.php b/backup/mod/resource/backuplib.php index ffb070081f6..f7581496304 100644 --- a/backup/mod/resource/backuplib.php +++ b/backup/mod/resource/backuplib.php @@ -24,7 +24,7 @@ function resource_check_backup_mods($course,$user_data=false) { //First the course data $info[0][0] = get_string("modulenameplural","resource"); - if ($ids = choice_ids ($course)) { + if ($ids = resource_ids ($course)) { $info[0][1] = count($ids); } else { $info[0][1] = 0; @@ -41,7 +41,7 @@ // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE //Returns an array of resources id - function resources_ids ($course) { + function resource_ids ($course) { global $CFG; diff --git a/backup/mod/survey/backuplib.php b/backup/mod/survey/backuplib.php new file mode 100644 index 00000000000..f407402578a --- /dev/null +++ b/backup/mod/survey/backuplib.php @@ -0,0 +1,81 @@ +id) |(CL,pk->id,?????) | + // | -------------------- + // | + // ----------------------------------- + // | | + // survey_analysis survey_answers + // (UL,pk->id, fk->survey) (UL,pk->id, fk->survey) + // + // Meaning: pk->primary key field of the table + // fk->foreign key to link with parent + // nt->nested field (recursive data) + // CL->course level info + // UL->user level info + // files->table may have files) + // + //----------------------------------------------------------- + + function survey_backup_mods() { + print "hola"; + } + + ////Return an array of info (name,value) + function survey_check_backup_mods($course,$user_data=false) { + //First the course data + $info[0][0] = get_string("modulenameplural","survey"); + if ($ids = survey_ids ($course)) { + $info[0][1] = count($ids); + } else { + $info[0][1] = 0; + } + + //Now, if requested, the user_data + if ($user_data) { + //Subscriptions + $info[1][0] = get_string("answers","survey"); + if ($ids = survey_answer_ids_by_course ($course)) { + $info[1][1] = count($ids); + } else { + $info[1][1] = 0; + } + } + return $info; + } + + + + + + + // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE + + //Returns an array of surveys id + function survey_ids ($course) { + + global $CFG; + + return get_records_sql ("SELECT a.id, a.course + FROM {$CFG->prefix}survey a + WHERE a.course = '$course'"); + } + + //Returns an array of survey answer id + function survey_answer_ids_by_course ($course) { + + global $CFG; + + return get_records_sql ("SELECT s.id , s.survey + FROM {$CFG->prefix}survey_answers s, + {$CFG->prefix}forum a + WHERE a.course = '$course' AND + s.survey = a.id"); + } + +?>