view.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
  3. require_once(dirname(__FILE__).'/lib.php');
  4. require_once($CFG->libdir.'/filelib.php');
  5. require_once('locallib.php');
  6. global $DB;
  7. $id = optional_param('id', 0, PARAM_INT); // course_module ID, or
  8. $g = optional_param('g', 0, PARAM_INT); // gradeimporter instance ID, should be named as the first character of the module
  9. $action = optional_param('action', 0, PARAM_INT);
  10. $cmid = optional_param('cmid', 0, PARAM_INT);
  11. $id = optional_param('id', 0, PARAM_INT);
  12. $fileid = optional_param('fileid', 0, PARAM_INT);
  13. $filename = optional_param('filename', 'a', PARAM_TEXT);
  14. if ($id) {
  15. if (! $cm = get_coursemodule_from_id('gradeimporter', $id)) {
  16. error('Course Module ID was incorrect');
  17. }
  18. if (! $course = $DB->get_record('course', array('id'=> $cm->course))) {
  19. error('Course is misconfigured');
  20. }
  21. if (! $gradeimporter = $DB->get_record('gradeimporter', array('id'=> $cm->instance) ) ) {
  22. error('Course module is incorrect');
  23. }
  24. } else if ($g) {
  25. if (! $gradeimporter = $DB->get_record('gradeimporter', array('id'=> $g)) ){
  26. error('Course module is incorrect');
  27. }
  28. if (! $course = $DB->get_record('course', array('id'=> $gradeimporter->course)) ) {
  29. error('Course is misconfigured');
  30. }
  31. if (! $cm = get_coursemodule_from_instance('gradeimporter', $gradeimporter->id, $course->id)) {
  32. error('Course Module ID was incorrect');
  33. }
  34. } else {
  35. error('You must specify a course_module ID or an instance ID');
  36. }
  37. require_login($course, true, $cm);
  38. $context = context_module::instance($cm->id);
  39. if ($action==1 && has_capability('mod/gradeimporter:edit', $context)){
  40. //download feedback file
  41. $fs = get_file_storage();
  42. $file = $fs->get_file($context->id, 'mod_gradeimporter', 'gradeimporter_feedback', $fileid, '/', $filename);
  43. if ($file){
  44. send_stored_file($file, 86400, 0, true);
  45. }
  46. } else if ($action == 2 && has_capability('mod/gradeimporter:edit', $context)){
  47. exportCSV($context);
  48. }
  49. /// Print the page header
  50. $PAGE->set_cm($cm);
  51. $PAGE->set_url('/mod/gradeimporter/view.php', array('id' => $cm->id));
  52. $PAGE->set_title(format_string($gradeimporter->name));
  53. $PAGE->set_heading(format_string($course->fullname));
  54. $PAGE->set_context($context);
  55. /*$button = '';
  56. if (has_capability('mod/gradeimporter:edit', $context)) {
  57. $urlparams = array('id'=>$id, 'page'=>$page, 'editing'=>$editing ? '0' : '1');
  58. $url = new moodle_url('/mod/gradeimporter/view.php', $urlparams);
  59. $strediting = get_string('turnediting'.($editing ? 'off' : 'on'));
  60. $button = $OUTPUT->single_button($url, $strediting, 'get'). ' ';
  61. }
  62. $PAGE->set_button($button);*/
  63. /// Print the main part of the page
  64. $output = $PAGE->get_renderer('mod_folder');
  65. echo $output->header();
  66. $heading = get_string('displayingview', 'gradeimporter', $gradeimporter->name);
  67. echo $output->heading($heading);
  68. //button to add new submission
  69. if (has_capability('mod/gradeimporter:edit', $context)) {
  70. $url = new moodle_url('/mod/gradeimporter/submission.php');
  71. $newbutton = '<form action="'. $url . '">'.
  72. '<input type="hidden" name="id" value="'. $gradeimporter->id .'" />'.
  73. '<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
  74. '<input type="hidden" name="page" value="0" />'.
  75. '<input type="submit" Value="'.get_string('newsubmission', 'gradeimporter').'" />'.
  76. '</form>';
  77. echo $newbutton;
  78. $url = new moodle_url("/mod/gradeimporter/view.php", array('id'=>$id, 'cmid'=>$cm->id, 'action'=>2));
  79. $newbutton = '<form action="'. $url . '">'.
  80. '<input type="hidden" name="id" value="'. $id .'" />'.
  81. '<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
  82. '<input type="hidden" name="action" value="2" />'.
  83. '<input type="submit" Value="'.get_string('downloadconfigcsv', 'gradeimporter').'" />'.
  84. '</form>';
  85. echo $newbutton;
  86. }
  87. //tabela com as notas vem aqui
  88. require_once($CFG->libdir . '/tablelib.php');
  89. require_once(dirname(__FILE__).'/locallib.php');
  90. use \gradeimporter\feedback;
  91. // $data = array();
  92. // $data["Prova"] = array();
  93. // $data["Prova"][] = array("P1", "7", "fulanoP1.pdf");
  94. // $data["Prova"][] = array("P2", "7", "fulanoP2.pdf");
  95. // $data["Prova"][] = array("P3", "7", "fulanoP3.pdf");
  96. // $data["Exercicio"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  97. // $data["Exercicio"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  98. // $data["teste"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  99. // $data["teste"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  100. $data = feedback::get_comments($cm->id, $id);
  101. $table = new html_table();
  102. $table->attributes['class'] = 'generaltable mod_index';
  103. $table->head = array ("Tipo", "Nome", "Nota", "Arquivos");
  104. $table->align = array ('center', 'center', 'center', 'center');
  105. if (count($data)) {
  106. $current = "";
  107. foreach ($data as $tipo => $cells) {
  108. if ($current != "" && $current != $tipo) {
  109. $row = new html_table_row();
  110. $cell = new html_table_cell();
  111. $cell->colspan = 5;
  112. $row->cells[] = $cell;
  113. $table->data[] = $row;
  114. }
  115. $current = $tipo;
  116. $row = new html_table_row();
  117. $cell = new html_table_cell($tipo);
  118. $cell->rowspan = count($cells)+1;
  119. $row->cells[] = $cell;
  120. $table->data[] = $row;
  121. foreach ($cells as $cell) {
  122. $row = new html_table_row();
  123. foreach ($cell as $value) {
  124. $cell = new html_table_cell($value);
  125. $row->cells[] = $cell;
  126. }
  127. $table->data[] = $row;
  128. }
  129. }
  130. }
  131. echo html_writer::table($table);
  132. /// Finish the page
  133. echo $output->footer();