settings.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. *
  4. * This PHP script is invoked by Moodle every time it enters at Admin section (./admin/search.php).
  5. * It provides a link to the NASA-TLX/LInE general configurations area ('pluginname').
  6. *
  7. * @package mod_nasatlx
  8. * @author Leônidas O. Brandão
  9. * @version v 0.1 2019/03/04
  10. * @category
  11. * @copyright 2014 LInE - http://line.ime.usp.br
  12. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  13. */
  14. // Moodle core defines constant MOODLE_INTERNAL which shall be used to make sure that the script is included and not called directly.
  15. defined('MOODLE_INTERNAL') || die();
  16. global $OUTPUT, $CFG, $DB;
  17. require_once($CFG->dirroot . '/mod/nasatlx/lib.php');
  18. require_once($CFG->dirroot . '/mod/nasatlx/locallib.php');
  19. $action = optional_param('action', 'view', PARAM_TEXT);
  20. $ilm_id = optional_param('ilm_id', 0, PARAM_INT);
  21. $ilm_param_id = optional_param('ilm_param_id', 0, PARAM_INT);
  22. $ilm_id_parent = optional_param('ilm_id_parent', 0, PARAM_INT);
  23. $status = optional_param('status', 0, PARAM_INT);
  24. if (!$action && !$ilm_id) {
  25. return; // nothing to be done (it is the Admin entering at the initial administrative section)
  26. }
  27. //D echo "/mod/nasatlx/settings.php: action=$action<br/>";
  28. /*
  29. if ($action == 'visible') {
  30. ilm_settings::visible_ilm($ilm_id, $status);
  31. $action = 'config';
  32. $ilm_id = $ilm_id_parent;
  33. }
  34. else
  35. if ($action == 'visible_param') {
  36. ilm_settings::visible_param($ilm_param_id, $status);
  37. $action = 'config';
  38. }
  39. else
  40. if ($action == 'export') {
  41. ilm_settings::export_ilm($ilm_id);
  42. $action = 'config';
  43. }
  44. */
  45. $str = '';
  46. //D if (!file_exists($CFG->dirroot . '/blocks/nasatlx_block/version.php')) {
  47. //D $str .= $OUTPUT->box_start();
  48. //D $str .= '<center>' . $OUTPUT->error_text(get_string('error_check_nasatlx_block', 'nasatlx')) . '</center>';
  49. //D $str .= $OUTPUT->box_end();
  50. //D }
  51. if ($action == 'view') {
  52. // echo "settings.php: action==view<br/>"; exit;
  53. $url_export_all = new moodle_url('/mod/nasatlx/settings_nasatlx_line.php', array('action' => 'export'));
  54. $action_add = new popup_action('click', $url_export_all, 'popup', array('width' => 900, 'height' => 650));
  55. $link_export_all = $OUTPUT->action_link($url_export_all, get_string('export_all_nasatlx', 'nasatlx'), $action_add) . $OUTPUT->help_icon('export_all_nasatlx', 'nasatlx');
  56. //TODO Implement export all questionnaires NASA-TLX/LInE and their associated data (all of them)
  57. //DDD $url_import = new moodle_url('/mod/nasatlx/settings_nasatlx_line.php', array('action' => 'import'));
  58. //DDD $action_import = new popup_action('click', $url_import, 'popup', array('width' => 900, 'height' => 650));
  59. //DDD $link_import = $OUTPUT->action_link($url_import, get_string('export_nasatlx', 'nasatlx'), $action_import) . $OUTPUT->help_icon('export_nasatlx', 'nasatlx');
  60. // First list all iLM from type HTML
  61. // Table '*_nasatlx' : id course name intro introformat timecreated timemodified
  62. // Table '*_nasatlx_resps': id scale1 scale2 scale3 scale4 scale5 calc1 calc2 calc3 calc4 calc5 peso1 peso2 peso3 peso4 peso5 cmid course user created
  63. $nasatlx_list = $DB->get_records_sql("SELECT * FROM {nasatlx} WHERE 1 = 1");
  64. //D foreach ($nasatlx_list as $nasa_item) echo " * " . $nasa_item->id . ", " . $nasa_item->course . ", " . $nasa_item->name . ", " . $nasa_item->intro . "<br/>";
  65. $str .= '<table id="outlinetable" class="generaltable boxaligncenter" cellpadding="5" width="100%">' . chr(13);
  66. $str .= '<tr><td colspan=2 align=left>' . $link_export_all . '</td>'; // must be implemented in 'settings_nasatlx_line.php'
  67. // $str .= '<td colspan=2 align=right>' . $link_import . '</td></tr>';
  68. if ($nasatlx_list) {
  69. foreach ($nasatlx_list as $item_quest) {
  70. $url_view_quest = new moodle_url('/admin/settings.php', array('section' => 'modsettingnasatlx', 'action' => 'config', 'ilm_id' => $item_quest->id));
  71. //DDD $link_config = $OUTPUT->action_link($url_view_quest, nasatlx_icons::insert('config_ilm'));
  72. $str .= ' <tr>' . chr(13);
  73. $str .= ' <td class="header c1" width=75% title="fields: name, description"><strong>' . $item_quest->name . ' (' . $item_quest->id . ')</strong></td>' . chr(13);
  74. $str .= '<td class="header c1" width=10% ><strong title="course id">' . $item_quest->course . '</strong></td>' . chr(13);
  75. //TODO implement 'search_total_of_answers($id)': return the total of answers in this questionnaire
  76. // $str .= '<td class="header c1" width=10% ><strong title="number of answers">' . search_total_of_answers($item_quest->id) . ':</strong></td>' . chr(13);
  77. $str .= '</tr>';
  78. } // foreach ($nasatlx_list as $item_quest)
  79. } // if ($nasatlx_list)
  80. $str .= '</table>';
  81. $settings->add(new admin_setting_heading('nasatlx', get_string('view_nasatlx', 'nasatlx') . $OUTPUT->help_icon('modulename', 'nasatlx'), $str));
  82. } // if ($action == 'view')
  83. else if ($action == 'confirm_upgrade') {
  84. //D print "settings.php: 1 action==confirm_upgrade - to be implemented<br/>";
  85. if (is_debugging()) print "nasatlx: settings.php: action==confirm_upgrade - to be implemented<br/>";
  86. // debugging("settings.php: action==confirm_upgrade - to be implemented<br/>", DEBUG_DEVELOPER);
  87. } // else if ($action == 'confirm_upgrade')
  88. else if ($action == 'config') { // Administration > plugins > NASA-TLX/LInE : after select the iLM reaches this point
  89. //D print "settings.php: action==config - to be implemented<br/>";
  90. //debugging("settings.php: action==config - to be implemented<br/>", DEBUG_DEVELOPER);
  91. //D if (is_debugging()) // declared in 'lib.php' // NOT WORKING!!!!
  92. //D print "<br/>&bnsp;<br/>&bnsp;<br/>&bnsp;<br/>&bnsp;<br/>&bnsp;<br/>&bnsp;<br/>&bnsp;nasatlx: settings.php: action==config - to be implemented<br/>";
  93. }