Explorar el Código

Implemented table iassign_submission_trace

Igor hace 4 años
padre
commit
037d8019ce
Se han modificado 3 ficheros con 261 adiciones y 9 borrados
  1. 22 2
      db/install.xml
  2. 1 1
      ilm_handlers/html5.php
  3. 238 6
      locallib.php

+ 22 - 2
db/install.xml

@@ -121,7 +121,7 @@
                 <KEY NAME="iassign_ilmid" TYPE="foreign" FIELDS="iassign_ilmid" REFTABLE="iassign_ilm" REFFIELDS="id" PREVIOUS="iassignid"/>
             </KEYS>
         </TABLE>
-        <TABLE NAME="iassign_submission" COMMENT="Info about submissions of interactive activities" PREVIOUS="iassign_statement" NEXT="iassign_submission_comment">
+        <TABLE NAME="iassign_submission" COMMENT="Info about submissions of interactive activities" PREVIOUS="iassign_statement" NEXT="iassign_submission_trace">
             <FIELDS>
                 <FIELD NAME="id"                  TYPE="int"  LENGTH="10"  NOTNULL="true" UNSIGNED="true"              SEQUENCE="true"   ENUM="false" COMMENT="Primary key of table"                                                                                                              NEXT="iassign_statementid"/>
                 <FIELD NAME="iassign_statementid" TYPE="int"  LENGTH="10"  NOTNULL="true" UNSIGNED="true"  DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="id interactive activity"                                                                            PREVIOUS="id"                  NEXT="userid"/>
@@ -142,7 +142,27 @@
                 <INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
             </INDEXES>
         </TABLE>
-        <TABLE NAME="iassign_submission_comment" COMMENT="Comments of interactive activities" PREVIOUS="iassign_submission" NEXT="iassign_security">
+        <TABLE NAME="iassign_submission_trace" COMMENT="Trace about submissions of interactive activities" PREVIOUS="iassign_submission" NEXT="iassign_submission_comment">
+            <FIELDS>
+                <FIELD NAME="id"                  TYPE="int"  LENGTH="10"  NOTNULL="true" UNSIGNED="true"              SEQUENCE="true"   ENUM="false" COMMENT="Primary key of table"                                                                                                              NEXT="iassign_statementid"/>
+                <FIELD NAME="iassign_statementid" TYPE="int"  LENGTH="10"  NOTNULL="true" UNSIGNED="true"  DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="id interactive activity"                                                                            PREVIOUS="id"                  NEXT="userid"/>
+                <FIELD NAME="userid"              TYPE="int"  LENGTH="10"  NOTNULL="true" UNSIGNED="true"  DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="id of submitting author"                                                                            PREVIOUS="iassign_statementid" NEXT="timecreated"/>
+                <FIELD NAME="timecreated"         TYPE="int"  LENGTH="10"  NOTNULL="true" UNSIGNED="true"  DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="Date of first submission"                                                                           PREVIOUS="userid"              NEXT="grade"/>
+                <FIELD NAME="grade"               TYPE="float"             NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="Grade of evaluation"                                                                                PREVIOUS="timecreated"         NEXT="teacher"/>
+                <FIELD NAME="teacher"             TYPE="int"  LENGTH="10"  NOTNULL="true" UNSIGNED="true"  DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="id teacher"                                                                                         PREVIOUS="grade"               NEXT="answer"/>
+                <FIELD NAME="answer"              TYPE="text" LENGTH="big" NOTNULL="true"                              SEQUENCE="false"  ENUM="false" COMMENT="String with the last solution sent by the student"                                                  PREVIOUS="teacher"             NEXT="experiment"/>
+                <FIELD NAME="experiment"          TYPE="int"  LENGTH="1"   NOTNULL="true" UNSIGNED="true"  DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="Total  of submissions"                                                                              PREVIOUS="answer"              NEXT="status"/>
+                <FIELD NAME="status"              TYPE="int"  LENGTH="1"   NOTNULL="true" UNSIGNED="true"  DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="Status of activities. 0-not submitted/1-submitted/2-evaluated as incorrect/3-evaluated as correct"  PREVIOUS="experiment"/>
+            </FIELDS>
+            <KEYS>
+                <KEY NAME="primary"             TYPE="primary" FIELDS="id" NEXT="iassign_statementid"/>
+                <KEY NAME="iassign_statementid" TYPE="foreign" FIELDS="iassign_statementid" REFTABLE="iassign_statement" REFFIELDS="id" PREVIOUS="primary"/>
+            </KEYS>
+            <INDEXES>
+                <INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
+            </INDEXES>
+        </TABLE>
+        <TABLE NAME="iassign_submission_comment" COMMENT="Comments of interactive activities" PREVIOUS="iassign_submission_trace" NEXT="iassign_security">
             <FIELDS>
                 <FIELD NAME="id"                    TYPE="int"  LENGTH="10"   NOTNULL="true" UNSIGNED="true"             SEQUENCE="true"   ENUM="false" COMMENT="Primary key of table"                                                            NEXT="iassign_submissionid"/>
                 <FIELD NAME="iassign_submissionid"  TYPE="int"  LENGTH="10"   NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false"  ENUM="false" COMMENT="id submission comment"                          PREVIOUS="id"                    NEXT="comment_authorid"/>

+ 1 - 1
ilm_handlers/html5.php

@@ -135,6 +135,7 @@ class html5 implements ilm_handle {
           $parameters = ' style="width: ' . $iassign_ilm_width . 'px; height: ' . $iassign_ilm_height . 'px;" ';
 
           $html .= '<iframe frameborder="0" name="iLM" src="' . $iassign_ilm->file_jar . $iassign_ilm->file_class . $paramsStr . '" ' . $parameters . ' id="iLM">' . "\n";
+          //$html .= '<iframe frameborder="0" name="iLM" src="' . $iassign_ilm->file_jar . $iassign_ilm->file_class . $paramsStr . '&iLM_PARAM_TeacherAutoEval=algumacoisa.php" ' . $parameters . ' id="iLM">' . "\n";          
           $html .= '</iframe>' . "\n";
 
         } // if (!empty($file_url))
@@ -174,7 +175,6 @@ class html5 implements ilm_handle {
   /// Exibe a atividade no iLM
   //  @calledby locallib.php : view_iLM(...)
   public static function show_activity_in_ilm ($iassign_statement_activity_item, $student_answer, $enderecoPOST, $view_teacherfileversion) {
-
     global $USER, $CFG, $COURSE, $DB, $OUTPUT;
 
     $special_param1 = $iassign_statement_activity_item->special_param1;

+ 238 - 6
locallib.php

@@ -321,16 +321,248 @@ class iassign {
   /// This method runs activities auto evaluation in teacher area
   function auto_evaluate () {
 
-    global $COURSE, $CFG, $USER, $DB, $OUTPUT;
+    global $USER;
 
     if (!has_capability('mod/iassign:runautoevaluate',  $USER->context, $USER->id))
       exit;
 
-    print $OUTPUT->header();
-    
-    print $OUTPUT->footer();
+    global $CFG, $DB, $OUTPUT;
+    $id = $this->cm->id;
+    $iassign_list = $DB->get_records_list('iassign_statement', 'iassignid', array('iassignid' => $this->iassign->id), "position ASC");
 
-  }
+    if ($this->action != 'print') {
+      $title = get_string('report', 'iassign');
+      print $OUTPUT->header();
+      } // if ($this->action != 'print')
+
+    if ($this->action == 'print')
+      print '<table border=1 width="100%">' . "\n";
+    else
+      print '<table id="outlinetable" class="generaltable boxaligncenter" cellpadding="5" width="100%">' . "\n";
+    print '<tr><th colspan=2 class="header c1">' . iassign_utils::remove_code_message($this->iassign->name) . '</th></tr>' . "\n";
+    // $num = array();
+    $i = 1;
+    $num = array();
+
+    foreach ($iassign_list as $iassign) {
+      $test_exercise = "";
+      $iassign_submission = $DB->get_records("iassign_submission", array("iassign_statementid" => $iassign->id));
+      if (($iassign_submission) && $iassign->type_iassign < 3) {
+        $test_exercise = "&nbsp;<b>(" . get_string('iassign_exercise', 'iassign') . ")</b>";
+        } // if (($iassign_submission) && $iassign->type_iassign < 3)
+      if ($iassign->type_iassign == 3 || ($iassign_submission)) {
+        $num[$i] = new stdClass();
+        $num[$i]->name = $iassign->name;
+        $num[$i]->id = $i;
+        $num[$i]->iassignid = $iassign->id;
+        print ' <tr >' . "\n";
+        print "  <td class=\"cell c1 numviews\" width=5% align='center'><strong>" . $num[$i]->id . "</strong></td>\n";
+        print "<td class=\"cell c0 actvity\">";
+        print '&nbsp;' . $num[$i]->name . '&nbsp;' . $test_exercise . "</td>";
+        print ' </tr>' . "\n";
+        $i ++;
+        } // if ($iassign->type_iassign == 3 || ($iassign_submission))
+      } // foreach ($iassign_list as $iassign)
+    print "</table>";
+    print "<p></p>";
+    if ($this->action == 'print')
+      print '<table border=1 width="100%">' . "\n";
+    else
+      print '<table id="outlinetable" class="generaltable boxaligncenter" cellpadding="5" width="100%">' . "\n";
+    $context = context_course::instance($this->course->id);
+    if ($i > 1) {
+
+      // $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {$CFG->prefix}role s WHERE s.shortname = 'student'");
+      $params = array('shortname' => 'student');
+      $role = $DB->get_record_sql(
+        "SELECT s.id, s.shortname FROM {role} s " .
+        " WHERE s.shortname = :shortname", $params);
+
+      // $students = $DB->get_records_sql("SELECT s.userid, a.firstname, a.lastname FROM {$CFG->prefix}role_assignments s, {$CFG->prefix}user a WHERE s.contextid = '$context->id' AND s.userid = a.id AND s.roleid = '$role->id' ORDER BY a.firstname ASC,a.lastname ASC");
+      $params = array('contextid' => $context->id, 'roleid' => $role->id);
+      $students = $DB->get_records_sql(
+        "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .
+        " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " .
+        " ORDER BY a.firstname ASC,a.lastname ASC", $params);
+
+      print '<tr><th class="header c1">' . get_string('students', 'iassign') . '</th>' . "\n";
+      for ($j = 1; $j < $i; $j ++) {
+        $sum_iassign_correct[$j] = 0;
+        print '<th class="header c1" scope="col">' . $num[$j]->id . '</th>' . "\n"; // <th class="header c1" scope="col">
+        }
+      $sum_iassign = $j - 1;
+      print '</tr>' . "\n";
+      $total = 0;
+      $sum_student = 0;
+      $sum_correct_iassign = array();
+      $sum_correct_student = array();
+
+      $USER->matrix_iassign = array();
+      if ($students) {
+        $w = 0;
+        foreach ($students as $tmp) {
+          $users_array[$w] = $tmp;
+          $w ++;
+          }
+
+        for ($x = 0; $x < $w; $x ++) {
+          print '<tr>' . "\n";
+          $sum_student ++;
+          $name = $users_array[$x]->firstname . '&nbsp;' . $users_array[$x]->lastname;
+          print '  <td >' . $name . '</td>' . "\n";
+          $total_student = 0;
+          $tentativas = 0;
+
+          for ($j = 1; $j < $i; $j ++) {
+
+            $student_submissions = $DB->get_record("iassign_submission", array('iassign_statementid' => $num[$j]->iassignid, 'userid' => $users_array[$x]->userid));
+
+            if ($student_submissions) {
+              $last_solution_submission = " title=\"" . userdate($student_submissions->timemodified) . "\" "; // timemodified: time of the last student solution
+              $tentativas = $student_submissions->experiment;
+
+              // informations to previous activities
+              if ($j - 1 < 1 || $j == $i)
+                $iassign_previous = "-1";
+              else
+                $iassign_previous = $num[$j - 1]->iassignid;
+
+              if ($x - 1 < 0 || $x == $w)
+                $user_previous = "-1";
+              else
+                $user_previous = $users_array[$x - 1]->userid;
+
+              // next
+              if ($i - 1 > $j)
+                $iassign_next = $num[$j + 1]->iassignid;
+              else
+                $iassign_next = "-1";
+
+              if ($w - 1 > $x)
+                $user_next = $users_array[$x + 1]->userid;
+              else
+                $user_next = "-1";
+
+              $position = "&row= $x&column=$j";
+
+              $url = "" . $CFG->wwwroot . "/mod/iassign/view.php?action=viewsubmission&id=" . $id . "&iassign_submission_current=" . $student_submissions->id .
+                "&userid_iassign=" . $users_array[$x]->userid . "&iassign_current=" . $num[$j]->iassignid . "&view_iassign=" . $this->view_iassign;
+              $url .= $position;
+
+              // receiver=1 - message to teacher
+              // receiver=2 - message to student
+              // $verify_message = $DB->get_record_sql("SELECT COUNT(iassign_submissionid) FROM {$CFG->prefix}ia_assign_submissions_comment " .
+              // "WHERE iassign_submissionid = '$student_submissions->id' AND return_status='0' AND receiver='1'");
+
+              $params = array('iassign_submissionid' => $student_submissions->id, 'return_status' => '0', 'receiver' => '1');
+              
+              if ($student_submissions->status == 3) {
+                  $sum_iassign_correct[$j] ++;
+                  $total_student ++;
+                  $feedback = iassign_icons::insert('correct');
+                }
+              elseif ($student_submissions->status == 2) {
+                  $feedback = iassign_icons::insert('incorrect');
+                }
+              elseif ($student_submissions->status == 1) {
+                  $feedback = iassign_icons::insert('post');
+                }
+              elseif ($student_submissions->status == 0) {
+                  $feedback = iassign_icons::insert('not_post');
+                }
+
+              if ($this->action != 'print') {
+                if ($tentativas > 0)
+                  print '<td> <a href="' . $url . '" ' . $last_solution_submission . '>' . $feedback . '</a> &nbsp;(' . $tentativas . ')</td>' . "\n";
+                else
+                  print '<td> <a href="' . $url . '" ' . $last_solution_submission . '>' . $feedback . '</a> </td>' . "\n";
+                }
+
+              if ($this->action == 'print')
+                  print $feedback . '&nbsp;(' . $tentativas . ')<br>' . $comment . '&nbsp;(' . $sum_comment . ')&nbsp;' . "\n";
+
+              } // if ($student_submissions)
+            else { // if ($student_submissions)
+
+              // informations to browse previous activities
+              if ($j - 1 < 1 || $j == $i)
+                $iassign_previous = "-1";
+              else
+                $iassign_previous = $num[$j - 1]->iassignid;
+
+              if ($x - 1 < 0 || $x == $w)
+                $user_previous = "-1";
+              else
+                $user_previous = $users_array[$x - 1]->userid;
+
+              // next
+              if ($i - 1 > $j)
+                $iassign_next = $num[$j + 1]->iassignid;
+              else
+                $iassign_next = "-1";
+
+              if ($w - 1 > $x)
+                $user_next = $users_array[$x + 1]->userid;
+              else
+                $user_next = "-1";
+
+              $position = "&row= $x&column=$j";
+
+              $url = $CFG->wwwroot . "/mod/iassign/view.php?action=viewsubmission&id=" . $id . "&userid_iassign=" . $users_array[$x]->userid .
+                "&iassign_current=" . $num[$j]->iassignid . "&view_iassign=" . $this->view_iassign;
+              $url .= $position;
+              $feedback = iassign_icons::insert('not_post');
+              if ($this->action == 'print')
+                print $feedback . '&nbsp;(0)<br>' . $comment . '&nbsp;(' . $sum_comment . ')&nbsp;' . "\n";
+              else {
+                print '<td> <a href="' . $url . '">' . $feedback . '</a> </td>' . "\n";
+                }
+              } // else if ($student_submissions)
+            $USER->matrix_iassign[$x][$j] = new stdClass();
+            $USER->matrix_iassign[$x][$j]->iassign_previous = $iassign_previous;
+            $USER->matrix_iassign[$x][$j]->user_previous = $user_previous;
+            $USER->matrix_iassign[$x][$j]->iassign_next = $iassign_next;
+            $USER->matrix_iassign[$x][$j]->user_next = $user_next;
+
+            if ($student_submissions)
+                $USER->matrix_iassign[$x][$j]->iassign_submission_current = $student_submissions->id;
+            else
+                $USER->matrix_iassign[$x][$j]->iassign_submission_current = 0;
+            print '</td>' . "\n";
+            } // for ($j=1; $j<$i; $j++)
+
+          $total = $total + $total_student;
+          $porcentagem = ($total_student / ($j - 1)) * 100;
+
+          
+
+          print '</tr>' . "\n";
+          $sum_correct_student[$sum_student] = new stdClass();
+          $sum_correct_student[$sum_student]->name = $name;
+          $sum_correct_student[$sum_student]->sum = $total_student;
+          } // for ($x = 0; $x < $w; $x ++)
+
+        for ($i = 1; $i < $j; $i ++) {
+          if (is_null($sum_iassign_correct[$i]))
+            $sum_iassign_correct[$i] = 0;
+
+          $sum_correct_iassign[$i] = new stdClass();
+          $sum_correct_iassign[$i]->sum = $sum_iassign_correct[$i];
+          $sum_correct_iassign[$i]->name = $num[$i]->name;
+          }
+        // print '</tr></table>' . "\n";
+        }
+      } // if ($i>1)
+    else {
+      print_string('no_activity', 'iassign');
+      }
+    print "</table>\n";
+
+    if ($this->action != 'print')
+      print $OUTPUT->footer();
+    die();
+
+  } // auto_evaluate
 
   /// This method moves an iAssign activity
   function move_activity () {
@@ -1328,7 +1560,7 @@ class iassign {
       print '</td>' . "\n";
       if ($this->action != 'print') {
         $link_print = "<a href='" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=print&iassignid=" . $this->iassign->id . "'>" . iassign_icons::insert('print') . '&nbsp;' . get_string('print', 'iassign') . "</a>";
-        //$link_stats = "<a href='" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=stats&iassignid=" . $this->iassign->id . "'>" . iassign_icons::insert('results') . '&nbsp;' . get_string('graphic', 'iassign') . "</a>";
+        $link_stats = "<a href='" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=stats&iassignid=" . $this->iassign->id . "'>" . iassign_icons::insert('results') . '&nbsp;' . get_string('graphic', 'iassign') . "</a>";
         $link_export = "<a href='" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=export_csv&iassignid=" . $this->iassign->id . "'>" . iassign_icons::insert('export_ilm') . '&nbsp;' . get_string('export_csv', 'iassign') . "</a>";
         $link_auto_evaluate = "<a href='" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=auto_evaluate&iassignid=" . $this->iassign->id . "'>" . iassign_icons::insert('correct') . '&nbsp;' . get_string('auto_evaluate_reprocess', 'iassign') . "</a>";
         print '<td width=15% align="right">' . $link_stats . '</td>' . "\n";