/inicrond/src/modules/tests-results/normal_dist_time_img.php

https://github.com/sebhtml/inicrond · PHP · 147 lines · 96 code · 26 blank · 25 comment · 13 complexity · 387d190019cbc633a7ee470ba6eebace MD5 · raw file

  1. <?php
  2. /*
  3. $Id$
  4. Inicrond : Network of Interactive Courses Registred On a Net Domain
  5. Copyright (C) 2004, 2005 Sébastien Boisvert
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. $_GET['image'] = "png.png";
  19. define('__INICROND_INCLUDED__', TRUE);
  20. define('__INICROND_INCLUDE_PATH__', '../../');
  21. include __INICROND_INCLUDE_PATH__.'includes/kernel/pre_modulation.php';
  22. include 'includes/languages/'.$_SESSION['language'].'/lang.php';
  23. //conversions
  24. include __INICROND_INCLUDE_PATH__."modules/tests-php-mysql/includes/functions/conversion.function.php";
  25. include __INICROND_INCLUDE_PATH__.'modules/members/includes/functions/access.inc.php';
  26. include __INICROND_INCLUDE_PATH__.'modules/groups/includes/functions/access.inc.php';
  27. $_GET['image'] = $_LANG['test_lengths'];
  28. $query = "
  29. SELECT
  30. time_GMT_end-time_GMT_start AS value
  31. FROM
  32. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['results'].",
  33. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['online_time']."
  34. WHERE
  35. time_GMT_end>time_GMT_start
  36. and
  37. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['results'].".session_id = ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['online_time'].".session_id
  38. ";
  39. //validation
  40. $ok = FALSE;
  41. if(isset($_GET['usr_id']) && $_GET['usr_id'] != "" && (int) $_GET['usr_id']
  42. && is_in_charge_of_user($_SESSION['usr_id'], $_GET['usr_id']))
  43. {
  44. $query2 = "
  45. SELECT
  46. usr_name
  47. FROM
  48. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['usrs']."
  49. WHERE
  50. usr_id=".$_GET['usr_id']."";
  51. $rs = $inicrond_db->Execute($query2);
  52. $fetch_result = $rs->FetchRow();
  53. $_GET["image"] .= "_".$fetch_result['usr_name'];//the file name...
  54. $ok = TRUE;
  55. $query .= " AND usr_id=".$_GET['usr_id']."";
  56. }
  57. if(isset($_GET['test_id']) && $_GET['test_id'] != "" && (int) $_GET['test_id']
  58. && (isset($_GET['usr_id']) || is_teacher_of_cours($_SESSION['usr_id'],test_2_cours($_GET['test_id']))))
  59. {
  60. $query2 = "
  61. SELECT
  62. test_name
  63. FROM
  64. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['tests']."
  65. WHERE
  66. test_id=".$_GET['test_id']."
  67. ";
  68. $rs = $inicrond_db->Execute($query2);
  69. $fetch_result = $rs->FetchRow();
  70. $_GET["image"] .= "_".str_replace(" ", "_", $fetch_result['test_name']);//the file name...
  71. $ok = TRUE;
  72. $query .= " AND test_id=".$_GET['test_id']."";
  73. }
  74. elseif(is_numeric($_GET['group_id']) && is_in_charge_of_group($_SESSION['usr_id'], $_GET['group_id']))
  75. {
  76. $ok = 1 ;
  77. //////////////////
  78. //get the cours id for this group.
  79. //define the query in one shot...
  80. $query = "
  81. SELECT
  82. time_GMT_end-time_GMT_start AS value
  83. FROM
  84. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['results'].",
  85. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['tests'].",
  86. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['groups_usrs'].",
  87. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['groups'].",
  88. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['online_time']."
  89. WHERE
  90. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['results'].".session_id = ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['online_time'].".session_id
  91. and
  92. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['tests'].".cours_id=".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['groups'].".cours_id
  93. AND
  94. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['groups_usrs'].".usr_id=".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['online_time'].".usr_id
  95. AND
  96. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['groups_usrs'].".group_id=".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['groups'].".group_id
  97. AND
  98. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['groups_usrs'].".group_id = ".$_GET['group_id']."
  99. AND
  100. time_GMT_end>time_GMT_start
  101. AND
  102. ".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['tests'].".test_id=".$_OPTIONS['table_prefix'].$_OPTIONS['tables']['results'].".test_id
  103. ";
  104. }
  105. $_GET["image"] .= ".png";
  106. if(!$ok)//access denied
  107. {
  108. exit();
  109. }
  110. include __INICROND_INCLUDE_PATH__."includes/class/Histogram_graphic.php";
  111. $Histogram_graphic = new Histogram_graphic;
  112. $Histogram_graphic->inicrond_db = &$inicrond_db;
  113. $Histogram_graphic->title = &$_LANG['GD_distribution_of_time'];
  114. $Histogram_graphic->query = &$query;
  115. $Histogram_graphic->preprocessor = "format_time_length";
  116. $Histogram_graphic->render();
  117. ?>