view.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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_cm($cm);
  34. $PAGE->set_url('/mod/gradeimporter/view.php', array('id' => $cm->id));
  35. $PAGE->set_title(format_string($gradeimporter->name));
  36. $PAGE->set_heading(format_string($course->fullname));
  37. $PAGE->set_context($context);
  38. /*$button = '';
  39. if (has_capability('mod/gradeimporter:edit', $context)) {
  40. $urlparams = array('id'=>$id, 'page'=>$page, 'editing'=>$editing ? '0' : '1');
  41. $url = new moodle_url('/mod/gradeimporter/view.php', $urlparams);
  42. $strediting = get_string('turnediting'.($editing ? 'off' : 'on'));
  43. $button = $OUTPUT->single_button($url, $strediting, 'get'). ' ';
  44. }
  45. $PAGE->set_button($button);*/
  46. /// Print the main part of the page
  47. $output = $PAGE->get_renderer('mod_folder');
  48. echo $output->header();
  49. $heading = get_string('displayingview', 'gradeimporter', $gradeimporter->name);
  50. echo $output->heading($heading);
  51. //button to add new submission
  52. if (has_capability('mod/gradeimporter:edit', $context)) {
  53. $url = new moodle_url('/mod/gradeimporter/submission.php');
  54. $newSubmission = '<form action="'. $url . '">'.
  55. '<input type="hidden" name="id" value="'. $gradeimporter->id .'" />'.
  56. '<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
  57. '<input type="hidden" name="page" value="0" />'.
  58. '<input type="submit" Value="'.get_string('newsubmission', 'gradeimporter').'" />'.
  59. '</form>';
  60. echo $newSubmission;
  61. }
  62. //tabela com as notas vem aqui
  63. echo 'parte principal do importador de notas Z';
  64. require_once($CFG->libdir . '/tablelib.php');
  65. require_once(dirname(__FILE__).'/locallib.php');
  66. use \gradeimporter\feedback;
  67. // $data = array();
  68. // $data["Prova"] = array();
  69. // $data["Prova"][] = array("P1", "7", "fulanoP1.pdf");
  70. // $data["Prova"][] = array("P2", "7", "fulanoP2.pdf");
  71. // $data["Prova"][] = array("P3", "7", "fulanoP3.pdf");
  72. // $data["Exercicio"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  73. // $data["Exercicio"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  74. // $data["teste"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  75. // $data["teste"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  76. $data = feedback::get_comments();
  77. $table = new html_table();
  78. $table->attributes['class'] = 'generaltable mod_index';
  79. $table->head = array ("Tipo", "Nome", "Nota", "Arquivos");
  80. $table->align = array ('center', 'center', 'center', 'center');
  81. if (count($data)) {
  82. $current = "";
  83. foreach ($data as $tipo => $cells) {
  84. if ($current != "" && $current != $tipo) {
  85. $row = new html_table_row();
  86. $cell = new html_table_cell();
  87. $cell->colspan = 5;
  88. $row->cells[] = $cell;
  89. $table->data[] = $row;
  90. }
  91. $current = $tipo;
  92. $row = new html_table_row();
  93. $cell = new html_table_cell($tipo);
  94. $cell->rowspan = count($cells)+1;
  95. $row->cells[] = $cell;
  96. $table->data[] = $row;
  97. foreach ($cells as $cell) {
  98. $row = new html_table_row();
  99. foreach ($cell as $value) {
  100. $cell = new html_table_cell($value);
  101. $row->cells[] = $cell;
  102. }
  103. $table->data[] = $row;
  104. }
  105. }
  106. }
  107. echo html_writer::table($table);
  108. /// Finish the page
  109. echo $output->footer();