Completed the module_check_backup_mods function (used in check.html)

This commit is contained in:
stronk7 2003-05-02 00:54:51 +00:00
parent c53987bbb8
commit d67257815d
3 changed files with 218 additions and 5 deletions

View File

@ -4,7 +4,7 @@
//This is the "graphical" structure of the assignment mod:
//
// assignment
// assignment
// (CL,pk->id)
// |
// |
@ -21,11 +21,58 @@
//
//-----------------------------------------------------------
function assignment_backup_mods() {
function assignment_backup_mods($course,$user_data=false) {
print "hola";
}
function assignment_check_backup_mods() {
print "hola";
//Return an array of info (name,value)
function assignment_check_backup_mods($course,$user_data=false) {
//First the course data
$info[0][0] = get_string("modulenameplural","assignment");
if ($ids = assignment_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("submissions","assignment");
if ($ids = assignment_submission_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 assignments id
function assignment_ids ($course) {
global $CFG;
return get_records_sql ("SELECT a.id, a.course
FROM {$CFG->prefix}assignment a
WHERE a.course = '$course'");
}
//Returns an array of assignment_submissions id
function assignment_submission_ids_by_course ($course) {
global $CFG;
return get_records_sql ("SELECT s.id , s.assignment
FROM {$CFG->prefix}assignment_submissions s,
{$CFG->prefix}assignment a
WHERE a.course = '$course' AND
s.assignment = a.id");
}
?>

View File

@ -21,7 +21,58 @@
//
//-----------------------------------------------------------
function choice_backup_mods() {
function choice_backup_mods($course,$user_data=false) {
print "hola";
}
////Return an array of info (name,value)
function choice_check_backup_mods($course,$user_data=false) {
//First the course data
$info[0][0] = get_string("modulenameplural","choice");
if ($ids = choice_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("responses","choice");
if ($ids = choice_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 choices id
function choice_ids ($course) {
global $CFG;
return get_records_sql ("SELECT a.id, a.course
FROM {$CFG->prefix}choice a
WHERE a.course = '$course'");
}
//Returns an array of choice_answers id
function choice_answer_ids_by_course ($course) {
global $CFG;
return get_records_sql ("SELECT s.id , s.choice
FROM {$CFG->prefix}choice_answers s,
{$CFG->prefix}choice a
WHERE a.course = '$course' AND
s.choice = a.id");
}
?>

View File

@ -34,4 +34,119 @@
function forum_backup_mods() {
print "hola";
}
////Return an array of info (name,value)
function forum_check_backup_mods($course,$user_data=false) {
//First the course data
$info[0][0] = get_string("modulenameplural","forum");
if ($ids = forum_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("subscriptions","forum");
if ($ids = forum_subscription_ids_by_course ($course)) {
$info[1][1] = count($ids);
} else {
$info[1][1] = 0;
}
//Discussions
$info[2][0] = get_string("discussions","forum");
if ($ids = forum_discussion_ids_by_course ($course)) {
$info[2][1] = count($ids);
} else {
$info[2][1] = 0;
}
//Posts
$info[3][0] = get_string("posts","forum");
if ($ids = forum_post_ids_by_course ($course)) {
$info[3][1] = count($ids);
} else {
$info[3][1] = 0;
}
//Ratings
$info[4][0] = get_string("ratings","forum");
if ($ids = forum_rating_ids_by_course ($course)) {
$info[4][1] = count($ids);
} else {
$info[4][1] = 0;
}
}
return $info;
}
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
//Returns an array of forums id
function forum_ids ($course) {
global $CFG;
return get_records_sql ("SELECT a.id, a.course
FROM {$CFG->prefix}forum a
WHERE a.course = '$course'");
}
//Returns an array of forum subscriptions id
function forum_subscription_ids_by_course ($course) {
global $CFG;
return get_records_sql ("SELECT s.id , s.forum
FROM {$CFG->prefix}forum_subscriptions s,
{$CFG->prefix}forum a
WHERE a.course = '$course' AND
s.forum = a.id");
}
//Returns an array of forum discussions id
function forum_discussion_ids_by_course ($course) {
global $CFG;
return get_records_sql ("SELECT s.id , s.forum
FROM {$CFG->prefix}forum_discussions s,
{$CFG->prefix}forum a
WHERE a.course = '$course' AND
s.forum = a.id");
}
//Returns an array of forum posts id
function forum_post_ids_by_course ($course) {
global $CFG;
return get_records_sql ("SELECT p.id , p.discussion, s.forum
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions s,
{$CFG->prefix}forum a
WHERE a.course = '$course' AND
s.forum = a.id AND
p.discussion = s.id");
}
//Returns an array of ratings posts id
function forum_rating_ids_by_course ($course) {
global $CFG;
return get_records_sql ("SELECT r.id, r.post, p.discussion, s.forum
FROM {$CFG->prefix}forum_ratings r,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions s,
{$CFG->prefix}forum a
WHERE a.course = '$course' AND
s.forum = a.id AND
p.discussion = s.id AND
r.post = p.id");
}
?>