| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 | 
							- <?php
 
- /**
 
-  * Settings NASA-TLX/LInE manager. Reaches this code from administrative Moodle area, in setting 'plugins' of iAssign.
 
-  * 1. action==export: see a table with all data from NASA-TLX/LInE (all questionnaires, each one with all answers)
 
-  * 2. action==?
 
-  * 
 
-  * Release Notes:
 
-  * - v 0.1 2019/03/04
 
-  * 
 
-  * @package   mod_nasatlx
 
-  * @author    Leônidas de Oliveira Brandão
 
-  * @version   v 0.1 2019/03/04
 
-  * @category  
 
-  * @copyright 2014 LInE - http://line.ime.usp.br
 
-  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 
-  */
 
- global $CFG, $USER, $PAGE, $OUTPUT, $DB;
 
- require_once("../../config.php");
 
- require_once($CFG->dirroot . '/mod/nasatlx/locallib.php');
 
- //DDD require_once($CFG->dirroot . '/mod/nasatlx/settings_form.php');
 
- require_login();
 
- if (isguestuser()) {
 
-   die();
 
-   }
 
- //Parameters GET e POST (parâmetros GET e POST)
 
- $nasa_id = optional_param('nasa_id', 0, PARAM_INT);
 
- $action = optional_param('action', NULL, PARAM_TEXT);
 
- $url = new moodle_url('/admin/settings.php', array('section' => 'modsettingnasatlx'));
 
- //$from = optional_param('from', NULL, PARAM_TEXT);
 
- //$status = optional_param('status', 0, PARAM_INT);
 
- $contextuser = context_user::instance($USER->id);
 
- $PAGE->set_url($url);
 
- $PAGE->set_context($contextuser);
 
- $PAGE->blocks->show_only_fake_blocks(); //
 
- $PAGE->set_pagelayout('popup');
 
- //D echo "settings_nasatlx_line.php: 5 action=$action<br/>\n";
 
- if ($action == 'export') {
 
-   // echo "Export not yet implemented<br/>\n";
 
-   $title = get_string('export_all_nasatlx', 'nasatlx') . $OUTPUT->help_icon('export_all_nasatlx', 'nasatlx');
 
-   $PAGE->set_title($title);
 
-   // print($OUTPUT->notification(get_string('error_upload_ilm', 'nasatlx'), 'notifyproblem'));
 
-   print($OUTPUT->header());
 
-   print($OUTPUT->heading($title));
 
-   print "  <style>\n " .
 
-         " th.c { border: 1px solid #aaa; padding: 5px 10px; background-color: #6a9ada; } " .
 
-         " th { border: 1px solid #aaa; padding: 5px 10px; background-color: #5a8aca; } " .
 
-         " .td1l { border: 1px solid #aaa; padding: 5px 10px; background-color: #eeeefe; text-align:left} " .
 
-         " .td1r { border: 1px solid #aaa; padding: 5px 10px; background-color: #eeeefe; text-align:right} " .
 
-         " .td2l { border: 1px solid #aaa; padding: 5px 10px; background-color: #eeefee; text-align:left} " .
 
-         " .td2r { border: 1px solid #aaa; padding: 5px 10px; background-color: #eeefee; text-align:right}\n" .
 
-         "  </style>\n";
 
-   // Tables: 'nasatlx' (id, course, name, intro, timecreated, timemodified), 'course' (id, fullname)
 
-   //  SELECT m_nasatlx_resps.id, m_nasatlx_resps.cmid, m_nasatlx_resps.course, m_nasatlx_resps.user FROM m_course_modules, m_nasatlx, m_nasatlx_resps
 
-   //  WHERE m_nasatlx_resps.cmid=m_course_modules.id  AND  m_course_modules.instance=m_nasatlx.id  AND  m_nasatlx.id = 1;
 
-   $query1 = "SELECT n.*, c.id AS courseid, c.fullname FROM {nasatlx} n, {course} c WHERE c.id = n.course";
 
-   //D echo "$query1<br/>";
 
-   $nasatlx_quest = $DB->get_records_sql($query1); // *_nasatlx = id, course, name, intro, timecreated, timemodified
 
-   // foreach ($nasatlx_quest as $nasa_item) echo " * " . $nasa_item->id . ", " . $nasa_item->course . ", " . $nasa_item->name . ", " . $nasa_item->intro . "<br/>";
 
-   if (!$nasatlx_quest)
 
-      print get_string('list_all_nasatlx_empty', 'nasatlx') . "<br/>\n";
 
-   else { // There are NASA questionnaires
 
-     // $nasatlx_quest = Array ( [1] => stdClass Object ( [id] => 1 [course] => 2 [name] => Title questionnaire NASA-TLX/LInE [intro] => Text... [introformat] => 1 [timecreated] => 1551989761 [timemodified] => 0 [courseid] => 2 [fullname] => Curso teste ) )
 
-     //_ foreach ($nasatlx_quest as $item_nasa_quest) { // usually array[1]
 
-     //_   print "  <table class='nicetable'>\n";
 
-     //_   print "    <tr class='td1l'><th class='c' title='course id'>". $item_nasa_quest->courseid . "</th><th class='c' title='course fullname' colspan='24'>" . $item_nasa_quest->fullname . "</th></tr>\n";
 
-     //_   print "    <tr class='td2l'><th class='c' title='nasatlx id'>". $item_nasa_quest->id . "</th><th class='c' title='nasatlx name' colspan='24'>" . $item_nasa_quest->name . "</th></tr>\n";
 
-     //_   }
 
-     //_ print "  </table >\n<br/>\n";
 
-     print "  <table class='nicetable'>\n";      
 
-     $count1 = 0;
 
-     foreach ($nasatlx_quest as $item_nasa_quest) { // select all answer to the questionnaire $item_nasa_quest
 
-       $nasa_id = $item_nasa_quest->id;
 
-       print "    <tr class='td1l'><th class='c' title='course id'>". $item_nasa_quest->courseid . "</th><th class='c' title='course fullname' colspan='24'>" . $item_nasa_quest->fullname . "</th></tr>\n";
 
-       print "    <tr class='td2l'><th class='c' title='nasatlx id'>". $item_nasa_quest->id . "</th><th class='c' title='nasatlx name' colspan='24'>" . $item_nasa_quest->name . "</th></tr>\n";
 
-       // See tables: nasatlx_resps, nasatlx, course_modules, course
 
-       // $query_str = "SELECT s.id, s.name, s.dependency FROM {iassign_statement} s WHERE s.iassignid = :iassignid ORDER BY s.position ASC";
 
-       $query2 = "SELECT r.* FROM {nasatlx_resps} r, {course_modules} cm, {nasatlx} tlx WHERE " .
 
-                "r.cmid=cm.id AND cm.instance=tlx.id AND tlx.id = " . $nasa_id;
 
-       $nasatlx_answers = $DB->get_records_sql($query2);
 
-       if (!$nasatlx_quest)
 
-          print get_string('list_all_nasatlx_ans_empty', 'nasatlx') . "<br/r>\n";
 
-       else {
 
-         // *_nasatlx : id scale1 scale2 scale3 scale4 scale5 calc1 calc2 calc3 calc4 calc5 peso1 peso2 peso3 peso4 peso5 cmid course user created 
 
-         // print "    <tr><th>". $item_nasa_quest->id . "</th><th colspan='20'>" . $item_nasa_quest->name . "</th></tr>\n";
 
-         print "    <tr>\n";
 
-         print "      <th>id</th><th>scale1</th><th>scale2</th><th>scale3</th><th>scale4</th><th>scale5</th><th>scale6</th>\n" .
 
-               "      <th>calc1</th><th>calc2</th><th>calc3</th><th>calc4</th><th>calc5</th><th>calc6</th>\n";
 
-         print "      <th>peso1</th><th>peso2</th><th>peso3</th><th>peso4</th><th>peso5</th><th>peso6</th>\n" .
 
-               "      <th>pares</th><th>cmid</th><th>course</th><th>user</th><th>created</th></tr>\n";
 
-         $count2 = 0;
 
-         foreach ($nasatlx_answers as $answer) { // fields : id scale1 scale2 scale3 scale4 scale5 calc1 calc2 calc3 calc4 calc5 peso1 peso2 peso3 peso4 peso5 cmid course user created
 
-           print "    <tr>\n";
 
-           //D if ($count1==0) { echo "answer: "; print_r($answer); echo "<br/>"; }
 
-           foreach ($answer as $nvalue) { // turn the object in array (or use 'foreach ($answer as $nkey=>$nvalue)')
 
-             $count2++;
 
-             if ($count1 % 2 == 0) {
 
-               if ($count2 < 12) print "<td class='td1r'>" .  $nvalue . "</td>";
 
-               else print "<td class='td1l'>" .  $nvalue . "</td>";
 
-               }
 
-             else {
 
-               if ($count2 < 12) print "<td class='td2r'>" .  $nvalue . "</td>";
 
-               else print "<td class='td2l'>" .  $nvalue . "</td>";
 
-               }
 
-             $count1++;
 
-             } // foreach ($answer as $nvalue)
 
-           print "    </tr>\n";
 
-           } // foreach ($nasatlx_answers as $answer)
 
-         // $nasatlx_answers = $DB->get_records_sql($query2);
 
-         }
 
-       } // foreach ($nasatlx_quest as $item_nasa_quest)
 
-     print "  </table>\n";
 
-     } // else if (!$nasatlx_quest)
 
-   print "<br/><b>Total respostas: $count1<b><br/>\n";
 
-   print($OUTPUT->footer());
 
-   die;
 
-   } // if ($action == 'export')
 
- /*
 
- else
 
- if ($action == 'edit') { // Edit data of an NASA-TLX/LInE => processed in 'settings_form.php'
 
-   print "Edit not yet implemented<br/>\n";
 
-   //_ $title = get_string('edit_nasa_item', 'nasatlx') . $OUTPUT->help_icon('add_ilm_nasatlx', 'nasatlx');
 
-   //_ $PAGE->set_title($title);
 
-   //_ $param = ilm_settings::add_edit_copy_nasa_item($nasa_id, $action);
 
-   //_ $description = $param->description_lang; // used to present the NASA-TLX/LInE description in 'settings_form.php' - {"en":"...","pt":"..."}
 
-   //_ $mform = new mod_ilm_form($param); // in 'settings_form.php': class mod_ilm_form
 
-   //_ $mform->set_data($param);
 
-   //_ if ($mform->is_cancelled()) {
 
-   //_   close_window();
 
-   //_   die;
 
-   //_   }
 
-   //_ else if ($formdata = $mform->get_submitted_data()) {
 
-   //_   ilm_settings::edit_nasa_item($formdata, $formdata->file);
 
-   //_   close_window(0, true);
 
-   //_   die;
 
-   //_   }
 
-   //_ print($OUTPUT->header());
 
-   //_ print($OUTPUT->heading($title));
 
-   //_ $mform->display();
 
-   //_ print($OUTPUT->footer());
 
-   //_ die;
 
-   }
 
- else
 
- if ($action == 'copy') {
 
-   print "Copy not yet implemented<br/>\n";
 
-   //_ $title = get_string('copy_nasa_item', 'nasatlx') . $OUTPUT->help_icon('add_ilm_nasatlx', 'nasatlx');
 
-   //_ $PAGE->set_title($title);
 
-   //_ $param = ilm_settings::add_edit_copy_nasa_item($nasa_id, $action);
 
-   //_ $mform = new mod_ilm_form();
 
-   //_ $mform->set_data($param);
 
-   //_ if ($mform->is_cancelled()) {
 
-   //_   close_window();
 
-   //_   die;
 
-   //_   }
 
-   //_ else if ($formdata = $mform->get_data()) {
 
-   //_   ilm_settings::copy_new_version_ilm($formdata);
 
-   //_   close_window(0, true);
 
-   //_   die;
 
-   //_   }
 
-   //_ print($OUTPUT->header());
 
-   //_ print($OUTPUT->heading($title));
 
-   //_ $mform->display();
 
-   //_ print($OUTPUT->footer());
 
-   //_ die;
 
-   }
 
- else
 
- if ($action == 'confirm_remove_nasa_item') {
 
-   print "Remove not yet implemented<br/>\n";
 
-   //_ $title = get_string('remove_nasa_item', 'nasatlx');
 
-   //_ $PAGE->set_title($title);
 
-   //_ $PAGE->set_pagelayout('base');
 
-   //_ $remove_nasa_item = ilm_settings::confirm_remove_nasa_item($nasa_id, $ilm_parent);
 
-   //_ print($OUTPUT->header());
 
-   //_ print($OUTPUT->heading($title));
 
-   //_ print($remove_nasa_item);
 
-   //_ print($OUTPUT->footer());
 
-   //_ die;
 
-   //_ }
 
- else
 
- if ($action == 'remove') {
 
-   print "Remove not yet implemented<br/>\n";
 
-   //_ $title = get_string('remove_nasa_item', 'nasatlx');
 
-   //_ $PAGE->set_title($title);
 
-   //_ $PAGE->set_pagelayout('redirect');
 
-   //_ $parent = ilm_settings::remove_nasa_item($nasa_id);
 
-   //_ if ($parent == null) {
 
-   //_   $title = get_string('remove_nasa_item', 'nasatlx');
 
-   //_   $PAGE->set_title($title);
 
-   //_   $PAGE->set_pagelayout('base');
 
-   //_   $remove_nasa_item = ilm_settings::confirm_remove_nasa_item($nasa_id, $ilm_parent);
 
-   //_   print($OUTPUT->header());
 
-   //_   print($OUTPUT->heading($title));
 
-   //_   print($OUTPUT->notification(get_string('error_folder_permission_denied', 'nasatlx'), 'notifyproblem'));
 
-   //_   print($remove_nasa_item);
 
-   //_   print($OUTPUT->footer());
 
-   //_   die;
 
-   //_   }
 
-   //_ if ($parent == 0)
 
-   //_   redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingnasatlx', 'action' => 'view')));
 
-   //_ else
 
-   //_   redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingnasatlx', 'action' => 'config', 'nasa_id' => $ilm_parent)));
 
-   //_ }
 
- else
 
- if ($action == 'default') {
 
-   //_ $title = get_string('default_ilm', 'nasatlx');
 
-   //_ $PAGE->set_title($title);
 
-   //_ $PAGE->set_pagelayout('redirect');
 
-   //_ ilm_settings::default_ilm($nasa_id);
 
-   //_ redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingnasatlx', 'action' => 'config', 'nasa_id' => $ilm_parent)));
 
-   }
 
- else
 
- if ($action == 'list') {
 
-   //_ $title = get_string('list_ilm', 'nasatlx');
 
-   //_ $PAGE->set_title($title);
 
-   //_ $list_ilm = ilm_settings::list_ilm();
 
-   //_ print($OUTPUT->header());
 
-   //_ print($OUTPUT->heading($title . $OUTPUT->help_icon('list_ilm', 'nasatlx')));
 
-   //_ print($list_ilm);
 
-   //_ print($OUTPUT->footer());
 
-   //_ die;
 
-   }
 
- else
 
- if ($action == 'upgrade') {
 
-   //_ $title = get_string('upgrade_ilm_title', 'nasatlx');
 
-   //_ $PAGE->set_title($title);
 
-   //_ $PAGE->set_pagelayout('redirect');
 
-   //_ $ilm = ilm_settings::upgrade_ilm($nasa_id);
 
-   //_ if ($ilm == 0)
 
-   //_   redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingnasatlx', 'action' => 'view')));
 
-   //_ else
 
-   //_   redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingnasatlx', 'action' => 'config', 'nasa_id' => $ilm)));
 
-   }
 
- else
 
- if ($action == 'view') {
 
-   $nasatlx_ilm = $DB->get_record('nasatlx_ilm', array('id' => $nasa_id));
 
-   $title = get_string('view_ilm', 'nasatlx') . $OUTPUT->help_icon('add_ilm_nasatlx', 'nasatlx');
 
-   $PAGE->set_title($title . ': ' . $nasatlx_ilm->name . ' ' . $nasatlx_ilm->version);
 
-   $view_ilm = ilm_settings::view_ilm($nasa_id, $from);
 
-   print($OUTPUT->header());
 
-   print($OUTPUT->heading($title . ': ' . $nasatlx_ilm->name . ' ' . $nasatlx_ilm->version));
 
-   print($view_ilm);
 
-   print($OUTPUT->footer());
 
-   die;
 
-   }
 
- */
 
 
  |