Explorar el Código

Atualizar 'view.php'

Felipe-cavalieri hace 5 años
padre
commit
9dedec42fa
Se han modificado 1 ficheros con 83 adiciones y 27 borrados
  1. 83 27
      view.php

+ 83 - 27
view.php

@@ -79,7 +79,7 @@ if (has_capability('mod/gradeimporter:edit', $context)) {
 }
 
 //tabela com as notas vem aqui
-echo 'parte principal do importador de notas Z';
+echo 'parte principal do importador de notas';
 
 require_once($CFG->libdir . '/tablelib.php');
 require_once(dirname(__FILE__).'/locallib.php');
@@ -97,43 +97,99 @@ use \gradeimporter\feedback;
 
 $data = feedback::get_comments();
 
-$table = new html_table();
-$table->attributes['class'] = 'generaltable mod_index';
-$table->head  = array ("Tipo", "Nome", "Nota", "Arquivos");
-$table->align = array ('center', 'center', 'center', 'center');
+if (!feedback::is_capability()) {
+  $table = new html_table();
+  $table->attributes['class'] = 'generaltable mod_index';
+  $table->head  = array ("Tipo", "Nome", "Nota", "Arquivos");
+  $table->align = array ('center', 'center', 'center', 'center');
+
+  if (count($data)) {
+    $current = "";
+    foreach ($data as $tipo => $cells) {
+      if ($current != "" && $current != $tipo) {
+        $row = new html_table_row();
+        $cell = new html_table_cell();
+        $cell->colspan = 5;
+        $row->cells[] = $cell;
+        $table->data[] = $row;
+      }
+      $current = $tipo;
 
-if (count($data)) {
-  $current = "";
-  foreach ($data as $tipo => $cells) {
-    if ($current != "" && $current != $tipo) {
       $row = new html_table_row();
-      $cell = new html_table_cell();
-      $cell->colspan = 5;
+      $cell = new html_table_cell($tipo);
+      $cell->rowspan = count($cells)+1;
       $row->cells[] = $cell;
       $table->data[] = $row;
+
+      foreach ($cells as $cell) {
+        $row = new html_table_row();
+        foreach ($cell as $value) {
+          $cell = new html_table_cell($value);
+          $row->cells[] = $cell;
+        }
+        $table->data[] = $row;
+      }
     }
-    $current = $tipo;
-
-    $row = new html_table_row();
-    $cell = new html_table_cell($tipo);
-    $cell->rowspan = count($cells)+1;
-    $row->cells[] = $cell;
-    $table->data[] = $row;
-    foreach ($cells as $cell) {
-      $row = new html_table_row();
-      foreach ($cell as $value) {
-        $cell = new html_table_cell($value);
+  }
+
+  echo html_writer::table($table);
+}
+
+if (feedback::is_capability()) {
+  // $data["Aluno3"] = array();
+  // $data["Aluno3"]["Prova"] = array();
+  // $data["Aluno3"]["Prova"][] = array("P1", "7", "fulanoP1.pdf");
+  // $data["Aluno3"]["Prova"][] = array("P2", "7", "fulanoP2.pdf");
+  // $data["Aluno3"]["Prova"][] = array("P3", "7", "fulanoP3.pdf");
+  // $data["Aluno3"]["Exercicio"][] = array("E1", "-", "fulanoE1.pdf.pdf");
+  // $data["Aluno3"]["Exercicio"][] = array("E2", "-", "fulanoE2.pdf.pdf");
+  // $data["Aluno3"]["teste"][] = array("E1", "-", "fulanoE1.pdf.pdf");
+  // $data["Aluno3"]["teste"][] = array("E2", "-", "fulanoE2.pdf.pdf");
+
+  $table = new html_table();
+  $table->attributes['class'] = 'generaltable mod_index';
+  $table->head  = array ("Aluno", "Tipo", "Nome", "Nota", "Arquivos");
+  $table->align = array ('center', 'center', 'center', 'center', 'center');
+
+  if (count($data)) {
+    $currentAluno = "";
+    foreach ($data as $aluno => $datas) {
+      if ($currentAluno != "" && $currentAluno != $aluno) {
+        $row = new html_table_row();
+        $cell = new html_table_cell();
+        $cell->colspan = 6;
         $row->cells[] = $cell;
+        $table->data[] = $row;
       }
+      $t = count($datas);
+      foreach ($datas as $tipo => $cells) {$t += count($cells);};
+      $currentAluno = $aluno;
+      $row = new html_table_row();
+      $cell = new html_table_cell($aluno);
+      $cell->rowspan = $t+1;
+      $row->cells[] = $cell;
       $table->data[] = $row;
+
+      foreach ($datas as $tipo => $cells) {
+        $row = new html_table_row();
+        $cell = new html_table_cell($tipo);
+        $cell->rowspan = count($cells)+1;
+        $row->cells[] = $cell;
+        $table->data[] = $row;
+
+        foreach ($cells as $cell) {
+          $row = new html_table_row();
+          foreach ($cell as $value) {
+            $row->cells[] = new html_table_cell($value);
+          }
+          $table->data[] = $row;
+        }
+      }
     }
   }
-}
 
-echo html_writer::table($table);
+  echo html_writer::table($table);
+}
 
 /// Finish the page
 echo $output->footer();
-
-
-