public function view_stats app_type grade_types array Very poor Poor A

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
public function view_stats($app_type)
{
$grade_types = array( 1 => 'Very poor', 2 => 'Poor', 3 => 'Avarage', 4 => 'Good', 5 => 'Excellent');
$sql = mysql_query("SELECT * FROM pools");
while($row = mysql_fetch_assoc($sql))
{
$polls_array[$row['app_type']][] = $row;
}
$sql = mysql_query("SELECT `email`,`first_name`,`last_name` FROM tasks_info");
while($row = mysql_fetch_assoc($sql))
{
$names[$row['email']][] = $row;
}
//print_r($names);
//print_r($polls_array);
//echo '<hr>';
$sql = mysql_query("SELECT * FROM pools_answer");
while($row = mysql_fetch_assoc($sql))
{
$answers_array[$row['id_poll']][] = $row;
}
$sql = mysql_query("SELECT pools. `app_type` , pools_answer . * FROM pools, pools_answer WHERE pools.id = pools_answer.id_poll");
while($row = mysql_fetch_assoc($sql))
{
$answers_array_2[$row['app_type']][] = $row;
}
//print_r($answers_array);
//print("----");
//print_r($answers_array_2);
foreach($answers_array as $i => $arr)
{
//echo $i.'--->'.count($arr).'<br>';
@$percent[$i]['all'] = count($arr);
//echo '<br>-----<br>';
foreach($answers_array[$i] as $z => $answ)
{
//print_r($answ);
//echo 'id:'.$i.'grade:'.$answ['grade'].'<br>';
@$percent[$i][$answ['grade']]++;
}
//echo '<br>-----<br>';
}
print_r($percent);
echo count($answers_array_2[1]);
foreach($app_type as $i => $app)
{
@$html .= $app.' Polls:'.count($polls_array[$i]).' Answers:'.count($answers_array_2[$i]).' <br> ';
if(count(@$polls_array[$i]) > 0) foreach($polls_array[$i] as $array)
{
$html .= '<div style="padding-left:10px">'.$array['name'].'-'.$array['id'].'</div>';
if(count(@$answers_array[$array['id']]) > 0) foreach(@$answers_array[$array['id']] as $answers)
{
$html .= '<div style="padding-left:20px">'.$names[$answers['email']][0]['first_name'].'
'.$names[$answers['email']][0]['last_name'].': Answer:';
if($array['type'] == 0) $html .= $grade_types[$answers['grade']]; else $html .= $array['q'.$answers['grade']];
$html .= ' Comment:'.$answers['comment'].'-'.$answers['id'].'</div>';
}
}
}
return $html;
}