|
@@ -186,8 +186,10 @@ class iassign {
|
|
|
else if (!$this->iassign = $DB->get_record('iassign', array('id' => $this->cm->instance))) {
|
|
|
print_error('invalidid', 'iassign');
|
|
|
}
|
|
|
+
|
|
|
$USER->context = context_module::instance($this->cm->id);
|
|
|
$USER->cm = $this->cm->id;
|
|
|
+
|
|
|
$this->iassign->cmidnumber = $this->cm->idnumber; // compatibility with modedit ia obj
|
|
|
$this->iassign->courseid = $this->course->id; // compatibility with modedit ia obj
|
|
|
$this->context = context_module::instance($this->cm->id);
|
|
@@ -284,8 +286,9 @@ class iassign {
|
|
|
'stats' => '$this->stats();',
|
|
|
'printstats' => '$this->stats();');
|
|
|
|
|
|
- $restricted = array('up' => '$this->activity->move_iassign($this->iassign_up,$this->return);',
|
|
|
- 'down' => '$this->activity->move_iassign($this->iassign_down,$this->return);',
|
|
|
+ $restricted = array('firstdown' => '$this->activity->move_iassign("firstdown", $this->iassign_down, $this->return);',
|
|
|
+ 'up' => '$this->activity->move_iassign("up", $this->iassign_up, $this->return);',
|
|
|
+ 'down' => '$this->activity->move_iassign("down", $this->iassign_down, $this->return);',
|
|
|
'visible' => '$this->activity->visible_iassign($this->return);',
|
|
|
'delete' => '$this->activity->delete($this->return);',
|
|
|
'deleteno' => '$this->return_home_course("confirm_not_delete_iassign");',
|
|
@@ -307,7 +310,7 @@ class iassign {
|
|
|
elseif (has_capability('mod/iassign:evaluateiassign', $this->context, $USER->id)) {
|
|
|
eval($action_iassign_limit[$this->action]);
|
|
|
}
|
|
|
- else {
|
|
|
+ else { // Student reaches this point
|
|
|
// When student do/redo activity: do => action = "view"; redo => action = "repeat"
|
|
|
// Arrive here with: "get_answer"; "view"
|
|
|
eval($action_iassign[$this->action]); // Now load 'view_iassign_current()' with 'view'
|
|
@@ -1374,6 +1377,9 @@ class iassign {
|
|
|
global $USER, $CFG, $COURSE, $DB, $OUTPUT;
|
|
|
$id = $this->cm->id;
|
|
|
$iassignid = $this->iassign->id;
|
|
|
+
|
|
|
+ $only_one_send_button = 0; // to avoid to put 2 copies of comments (area to send and see comments between teacher and student)
|
|
|
+
|
|
|
$iassign = $DB->get_record("iassign", array("id" => $iassignid)); // from table '*_iassign': id course name intro introformat activity_group grade timeavailable timedue preventlate test max_experiment
|
|
|
|
|
|
// Get data of current activity : table '*_iassign_statement' = id name iassignid type_iassign proposition author_name author_modified_name iassign_ilmid file grade timemodified timecreated ...
|
|
@@ -1408,7 +1414,7 @@ class iassign {
|
|
|
} else {
|
|
|
$iassign_submission = $DB->get_record("iassign_submission", array("iassign_statementid" => $this->activity->get_activity()->id, "userid" => $this->userid_iassign)); // data about student solution
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ($iassign_submission)
|
|
|
$this->update_comment($iassign_submission->id);
|
|
|
|
|
@@ -1430,6 +1436,7 @@ class iassign {
|
|
|
// *** Teacher access (view learner's submission)
|
|
|
if (($this->action != 'viewsubmission') && has_capability('mod/iassign:evaluateiassign', $USER->context, $USER->id)) {
|
|
|
//TODO leo Verificar se o correto eh '$this->context' ou '$USER->context' como deixei
|
|
|
+
|
|
|
// It is not 'viewsubmission' and it is teacher or 'non editing teacher'?
|
|
|
// ---> access teacher for test
|
|
|
|
|
@@ -1655,42 +1662,18 @@ class iassign {
|
|
|
|
|
|
print $OUTPUT->box('<p><strong>' . $last_iassign . '</strong></p>' . "\n");
|
|
|
|
|
|
- if (!$enderecoPOST) $enderecoPOST = "";
|
|
|
+ if (!isset($enderecoPOST)) $enderecoPOST = "";
|
|
|
// Prepare tags to present the iLM
|
|
|
print $OUTPUT->box($ilm->view_iLM($iassign_statement_activity_item, $student_answer, $enderecoPOST, $loadTeacherActivity));
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ($iassign_statement_activity_item->type_iassign == 3) { // type_iassign=3 => activity of type "exercise" - submit button and automatic evaluation
|
|
|
- $output = '';
|
|
|
- $history_comment = '';
|
|
|
- if ($iassign_submission) {
|
|
|
- $enderecoPOSTcomment = "" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=newcomment&iassign_current=" . $this->activity->get_activity()->id .
|
|
|
- "&iassign_submission_current=" . $iassign_submission->id . "&userid_iassign=" . $this->userid_iassign . "&row=" . ($row) . "&column=" . ($column);
|
|
|
- $history_comment = $this->search_comment_submission($iassign_submission->id);
|
|
|
- }
|
|
|
- else {
|
|
|
- $enderecoPOSTcomment = "" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=newcomment&iassign_current=" . $this->activity->get_activity()->id .
|
|
|
- "&userid_iassign=" . $this->userid_iassign . "&row=" . ($row) . "&column=" . ($column);
|
|
|
- }
|
|
|
-
|
|
|
- $output .= $OUTPUT->box_start();
|
|
|
-
|
|
|
- $output .= "<center><form name='formEnvioComment' id='formEnvioComment1' method='post' action='$enderecoPOSTcomment' enctype='multipart/form-data'>\n";
|
|
|
- $output .= "<p><textarea rows='2' cols='60' name='submission_comment'></textarea></p>\n";
|
|
|
- $output .= "<p><input type=submit value='" . get_string('submit_comment', 'iassign') . "'\></p>\n";
|
|
|
- $output .= "</form></center>\n";
|
|
|
- if (!empty($history_comment)) {
|
|
|
- $output .= " <table id='outlinetable' class='generaltable boxaligncenter' cellpadding='5' width='100%'> \n";
|
|
|
- $output .= " <tr><th>" . get_string('history_comments', 'iassign') . "</th></tr>";
|
|
|
- $output .= $history_comment;
|
|
|
- $output .= "</table>";
|
|
|
- }
|
|
|
- $output .= $OUTPUT->box_end();
|
|
|
+ //2020 Eliminei daqui o codigo para colocar o quadro com area para enivar e ler comentarios
|
|
|
+ //2020 Estava subordinado ao: elseif (($this->action == 'viewsubmission') && has_capability('mod/iassign:evaluateiassign', $USER->context, $USER->id))
|
|
|
+ //2020 e com isso NAO permitia aluno ter o quadro para envio!
|
|
|
+ //2020 Foi para final dessa funcao 'view_iassign_current()'
|
|
|
|
|
|
- print $output;
|
|
|
- } // if ($iassign_statement_activity_item->type_iassign == 3)
|
|
|
- } // elseif (($this->action == 'viewsubmission')
|
|
|
+ } // elseif (($this->action == 'viewsubmission') && has_capability('mod/iassign:evaluateiassign', $USER->context, $USER->id))
|
|
|
// *** (end) Teacher access (view learner's submission to the activity)
|
|
|
|
|
|
// *** Student access (view the activity)
|
|
@@ -1976,6 +1959,9 @@ class iassign {
|
|
|
$output .= "</form></center>\n";
|
|
|
$output .= $OUTPUT->box_end();
|
|
|
print $output;
|
|
|
+
|
|
|
+ $only_one_send_button = 1; // avoid put comment frame again (bellow)
|
|
|
+
|
|
|
} else { // if ($iassign_statement_activity_item->type_iassign == 3)
|
|
|
$output .= $OUTPUT->box_end();
|
|
|
print $output;
|
|
@@ -2004,6 +1990,40 @@ class iassign {
|
|
|
print $output;
|
|
|
}
|
|
|
|
|
|
+ //2020 Quadro com area para enivar e ler comentarios veio para este ponto para permitir todos o terem
|
|
|
+ // $only_one_send_button is to avoid to put 2 copies of comments (area to send and see comments between teacher and student)
|
|
|
+ if ($only_one_send_button==0 && $iassign_statement_activity_item->type_iassign == 3) { // type_iassign=3 => activity of type "exercise" - submit button and automatic evaluation
|
|
|
+ // Put a block with area to sent/answer comments
|
|
|
+ $output = '';
|
|
|
+ $history_comment = '';
|
|
|
+ $row = optional_param('row', 0, PARAM_INT);
|
|
|
+ $column = optional_param('column', 0, PARAM_INT);
|
|
|
+ if ($iassign_submission) {
|
|
|
+ $enderecoPOSTcomment = "" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=newcomment&iassign_current=" . $this->activity->get_activity()->id .
|
|
|
+ "&iassign_submission_current=" . $iassign_submission->id . "&userid_iassign=" . $this->userid_iassign . "&row=" . ($row) . "&column=" . ($column);
|
|
|
+ $history_comment = $this->search_comment_submission($iassign_submission->id);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $enderecoPOSTcomment = "" . $CFG->wwwroot . "/mod/iassign/view.php?id=" . $id . "&action=newcomment&iassign_current=" . $this->activity->get_activity()->id .
|
|
|
+ "&userid_iassign=" . $this->userid_iassign . "&row=" . ($row) . "&column=" . ($column);
|
|
|
+ }
|
|
|
+
|
|
|
+ $output .= $OUTPUT->box_start();
|
|
|
+ $output .= "<center><form name='formEnvioComment' id='formEnvioComment1' method='post' action='$enderecoPOSTcomment' enctype='multipart/form-data'>\n";
|
|
|
+ $output .= "<p><textarea rows='2' cols='60' name='submission_comment'></textarea></p>\n";
|
|
|
+ $output .= "<p><input type=submit value='" . get_string('submit_comment', 'iassign') . "'\></p>\n";
|
|
|
+ $output .= "</form></center>\n";
|
|
|
+ if (!empty($history_comment)) {
|
|
|
+ $output .= " <table id='outlinetable' class='generaltable boxaligncenter' cellpadding='5' width='100%'> \n";
|
|
|
+ $output .= " <tr><th>" . get_string('history_comments', 'iassign') . "</th></tr>";
|
|
|
+ $output .= $history_comment;
|
|
|
+ $output .= "</table>";
|
|
|
+ }
|
|
|
+ $output .= $OUTPUT->box_end();
|
|
|
+ print $output;
|
|
|
+ } // if ($iassign_statement_activity_item->type_iassign == 3)
|
|
|
+
|
|
|
+
|
|
|
// final block 'studant'
|
|
|
print $OUTPUT->footer();
|
|
|
die();
|
|
@@ -3142,14 +3162,20 @@ class iassign {
|
|
|
$links = " <a href='view.php?id=$id&userid_iassign=$USER->id&action=view&iassign_current=$iassign_current'>" . $iassign_array[$j]->name . "</a>";
|
|
|
$links .= $comment_unread;
|
|
|
if (has_capability('mod/iassign:editiassign', $this->context, $USER->id) && $USER->iassignEdit == 1) {
|
|
|
- $aux = "&id=$id&iassign_current=$iassign_current&iassign_up=$iassign_up&iassign_down=$iassign_down";
|
|
|
- $link_up = " <a href='view.php?action=up$aux'>" . iassign_icons::insert('move_up_iassign') . "</a>";
|
|
|
- $link_down = " <a href='view.php?action=down$aux'>" . iassign_icons::insert('move_down_iassign') . "</a>";
|
|
|
- $link_delete = " <a href='view.php?action=delete$aux'>" . iassign_icons::insert('delete_iassign') . "</a>";
|
|
|
- $link_visible_hide = " <a href='view.php?action=visible$aux'>" . iassign_icons::insert('hide_iassign') . "</a>";
|
|
|
- $link_visible_show = " <a href='view.php?action=visible$aux'>" . iassign_icons::insert('show_iassign') . "</a>";
|
|
|
- $link_edit = " <a href='view.php?action=edit$aux'>" . iassign_icons::insert('edit_iassign') . "</a>";
|
|
|
- $link_duplicate_activity = " <a href='view.php?action=duplicate_activity$aux' >" . iassign_icons::insert('duplicate_iassign') . "</a>\n";
|
|
|
+
|
|
|
+ //D echo "id=$id, iassign_current=$iassign_current, iassign_up=$iassign_up, iassign_down=$iassign_down<br/>";
|
|
|
+ $str_aux = "&id=$id&iassign_current=$iassign_current&iassign_up=$iassign_up&iassign_down=$iassign_down";
|
|
|
+
|
|
|
+ $link_up = " <a href='view.php?action=up$str_aux'>" . iassign_icons::insert('move_up_iassign') . "</a>";
|
|
|
+ if ($j==0) // first activity
|
|
|
+ $link_down = " <a href='view.php?action=firstdown$str_aux'>" . iassign_icons::insert('move_down_iassign') . "</a>";
|
|
|
+ else
|
|
|
+ $link_down = " <a href='view.php?action=down$str_aux'>" . iassign_icons::insert('move_down_iassign') . "</a>";
|
|
|
+ $link_delete = " <a href='view.php?action=delete$str_aux'>" . iassign_icons::insert('delete_iassign') . "</a>";
|
|
|
+ $link_visible_hide = " <a href='view.php?action=visible$str_aux'>" . iassign_icons::insert('hide_iassign') . "</a>";
|
|
|
+ $link_visible_show = " <a href='view.php?action=visible$str_aux'>" . iassign_icons::insert('show_iassign') . "</a>";
|
|
|
+ $link_edit = " <a href='view.php?action=edit$str_aux'>" . iassign_icons::insert('edit_iassign') . "</a>";
|
|
|
+ $link_duplicate_activity = " <a href='view.php?action=duplicate_activity$str_aux' >" . iassign_icons::insert('duplicate_iassign') . "</a>\n";
|
|
|
$link_move_activity = " <a href='#' onclick='load_move($iassign_current); return false;' >" . iassign_icons::insert('move_activity') . "</a>\n";
|
|
|
|
|
|
if (count($iassign_array) > 1) {
|
|
@@ -3272,24 +3298,36 @@ class iassign {
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// Search comment of activity
|
|
|
function search_comment_submission ($iassign_submissionid) {
|
|
|
global $USER, $DB, $OUTPUT, $COURSE;
|
|
|
- $context = context_course::instance($COURSE->id);
|
|
|
+ // $context = context_course::instance($COURSE->id);
|
|
|
+ $colorEdit1 = "#a7bede"; // "#dce7ec"
|
|
|
+ $colorEdit2 = "#b7ceee";
|
|
|
+ $has_capability = 0;
|
|
|
|
|
|
$comments = $DB->get_records_list('iassign_submission_comment', 'iassign_submissionid', array('iassign_submissionid' => $iassign_submissionid), 'timecreated DESC'); // 'ORDER BY "timecreated" ASC'
|
|
|
$text = "";
|
|
|
if ($comments) {
|
|
|
|
|
|
+ $even = 1;
|
|
|
foreach ($comments as $tmp) {
|
|
|
$user_data = $DB->get_record("user", array('id' => $tmp->comment_authorid));
|
|
|
- if (has_capability('mod/iassign:editiassign', $context, $tmp->comment_authorid)) {
|
|
|
- $text .= "<tr><td bgcolor='#fee7ae'><b> $user_data->firstname</b> (" . userdate($tmp->timecreated) . "</br>\n";
|
|
|
- $text .= "$tmp->comment</td></tr>";
|
|
|
- } else {
|
|
|
- $text .= "<tr><td bgcolor='#dce7ec'>»<b>" . $user_data->firstname . "</b> (" . userdate($tmp->timecreated) . "</br>\n";
|
|
|
- $text .= $tmp->comment . "</td></tr>\n";
|
|
|
+ // if (has_capability('mod/iassign:editiassign', $context, $tmp->comment_authorid)) {
|
|
|
+ // $text .= "<tr><td bgcolor='#fee7ae'><b> $user_data->firstname</b> (" . userdate($tmp->timecreated) . ")</br>\n";
|
|
|
+ // $text .= $tmp->comment . "</td></tr>";
|
|
|
+ //} else {
|
|
|
+ // $text .= "<tr><td bgcolor='#dce7ec'>»<b>" . $user_data->firstname . "</b> (" . userdate($tmp->timecreated) . "</br>\n";
|
|
|
+ if ($even) {
|
|
|
+ $text .= "<tr><td bgcolor='" . $colorEdit1 . "'>»<b>" . $user_data->firstname . "</b> (" . userdate($tmp->timecreated) . ")</br>\n";
|
|
|
+ $even = 0;
|
|
|
+ } else {
|
|
|
+ $text .= "<tr><td bgcolor='" . $colorEdit2 . "'>»<b>" . $user_data->firstname . "</b> (" . userdate($tmp->timecreated) . ")</br>\n";
|
|
|
+ $even = 1;
|
|
|
}
|
|
|
+ $text .= $tmp->comment . "</td></tr>\n";
|
|
|
+
|
|
|
} // foreach ($comments as $tmp)
|
|
|
}
|
|
|
return $text;
|
|
@@ -3576,23 +3614,48 @@ class activity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// Changes position within of interactive group activity
|
|
|
- function move_iassign ($target, $return) {
|
|
|
- global $DB, $OUTPUT;
|
|
|
- $iassign_target = $DB->get_record("iassign_statement", array("id" => $target));
|
|
|
- $aux = $this->activity->position;
|
|
|
- $newentry = new stdClass();
|
|
|
- $newentry->id = $this->activity->id;
|
|
|
- $newentry->position = $iassign_target->position;
|
|
|
|
|
|
- if (!$DB->update_record('iassign_statement', $newentry)) {
|
|
|
+ /// Changes position of activities (between those inside a group of interactive activities)
|
|
|
+ // @param $move_action = must be "up" or "down"
|
|
|
+ // @param $target = if 'down' => is 'iassign_statement.id' of the activity bellow the current one; if 'up' => is activity above the current one
|
|
|
+ function move_iassign ($move_action, $target, $return) {
|
|
|
+ global $DB, $OUTPUT;
|
|
|
+ //D echo "mover: this->id=" . $this->activity->id . ", target = $target<br/>";
|
|
|
+ $initial_position_source = $this->activity->position; // the position of the "source activity" (that one to be moved)
|
|
|
+ $iassign_target = $DB->get_record("iassign_statement", array("id" => $target)); // "target activity" = the activity in the position the receive "source activity"
|
|
|
+ if ($move_action=="firstdown") {
|
|
|
+ $final_position_source = 2;
|
|
|
+ $final_position_target = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ if ($move_action=="down") {
|
|
|
+ $final_position_target = $this->activity->position;
|
|
|
+ $final_position_source = $final_position_target + 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ if ($move_action=="up") {
|
|
|
+ $final_position_target = $this->activity->position;
|
|
|
+ $final_position_source = $final_position_target - 1;
|
|
|
+ }
|
|
|
+ else { // error:
|
|
|
print_error('error_update_move_iassign', 'iassign');
|
|
|
+ exit;
|
|
|
}
|
|
|
+ $newentry = new stdClass(); // define a new object (activity) to receive only 2 fields: 'id' and 'position'
|
|
|
+ $newentry->id = $this->activity->id; // ID of the "source activity"
|
|
|
+ $newentry->position = $final_position_source;
|
|
|
+ //D echo "mover: id=" . $this->activity->id . ": de " . $this->activity->position . " -> " . $final_position_source . "<br/>";
|
|
|
+ //D echo "mover: id=" . $iassign_target->id . ": de " . $iassign_target->position . " -> " . $final_position_target . "<br/>"; exit;
|
|
|
|
|
|
- $newentry->id = $iassign_target->id;
|
|
|
- $newentry->position = $aux;
|
|
|
- if (!$DB->update_record('iassign_statement', $newentry))
|
|
|
+ if (!$DB->update_record('iassign_statement', $newentry)) { // modify 'position' of the activity with 'id'=$target
|
|
|
print_error('error_update_move_iassign', 'iassign');
|
|
|
+ }
|
|
|
+ else { // first update performed successfully
|
|
|
+ $newentry->id = $iassign_target->id;
|
|
|
+ $newentry->position = $final_position_target;
|
|
|
+ if (!$DB->update_record('iassign_statement', $newentry))
|
|
|
+ print_error('error_update_move_iassign', 'iassign');
|
|
|
+ }
|
|
|
redirect($return);
|
|
|
}
|
|
|
|
|
@@ -4027,6 +4090,7 @@ class ilm {
|
|
|
$this->ilm = null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// Shows activity in iLM
|
|
|
// @calledby view_iassign_current()
|
|
|
function view_iLM ($iassign_statement_activity_item, $student_answer, $enderecoPOST, $view_teacherfileversion) {
|
|
@@ -4215,8 +4279,8 @@ class ilm_settings {
|
|
|
if (!$iassign_ilm) { // The second turn (form sended) reaches this point - Just in case (if the admin use back and forward in the browser)
|
|
|
print get_string('empty_file', 'iassign') . "?<br/>\n"; //TODO warning not to use back?
|
|
|
// echo "Sem dados<br/>"; exit;
|
|
|
- return;
|
|
|
- }
|
|
|
+ return;
|
|
|
+ }
|
|
|
$description = json_decode($iassign_ilm->description);
|
|
|
if ($iassign_ilm) {
|
|
|
if ($iassign_ilm->parent == 0)
|
|
@@ -6134,7 +6198,7 @@ class ilm_manager {
|
|
|
// $array_files_aux[] = $item_fc;
|
|
|
$itemid = $item_fc->get_id();
|
|
|
if (!in_array($itemid, $array_files_id)) {
|
|
|
- //TODO Avoid to insert twice - necessary since it has been inserting 2 copies in iassign_statement
|
|
|
+ //TODO Avoid to insert twice - necessary since it has been inserting 2 copies in iassign_statement
|
|
|
$allfiles[] = $item_fc;
|
|
|
$array_files_id[] = $itemid;
|
|
|
$countf++;
|