--------------- PHP CODE BELOW --------------------------
- Code: Select all
<div style="width:940px;margin:0 auto;">
<div style="float:right"><select name="TakeAssessmentTest"><option value="">Select Assessment Test</option>
<?
foreach($admin->listActiveForms() as $str){
echo '<option value="'.$str['formId'].'">'.$str['formTitle'].' Ver. '.$str['formVersion'].'</option>';
}
?>
</select> <input type="button" value="New" id="<?=$_GET['uid'];?>" class="clientNewAssess" /></div>[color=#FF0000][b] THIS IS LINE 21[/b][/color]
<h1 style="width:470px"><?=$client['firstName']. ' '.$client['middleInit'].' '.$client['lastName'];?></h1>
</div>
<?
if($form){
$i = 1;
$total_risc = 0;
$data = json_decode($form['assess_answers'], true);
$compared = (date("Y", strtotime($form['formCreated'])) == date("Y")) ? true : false;
$html = '<table class="form_table" cellspacing="0">';
$html .= '<thead><tr><th colspan="3">'.
$form['formTitle'].' Ver. '.$form['formVersion'];
if($compared){
$html .= '<input type="button" id="'.$form['c_a_id'].'" class="editAssessmentC" style="float:right" value="Edit" />';
}
$html .= '</th></tr></thead>';
foreach($data as $key => $str){
$sql = "SELECT * FROM form_categories WHERE cat_id ='".$key."'";
$stmt = $admin->db->prepare($sql);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$o = $stmt->fetch();
$fac = 0;
$total[$o['cat_title']][num] = 0;
if($o['question_rating'] != 'None'){
$sql2 = "SELECT * FROM form_questions WHERE catId='".$key."' AND question_rating = 'Factor'";
$stmt2 = $admin->db->prepare($sql2);
$stmt2->execute();
$stmt2->setFetchMode(PDO::FETCH_ASSOC);
while($o2 = $stmt2->fetch()){
$fac = $fac + $o2['question_high_rating'];
$total[$o['cat_title']][num] = $total[$o['cat_title']][num] + 1;
}
$total[$o['cat_title']]['num_questions'] = $stmt->rowCount();
$sql3 = "SELECT question_high_rating FROM form_questions WHERE catId='".$key."' AND question_rating = 'Social'";
$stmt3 = $admin->db->prepare($sql3);
$stmt3->execute();
$stmt3->setFetchMode(PDO::FETCH_ASSOC);
$o3 = $stmt3->fetch();
$soc = $o3['question_high_rating'];
}
$total[$o['cat_title']]['factor_score'] = array_sum($str[ratings][factor]);
$total[$o['cat_title']]['possible_score'] = $fac;
$total[$o['cat_title']]['social'] = $str[ratings][social];
$factor = round((((array_sum($str[ratings][factor])/$fac)) * 67), 2);
$social = round((($str[ratings][social]/$soc) * 33), 2);
$html .= '<tr><th style="width:700px" colspan="2">'.$o['cat_title'].'</th><th style="width:100px">'.($factor + $social).'</th></tr>';
foreach($str[answers] as $key1=>$str1){
$sql4 = "SELECT * FROM form_questions WHERE question_id = :id";
$stmt4 = $admin->db->prepare($sql4);
$stmt4->bindParam(':id', $str1[q_id]);
$stmt4->execute();
$stmt4->setFetchMode(PDO::FETCH_ASSOC);
$o4 = $stmt4->fetch();
$ans = explode("[", $str1['answer']);
$html .= '<tr>'.
'<td>'.$i.'.</td>'.
'<td>'.$o4['question_name'].'<br /><span style="margin:0 5px;">'.$ans[0].'</td>';
if($o4['question_rating'] == 'None'){
$style = ' style="background:#CCC"';
} else {
$style = ' style="background:#FFF"';
}
$html .= '<td'.$style.'>';
if($o4['question_rating']!='None'){
$html .= $str1['rating'];
}
$html .= '</td></tr>';
$i++;
}
$total_risc++;
}
$html .= '</table>';
} else {
$no = '<strong>No assessments taken.</strong>';
}
if($html){
echo '<script type="text/javascript">'.
'$(function(){'.
'$("#viewAssessmentForm").change(function(){'.
'window.location = \'assessment.php?page=view&uid='.$_GET['uid'].'&aid=\' + $(this).val();'.
'});'.
'});'.
'</script>';
echo '<table class="results_table form_table" cellspacing="0">'.
'<thead><tr><th colspan="6"><div style="float:right"> Go to assessment: <select id="viewAssessmentForm">';
foreach($taken_a as $tkey=>$tstr){
$selected = $_GET['aid']==$tstr['c_a_id']? ' selected="selected"' : '';
echo '<option value="'.$tstr['c_a_id'].'"'.$selected.'>'.$tstr['formTitle'].' - '.date("M d, Y", strtotime($tstr['c_a_date'])).'</option>';
}
echo '</select></div>Assessment Date: '.date("M d, Y", strtotime($form['c_a_date'])).'</th></tr>'.
'<tr><th>Section</th><th># of ?\'s</th><th>Factor Result By</th><th>Initial Rating <u>(20)</u></th>'.
'<th>Rating</th><th>Social Worker Risk Rating</th></tr></thead><tbody>';
foreach($total as $key=>$str){
$factor_rating = round(10 / $str[num], 2) * $str['factor_score'];
echo '<tr><td>'.$key.'</td><td>'.$str[num].'</td><td>'. round(10 / $str[num], 2) .'</td><td></td><td>' . $factor_rating . '</td><td>'.$str['social'].'</td></tr>';
$f_r_total[] = $factor_rating;
$s_r_total[] = $str['social'];
}
echo '</tbody><tfoot><td colspan="3" style="border-right:1px solid #fab331">Highest Risk Total on Rating Scale: '.$total_risc * 20 .
'</td><td style="border-right:1px solid #fab331"></td>'.
'<td style="border-right:1px solid #fab331">'.array_sum($f_r_total).'</td>'.
'<td>'.array_sum($s_r_total).'</td></tfoot></table><p>';
echo $html;
} else {
echo $no;
};
?>
</p>
------------------ PHP CODE ABOVE -------------------
PLEASE HELP!
Thanks,
Kelvin Jones