|
@@ -4,6 +4,9 @@
|
|
|
* This class provides all the functionality for an ia (interactive activities).
|
|
|
*
|
|
|
* Release Notes:
|
|
|
+ * - v 4.9.7 2022/02/11
|
|
|
+ * + Try to fix teacher edit of activity changing 'statement.id' to 'statement.file' in 'add_edit_iassign()'
|
|
|
+ *
|
|
|
* - v 4.9.6 2022/01/21
|
|
|
* + Try to fix view activity not sent through report ("view_iassign_current()": else if (!$student_answer) $loadTeacherActivity=true;)
|
|
|
*
|
|
@@ -210,7 +213,7 @@ class iassign {
|
|
|
$this->return = $CFG->wwwroot . "/mod/iassign/view.php?id=" . $this->cm->id;
|
|
|
$this->bottonPost = 0;
|
|
|
$this->view_iassign = optional_param('action', false, PARAM_BOOL);
|
|
|
- $this->activity = new activity(optional_param('iassign_current', NULL, PARAM_TEXT));
|
|
|
+ $this->activity = new activity(optional_param('iassign_current', NULL, PARAM_TEXT));
|
|
|
|
|
|
$this->view();
|
|
|
}
|
|
@@ -369,8 +372,9 @@ class iassign {
|
|
|
$iassign_statement = $DB->get_record("iassign_statement", array("id" => $ilmid));
|
|
|
$fs = get_file_storage();
|
|
|
|
|
|
- $files = $fs->get_area_files(context_module::instance($this->cm->id)->id, 'mod_iassign', 'exercise', $iassign_statement->id);
|
|
|
|
|
|
+
|
|
|
+ $files = $fs->get_area_files(context_module::instance($this->cm->id)->id, 'mod_iassign', 'exercise', $iassign_statement->id);
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
if ($file->get_filename() != ".") {
|
|
@@ -703,8 +707,7 @@ class iassign {
|
|
|
$iassign_destiny = $this->iassign->id;
|
|
|
$activities_list = $_REQUEST['statements'];
|
|
|
|
|
|
- foreach($activities_list as $activity) {
|
|
|
-
|
|
|
+ foreach ($activities_list as $activity) {
|
|
|
$activity_source = $DB->get_record('iassign_statement', array('id' => $activity));
|
|
|
|
|
|
$activity_source->id = 0;
|
|
@@ -719,7 +722,6 @@ class iassign {
|
|
|
$activity_source->author_modified = $activity_source->author_modified_name;
|
|
|
|
|
|
if ($id_ = $DB->insert_record("iassign_statement", $activity_source)) {
|
|
|
-
|
|
|
$fs = get_file_storage();
|
|
|
|
|
|
$files_ids = $DB->get_records_sql('SELECT id FROM {files} WHERE component="mod_iassign" AND itemid=' . $filesid_from);
|
|
@@ -732,17 +734,15 @@ class iassign {
|
|
|
|
|
|
$newfile = $fs->create_file_from_storedfile(array('contextid' => $this->context->id, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $id_), $source_file);
|
|
|
|
|
|
- $updateentry = new stdClass();
|
|
|
- $updateentry->id = $id_;
|
|
|
- $updateentry->filesid = $id_;
|
|
|
+ $updateentry = new stdClass();
|
|
|
+ $updateentry->id = $id_;
|
|
|
+ $updateentry->filesid = $id_;
|
|
|
|
|
|
-
|
|
|
- $DB->update_record("iassign_statement", $updateentry);
|
|
|
+
|
|
|
+ $DB->update_record("iassign_statement", $updateentry);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
$destiny_url = new moodle_url('/mod/iassign/view.php', array('id' => $this->context->id));
|
|
|
|
|
@@ -1532,6 +1532,7 @@ var exercises = [ '; // '
|
|
|
$context = context_module::instance($USER->cm);
|
|
|
|
|
|
|
|
|
+
|
|
|
$files = $fs->get_area_files($context->id, 'mod_iassign', 'exercise', $iassign_statement->id);
|
|
|
|
|
|
foreach ($files as $value) {
|
|
@@ -2394,6 +2395,7 @@ var exercises = [ '; // '
|
|
|
$dependency = explode(';', $iassign_statement_current->dependency);
|
|
|
$param->iassign_list = array();
|
|
|
|
|
|
+
|
|
|
$str_query = "SELECT * FROM {iassign_statement} s WHERE s.iassignid = '" . $iassignid . "' AND s.id!='" . $iassign_statement_current->id . "' AND s.dependency!=0";
|
|
|
$iassign_statement_dependency = $DB->get_records_sql($str_query);
|
|
|
|
|
@@ -2466,7 +2468,9 @@ var exercises = [ '; // '
|
|
|
$fs = get_file_storage();
|
|
|
|
|
|
|
|
|
- $files = $fs->get_area_files($context->id, $component, $filearea, $iassign_statement_current->id);
|
|
|
+
|
|
|
+ $files = $fs->get_area_files($context->id, $component, $filearea, $iassign_statement_current->file);
|
|
|
+
|
|
|
if ($files) {
|
|
|
foreach ($files as $file) {
|
|
|
if ($file->get_filename() != '.') {
|
|
@@ -5036,20 +5040,22 @@ var exercises = [ '; // '
|
|
|
print '<tr><td style="white-space: nowrap; width: 1%; padding-right: 2rem;" class="align-middle">' . $links . '</td><td class="align-middle">' . $action_links . "</td></tr>\n";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ $vector_final_order = array();
|
|
|
+ for ($j=0; $j<$total_of_activities; $j++) {
|
|
|
+
|
|
|
+ if ($iassign_array[$j]->position!=($j+1)) {
|
|
|
+ activity::move_change_activity_position($DB, $iassign_array[$j]->id, $iassign_array[$j]->id, $j+1, $j+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
print "</tbody></table>\n";
|
|
|
}
|
|
|
elseif (has_capability('mod/iassign:submitiassign', $this->context, $USER->id)) {
|
|
|
print '<h5 class="fw-bold" style="font-weight: 400; margin: -1rem 0 1.5rem 0;">' . $title . "</h5>\n";
|
|
|
print '<table class="table table-hover" style="border-bottom: 1px solid #dee2e6;">' . "\n";
|
|
|
|
|
|
- $corect_position = 1;
|
|
|
- for ($j=0; $j<$total_of_activities; $j++) {
|
|
|
- if ($iassign_array[$j]->position!=$corect_position) {
|
|
|
- activity::move_change_activity_position($DB, $iassign_array[$j]->id, $iassign_array[$j]->id, $corect_position, $corect_position);
|
|
|
- }
|
|
|
- $corect_position++;
|
|
|
- }
|
|
|
-
|
|
|
for ($j=0; $j<$total_of_activities; $j++) {
|
|
|
$icon_status = "";
|
|
|
$icon_comment = "";
|
|
@@ -5454,9 +5460,9 @@ class activity {
|
|
|
$iassign_submission_currents = $DB->get_records("iassign_submission", array("iassign_statementid" => $this->activity->id));
|
|
|
if ($iassign_submission_currents) {
|
|
|
if (has_capability('mod/iassign:deleteassignnull', $USER->context, $USER->id)) {
|
|
|
- foreach ($iassign_submission_currents as $iassign_submission)
|
|
|
- $DB->delete_records('iassign_submission_comment', array('iassign_submissionid' => $iassign_submission->id));
|
|
|
- $delete_iassign_submission_currents = $DB->delete_records("iassign_submission ", array("iassign_statementid" => $this->activity->id));
|
|
|
+ foreach ($iassign_submission_currents as $iassign_submission)
|
|
|
+ $DB->delete_records('iassign_submission_comment', array('iassign_submissionid' => $iassign_submission->id));
|
|
|
+ $delete_iassign_submission_currents = $DB->delete_records("iassign_submission ", array("iassign_statementid" => $this->activity->id));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -5464,6 +5470,7 @@ class activity {
|
|
|
|
|
|
|
|
|
$fs = get_file_storage();
|
|
|
+
|
|
|
$fs->delete_area_files($iassign->context->id, 'mod_iassign', 'exercise', $this->activity->id);
|
|
|
|
|
|
$this->delete_calendar($this->activity->id);
|
|
@@ -5473,7 +5480,8 @@ class activity {
|
|
|
if ($delete_iassign_current) {
|
|
|
$iassign->return_home_course('confirm_delete_iassign');
|
|
|
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
$iassign->return_home_course('error_confirm_delete_iassign');
|
|
|
|
|
|
}
|
|
@@ -5492,7 +5500,8 @@ class activity {
|
|
|
if (!$DB->update_record('iassign_statement', $newentry)) {
|
|
|
print_error('error_update_move_iassign', 'iassign');
|
|
|
}
|
|
|
- else if ($idFrom != $idTo) {
|
|
|
+
|
|
|
+ if ($idFrom != $idTo) {
|
|
|
$newentry->id = $idTo;
|
|
|
$newentry->position = $posTo;
|
|
|
if (!$DB->update_record('iassign_statement', $newentry))
|
|
@@ -5555,9 +5564,7 @@ class activity {
|
|
|
$newentry->iassignid = $param->iassignid;
|
|
|
$newentry->name = $param->name;
|
|
|
$newentry->type_iassign = $param->type_iassign;
|
|
|
- if (!isset($param->store_all_submissions)) {
|
|
|
- $newentry->store_all_submissions = 0;
|
|
|
- }
|
|
|
+ $newentry->store_all_submissions = $param->store_all_submissions;
|
|
|
|
|
|
|
|
|
$proposition = $param->proposition;
|
|
@@ -5769,9 +5776,7 @@ class activity {
|
|
|
$newentry->id = $param->iassign_id;
|
|
|
$newentry->name = $param->name;
|
|
|
$newentry->type_iassign = $param->type_iassign;
|
|
|
- if (!isset($param->store_all_submissions)) {
|
|
|
- $newentry->store_all_submissions = 0;
|
|
|
- }
|
|
|
+ $newentry->store_all_submissions = $param->store_all_submissions;
|
|
|
|
|
|
|
|
|
$proposition = $param->proposition;
|