view.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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';
  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. if (!feedback::is_capability()) {
  78. $table = new html_table();
  79. $table->attributes['class'] = 'generaltable mod_index';
  80. $table->head = array ("Tipo", "Nome", "Nota", "Arquivos");
  81. $table->align = array ('center', 'center', 'center', 'center');
  82. if (count($data)) {
  83. $current = "";
  84. foreach ($data as $tipo => $cells) {
  85. if ($current != "" && $current != $tipo) {
  86. $row = new html_table_row();
  87. $cell = new html_table_cell();
  88. $cell->colspan = 5;
  89. $row->cells[] = $cell;
  90. $table->data[] = $row;
  91. }
  92. $current = $tipo;
  93. $row = new html_table_row();
  94. $cell = new html_table_cell($tipo);
  95. $cell->rowspan = count($cells)+1;
  96. $row->cells[] = $cell;
  97. $table->data[] = $row;
  98. foreach ($cells as $cell) {
  99. $row = new html_table_row();
  100. foreach ($cell as $value) {
  101. $cell = new html_table_cell($value);
  102. $row->cells[] = $cell;
  103. }
  104. $table->data[] = $row;
  105. }
  106. }
  107. }
  108. echo html_writer::table($table);
  109. }
  110. if (feedback::is_capability()) {
  111. // $data["Aluno3"] = array();
  112. // $data["Aluno3"]["Prova"] = array();
  113. // $data["Aluno3"]["Prova"][] = array("P1", "7", "fulanoP1.pdf");
  114. // $data["Aluno3"]["Prova"][] = array("P2", "7", "fulanoP2.pdf");
  115. // $data["Aluno3"]["Prova"][] = array("P3", "7", "fulanoP3.pdf");
  116. // $data["Aluno3"]["Exercicio"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  117. // $data["Aluno3"]["Exercicio"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  118. // $data["Aluno3"]["teste"][] = array("E1", "-", "fulanoE1.pdf.pdf");
  119. // $data["Aluno3"]["teste"][] = array("E2", "-", "fulanoE2.pdf.pdf");
  120. $table = new html_table();
  121. $table->attributes['class'] = 'generaltable mod_index';
  122. $table->head = array ("Aluno", "Tipo", "Nome", "Nota", "Arquivos");
  123. $table->align = array ('center', 'center', 'center', 'center', 'center');
  124. if (count($data)) {
  125. $currentAluno = "";
  126. foreach ($data as $aluno => $datas) {
  127. if ($currentAluno != "" && $currentAluno != $aluno) {
  128. $row = new html_table_row();
  129. $cell = new html_table_cell();
  130. $cell->colspan = 6;
  131. $row->cells[] = $cell;
  132. $table->data[] = $row;
  133. }
  134. $t = count($datas);
  135. foreach ($datas as $tipo => $cells) {$t += count($cells);};
  136. $currentAluno = $aluno;
  137. $row = new html_table_row();
  138. $cell = new html_table_cell($aluno);
  139. $cell->rowspan = $t+1;
  140. $row->cells[] = $cell;
  141. $table->data[] = $row;
  142. foreach ($datas as $tipo => $cells) {
  143. $row = new html_table_row();
  144. $cell = new html_table_cell($tipo);
  145. $cell->rowspan = count($cells)+1;
  146. $row->cells[] = $cell;
  147. $table->data[] = $row;
  148. foreach ($cells as $cell) {
  149. $row = new html_table_row();
  150. foreach ($cell as $value) {
  151. $row->cells[] = new html_table_cell($value);
  152. }
  153. $table->data[] = $row;
  154. }
  155. }
  156. }
  157. }
  158. echo html_writer::table($table);
  159. }
  160. /// Finish the page
  161. echo $output->footer();