Add safetyquestion answers to student report fields

This commit is contained in:
james 2013-03-26 18:12:41 +00:00
parent 1c33c03d81
commit 224520e33a

View File

@ -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',