Нет описания

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. require_once 'processes/dbh.inc.php';
  3. // include("conection.php");
  4. include("funciones.php");
  5. // FUNCTION THAT CALCULATES THE STANDARD DEVIATION OF ARRAY ELEMENTS
  6. function stddev($arr) {
  7. $num_of_elements = count(array_filter($arr, function($x) { return is_numeric($x); }));
  8. //return $num_of_elements;
  9. $variance = 0.0;
  10. // calculating mean using array_sum() method
  11. $average = average($arr);
  12. foreach($arr as $i) {
  13. // sum of squares of differences between
  14. // all numbers and means.
  15. $variance += pow(($i - $average), 2);
  16. }
  17. return (float)sqrt($variance / $num_of_elements);
  18. }
  19. // FUNCTION THAT CALCULATES THE AVERAGE OF ARRAY ELEMENTS
  20. function average($valores) {
  21. //return array_sum(array_filter($valores) / count(array_filter($valores));
  22. //return array_sum(array_filter($valores)) / count(array_filter($valores,function($x) { return is_numeric($x); }));
  23. return array_sum(array_filter($valores, function($x) { return is_numeric($x); })) / count(array_filter($valores, function($x) { return is_numeric($x); }));
  24. }
  25. // FUNCTION THAT CALCULATES THE PERCENT CHANGE BETWEEN TWO VALUES
  26. function porcientoCambio($primero, $segundo) {
  27. if(is_numeric($primero) and is_numeric($segundo)) {
  28. return 100.0 * ($segundo - $primero) / $primero;
  29. }
  30. //else return NaN;
  31. }
  32. // FUNCTION THAT ROUNDS DECIMAL NUMBER TO TWO DECIMAL PLACES
  33. function siDecimal2($numero) {
  34. if(is_numeric($numero)) {
  35. $numero = sprintf("%.2f", $numero);
  36. $numero = rtrim($numero, "0");
  37. $numero = rtrim($numero, ".");
  38. return $numero;
  39. }
  40. }
  41. //SELECT a.id_question, q.premise, a.id_subquestionnair , q.id_category,q.id_subcategory FROM `answer` a, question q WHERE a.`id_student` = 1860 and a.id_question=q.id ORDER BY `a`.`id_question` ASC
  42. $id_experiencia = mysqli_real_escape_string($connection, trim($_POST['id_exp']));
  43. $id_student = mysqli_real_escape_string($connection, trim($_POST['id_student']));
  44. $res_type = mysqli_real_escape_string($connection, trim($_POST['res_type']));
  45. // RUN CORRESPONDING SCRIPT DEPENDING ON SUMMARY VARIABLE (questions, subcategory, category)
  46. if($res_type == 0) {
  47. include "siPreguntas.php";
  48. }
  49. elseif($res_type == 1) {
  50. include "siSubCategoria.php";
  51. }
  52. elseif($res_type == 2) {
  53. include "siCategoria.php";
  54. }
  55. // print "<script>console.log('".print_r($preguntas)."');</script>";
  56. foreach($preguntas as $id => $pregunta) {
  57. print "<tr>";
  58. foreach($pregunta as $item) {
  59. print '<td style="vertical-align: middle; text-align: center;">'.$item.'</td>';
  60. }
  61. print "</tr>";
  62. }
  63. ?>