PageRenderTime 66ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/sources/hooks/systems/addon_registry/quizzes.php

https://github.com/chrisgraham/ocPortal
PHP | 338 lines | 218 code | 30 blank | 90 comment | 0 complexity | 6757c6a033d633022498059e36606b7e MD5 | raw file
  1. <?php /*
  2. ocPortal
  3. Copyright (c) ocProducts, 2004-2012
  4. See text/EN/licence.txt for full licencing information.
  5. NOTE TO PROGRAMMERS:
  6. Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
  7. **** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****
  8. */
  9. /**
  10. * @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
  11. * @copyright ocProducts Ltd
  12. * @package quizzes
  13. */
  14. class Hook_addon_registry_quizzes
  15. {
  16. /**
  17. * Get a list of file permissions to set
  18. *
  19. * @return array File permissions to set
  20. */
  21. function get_chmod_array()
  22. {
  23. return array();
  24. }
  25. /**
  26. * Get the version of ocPortal this addon is for
  27. *
  28. * @return float Version number
  29. */
  30. function get_version()
  31. {
  32. return ocp_version_number();
  33. }
  34. /**
  35. * Get the description of the addon
  36. *
  37. * @return string Description of the addon
  38. */
  39. function get_description()
  40. {
  41. return 'Construct competitions, surveys, and tests, for members to perform. Highly configurable, and comes with administrative tools to handle the results.';
  42. }
  43. /**
  44. * Get a mapping of dependency types
  45. *
  46. * @return array File permissions to set
  47. */
  48. function get_dependencies()
  49. {
  50. return array(
  51. 'requires'=>array(),
  52. 'recommends'=>array(),
  53. 'conflicts_with'=>array(),
  54. );
  55. }
  56. /**
  57. * Get a list of files that belong to this addon
  58. *
  59. * @return array List of files
  60. */
  61. function get_file_list()
  62. {
  63. return array(
  64. 'sources/hooks/systems/notifications/quiz_results.php',
  65. 'sources/hooks/systems/config_default/points_ADD_QUIZ.php',
  66. 'sources/hooks/systems/config_default/quiz_show_stats_count_total_open.php',
  67. 'sources/hooks/systems/meta/quiz.php',
  68. 'themes/default/images/bigicons/findwinners.png',
  69. 'themes/default/images/pagepics/findwinners.png',
  70. 'sources/hooks/blocks/side_stats/stats_quiz.php',
  71. 'QUIZ_ANSWERS_MAIL.tpl',
  72. 'QUIZ_ARCHIVE_SCREEN.tpl',
  73. 'QUIZ_TEST_ANSWERS_MAIL.tpl',
  74. 'sources/hooks/systems/content_meta_aware/quiz.php',
  75. 'sources/hooks/systems/addon_registry/quizzes.php',
  76. 'sources/hooks/modules/admin_import_types/quizzes.php',
  77. 'QUIZ_LINK.tpl',
  78. 'QUIZ_SCREEN.tpl',
  79. 'QUIZ_DONE_SCREEN.tpl',
  80. 'SURVEY_RESULTS_SCREEN.tpl',
  81. 'adminzone/pages/modules/admin_quiz.php',
  82. 'themes/default/images/bigicons/quiz.png',
  83. 'themes/default/images/pagepics/quiz.png',
  84. 'cms/pages/modules/cms_quiz.php',
  85. 'lang/EN/quiz.ini',
  86. 'site/pages/modules/quiz.php',
  87. 'sources/hooks/modules/admin_newsletter/quiz.php',
  88. 'sources/hooks/modules/admin_unvalidated/quiz.php',
  89. 'sources/hooks/modules/search/quiz.php',
  90. 'sources/hooks/systems/awards/quiz.php',
  91. 'sources/hooks/systems/do_next_menus/quiz.php',
  92. 'sources/quiz.php',
  93. 'themes/default/images/bigicons/survey_results.png',
  94. 'themes/default/images/pagepics/survey_results.png',
  95. 'sources/hooks/systems/preview/quiz.php',
  96. 'quizzes.css',
  97. );
  98. }
  99. /**
  100. * Get mapping between template names and the method of this class that can render a preview of them
  101. *
  102. * @return array The mapping
  103. */
  104. function tpl_previews()
  105. {
  106. return array(
  107. 'SURVEY_RESULTS_SCREEN.tpl'=>'survey_results_screen',
  108. 'QUIZ_LINK.tpl'=>'quiz_archive_screen',
  109. 'QUIZ_ARCHIVE_SCREEN.tpl'=>'quiz_archive_screen',
  110. 'QUIZ_SCREEN.tpl'=>'quiz_screen',
  111. 'QUIZ_TEST_ANSWERS_MAIL.tpl'=>'quiz_test_answers_mail',
  112. 'QUIZ_ANSWERS_MAIL.tpl'=>'quiz_answers_mail',
  113. 'QUIZ_DONE_SCREEN.tpl'=>'quiz_done_screen',
  114. );
  115. }
  116. /**
  117. * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  118. * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  119. * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  120. *
  121. * @return array Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  122. */
  123. function tpl_preview__survey_results_screen()
  124. {
  125. $fields = new ocp_tempcode();
  126. foreach (placeholder_array() as $k=>$v)
  127. {
  128. $fields->attach(do_lorem_template('VIEW_SPACE_FIELD_RAW',array('ABBR'=>'','NAME'=>lorem_phrase(),'VALUE'=>lorem_phrase())));
  129. }
  130. $summary = do_lorem_template('VIEW_SPACE',array('WIDTH'=>placeholder_number(),'FIELDS'=>$fields));
  131. $browse = do_lorem_template('NEXT_BROWSER_BROWSE_NEXT',array('PREVIOUS_LINK'=>placeholder_link(),'NEXT_LINK'=>placeholder_link(),'PAGE_NUM'=>placeholder_number(),'NUM_PAGES'=>placeholder_number()));
  132. $cells = new ocp_tempcode();
  133. foreach (placeholder_array() as $k=>$v)
  134. {
  135. $cells->attach(do_lorem_template('RESULTS_TABLE_FIELD_TITLE',array('VALUE'=>$v)));
  136. }
  137. $fields_title = $cells;
  138. $results = new ocp_tempcode();
  139. foreach (placeholder_array() as $k=>$v)
  140. {
  141. $cells = new ocp_tempcode();
  142. foreach (placeholder_array() as $k=>$v)
  143. {
  144. $cells->attach(do_lorem_template('RESULTS_TABLE_FIELD',array('VALUE'=>lorem_word()),NULL,false,'RESULTS_TABLE_FIELD'));
  145. }
  146. $results->attach(do_lorem_template('RESULTS_TABLE_ENTRY',array('VALUES'=>$cells),NULL,false,'RESULTS_TABLE_ENTRY'));
  147. }
  148. $selectors = new ocp_tempcode();
  149. foreach (placeholder_array() as $k=>$v)
  150. {
  151. $selectors->attach(do_lorem_template('RESULTS_BROWSER_SORTER',array('SELECTED'=>'','NAME'=>lorem_word(),'VALUE'=>lorem_word())));
  152. }
  153. $sort = do_lorem_template('RESULTS_BROWSER_SORT',array('HIDDEN'=>'','SORT'=>lorem_word(),'RAND'=>placeholder_random(),'URL'=>placeholder_url(),'SELECTORS'=>$selectors));
  154. $results_browser = placeholder_result_browser();
  155. $results = do_lorem_template('RESULTS_TABLE',array('TEXT_ID'=>lorem_phrase(),'FIELDS_TITLE'=>$fields_title,'FIELDS'=>$results,'MESSAGE'=>new ocp_tempcode(),'SORT'=>$sort,'BROWSER'=>$results_browser,'WIDTHS'=>array(placeholder_number())),NULL,false,'RESULTS_TABLE');
  156. return array(
  157. lorem_globalise(
  158. do_lorem_template('SURVEY_RESULTS_SCREEN',array(
  159. 'TITLE'=>lorem_title(),
  160. 'SUMMARY'=>$summary,
  161. 'RESULTS'=>$results,
  162. )
  163. ),NULL,'',true),
  164. );
  165. }
  166. /**
  167. * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  168. * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  169. * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  170. *
  171. * @return array Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  172. */
  173. function tpl_preview__quiz_archive_screen()
  174. {
  175. $content_tests=new ocp_tempcode();
  176. $content_competitions=new ocp_tempcode();
  177. $content_surveys=new ocp_tempcode();
  178. foreach (placeholder_array() as $k=>$v)
  179. {
  180. $link = do_lorem_template('QUIZ_LINK',array('TYPE'=>lorem_word(),'DATE'=>placeholder_time(),'URL'=>placeholder_url(),'NAME'=>lorem_phrase(),'START_TEXT'=>lorem_phrase(),'TIMEOUT'=>placeholder_number(),'REDO_TIME'=>placeholder_number(),'_TYPE'=>lorem_word(),'POINTS'=>placeholder_id()));
  181. }
  182. $content_surveys->attach($link);
  183. $content_tests->attach($link);
  184. $content_competitions->attach($link);
  185. $browse = do_lorem_template('NEXT_BROWSER_BROWSE_NEXT',array('NEXT_LINK'=>placeholder_url(),'PREVIOUS_LINK'=>placeholder_url(),'PAGE_NUM'=>placeholder_number(),'NUM_PAGES'=>placeholder_number()));
  186. return array(
  187. lorem_globalise(
  188. do_lorem_template('QUIZ_ARCHIVE_SCREEN',array(
  189. 'TITLE'=>lorem_title(),
  190. 'CONTENT_SURVEYS'=>$content_surveys,
  191. 'CONTENT_COMPETITIONS'=>$content_competitions,
  192. 'CONTENT_TESTS'=>$content_tests,
  193. 'BROWSE'=>$browse,
  194. )
  195. ),NULL,'',true),
  196. );
  197. }
  198. /**
  199. * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  200. * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  201. * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  202. *
  203. * @return array Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  204. */
  205. function tpl_preview__quiz_screen()
  206. {
  207. //This is for getting the do_ajax_request() javascript function.
  208. require_javascript('javascript_ajax');
  209. $warning_details = do_lorem_template('WARNING_TABLE',array('WARNING'=>lorem_phrase()));
  210. return array(
  211. lorem_globalise(
  212. do_lorem_template('QUIZ_SCREEN',array(
  213. 'TAGS'=>lorem_word_html(),
  214. 'ID'=>placeholder_id(),
  215. 'WARNING_DETAILS'=>$warning_details,
  216. 'URL'=>placeholder_url(),
  217. 'TITLE'=>lorem_title(),
  218. 'START_TEXT'=>lorem_sentence_html(),
  219. 'FIELDS'=>placeholder_fields(),
  220. 'TIMEOUT'=>'5',
  221. 'EDIT_URL'=>placeholder_url(),
  222. )
  223. ),NULL,'',true),
  224. );
  225. }
  226. /**
  227. * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  228. * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  229. * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  230. *
  231. * @return array Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  232. */
  233. function tpl_preview__quiz_test_answers_mail()
  234. {
  235. $_unknowns = new ocp_tempcode();
  236. foreach (placeholder_array() as $k=>$v)
  237. {
  238. $_unknowns->attach(lorem_phrase());
  239. }
  240. $_corrections = new ocp_tempcode();
  241. foreach (placeholder_array() as $k=>$v)
  242. {
  243. $_corrections->attach(lorem_phrase());
  244. }
  245. return array(
  246. lorem_globalise(
  247. do_lorem_template('QUIZ_TEST_ANSWERS_MAIL',array(
  248. 'UNKNOWNS'=>$_unknowns,
  249. 'CORRECTIONS'=>$_corrections,
  250. 'RESULT'=>lorem_phrase(),
  251. 'USERNAME'=>lorem_phrase(),
  252. )
  253. ),NULL,'',true),
  254. );
  255. }
  256. /**
  257. * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  258. * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  259. * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  260. *
  261. * @return array Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  262. */
  263. function tpl_preview__quiz_answers_mail()
  264. {
  265. $_answers=new ocp_tempcode();
  266. foreach (placeholder_array() as $k=>$v)
  267. {
  268. $_answers->attach(lorem_phrase());
  269. }
  270. return array(
  271. lorem_globalise(
  272. do_lorem_template('QUIZ_ANSWERS_MAIL',array(
  273. 'ANSWERS'=>$_answers,
  274. 'MEMBER_PROFILE_URL'=>placeholder_url(),
  275. 'USERNAME'=>lorem_phrase(),
  276. 'FORUM_DRIVER'=>NULL,
  277. )
  278. ),NULL,'',true),
  279. );
  280. }
  281. /**
  282. * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  283. * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  284. * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  285. *
  286. * @return array Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  287. */
  288. function tpl_preview__quiz_done_screen()
  289. {
  290. return array(
  291. lorem_globalise(
  292. do_lorem_template('QUIZ_DONE_SCREEN',array(
  293. 'RESULT'=>lorem_phrase(),
  294. 'TITLE'=>lorem_title(),
  295. 'TYPE'=>lorem_phrase(),
  296. 'MESSAGE'=>lorem_phrase(),
  297. 'CORRECTIONS_TO_SHOW'=>lorem_phrase(),
  298. 'POINTS_DIFFERENCE'=>placeholder_number(),
  299. )
  300. ),NULL,'',true),
  301. );
  302. }
  303. }