| 
					
				 | 
			
			
				@@ -52,7 +52,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if ($action==1 && has_capability('mod/gradeimporter:edit', $context)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if ($action==1 && has_capability('mod/gradeimporter:view', $context)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       //download feedback file 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $fs = get_file_storage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $file = $fs->get_file($context->id, 'mod_gradeimporter', 'gradeimporter_feedback', $fileid, '/', $filename); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -60,6 +60,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         send_stored_file($file, 86400, 0, true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } else if ($action == 2 && has_capability('mod/gradeimporter:edit', $context)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      //download students csv with their id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       exportCSV($context); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -70,15 +71,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $PAGE->set_title(format_string($gradeimporter->name)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $PAGE->set_heading(format_string($course->fullname)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $PAGE->set_context($context); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /*$button = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (has_capability('mod/gradeimporter:edit', $context)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $urlparams = array('id'=>$id, 'page'=>$page, 'editing'=>$editing ? '0' : '1'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $url = new moodle_url('/mod/gradeimporter/view.php', $urlparams); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $strediting = get_string('turnediting'.($editing ? 'off' : 'on')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $button = $OUTPUT->single_button($url, $strediting, 'get'). ' '; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $PAGE->set_button($button);*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/// Print the main part of the page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 $output = $PAGE->get_renderer('mod_folder'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 echo $output->header(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -115,51 +107,88 @@ require_once($CFG->libdir . '/tablelib.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 require_once(dirname(__FILE__).'/locallib.php'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use \gradeimporter\feedback; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data["Prova"] = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data["Prova"][] = array("P1", "7", "fulanoP1.pdf"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data["Prova"][] = array("P2", "7", "fulanoP2.pdf"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data["Prova"][] = array("P3", "7", "fulanoP3.pdf"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data["Exercicio"][] = array("E1", "-", "fulanoE1.pdf.pdf"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data["Exercicio"][] = array("E2", "-", "fulanoE2.pdf.pdf"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data["teste"][] = array("E1", "-", "fulanoE1.pdf.pdf"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// $data["teste"][] = array("E2", "-", "fulanoE2.pdf.pdf"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 $data = feedback::get_comments($cm->id, $id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-$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) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+if (has_capability('mod/gradeimporter:edit', $context)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  //loads teacher view 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $cell->colspan = 5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  //loads student view 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $table = new html_table(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $table->attributes['class'] = 'generaltable mod_index'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $table->head  = array ("Tipo", "Nome", "Nota", "Comentários", "Arquivos"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $table->align = array ('center', '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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          $row->cells[] = $cell; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $table->data[] = $row; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 echo html_writer::table($table); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /// Finish the page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 echo $output->footer(); 
			 |