From 224520e33ae8fbd758f8c0862172ad240df3a1a4 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 26 Mar 2013 18:12:41 +0000 Subject: [PATCH] Add safetyquestion answers to student report fields --- admin/reports_students.inc.php | 93 ++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/admin/reports_students.inc.php b/admin/reports_students.inc.php index 3684e66..1f4417b 100644 --- a/admin/reports_students.inc.php +++ b/admin/reports_students.inc.php @@ -53,6 +53,28 @@ function report_student_get_cheque_date_format($report, $field, $text){ return implode(' ', preg_split('//', $config['cheque_date_format'], -1)); } +function report_student_safety_question($report, $field, $text) { + + + /* Field is 'safetyquestion_x', registration_id is passed in $text */ + $q_ord = intval(substr($field, 15)); + $regid = $text; + + //safetyquestions start counting 1-10, but when we LIMIT, we need to index on 0-9 + $q_ord--; + + $q=mysql_query("SELECT safetyquestions.question, + safety.answer + FROM safetyquestions + JOIN safety ON safetyquestions.id=safety.safetyquestions_id + WHERE safety.registrations_id='".$regid."' + ORDER BY safetyquestions.ord LIMIT $q_ord,1"); + + $r=mysql_fetch_object($q); + return $r->answer; +} + + function reports_students_numstudents($report, $field, $text) { $year = $report['year']; @@ -459,6 +481,77 @@ $report_students_fields = array( 'width' => 3, 'table' => "projects.req_special"), + 'safetyquestion_1' => array( + 'start_option_group' => 'Project Safety Questions', + 'name' => 'Project Safety -- Safety Question 1', + 'header' => 'Q1', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_2' => array( + 'name' => 'Project Safety -- Safety Question 2', + 'header' => 'Q2', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_3' => array( + 'name' => 'Project Safety -- Safety Question 3', + 'header' => 'Q3', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_4' => array( + 'name' => 'Project Safety -- Safety Question 4', + 'header' => 'Q4', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_5' => array( + 'name' => 'Project Safety -- Safety Question 5', + 'header' => 'Q5', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_6' => array( + 'name' => 'Project Safety -- Safety Question 6', + 'header' => 'Q6', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_7' => array( + 'name' => 'Project Safety -- Safety Question 7', + 'header' => 'Q7', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_8' => array( + 'name' => 'Project Safety -- Safety Question 8', + 'header' => 'Q8', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_9' => array( + 'name' => 'Project Safety -- Safety Question 9', + 'header' => 'Q9', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + + 'safetyquestion_10' => array( + 'name' => 'Project Safety -- Safety Question 10', + 'header' => 'Q10', + 'width' => 15 /*mm*/, + 'table' => 'registrations.id', + 'exec_function' => 'report_student_safety_question'), + 'school' => array( 'start_option_group' => 'School Information', 'name' => 'School -- Name',