view.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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';
  44. require_once($CFG->libdir . '/tablelib.php');
  45. $data = array();
  46. $data["Prova"] = array();
  47. $data["Prova"][] = array("P1", "7", "fulanoP1.pdf");
  48. $data["Prova"][] = array("P2", "7", "fulanoP2.pdf");
  49. $data["Prova"][] = array("P3", "7", "fulanoP3.pdf");
  50. $data["Exercicio"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  51. $data["Exercicio"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  52. $data["teste"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  53. $data["teste"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  54. $table = new html_table();
  55. $table->attributes['class'] = 'generaltable mod_index';
  56. $table->head = array ("Tipo", "Nome", "Nota", "Arquivos");
  57. $table->align = array ('center', 'center', 'center', 'center');
  58. if (count($data)) {
  59. $current = "";
  60. foreach ($data as $tipo => $cells) {
  61. if ($current != "" && $current != $tipo) {
  62. $row = new html_table_row();
  63. $cell = new html_table_cell();
  64. $cell->colspan = 5;
  65. $row->cells[] = $cell;
  66. $table->data[] = $row;
  67. }
  68. $current = $tipo;
  69. $row = new html_table_row();
  70. $cell = new html_table_cell($tipo);
  71. $cell->rowspan = count($cells)+1;
  72. $row->cells[] = $cell;
  73. $table->data[] = $row;
  74. foreach ($cells as $cell) {
  75. $row = new html_table_row();
  76. foreach ($cell as $value) {
  77. $cell = new html_table_cell($value);
  78. $row->cells[] = $cell;
  79. }
  80. $table->data[] = $row;
  81. }
  82. }
  83. }
  84. echo html_writer::table($table);
  85. /// Finish the page
  86. echo $output->footer();