|  | @@ -40,31 +40,41 @@ function get_comments($cmid, $id){
 | 
												
													
														
															|  |    return $data;
 |  |    return $data;
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |  function get_teacher_view($cmid, $gradeimporterid, $enrolledusers){
 |  |  function get_teacher_view($cmid, $gradeimporterid, $enrolledusers){
 | 
												
													
														
															|  |    global $DB, $CFG;
 |  |    global $DB, $CFG;
 | 
												
													
														
															|  |    
 |  |    
 | 
												
													
														
															|  |    $tp = $CFG->prefix; // gets moodle tables prefix, not everyone uses mdl_
 |  |    $tp = $CFG->prefix; // gets moodle tables prefix, not everyone uses mdl_
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |    $table = new html_table();
 |  |    $table = new html_table();
 | 
												
													
														
															|  | -  $table->attributes['class'] = 'generaltable mod_index';
 |  | 
 | 
												
													
														
															|  | -  $table->align = array();
 |  | 
 | 
												
													
														
															|  | 
 |  | +  $table->align = array('center');
 | 
												
													
														
															|  | 
 |  | +  $table->attributes = array('class'=>'generaltable mod_index');
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |    //creates table head
 |  |    //creates table head
 | 
												
													
														
															|  | -  /*$subrow = new html_table_row();
 |  | 
 | 
												
													
														
															|  | -  $subrow->cells[] = new html_table_cell(get_string('nameCol', 'gradeimporter'));
 |  | 
 | 
												
													
														
															|  | -*/
 |  | 
 | 
												
													
														
															|  | - $subrow = array(get_string('nameCol', 'gradeimporter'));
 |  | 
 | 
												
													
														
															|  | - $table->align[] = 'center';
 |  | 
 | 
												
													
														
															|  | 
 |  | +  $subrow = new html_table_row();
 | 
												
													
														
															|  | 
 |  | +  
 | 
												
													
														
															|  | 
 |  | +  $cell = new html_table_cell(get_string('nameCol', 'gradeimporter'));
 | 
												
													
														
															|  | 
 |  | +  $cell->style = "border:1px solid black";
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +  $cell->colspan = 1;
 | 
												
													
														
															|  | 
 |  | +  $subrow->cells[] = $cell;
 | 
												
													
														
															|  |    $submissionsSQL = "SELECT id, name 
 |  |    $submissionsSQL = "SELECT id, name 
 | 
												
													
														
															|  | -                      FROM mdl_gradeimporter_submission 
 |  | 
 | 
												
													
														
															|  | -                      WHERE gradeimporterid = 1
 |  | 
 | 
												
													
														
															|  | 
 |  | +                      FROM ".$tp."gradeimporter_submission 
 | 
												
													
														
															|  | 
 |  | +                      WHERE gradeimporterid = $gradeimporterid
 | 
												
													
														
															|  |                        ORDER BY id";
 |  |                        ORDER BY id";
 | 
												
													
														
															|  |    $submissions = $DB->get_records_sql($submissionsSQL);
 |  |    $submissions = $DB->get_records_sql($submissionsSQL);
 | 
												
													
														
															|  |    foreach ($submissions as $submission){
 |  |    foreach ($submissions as $submission){
 | 
												
													
														
															|  | -    $subrow[] = $submission->name;
 |  | 
 | 
												
													
														
															|  | 
 |  | +    $subname = editSub($submission->name, $gradeimporterid, $cmid, $submission->id);
 | 
												
													
														
															|  | 
 |  | +    $cell = new html_table_cell($subname);
 | 
												
													
														
															|  | 
 |  | +    $cell->colspan = 2;
 | 
												
													
														
															|  | 
 |  | +    $cell->style = "border:1px solid black";
 | 
												
													
														
															|  | 
 |  | +    $subrow->cells[] = $cell;
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    //adds 2 align, one for grade and another to the file
 | 
												
													
														
															|  | 
 |  | +    $table->align[] = 'center';
 | 
												
													
														
															|  |      $table->align[] = 'center';
 |  |      $table->align[] = 'center';
 | 
												
													
														
															|  |    }
 |  |    }
 | 
												
													
														
															|  | -  $table->head = $subrow;
 |  | 
 | 
												
													
														
															|  | 
 |  | +  $table->data[] = $subrow;
 | 
												
													
														
															|  |    
 |  |    
 | 
												
													
														
															|  |    //all submissions names are on the table
 |  |    //all submissions names are on the table
 | 
												
													
														
															|  |    
 |  |    
 | 
												
											
												
													
														
															|  | @@ -96,10 +106,9 @@ function get_teacher_view($cmid, $gradeimporterid, $enrolledusers){
 | 
												
													
														
															|  |    foreach ($enrolledusers as $user){
 |  |    foreach ($enrolledusers as $user){
 | 
												
													
														
															|  |      $usersList[$user->id] = array('name'=>$user->firstname." ".$user->lastname);
 |  |      $usersList[$user->id] = array('name'=>$user->firstname." ".$user->lastname);
 | 
												
													
														
															|  |    }
 |  |    }
 | 
												
													
														
															|  | -  ksort($usersList);
 |  | 
 | 
												
													
														
															|  | 
 |  | +  //ksort($usersList);
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |    foreach ($records as $record){
 |  |    foreach ($records as $record){
 | 
												
													
														
															|  | -    echo "passou userid $record->gf_studentid  fileid $record->gf_fileid <br>";
 |  | 
 | 
												
													
														
															|  |      $url = buildurl($cmid, $record->gf_id, $record->gf_name);
 |  |      $url = buildurl($cmid, $record->gf_id, $record->gf_name);
 | 
												
													
														
															|  |      $usersList[$record->gf_studentid][$record->gs_id] = array('grade'=>$record->gf_grade, 'file'=>$url);
 |  |      $usersList[$record->gf_studentid][$record->gs_id] = array('grade'=>$record->gf_grade, 'file'=>$url);
 | 
												
													
														
															|  |    }
 |  |    }
 | 
												
											
												
													
														
															|  | @@ -107,6 +116,7 @@ function get_teacher_view($cmid, $gradeimporterid, $enrolledusers){
 | 
												
													
														
															|  |    foreach($usersList as $user){
 |  |    foreach($usersList as $user){
 | 
												
													
														
															|  |      $row = new html_table_row();
 |  |      $row = new html_table_row();
 | 
												
													
														
															|  |      $cell = new html_table_cell($user['name']);
 |  |      $cell = new html_table_cell($user['name']);
 | 
												
													
														
															|  | 
 |  | +    $cell->style = "border:1px solid black";
 | 
												
													
														
															|  |      $row->cells[] = $cell;
 |  |      $row->cells[] = $cell;
 | 
												
													
														
															|  |      foreach ($submissions as $submission){
 |  |      foreach ($submissions as $submission){
 | 
												
													
														
															|  |        if (array_key_exists($submission->id, $user)){
 |  |        if (array_key_exists($submission->id, $user)){
 | 
												
											
												
													
														
															|  | @@ -117,35 +127,15 @@ function get_teacher_view($cmid, $gradeimporterid, $enrolledusers){
 | 
												
													
														
															|  |          $grade = '-';
 |  |          $grade = '-';
 | 
												
													
														
															|  |        }
 |  |        }
 | 
												
													
														
															|  |        $cell = new html_table_cell ($grade);
 |  |        $cell = new html_table_cell ($grade);
 | 
												
													
														
															|  | 
 |  | +      $cell->style = "border:1px solid black; border-right:0";
 | 
												
													
														
															|  |        $row->cells[] = $cell;
 |  |        $row->cells[] = $cell;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |        $cell = new html_table_cell ($url);
 |  |        $cell = new html_table_cell ($url);
 | 
												
													
														
															|  | 
 |  | +      $cell->style = "border:1px solid black; border-left:0";
 | 
												
													
														
															|  |        $row->cells[] = $cell;
 |  |        $row->cells[] = $cell;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |      $table->data[] = $row;
 |  |      $table->data[] = $row;
 | 
												
													
														
															|  |    }
 |  |    }
 | 
												
													
														
															|  | -  
 |  | 
 | 
												
													
														
															|  | -  //gets all submission types relative to the gradeimporter instance
 |  | 
 | 
												
													
														
															|  | -  /*$subtype_array = $DB->get_records("gradeimporter_submissiontype", array('gradeimporterid' => $gradeimporterid), 'id', '*');
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -  foreach ($subtype_array as $subtype) {
 |  | 
 | 
												
													
														
															|  | -    //gets all submissions from a subtype;
 |  | 
 | 
												
													
														
															|  | -    $submission_array = $DB->get_records("gradeimporter_submission", array('type' => $subtype->id), 'id', '*');
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -    foreach ($submission_array as $submission) {
 |  | 
 | 
												
													
														
															|  | -      //gets all feedbacks from a submission
 |  | 
 | 
												
													
														
															|  | -      $feedback_array = $DB->get_records("gradeimporter_feedback", array('submissionid' => $submission->id), 'id', '*');
 |  | 
 | 
												
													
														
															|  | -      $cell = new html_table_cell($submission->name);
 |  | 
 | 
												
													
														
															|  | -      $cell->colspan = 2;
 |  | 
 | 
												
													
														
															|  | -      $subrow->cells[] = $cell;
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -      foreach ($feedback_array as $feedback) {
 |  | 
 | 
												
													
														
															|  | -          //for each feedback add it to the correspondent user list in $enrolledusers
 |  | 
 | 
												
													
														
															|  | -      }
 |  | 
 | 
												
													
														
															|  | -    }
 |  | 
 | 
												
													
														
															|  | -    $table->data[] = $subrow;
 |  | 
 | 
												
													
														
															|  | -  }*/
 |  | 
 | 
												
													
														
															|  | -  
 |  | 
 | 
												
													
														
															|  |    echo html_writer::table($table);
 |  |    echo html_writer::table($table);
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
											
												
													
														
															|  | @@ -157,7 +147,12 @@ require_once("$CFG->libdir/csvlib.class.php");
 | 
												
													
														
															|  |  function buildurl($cmid, $fileid, $filename){
 |  |  function buildurl($cmid, $fileid, $filename){
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |    $fileurl = new moodle_url("/mod/gradeimporter/view.php", array('id' => $cmid, 'fileid' => $fileid, 'filename' => $filename, 'action' => 1));
 |  |    $fileurl = new moodle_url("/mod/gradeimporter/view.php", array('id' => $cmid, 'fileid' => $fileid, 'filename' => $filename, 'action' => 1));
 | 
												
													
														
															|  | -  return "<a href=$fileurl> $filename</a>";
 |  | 
 | 
												
													
														
															|  | 
 |  | +  return "<a href=$fileurl target=_blank> $filename</a>";
 | 
												
													
														
															|  | 
 |  | +}
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +function editSub($subname, $gradeimporterid, $cmid, $subid){
 | 
												
													
														
															|  | 
 |  | +  $url = new moodle_url("/mod/gradeimporter/submission.php", array('id'=>$gradeimporterid, 'cmid'=>$cmid, 'subid'=>$subid, 'update'=>1));
 | 
												
													
														
															|  | 
 |  | +  return $subname.'<a href='.$url.' target="_blank"><i class="icon fa fa-pencil fa-fw"  title="'.get_string('editSub','gradeimporter').'" aria-label="'.get_string('editSub','gradeimporter').'"></i>';
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |  function exportCSV($context){
 |  |  function exportCSV($context){
 |