bottom to the common function area.
See bug 807
return $return;
}
+function assignment_get_participants($assignmentid) {
+//Returns the users with data in one assignment
+//(users with records in assignment_submissions, students and teachers)
+
+ global $CFG;
+
+ //Get students
+ $students = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}assignment_submissions a
+ WHERE a.assignment = '$assignmentid' and
+ u.id = a.userid");
+ //Get teachers
+ $teachers = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}assignment_submissions a
+ WHERE a.assignment = '$assignmentid' and
+ u.id = a.teacher");
+
+ //Add teachers to students
+ if ($teachers) {
+ foreach ($teachers as $teacher) {
+ $students[$teacher->id] = $teacher;
+ }
+ }
+ //Return students array (it contains an array of unique users)
+ return ($students);
+}
+
/// SQL STATEMENTS //////////////////////////////////////////////////////////////////
function assignment_log_info($log) {
echo "</DIV>";
}
-function assignment_get_participants($assignmentid) {
-//Returns the users with data in one assignment
-//(users with records in assignment_submissions, students and teachers)
-
- global $CFG;
-
- //Get students
- $students = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}assignment_submissions a
- WHERE a.assignment = '$assignmentid' and
- u.id = a.userid");
- //Get teachers
- $teachers = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}assignment_submissions a
- WHERE a.assignment = '$assignmentid' and
- u.id = a.teacher");
-
- //Add teachers to students
- if ($teachers) {
- foreach ($teachers as $teacher) {
- $students[$teacher->id] = $teacher;
- }
- }
- //Return students array (it contains an array of unique users)
- return ($students);
-}
-
?>
return $return;
}
+/**
+* Returns user records for all users who have DATA in a given attendance instance
+*
+* This function is present only for the backup routines. It won't return meaningful data
+* for an attendance roll because it only returns records for users who have been counted as
+* tardy or absent in the rolls for a single attendance instance, since these are the only
+* records I store in the database - for brevity's sake of course.
+*
+* @param int $attendanceid the id of the attendance record we're looging for student data from
+* @return (object)recordset associative array of records containing the student records we wanted
+*/
+function attendance_get_participants($attendanceid) {
+//Returns the users with data in one attendance
+//(users with records in attendance_roll, students)
+
+ global $CFG;
+
+ //Get students
+ $students = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}attendance_roll a
+ WHERE a.dayid = '$attendanceid' and
+ u.id = a.userid");
+
+ //Return students array (it contains an array of unique users)
+ return ($students);
+}
+
//////////////////////////////////////////////////////////////////////////////////////
/// Any other attendance functions go here. Each of them must have a name that
return get_records_sql($sql);
}
-/**
-* Returns user records for all users who have DATA in a given attendance instance
-*
-* This function is present only for the backup routines. It won't return meaningful data
-* for an attendance roll because it only returns records for users who have been counted as
-* tardy or absent in the rolls for a single attendance instance, since these are the only
-* records I store in the database - for brevity's sake of course.
-*
-* @param int $attendanceid the id of the attendance record we're looging for student data from
-* @return (object)recordset associative array of records containing the student records we wanted
-*/
-function attendance_get_participants($attendanceid) {
-//Returns the users with data in one attendance
-//(users with records in attendance_roll, students)
-
- global $CFG;
-
- //Get students
- $students = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}attendance_roll a
- WHERE a.dayid = '$attendanceid' and
- u.id = a.userid");
-
- //Return students array (it contains an array of unique users)
- return ($students);
-}
-
/**
* Determines if two dates are on the same day
*
return true;
}
+function chat_get_participants($chatid) {
+//Returns the users with data in one chat
+//(users with records in chat_messages, students)
+
+ global $CFG;
+
+ //Get students
+ $students = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}chat_messages c
+ WHERE c.chatid = '$chatid' and
+ u.id = c.userid");
+ //Return students array (it contains an array of unique users)
+ return ($students);
+}
//////////////////////////////////////////////////////////////////////
/// Functions that require some SQL
}
-function chat_get_participants($chatid) {
-//Returns the users with data in one chat
-//(users with records in chat_messages, students)
-
- global $CFG;
-
- //Get students
- $students = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}chat_messages c
- WHERE c.chatid = '$chatid' and
- u.id = c.userid");
-
- //Return students array (it contains an array of unique users)
- return ($students);
-}
-
?>
return $result;
}
+function choice_get_participants($choiceid) {
+//Returns the users with data in one choice
+//(users with records in choice_answers, students)
+
+ global $CFG;
+
+ //Get students
+ $students = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}choice_answers c
+ WHERE c.choice = '$choiceid' and
+ u.id = c.userid");
+
+ //Return students array (it contains an array of unique users)
+ return ($students);
+}
+
function choice_get_answer($choice, $code) {
// Returns text string which is the answer that matches the code
}
}
-function choice_get_participants($choiceid) {
-//Returns the users with data in one choice
-//(users with records in choice_answers, students)
-
- global $CFG;
-
- //Get students
- $students = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}choice_answers c
- WHERE c.choice = '$choiceid' and
- u.id = c.userid");
-
- //Return students array (it contains an array of unique users)
- return ($students);
-}
-
?>
return $return;
}
+function forum_get_participants($forumid) {
+//Returns the users with data in one forum
+//(users with records in forum_subscriptions, forum_posts and forum_ratings, students)
+
+ global $CFG;
+
+ //Get students from forum_subscriptions
+ $st_subscriptions = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}forum_subscriptions s
+ WHERE s.forum = '$forumid' and
+ u.id = s.userid");
+ //Get students from forum_posts
+ $st_posts = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}forum_discussions d,
+ {$CFG->prefix}forum_posts p
+ WHERE d.forum = '$forumid' and
+ p.discussion = d.id and
+ u.id = p.userid");
+
+ //Get students from forum_ratings
+ $st_ratings = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}forum_discussions d,
+ {$CFG->prefix}forum_posts p,
+ {$CFG->prefix}forum_ratings r
+ WHERE d.forum = '$forumid' and
+ p.discussion = d.id and
+ r.post = p.id and
+ u.id = r.userid");
+
+ //Add st_posts to st_subscriptions
+ if ($st_posts) {
+ foreach ($st_posts as $st_post) {
+ $st_subscriptions[$st_post->id] = $st_post;
+ }
+ }
+ //Add st_ratings to st_subscriptions
+ if ($st_ratings) {
+ foreach ($st_ratings as $st_rating) {
+ $st_subscriptions[$st_rating->id] = $st_rating;
+ }
+ }
+ //Return st_subscriptions array (it contains an array of unique users)
+ return ($st_subscriptions);
+}
/// SQL FUNCTIONS ///////////////////////////////////////////////////////////
}
}
-function forum_get_participants($forumid) {
-//Returns the users with data in one forum
-//(users with records in forum_subscriptions, forum_posts and forum_ratings, students)
-
- global $CFG;
-
- //Get students from forum_subscriptions
- $st_subscriptions = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}forum_subscriptions s
- WHERE s.forum = '$forumid' and
- u.id = s.userid");
- //Get students from forum_posts
- $st_posts = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}forum_discussions d,
- {$CFG->prefix}forum_posts p
- WHERE d.forum = '$forumid' and
- p.discussion = d.id and
- u.id = p.userid");
-
- //Get students from forum_ratings
- $st_ratings = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}forum_discussions d,
- {$CFG->prefix}forum_posts p,
- {$CFG->prefix}forum_ratings r
- WHERE d.forum = '$forumid' and
- p.discussion = d.id and
- r.post = p.id and
- u.id = r.userid");
-
- //Add st_posts to st_subscriptions
- if ($st_posts) {
- foreach ($st_posts as $st_post) {
- $st_subscriptions[$st_post->id] = $st_post;
- }
- }
- //Add st_ratings to st_subscriptions
- if ($st_ratings) {
- foreach ($st_ratings as $st_rating) {
- $st_subscriptions[$st_rating->id] = $st_rating;
- }
- }
- //Return st_subscriptions array (it contains an array of unique users)
- return ($st_subscriptions);
-}
-
?>
return $return;
}
+function glossary_get_participants($glossaryid) {
+//Returns the users with data in one glossary
+//(users with records in glossary_entries, students)
+
+ global $CFG;
+
+ //Get students
+ $students = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}glossary_entries g
+ WHERE g.glossaryid = '$glossaryid' and
+ u.id = g.userid");
+
+ //Return students array (it contains an array of unique users)
+ return ($students);
+}
//////////////////////////////////////////////////////////////////////////////////////
/// Any other glossary functions go here. Each of them must have a name that
$selectsql ORDER BY e.concept ASC $limit");
}
-function glossary_get_participants($glossaryid) {
-//Returns the users with data in one glossary
-//(users with records in glossary_entries, students)
-
- global $CFG;
-
- //Get students
- $students = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}glossary_entries g
- WHERE g.glossaryid = '$glossaryid' and
- u.id = g.userid");
-
- //Return students array (it contains an array of unique users)
- return ($students);
-}
-
-
function glossary_file_area_name($entry) {
// Creates a directory file name, suitable for make_upload_directory()
global $CFG;
return $return;
}
+function journal_get_participants($journalid) {
+//Returns the users with data in one journal
+//(users with records in journal_entries, students and teachers)
+
+ global $CFG;
+
+ //Get students
+ $students = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}journal_entries j
+ WHERE j.journal = '$journalid' and
+ u.id = j.userid");
+ //Get teachers
+ $teachers = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}journal_entries j
+ WHERE j.journal = '$journalid' and
+ u.id = j.teacher");
+
+ //Add teachers to students
+ if ($teachers) {
+ foreach ($teachers as $teacher) {
+ $students[$teacher->id] = $teacher;
+ }
+ }
+ //Return students array (it contains an array of unique users)
+ return ($students);
+}
// SQL FUNCTIONS ///////////////////////////////////////////////////////////////////
echo "</TD></TR></TABLE>";
}
-function journal_get_participants($journalid) {
-//Returns the users with data in one journal
-//(users with records in journal_entries, students and teachers)
-
- global $CFG;
-
- //Get students
- $students = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}journal_entries j
- WHERE j.journal = '$journalid' and
- u.id = j.userid");
- //Get teachers
- $teachers = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}journal_entries j
- WHERE j.journal = '$journalid' and
- u.id = j.teacher");
-
- //Add teachers to students
- if ($teachers) {
- foreach ($teachers as $teacher) {
- $students[$teacher->id] = $teacher;
- }
- }
- //Return students array (it contains an array of unique users)
- return ($students);
-}
-
?>
return $content;
}
+function survey_get_participants($surveyid) {
+//Returns the users with data in one survey
+//(users with records in survey_analysis and survey_answers, students)
+
+ global $CFG;
+
+ //Get students from survey_analysis
+ $st_analysis = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}survey_analysis a
+ WHERE a.survey = '$surveyid' and
+ u.id = a.userid");
+ //Get students from survey_answers
+ $st_answers = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}survey_answers a
+ WHERE a.survey = '$surveyid' and
+ u.id = a.userid");
+
+ //Add st_answers to st_analysis
+ if ($st_answers) {
+ foreach ($st_answers as $st_answer) {
+ $st_analysis[$st_answer->id] = $st_answer;
+ }
+ }
+ //Return st_analysis array (it contains an array of unique users)
+ return ($st_analysis);
+}
// SQL FUNCTIONS ////////////////////////////////////////////////////////
}
}
-function survey_get_participants($surveyid) {
-//Returns the users with data in one survey
-//(users with records in survey_analysis and survey_answers, students)
-
- global $CFG;
-
- //Get students from survey_analysis
- $st_analysis = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}survey_analysis a
- WHERE a.survey = '$surveyid' and
- u.id = a.userid");
- //Get students from survey_answers
- $st_answers = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}survey_answers a
- WHERE a.survey = '$surveyid' and
- u.id = a.userid");
-
- //Add st_answers to st_analysis
- if ($st_answers) {
- foreach ($st_answers as $st_answer) {
- $st_analysis[$st_answer->id] = $st_answer;
- }
- }
- //Return st_analysis array (it contains an array of unique users)
- return ($st_analysis);
-}
-
?>
return NULL;
}
+//////////////////////////////////////////////////////////////////////////////////////
+function workshop_get_participants($workshopid) {
+//Returns the users with data in one workshop
+//(users with records in workshop_submissions, workshop_assessments and workshop_comments, students)
+
+ global $CFG;
+
+ //Get students from workshop_submissions
+ $st_submissions = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}workshop_submissions s
+ WHERE s.workshopid = '$workshopid' and
+ u.id = s.userid");
+ //Get students from workshop_assessments
+ $st_assessments = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}workshop_assessments a
+ WHERE a.workshopid = '$workshopid' and
+ u.id = a.userid");
+
+ //Get students from workshop_comments
+ $st_comments = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}workshop_comments c
+ WHERE c.workshopid = '$workshopid' and
+ u.id = c.userid");
+
+ //Add st_assessments to st_submissions
+ if ($st_assessments) {
+ foreach ($st_assessments as $st_assessment) {
+ $st_submissions[$st_assessment->id] = $st_assessment;
+ }
+ }
+ //Add st_comments to st_submissions
+ if ($st_comments) {
+ foreach ($st_comments as $st_comment) {
+ $st_submissions[$st_comment->id] = $st_comment;
+ }
+ }
+ //Return st_submissions array (it contains an array of unique users)
+ return ($st_submissions);
+}
//////////////////////////////////////////////////////////////////////////////////////
AND u.id = s.userid AND e.id = a.workshopid");
}
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_participants($workshopid) {
-//Returns the users with data in one workshop
-//(users with records in workshop_submissions, workshop_assessments and workshop_comments, students)
-
- global $CFG;
-
- //Get students from workshop_submissions
- $st_submissions = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}workshop_submissions s
- WHERE s.workshopid = '$workshopid' and
- u.id = s.userid");
- //Get students from workshop_assessments
- $st_assessments = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}workshop_assessments a
- WHERE a.workshopid = '$workshopid' and
- u.id = a.userid");
-
- //Get students from workshop_comments
- $st_comments = get_records_sql("SELECT DISTINCT u.*
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}workshop_comments c
- WHERE c.workshopid = '$workshopid' and
- u.id = c.userid");
-
- //Add st_assessments to st_submissions
- if ($st_assessments) {
- foreach ($st_assessments as $st_assessment) {
- $st_submissions[$st_assessment->id] = $st_assessment;
- }
- }
- //Add st_comments to st_submissions
- if ($st_comments) {
- foreach ($st_comments as $st_comment) {
- $st_submissions[$st_comment->id] = $st_comment;
- }
- }
- //Return st_submissions array (it contains an array of unique users)
- return ($st_submissions);
-}
-
-
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_student_assessments($workshop, $user) {
// Return all assessments on the student submissions by a user, order by youngest first, oldest last