view.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
  3. require_once(dirname(__FILE__).'/lib.php');
  4. global $DB;
  5. $id = optional_param('id', 0, PARAM_INT); // course_module ID, or
  6. $g = optional_param('g', 0, PARAM_INT); // gradeimporter instance ID, should be named as the first character of the module
  7. if ($id) {
  8. if (! $cm = get_coursemodule_from_id('gradeimporter', $id)) {
  9. error('Course Module ID was incorrect');
  10. }
  11. if (! $course = $DB->get_record('course', array('id'=> $cm->course))) {
  12. error('Course is misconfigured');
  13. }
  14. if (! $gradeimporter = $DB->get_record('gradeimporter', array('id'=> $cm->instance) ) ) {
  15. error('Course module is incorrect');
  16. }
  17. } else if ($g) {
  18. if (! $gradeimporter = $DB->get_record('gradeimporter', array('id'=> $g)) ){
  19. error('Course module is incorrect');
  20. }
  21. if (! $course = $DB->get_record('course', array('id'=> $gradeimporter->course)) ) {
  22. error('Course is misconfigured');
  23. }
  24. if (! $cm = get_coursemodule_from_instance('gradeimporter', $gradeimporter->id, $course->id)) {
  25. error('Course Module ID was incorrect');
  26. }
  27. } else {
  28. error('You must specify a course_module ID or an instance ID');
  29. }
  30. require_login($course, true, $cm);
  31. $context = context_module::instance($cm->id);
  32. /// Print the page header
  33. $PAGE->set_url('/mod/gradeimporter/view.php', array('id' => $cm->id));
  34. $PAGE->set_title(format_string($gradeimporter->name));
  35. $PAGE->set_heading(format_string($course->fullname));
  36. $PAGE->set_context($context);
  37. /// Print the main part of the page
  38. $output = $PAGE->get_renderer('mod_folder');
  39. echo $output->header();
  40. $heading = get_string('displayingview', 'gradeimporter', $gradeimporter->name);
  41. echo $output->heading($heading);
  42. //tabela com as notas vem aqui
  43. echo 'parte principal do importador de notas Z';
  44. require_once($CFG->libdir . '/tablelib.php');
  45. require_once(dirname(__FILE__).'/locallib.php');
  46. use \gradeimporter\feedback;
  47. // $data = array();
  48. // $data["Prova"] = array();
  49. // $data["Prova"][] = array("P1", "7", "fulanoP1.pdf");
  50. // $data["Prova"][] = array("P2", "7", "fulanoP2.pdf");
  51. // $data["Prova"][] = array("P3", "7", "fulanoP3.pdf");
  52. // $data["Exercicio"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  53. // $data["Exercicio"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  54. // $data["teste"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  55. // $data["teste"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  56. $data = feedback::get_comments();
  57. $table = new html_table();
  58. $table->attributes['class'] = 'generaltable mod_index';
  59. $table->head = array ("Tipo", "Nome", "Nota", "Arquivos");
  60. $table->align = array ('center', 'center', 'center', 'center');
  61. if (count($data)) {
  62. $current = "";
  63. foreach ($data as $tipo => $cells) {
  64. if ($current != "" && $current != $tipo) {
  65. $row = new html_table_row();
  66. $cell = new html_table_cell();
  67. $cell->colspan = 5;
  68. $row->cells[] = $cell;
  69. $table->data[] = $row;
  70. }
  71. $current = $tipo;
  72. $row = new html_table_row();
  73. $cell = new html_table_cell($tipo);
  74. $cell->rowspan = count($cells)+1;
  75. $row->cells[] = $cell;
  76. $table->data[] = $row;
  77. foreach ($cells as $cell) {
  78. $row = new html_table_row();
  79. foreach ($cell as $value) {
  80. $cell = new html_table_cell($value);
  81. $row->cells[] = $cell;
  82. }
  83. $table->data[] = $row;
  84. }
  85. }
  86. }
  87. echo html_writer::table($table);
  88. /// Finish the page
  89. echo $output->footer();