|
@@ -112,7 +112,6 @@
|
|
|
* - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
*/
|
|
|
|
|
|
-
|
|
|
//TODO Review: eliminate iLM JAR under MoodleData? It is necessary to HTML5 packages (like iVProgH5), anyway
|
|
|
//TODO Whenever under HTTPS, verify if MoodleData is working, if it is not, please use iLM JAR under WWW setting $CONF_WWW = 1
|
|
|
//TODO (under HTTPS could fail 'pluginfile', like 'https://saw.atp.usp.br/pluginfile.php/1/mod_iassign/ilm/182563135/iassign/ilm/igeom/5920/iGeom.jar"'
|
|
@@ -310,27 +309,24 @@ class iassign {
|
|
|
}
|
|
|
else {
|
|
|
// When student do/redo activity: do => action = "view"; redo => action = "repeat"
|
|
|
- // Arive here with: "get_answer"; "view"
|
|
|
-
|
|
|
+ // Arrive here with: "get_answer"; "view"
|
|
|
eval($action_iassign[$this->action]); // Now load 'view_iassign_current()' with 'view'
|
|
|
-
|
|
|
}
|
|
|
|
|
|
} // function action()
|
|
|
|
|
|
+
|
|
|
/// This method runs activities auto evaluation in teacher area
|
|
|
function auto_evaluate () {
|
|
|
-
|
|
|
global $COURSE, $CFG, $USER, $DB, $OUTPUT;
|
|
|
|
|
|
if (!has_capability('mod/iassign:runautoevaluate', $USER->context, $USER->id))
|
|
|
exit;
|
|
|
|
|
|
print $OUTPUT->header();
|
|
|
-
|
|
|
print $OUTPUT->footer();
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
/// This method moves an iAssign activity
|
|
|
function move_activity () {
|
|
@@ -360,7 +356,7 @@ class iassign {
|
|
|
$id_context = $context_file->id;
|
|
|
|
|
|
$iassign_statement = $DB->get_record("iassign_statement", array("id" => $iassign_id));
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
|
|
|
$files = $fs->get_area_files(context_module::instance($this->cm->id)->id, 'mod_iassign', 'exercise', $iassign_statement->file);
|
|
|
|
|
@@ -415,7 +411,7 @@ class iassign {
|
|
|
if ($id_ = $DB->insert_record("iassign_statement", $iassign_statement)) {
|
|
|
|
|
|
// Duplicate activity file
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$files = $fs->get_area_files($context->id, 'mod_iassign', 'exercise', $iassign_statement->file);
|
|
|
|
|
|
foreach ($files as $value) {
|
|
@@ -443,7 +439,7 @@ class iassign {
|
|
|
|
|
|
|
|
|
/// This method gets the content from the iLM and register it
|
|
|
- // It could be the exercise (teacher) or an answer (student)
|
|
|
+ // It could be the "exercise template" (teacher) or an answer (student)
|
|
|
function get_answer () {
|
|
|
|
|
|
global $USER, $CFG, $DB, $OUTPUT;
|
|
@@ -464,6 +460,7 @@ class iassign {
|
|
|
// receives post and get
|
|
|
$iLM_PARAM_ActivityEvaluation = optional_param('iLM_PARAM_ActivityEvaluation', 0, PARAM_INT); // 1 - activity evaluated as correct / 0 - activity evaluated as incorrect
|
|
|
$iLM_PARAM_RealGrade = optional_param('iLM_PARAM_RealGrade', 0, PARAM_FLOAT);
|
|
|
+
|
|
|
//2016/02/16: IMPORTANTE trocar formatador para "nao formatado", pois esta destruindo o conteudo do arquivo
|
|
|
$iLM_PARAM_ArchiveContent = optional_param('iLM_PARAM_ArchiveContent', NULL, PARAM_RAW); // answer file (ATTENTION: do not change format, use RAW in order to ensure the correct content)
|
|
|
$MA_POST_Info = optional_param('MA_POST_Info', NULL, PARAM_FORMAT);
|
|
@@ -511,6 +508,7 @@ class iassign {
|
|
|
|
|
|
$status = 3;
|
|
|
$grade_student = $iLM_PARAM_RealGrade; // evaluated as correct solution submitted is assigned the note pattern of activity
|
|
|
+
|
|
|
$msg = '<tr><td colspan=2>' . iassign_icons::insert('feedback_correct') . '<br>' . get_string('get_answer_correct', 'iassign') . '</td>';
|
|
|
|
|
|
// log record
|
|
@@ -602,11 +600,8 @@ class iassign {
|
|
|
$newentry->experiment = 1;
|
|
|
|
|
|
if (!$newentry->id = $DB->insert_record("iassign_submission", $newentry)) {
|
|
|
-
|
|
|
print_error('error_insert', 'iassign');
|
|
|
-
|
|
|
} else {
|
|
|
-
|
|
|
// Trigger module viewed event.
|
|
|
$event = \mod_iassign\event\submission_created::create(array(
|
|
|
'objectid' => $this->iassign->id,
|
|
@@ -742,6 +737,26 @@ class iassign {
|
|
|
exit;
|
|
|
} // function export_file_answer()
|
|
|
|
|
|
+
|
|
|
+ /// Prepare data to static exportation (with course name, iAsssing block name, and exercices names
|
|
|
+ // @calledby $this->export_package_answer()
|
|
|
+ //TODO Precisa terminar! //TODO_HTML
|
|
|
+ function htmlcode_2_export ($course_fullname, $course_id, $iassign_block_id, $iassign_block_name, $array_iassign_name, $array_iassign_id, $userid, $username) {
|
|
|
+ $str_html = "<html dir='ltr' lang='pt-br' xml:lang='pt-br'>
|
|
|
+ <head>
|
|
|
+ <title>" . get_string('pluginname', 'iassign') . "</title>\n"; // 'iAssign: interactive Learning Activities'
|
|
|
+ $str_html .= " </head>
|
|
|
+ <body>\n";
|
|
|
+ $tam = sizeof($array_iassign_name);
|
|
|
+ for ($ii=0; $ii<$tam; $ii++) {
|
|
|
+ //TODO_HTML completar construir HTML com titulo do exercicio e talvez legar com HTML para abri-lo com o iMA
|
|
|
+ }
|
|
|
+ $str_html .= "
|
|
|
+ </body>\n</html>";
|
|
|
+ return $str_html;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// Export an package (zip) with all answer of students
|
|
|
// @calledby $this->action()
|
|
|
function export_package_answer () {
|
|
@@ -879,6 +894,7 @@ class iassign {
|
|
|
|
|
|
|
|
|
/// Add or Edit interactive activities
|
|
|
+ // @calledby $this->action()
|
|
|
function add_edit_iassign () {
|
|
|
global $USER, $CFG, $COURSE, $DB, $OUTPUT;
|
|
|
require_once('iassign_form.php');
|
|
@@ -931,11 +947,12 @@ class iassign {
|
|
|
$param->iassign_list = array();
|
|
|
if ($iassign_statement) {
|
|
|
foreach ($iassign_statement as $iassign) {
|
|
|
- $param->iassign_list[$iassign->id] = 0;
|
|
|
- $COURSE->iassign_list[$iassign->id] = new stdClass();
|
|
|
- $COURSE->iassign_list[$iassign->id]->id = $iassign->id;
|
|
|
- $COURSE->iassign_list[$iassign->id]->name = $iassign->name;
|
|
|
- $COURSE->iassign_list[$iassign->id]->enable = 1;
|
|
|
+ $iassignid = $iassign->id;
|
|
|
+ $param->iassign_list[$iassignid] = 0;
|
|
|
+ $COURSE->iassign_list[$iassignid] = new stdClass();
|
|
|
+ $COURSE->iassign_list[$iassignid]->id = $iassignid;
|
|
|
+ $COURSE->iassign_list[$iassignid]->name = $iassign->name;
|
|
|
+ $COURSE->iassign_list[$iassignid]->enable = 1;
|
|
|
} // foreach ($iassign_statement as $iassign)
|
|
|
}
|
|
|
$param->iassign_ilmid = 0;
|
|
@@ -1010,32 +1027,34 @@ class iassign {
|
|
|
$total_of_activities = count($all_others_iassign_statement) + 1;
|
|
|
|
|
|
$inter = array();
|
|
|
- if ($all_others_iassign_statement)
|
|
|
+ if ($all_others_iassign_statement) {
|
|
|
foreach ($all_others_iassign_statement as $iassign)
|
|
|
if (in_array($iassign->id, $dependency))
|
|
|
$inter[] = $iassign->id;
|
|
|
+ }
|
|
|
|
|
|
if ($all_others_iassign_statement) {
|
|
|
foreach ($all_others_iassign_statement as $iassign) {
|
|
|
- $COURSE->iassign_list[$iassign->id] = new stdClass();
|
|
|
- $COURSE->iassign_list[$iassign->id]->name = $iassign->name;
|
|
|
- $COURSE->iassign_list[$iassign->id]->id = $iassign->id;
|
|
|
+ $iassignid = $iassign->id;
|
|
|
+ $COURSE->iassign_list[$iassignid] = new stdClass();
|
|
|
+ $COURSE->iassign_list[$iassignid]->name = $iassign->name;
|
|
|
+ $COURSE->iassign_list[$iassignid]->id = $iassignid;
|
|
|
|
|
|
- if (in_array($iassign->id, $dependency))
|
|
|
- $param->iassign_list[$iassign->id] = 1;
|
|
|
+ if (in_array($iassignid, $dependency))
|
|
|
+ $param->iassign_list[$iassignid] = 1;
|
|
|
else
|
|
|
- $param->iassign_list[$iassign->id] = 0;
|
|
|
+ $param->iassign_list[$iassignid] = 0;
|
|
|
|
|
|
- if (in_array($iassign->id, $array_dependency))
|
|
|
- $COURSE->iassign_list[$iassign->id]->enable = 0;
|
|
|
+ if (in_array($iassignid, $array_dependency))
|
|
|
+ $COURSE->iassign_list[$iassignid]->enable = 0;
|
|
|
else
|
|
|
- $COURSE->iassign_list[$iassign->id]->enable = 1;
|
|
|
+ $COURSE->iassign_list[$iassignid]->enable = 1;
|
|
|
} // foreach ($all_others_iassign_statement as $iassign)
|
|
|
}
|
|
|
|
|
|
$param->iassign_ilmid = $iassign_statement_current->iassign_ilmid;
|
|
|
$param->fileold = 0;
|
|
|
- $param->file = 0;
|
|
|
+ $param->file = 0; //TODO Criar campo 'iassign_statement.filesid' para registar 'files.id' - abaixo faz '$file->get_id();'
|
|
|
$param->filename = '';
|
|
|
$param->grade = $iassign_statement_current->grade;
|
|
|
$param->timecreated = $iassign_statement_current->timecreated; // oculto
|
|
@@ -1049,7 +1068,8 @@ class iassign {
|
|
|
$param->max_experiment = $iassign_statement_current->max_experiment;
|
|
|
$param->automatic_evaluate = $iassign_statement_current->automatic_evaluate;
|
|
|
$param->show_answer = $iassign_statement_current->show_answer;
|
|
|
- $fs = get_file_storage();
|
|
|
+
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
|
|
|
$files = $fs->get_area_files($context->id, $component, $filearea, $iassign_statement_current->file);
|
|
|
if ($files) {
|
|
@@ -1634,7 +1654,8 @@ class iassign {
|
|
|
}
|
|
|
|
|
|
print $OUTPUT->box('<p><strong>' . $last_iassign . '</strong></p>' . "\n");
|
|
|
- if (!$enderecoPOST) $enderecoPOST = "";
|
|
|
+
|
|
|
+ if (!$enderecoPOST) $enderecoPOST = "";
|
|
|
// Prepare tags to present the iLM
|
|
|
print $OUTPUT->box($ilm->view_iLM($iassign_statement_activity_item, $student_answer, $enderecoPOST, $loadTeacherActivity));
|
|
|
|
|
@@ -1988,6 +2009,7 @@ class iassign {
|
|
|
die();
|
|
|
} // function view_iassign_current()
|
|
|
|
|
|
+
|
|
|
/// Export the data from performance report into CSV file format
|
|
|
function export_csv () {
|
|
|
global $USER, $CFG, $DB, $OUTPUT;
|
|
@@ -2000,15 +2022,13 @@ class iassign {
|
|
|
$c = 1;
|
|
|
foreach ($iassign_list as $iassign) {
|
|
|
$fields .= ", activity_id_$c, activity_name_$c, total_submissions_activity_$c, grade_activity_$c"
|
|
|
- . ", status_activity_$c, ilm_id_activity_$c, ilm_name_activity_$c";
|
|
|
+ . ", status_activity_$c, ilm_id_activity_$c, ilm_name_activity_$c";
|
|
|
$c ++;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
// Finding enrolled students:
|
|
|
$params = array('shortname' => 'student');
|
|
|
- $role = $DB->get_record_sql(
|
|
|
- "SELECT s.id, s.shortname FROM {role} s " .
|
|
|
- " WHERE s.shortname = :shortname", $params);
|
|
|
+ $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params);
|
|
|
$context = context_course::instance($this->course->id);
|
|
|
$params = array('contextid' => $context->id, 'roleid' => $role->id);
|
|
|
$students = $DB->get_records_sql(
|
|
@@ -2040,23 +2060,24 @@ class iassign {
|
|
|
case 0:
|
|
|
$str .= '"not_post",';
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
$str .= $iassign->iassign_ilmid . ',';
|
|
|
|
|
|
$ilm_activity = $DB->get_record("iassign_ilm", array('id' => $iassign->iassign_ilmid));
|
|
|
$str .= '"' . $ilm_activity->name . '"';
|
|
|
- }
|
|
|
+ }
|
|
|
$str .= "\n";
|
|
|
- }
|
|
|
+ }
|
|
|
$str = $fields . "\n" . $str;
|
|
|
header("Content-disposition: attachment; filename=report.csv");
|
|
|
header("Pragma: no-cache");
|
|
|
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
|
|
|
header('Content-Length: ' . strlen($str));
|
|
|
header('Connection: close');
|
|
|
- echo $str;
|
|
|
+ print $str;
|
|
|
flush();
|
|
|
- }
|
|
|
+ } // function export_csv()
|
|
|
+
|
|
|
|
|
|
/// Display report of performance
|
|
|
function report () {
|
|
@@ -2247,12 +2268,11 @@ class iassign {
|
|
|
else
|
|
|
print '<td> <a href="' . $url . '" ' . $last_solution_submission . '>' . $feedback . '</a> </td>' . "\n";
|
|
|
print '<td> </td>';
|
|
|
- print '</tr>';
|
|
|
+ print '</tr>' . "\n";
|
|
|
if ($sum_comment > 0 && $sum_verify_message > 0)
|
|
|
print '<tr><td colspan="2"> <a href="' . $url . '"> ' . $comment . '</a> (' . $sum_verify_message . '/' . $sum_comment . ') </td></tr>' . "\n";
|
|
|
else if ($sum_comment > 0)
|
|
|
print '<tr><td colspan="2"> <a href="' . $url . '"> ' . $comment . '</a> (' . $sum_comment . ') </td></tr>' . "\n";
|
|
|
-
|
|
|
print '</table>' . "\n";
|
|
|
}
|
|
|
|
|
@@ -3417,10 +3437,6 @@ class iassign {
|
|
|
if ($receiver == 2) // teacher message to student (write id teacher)
|
|
|
$newentry->teacher = $USER->id;
|
|
|
|
|
|
- //D echo "locallib.php: new_submission(): answer=" . $newentry->answer . "<br/>"; exit;
|
|
|
- //D echo "locallib.php: new_submission(): id_user=$id_user<br/>";
|
|
|
- //D exit;
|
|
|
-
|
|
|
if (!$newentry->id = $DB->insert_record("iassign_submission", $newentry))
|
|
|
return_home_course('error_insert_submissions');
|
|
|
else {
|
|
@@ -3593,7 +3609,9 @@ class activity {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /// Add news interactive activities
|
|
|
+ /// Add news interactive activities (register in table 'iassign_statement')
|
|
|
+ // @calledby this->add_edit_iassign() : $iassignid = $this->activity->new_iassign($result);
|
|
|
+ // @see ilm_manager.php: $ilm_manager_instance->ilm_editor_new();
|
|
|
function new_iassign ($param) {
|
|
|
global $DB;
|
|
|
|
|
@@ -3617,7 +3635,11 @@ class activity {
|
|
|
$newentry->author_name = $param->author_name;
|
|
|
$newentry->author_modified_name = $param->author_modified_name;
|
|
|
$newentry->iassign_ilmid = $param->iassign_ilmid;
|
|
|
- $newentry->file = $param->file;
|
|
|
+
|
|
|
+ $newentry->file = $param->file; // came from a file from 'get_file_storage()' (it is its ID)
|
|
|
+
|
|
|
+ //TODO criar o campo 'iassign_statement.filesid' e usar: $newentry->filesid = $param->file; // register 'files.id' here in 'iassign_statement.filesid'
|
|
|
+
|
|
|
$newentry->grade = $param->grade;
|
|
|
$newentry->timemodified = time();
|
|
|
$newentry->timecreated = time();
|
|
@@ -3644,12 +3666,21 @@ class activity {
|
|
|
if ($id) {
|
|
|
$component = 'mod_iassign';
|
|
|
$filearea = 'exercise';
|
|
|
- $fs = get_file_storage();
|
|
|
+
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$file = $fs->get_file_by_id($param->file);
|
|
|
- $itemid = $file->get_itemid() + $id;
|
|
|
+
|
|
|
+ $itemid = $file->get_itemid() + $id; //TODO Verificar: melhor deixar "$itemid = $file->get_itemid()" pois assim 'files.itemid' guarda 'iassign_statement.id'???
|
|
|
+
|
|
|
+ // File already inserted in other context!
|
|
|
+ //TODO Verificar se apenas esta' inserindo nova referencia em 'files' (NAO deve duplicar no Moodle Data)
|
|
|
$newfile = $fs->create_file_from_storedfile(array('contextid' => $param->context->id, 'component' => $component, 'filearea' => $filearea, 'itemid' => $itemid), $file);
|
|
|
+
|
|
|
$updateentry = new stdClass();
|
|
|
$updateentry->id = $id;
|
|
|
+
|
|
|
+ //TODO Implementar campo 'iassign_statement.filesid' e usar: $updateentry->filesid = $param->file; // register in 'iassign_statement' the 'files.id'
|
|
|
+
|
|
|
$updateentry->file = $newfile->get_itemid();
|
|
|
if (!$DB->update_record("iassign_statement", $updateentry))
|
|
|
print_error('error_add', 'iassign');
|
|
@@ -3767,7 +3798,7 @@ class activity {
|
|
|
|
|
|
$component = 'mod_iassign';
|
|
|
$filearea = 'exercise';
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$file = $fs->get_file_by_id($param->file);
|
|
|
$fileold = $fs->get_file_by_id($param->fileold);
|
|
|
|
|
@@ -3782,7 +3813,9 @@ class activity {
|
|
|
|
|
|
if (!$fs->file_exists($param->context->id, $component, $filearea, $file->get_itemid(), $file->get_filepath(), $file->get_filename())) {
|
|
|
$itemid = $file->get_itemid() + $param->iassign_id;
|
|
|
+
|
|
|
$newfile = $fs->create_file_from_storedfile(array('contextid' => $param->context->id, 'component' => $component, 'filearea' => $filearea, 'itemid' => $itemid), $file);
|
|
|
+
|
|
|
$param->file = $newfile->get_itemid();
|
|
|
} else
|
|
|
$param->file = $file->get_itemid();
|
|
@@ -3806,7 +3839,8 @@ class activity {
|
|
|
|
|
|
$newentry->iassign_ilmid = $param->iassign_ilmid;
|
|
|
|
|
|
- $newentry->file = $param->file;
|
|
|
+ $newentry->file = $param->file; // came from a file from 'get_file_storage()' (it is its ID)
|
|
|
+
|
|
|
$newentry->grade = $param->grade;
|
|
|
$newentry->author_modified_name = $param->author_modified_name;
|
|
|
|
|
@@ -4045,7 +4079,7 @@ class ilm {
|
|
|
/// Class to manage settings of iLM.
|
|
|
class ilm_settings {
|
|
|
|
|
|
- /// Function to prepare tag to load iLM (that is stored in Moodle filesystem - usually /var/moodledata/filedir/).
|
|
|
+ /// Function to prepare tag to load iLM (that is stored in Moodle file system - usually /var/moodledata/filedir/).
|
|
|
// In case of JAR it will prepare the tag "applet". In case of HTML5 will prepare an "iframe".
|
|
|
// @param int $ilm_id Id of iLM
|
|
|
// @param array $options An array with options for create dynamic tag html APPLET
|
|
@@ -4068,7 +4102,7 @@ class ilm_settings {
|
|
|
// @return string Return with the filenames and modified date
|
|
|
static function applet_filetime ($file_jar) {
|
|
|
$filetime = "";
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$files_jar = explode(",", $file_jar);
|
|
|
foreach ($files_jar as $one_file) {
|
|
|
$file = $fs->get_file_by_id($one_file);
|
|
@@ -4084,7 +4118,7 @@ class ilm_settings {
|
|
|
// @return boolean Return true or fale if applet is default
|
|
|
static function applet_default ($file_jar) {
|
|
|
$is_default = true;
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$files_jar = explode(",", $file_jar);
|
|
|
foreach ($files_jar as $one_file) {
|
|
|
$file = $fs->get_file_by_id($one_file);
|
|
@@ -4247,7 +4281,7 @@ class ilm_settings {
|
|
|
|
|
|
$return = null;
|
|
|
$file_jar = array();
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$contextuser = context_user::instance($USER->id);
|
|
|
$contextsystem = context_system::instance();
|
|
|
$files_ilm = $fs->get_area_files($contextuser->id, 'user', 'draft', $itemid);
|
|
@@ -4255,17 +4289,17 @@ class ilm_settings {
|
|
|
if ($files_ilm) {
|
|
|
|
|
|
foreach ($files_ilm as $value) {
|
|
|
- // VERIFICA SE e' DO TIPO HTML5
|
|
|
+ // CHECK IF file is HTML type
|
|
|
if ($iassign_ilm->type == 1) {
|
|
|
- // Verifica a extensão do arquivo iLM para verificar se é ZIP
|
|
|
+ // Check if the file extension is ZIP
|
|
|
$ext = pathinfo($value->get_filename(), PATHINFO_EXTENSION);
|
|
|
- // CASO SEJA ZIP: COPIA O ARQUIVO, PARA O ilm_debug E DESCOMPACTA no diretorio 'ilm'
|
|
|
+ // It is ZIP: copy it to the 'ilm_debug' and unpack it on directory 'ilm/'
|
|
|
if ((strtolower($ext) == 'zip')) {
|
|
|
- // COPIA:
|
|
|
+ // Coping...:
|
|
|
$destination = 'ilm_debug/' . $value->get_filename();
|
|
|
$value->copy_content_to($destination);
|
|
|
|
|
|
- // EXTRAIR CONTEUDO:
|
|
|
+ // Extracting content...:
|
|
|
$zip = new ZipArchive();
|
|
|
$extracted = './ilm';
|
|
|
$dir = "";
|
|
@@ -4291,17 +4325,17 @@ class ilm_settings {
|
|
|
$zip->extractTo($extracted);
|
|
|
$zip->close();
|
|
|
|
|
|
- // Apos extrair, remover do DEBUG:
|
|
|
+ // After the extraction, remove it from DEBUG
|
|
|
unlink($destination);
|
|
|
- } else {
|
|
|
- // APÓS NAO CONSEGUIR EXTRAIR, apagar O ZIP:
|
|
|
+ } else { // Error trying to open destination...
|
|
|
+ // After the extraction error, also remove it from DEBUG
|
|
|
unlink($destination);
|
|
|
print_error('error_add_ilm_zip', 'iassign');
|
|
|
}
|
|
|
|
|
|
return $dir;
|
|
|
}
|
|
|
- }
|
|
|
+ } // if ($iassign_ilm->type == 1)
|
|
|
|
|
|
if ($value->get_filename() != '.') {
|
|
|
$file_ilm = array(
|
|
@@ -4326,7 +4360,8 @@ class ilm_settings {
|
|
|
$fs->delete_area_files($contextsystem->id, 'mod_iassign', 'ilm', $file->get_itemid());
|
|
|
}
|
|
|
}
|
|
|
- } else
|
|
|
+ }
|
|
|
+ else // if ($files_ilm)
|
|
|
$return = $iassign_ilm->file_jar;
|
|
|
|
|
|
$delete_file = $fs->delete_area_files($contextuser->id, 'user', 'draft', $itemid);
|
|
@@ -4349,7 +4384,7 @@ class ilm_settings {
|
|
|
|
|
|
$contextuser = context_user::instance($USER->id);
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$zip = new zip_packer();
|
|
|
$files = $fs->get_directory_files($contextuser->id, 'user', 'draft', $itemid, '/');
|
|
|
foreach ($files as $file) {
|
|
@@ -4418,7 +4453,7 @@ class ilm_settings {
|
|
|
|
|
|
$contextuser = context_user::instance($USER->id);
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$zip = new zip_packer();
|
|
|
$files = $fs->get_directory_files($contextuser->id, 'user', 'draft', $itemid, '/');
|
|
|
$files_extract = null;
|
|
@@ -4448,7 +4483,7 @@ class ilm_settings {
|
|
|
|
|
|
$contextuser = context_user::instance($USER->id);
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$zip = new zip_packer();
|
|
|
$files = $fs->get_directory_files($contextuser->id, 'user', 'draft', $itemid, '/');
|
|
|
$files_extract = null;
|
|
@@ -4691,7 +4726,7 @@ class ilm_settings {
|
|
|
return "./" . $diretorio;
|
|
|
}
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$file_jar = array();
|
|
|
$files_ilm = explode(",", $application_xml->file_jar);
|
|
|
$contextsystem = context_system::instance();
|
|
@@ -4717,7 +4752,7 @@ class ilm_settings {
|
|
|
unlink($file);
|
|
|
}
|
|
|
return $file_jar;
|
|
|
- }
|
|
|
+ } // static function save_ilm_by_xml($application_xml, $files_extract)
|
|
|
|
|
|
|
|
|
/// Function for import the iLM from an package
|
|
@@ -4734,7 +4769,7 @@ class ilm_settings {
|
|
|
|
|
|
$contextuser = context_user::instance($USER->id);
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$zip = new zip_packer();
|
|
|
$files = $fs->get_directory_files($contextuser->id, 'user', 'draft', $itemid, '/');
|
|
|
foreach ($files as $file) {
|
|
@@ -4850,7 +4885,7 @@ class ilm_settings {
|
|
|
die;
|
|
|
}
|
|
|
$zip = new zip_packer();
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$contextuser = context_user::instance($USER->id);
|
|
|
$files_extract = $zip->extract_to_pathname($zip_filename, $CFG->dataroot . '/temp/');
|
|
|
|
|
@@ -5106,13 +5141,15 @@ class ilm_manager {
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
$fileid = optional_param('fileid', NULL, PARAM_INT);
|
|
|
//$filename = optional_param('filename', NULL, PARAM_TEXT);
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$md_file = $fs->get_file_by_id($fileid);
|
|
|
$ilm_content_file = $md_file->get_content();
|
|
|
return $ilm_content_file;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// Function for creating a new file from the iLM online editor
|
|
|
+ // @calledby ilm_manager.php: case 'new': $ilm_manager_instance->ilm_editor_new();
|
|
|
function ilm_editor_new () {
|
|
|
global $CFG, $DB, $OUTPUT, $PAGE;
|
|
|
|
|
@@ -5161,6 +5198,7 @@ class ilm_manager {
|
|
|
$_SESSION['file_name'] = $filename;
|
|
|
|
|
|
//$this->write_file_iassign($string, $filename);
|
|
|
+
|
|
|
// Register and (by JS.alet(.)) inform the user about the result (and the final name of the file)
|
|
|
$this->write_file_iassign($stringArchiveContent, $filename); // class ilm_manager - inform the user about the file insertion result
|
|
|
|
|
@@ -5178,7 +5216,7 @@ class ilm_manager {
|
|
|
$str_submitbutton_name = "submit_iLM_Answer()"; // to call 'submit_iLM_Answer()'
|
|
|
}
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$files = $fs->get_area_files($context->id, 'mod_iassign', 'activity');
|
|
|
$files_array = '';
|
|
|
foreach ($files as $value) {
|
|
@@ -5207,16 +5245,8 @@ class ilm_manager {
|
|
|
docFormOnLineEditor.iLM_PARAM_ArchiveContent.value = resposta_exerc[0];
|
|
|
var files = new Array(" . $files_array . ");
|
|
|
var filename = docFormOnLineEditor.filename.value+'.'+'" . $extension . "';
|
|
|
-" .
|
|
|
- //D alert('#files = ' + files.length);
|
|
|
- // 2016/02/16: NOT necessary, since it is teacher editing (perhaps he only make an example as exercise)
|
|
|
- // if (resposta_exerc[0] == -1) {
|
|
|
- // alert('" . get_string('error_null_iassign', 'iassign') . "'); // ERRO: O exercício esta vazio ou não foi alterado
|
|
|
- // return false;
|
|
|
- // } else {
|
|
|
- "
|
|
|
if (docFormOnLineEditor.filename.value=='') {
|
|
|
- // ERRO: O nome do arquivo está vazio.
|
|
|
+ // ERROR: the file name is empty
|
|
|
alert('" . get_string('error_file_null_iassign', 'iassign') . "');
|
|
|
return false;
|
|
|
}
|
|
@@ -5294,7 +5324,7 @@ class ilm_manager {
|
|
|
}
|
|
|
|
|
|
//2017/03/12 //QUARANTINE agora vindo de 'ilm_manager.php' via os 3 parametros
|
|
|
- //2017/03/12 $fs = get_file_storage(); // from Moodle data
|
|
|
+ //2017/03/12 $fs = get_file_storage(); // Get reference to all files in Moodle data // from Moodle data
|
|
|
//2017/03/12 $filename = ''; $end_file = ''; $file = $fs->get_file_by_id($fileid); if ($file) $filename = iassign_utils::format_filename($file->get_filename());
|
|
|
//D echo "locallib.php: ilm_editor_update(): filename=$filename<br/>\n";
|
|
|
//2016/02/16: IMPORTANTE trocar formatador para "nao formatado", pois esta destruindo o conteudo do arquivo
|
|
@@ -5389,6 +5419,7 @@ class ilm_manager {
|
|
|
|
|
|
|
|
|
/// Function for write iAssign file in Moodle data (exercise)
|
|
|
+ // @calledby ilm_editor_new(): $this->write_file_iassign($stringArchiveContent, $filename);
|
|
|
// @param string $stringArchiveContent Content of iassign file
|
|
|
// @param string $filename Filename of iassign file
|
|
|
function write_file_iassign ($stringArchiveContent, $filename) {
|
|
@@ -5396,7 +5427,7 @@ class ilm_manager {
|
|
|
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
$context = context_course::instance($this->id);
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$dirid = $this->get_dir_ilm('dirid');
|
|
|
$dir = $fs->get_file_by_id($dirid);
|
|
|
|
|
@@ -5408,8 +5439,11 @@ class ilm_manager {
|
|
|
'userid' => $USER->id,
|
|
|
'author' => $USER->firstname . ' ' . $USER->lastname, 'license' => 'allrightsreserved', // allrightsreserved
|
|
|
'filename' => $filename); // any filename
|
|
|
+
|
|
|
// Create file containing text. '$stringArchiveContent'
|
|
|
+ //TODO Verificar se apenas esta' inserindo nova referencia em 'files' (NAO deve duplicar no Moodle Data)
|
|
|
$file_course = $fs->create_file_from_string($fileinfo, $stringArchiveContent);
|
|
|
+
|
|
|
// sucess_write -> 'Interactive assignment successfully registered under the name: '
|
|
|
// 'Tarea interactiva registrada exitosamente bajo el nombre:'
|
|
|
// 'Activité interactive enregistrée avec succès sous le nom:';
|
|
@@ -5438,7 +5472,7 @@ class ilm_manager {
|
|
|
$dirid = $this->get_dir_ilm('dirid');
|
|
|
|
|
|
if ($stringArchiveContent != (-1)) {
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$file = $fs->get_file_by_id($fileid);
|
|
|
if (!$file) {
|
|
|
print $OUTPUT->notification(get_string('error_view_ilm', 'iassign'), 'notifyproblem');
|
|
@@ -5456,7 +5490,10 @@ class ilm_manager {
|
|
|
'timecreated' => $file->get_timecreated(),
|
|
|
'filename' => $file->get_filename()); // any filename
|
|
|
$file->delete();
|
|
|
+
|
|
|
+ //TODO Verificar se apenas esta' inserindo nova referencia em 'files' (NAO deve duplicar no Moodle Data)
|
|
|
$file_course = $fs->create_file_from_string($fileinfo, $stringArchiveContent); //$string
|
|
|
+
|
|
|
}
|
|
|
$output = "<script type='text/javascript'>
|
|
|
//<![CDATA[
|
|
@@ -5478,7 +5515,7 @@ class ilm_manager {
|
|
|
function tag_ilm ($fileid) {
|
|
|
global $DB;
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$width = '600';
|
|
|
$height = '400';
|
|
|
$file = $fs->get_file_by_id($fileid);
|
|
@@ -5498,7 +5535,7 @@ class ilm_manager {
|
|
|
function delete_file_ilm () {
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$fileid = optional_param('fileid', NULL, PARAM_RAW);
|
|
|
$file = $fs->get_file_by_id($fileid);
|
|
|
if ($file)
|
|
@@ -5510,7 +5547,7 @@ class ilm_manager {
|
|
|
/// Function for delete selected iAssign file in Moodle data (exercise)
|
|
|
function delete_selected_ilm () {
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$context = context_course::instance($this->id);
|
|
|
$files_id = explode(",", optional_param('files_id', '', PARAM_TEXT));
|
|
|
$dirid = $this->get_dir_ilm('dirid');
|
|
@@ -5538,7 +5575,7 @@ class ilm_manager {
|
|
|
global $USER, $COURSE;
|
|
|
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$fileid = optional_param('fileid', NULL, PARAM_INT);
|
|
|
$filename = optional_param('filename', NULL, PARAM_RAW);
|
|
|
|
|
@@ -5565,7 +5602,7 @@ class ilm_manager {
|
|
|
/// Function for rename iAssign file
|
|
|
function rename_file_ilm () {
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$fileid = optional_param('fileid', NULL, PARAM_INT);
|
|
|
$filename = optional_param('filename', NULL, PARAM_TEXT);
|
|
|
|
|
@@ -5699,7 +5736,7 @@ class ilm_manager {
|
|
|
$zip_filename = $CFG->dataroot . '/temp/backup-iassign-files-' . date("Ymd-Hi") . '.zip';
|
|
|
$zip = new zip_archive();
|
|
|
$zip->open($zip_filename);
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
foreach ($files_id as $file_id) {
|
|
|
$file = $fs->get_file_by_id($file_id);
|
|
|
if (!$file->is_directory())
|
|
@@ -5812,7 +5849,7 @@ class ilm_manager {
|
|
|
// @param string $key Key for return information
|
|
|
// @return Ambigous <unknown, number, string, NULL> Return an information requested
|
|
|
function get_dir_ilm ($key) {
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$context = context_course::instance($this->id);
|
|
|
$dirid = optional_param('dirid', 0, PARAM_INT);
|
|
|
$dir_home = $fs->get_file($context->id, 'mod_iassign', 'activity', 0, $dir_base = '/', '.');
|
|
@@ -5839,7 +5876,7 @@ class ilm_manager {
|
|
|
$dir_base = $this->get_dir_ilm('dir_base');
|
|
|
|
|
|
$context = context_course::instance($this->id);
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
|
|
|
$fs->create_directory($context->id, 'mod_iassign', 'activity', 0, $dir_base . $dirname . "/", $USER->id);
|
|
|
$dir_base = $fs->get_file($context->id, 'mod_iassign', 'activity', 0, $dir_base . $dirname . "/", '.');
|
|
@@ -5851,7 +5888,7 @@ class ilm_manager {
|
|
|
|
|
|
/// Function for delete an dir
|
|
|
function delete_dir_ilm () { //
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
$context = context_course::instance($this->id);
|
|
|
$dir = $fs->get_file_by_id($this->get_dir_ilm('dirid'));
|
|
@@ -5871,7 +5908,7 @@ class ilm_manager {
|
|
|
|
|
|
/// Function for rename an dir
|
|
|
function rename_dir_ilm () {
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
$context = context_course::instance($this->id);
|
|
|
$dir = $fs->get_file_by_id($this->get_dir_ilm('dirid'));
|
|
@@ -5894,7 +5931,7 @@ class ilm_manager {
|
|
|
/// Function for move an dir and your content for other dir
|
|
|
function selected_move_ilm () {
|
|
|
global $PAGE, $OUTPUT, $CFG;
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$context = context_course::instance($this->id);
|
|
|
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
@@ -5987,7 +6024,7 @@ class ilm_manager {
|
|
|
|
|
|
/// Function for move files for an dir
|
|
|
function move_files_ilm () {
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$context = context_course::instance($this->id);
|
|
|
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
@@ -6026,7 +6063,7 @@ class ilm_manager {
|
|
|
function recover_files_ilm () {
|
|
|
global $DB, $USER;
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$courseid = optional_param('id', NULL, PARAM_INT);
|
|
|
$dirid = $this->get_dir_ilm('dirid');
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
@@ -6053,7 +6090,9 @@ class ilm_manager {
|
|
|
'license' => 'allrightsreserved',
|
|
|
'timecreated' => time(),
|
|
|
'filename' => $iassign_statement_activity_item->name . "." . $extension[1]); // any filename
|
|
|
+
|
|
|
$newfile = $fs->create_file_from_string($fileinfo, $value->get_content());
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
} // if ($files)
|
|
@@ -6064,11 +6103,42 @@ class ilm_manager {
|
|
|
die();
|
|
|
} // function recover_files_ilm()
|
|
|
|
|
|
+
|
|
|
+ /// Auxiliary function the get all files in a given context
|
|
|
+ // @return [array_contextid_files_thisauthor[], array_contextid_files_otherauthors[], array_contextid_files_otherauthors_userid[]]
|
|
|
+ //TODO Falta separar os arquivos listados, apresentar primeiro aqueles do autor e depois os demais.
|
|
|
+ //TODO Nao devemos listar aqueles que estao sem permissao (license == 'allrightsreserved')
|
|
|
+ function get_files_in_context (&$allfiles, $contextid, $extension, $userid) {
|
|
|
+ // s_iassign_statement: id name iassignid type_iassign proposition author_name author_modified_name iassign_ilmid
|
|
|
+ // (NAO s_iassign_statement.file = s_files.id)
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
+ $dir_base = $this->get_dir_ilm('dir_base');
|
|
|
+ $files_course = $fs->get_directory_files($contextid, 'mod_iassign', 'activity', 0, $dir_base, false, true, 'filename');
|
|
|
+ $countf = 0;
|
|
|
+ $array_files_id = array(); // all files from this context
|
|
|
+ foreach ($files_course as $item_fc) { // license = not "allrightsreserved" AND is not from this author => present it
|
|
|
+ //$filename = $item_fc->get_filename();
|
|
|
+ //$filepath = $item_fc->get_filepath();
|
|
|
+ //$fileid = $item_fc->get_id(); // get file ID (in *_iassign_statement table)
|
|
|
+ //$fileuserid = $item_fc->get_userid(); // get user.id of the author
|
|
|
+ // $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
|
|
|
+ $allfiles[] = $item_fc;
|
|
|
+ $array_files_id[] = $itemid;
|
|
|
+ $countf++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $countf;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// List iassign files from course directory
|
|
|
// @calledby ilm_manager.php : $ilm_manager_instance->view_files_ilm($iassign_ilm->extension);
|
|
|
function view_files_ilm ($iassign_ilm_class, $extension) {
|
|
|
global $CFG, $DB, $USER, $OUTPUT;
|
|
|
- $fs = get_file_storage();
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
$context = context_course::instance($this->id); // $this->id = ID of the current course
|
|
|
$ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
$dirid = $this->get_dir_ilm('dirid');
|
|
@@ -6144,7 +6214,7 @@ class ilm_manager {
|
|
|
$dirs_array .= "''";
|
|
|
$error_dir_exists = get_string('error_dir_exists', 'iassign');
|
|
|
|
|
|
- // TODO Rever o preview pois só deixar ver uma vez.
|
|
|
+ //TODO Rever o 'preview' pois soh poder deixar ver uma vez
|
|
|
$code_javascript_ilm = "
|
|
|
<script type='text/javascript'>
|
|
|
//<![CDATA[
|
|
@@ -6352,13 +6422,7 @@ class ilm_manager {
|
|
|
//$contextid = $array_contextid_files[$ii]; // Notice: Undefined offset: 2257 in /var/www/html/saw/mod/iassign/locallib.php on line 6333
|
|
|
//$files_course = $array_files_course[$ii];
|
|
|
$one_file = $array_all_files[$ii];
|
|
|
-------
|
|
|
- //Estava foreach ($files_course as $one_file)
|
|
|
- for ($ii=$count_all_files-1; $ii>0; $ii--) { // function view_files_ilm ($iassign_ilm_class, $extension)
|
|
|
|
|
|
- //$contextid = $array_contextid_files[$ii]; // Notice: Undefined offset: 2257 in /var/www/html/saw/mod/iassign/locallib.php on line 6333
|
|
|
- //$files_course = $array_files_course[$ii];
|
|
|
- $one_file = $array_all_files[$ii];
|
|
|
|
|
|
$filename = $one_file->get_filename();
|
|
|
$filepath = $one_file->get_filepath();
|
|
@@ -6832,4 +6896,4 @@ class iassign_log {
|
|
|
print_error('error_add_log', 'iassign');
|
|
|
} // static function add_log($action, $information = "", $cmid = 0, $ilmid = 0)
|
|
|
|
|
|
- } // class iassign_log
|
|
|
+ } // class iassign_log
|