From 129b193d07e5d21a502a49285e7ebf4f04a0825e Mon Sep 17 00:00:00 2001 From: Daniel Mundra Date: Thu, 15 Feb 2024 15:11:17 -0800 Subject: [PATCH] Added option to change the CSV export delimiter per InteractiveVideo item for Ilias 8 version. --- classes/class.ilObjInteractiveVideo.php | 24 ++++++++++++++++++++-- classes/class.ilObjInteractiveVideoGUI.php | 20 +++++++++++++++--- lang/ilias_de.lang | 9 +++++--- lang/ilias_en.lang | 13 +++++++----- plugin.php | 4 ++-- sql/dbupdate.php | 23 ++++++++++++++++----- 6 files changed, 73 insertions(+), 20 deletions(-) diff --git a/classes/class.ilObjInteractiveVideo.php b/classes/class.ilObjInteractiveVideo.php index 3360b9750..673e4dcac 100644 --- a/classes/class.ilObjInteractiveVideo.php +++ b/classes/class.ilObjInteractiveVideo.php @@ -43,6 +43,12 @@ class ilObjInteractiveVideo extends ilObjectPlugin implements ilLPStatusPluginIn * @var boolean */ protected $fixed_modal = 0; + + /** + * @var string + */ + protected $csv_export_delimiter = ";"; + /** * @var int */ @@ -107,7 +113,7 @@ protected function doRead(): void [$this->getId()] ); $row = $this->db->fetchAssoc($res); - + $this->setIsAnonymized($row['is_anonymized']); $this->setIsRepeat($row['is_repeat']); $this->setIsPublic($row['is_public']); @@ -120,6 +126,7 @@ protected function doRead(): void $this->setEnableToolbar($row['show_toolbar']); $this->setAutoResumeAfterQuestion($row['auto_resume']); $this->setFixedModal($row['fixed_modal']); + $this->setCSVExportDelimiter($row['csv_export_delimiter']); $this->setShowTocFirst($row['show_toc_first']); $this->setEnableCommentStream($row['disable_comment_stream']); $this->setNoCommentStream($row['no_comment_stream']); @@ -326,6 +333,7 @@ protected function doCreate(bool $clone_mode = false): void 'is_task' => ['integer', $is_task], 'auto_resume' => ['integer', $auto_resume], 'fixed_modal' => ['integer', $fixed_modal], + 'csv_export_delimiter' => ['text', ";"], 'task' => ['text', $task], 'enable_comment' => ['integer', 1], 'show_toolbar' => ['integer', $show_toolbar], @@ -363,7 +371,7 @@ protected function doCreate(bool $clone_mode = false): void protected function doUpdate(): void { parent::doUpdate(); - + $old_source_id = $this->getOldVideoSource(); if($old_source_id != null && $old_source_id != $this->getSourceId()) { @@ -382,6 +390,7 @@ protected function doUpdate(): void 'task' => ['text', $this->getTask()], 'auto_resume' => ['integer', $this->isAutoResumeAfterQuestion()], 'fixed_modal' => ['integer', $this->isFixedModal()], + 'csv_export_delimiter' => ['text', $this->getCSVExportDelimiter()], 'show_toc_first' => ['integer', $this->getShowTocFirst()], 'disable_comment_stream' => ['integer', $this->getEnableCommentStream()], 'lp_mode' => ['integer', $this->getLearningProgressMode()], @@ -437,6 +446,7 @@ protected function doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_c 'task' => ['text', $this->getTask()], 'auto_resume' => ['integer', $this->isAutoResumeAfterQuestion()], 'fixed_modal' => ['integer', $this->isFixedModal()], + 'csv_export_delimiter' => ['text', $this->getCSVExportDelimiter()], 'show_toc_first' => ['integer', $this->getShowTocFirst()], 'disable_comment_stream' => ['integer', $this->getEnableCommentStream()], 'lp_mode' => ['integer', $this->getLearningProgressMode()], @@ -1233,6 +1243,16 @@ public function setFixedModal(bool $fixed_modal): void $this->fixed_modal = $fixed_modal; } + public function getCSVExportDelimiter(): string + { + return $this->csv_export_delimiter; + } + + public function setCSVExportDelimiter(string $csv_export_delimiter): void + { + $this->csv_export_delimiter = $csv_export_delimiter; + } + public function getShowTocFirst(): int { return $this->show_toc_first; diff --git a/classes/class.ilObjInteractiveVideoGUI.php b/classes/class.ilObjInteractiveVideoGUI.php index ab0d1df72..1b016e88a 100644 --- a/classes/class.ilObjInteractiveVideoGUI.php +++ b/classes/class.ilObjInteractiveVideoGUI.php @@ -943,6 +943,9 @@ protected function updateCustom(ilPropertyFormGUI $form): void $fixed_modal = $form->getInput('fixed_modal'); $this->object->setFixedModal((int)$fixed_modal); + $csv_export_delimiter = $form->getInput('csv_export_delimiter'); + $this->object->setCSVExportDelimiter(ilInteractiveVideoPlugin::stripSlashesWrapping($csv_export_delimiter)); + $marker_for_students = $form->getInput('marker_for_students'); $this->object->setMarkerForStudents((int)$marker_for_students); @@ -1139,6 +1142,15 @@ protected function appendDefaultFormOptions(ilPropertyFormGUI $a_form): void $fixed_modal->setInfo($plugin->txt('fixed_modal_info')); $fixed_modal->setValue(1); $a_form->addItem($fixed_modal); + + $section = new ilFormSectionHeaderGUI(); + $section->setTitle($plugin->txt('export_section')); + $a_form->addItem($section); + + $csv_export_delimiter = new ilTextInputGUI($plugin->txt('csv_export_delimiter'), 'csv_export_delimiter'); + $csv_export_delimiter->setInfo($plugin->txt('csv_export_delimiter_info')); + $csv_export_delimiter->setValue(";"); + $a_form->addItem($csv_export_delimiter); } /** @@ -1181,6 +1193,7 @@ protected function getEditFormCustomValues(array &$a_values): void $a_values['task'] = $this->object->getTask(); $a_values['auto_resume'] = $this->object->isAutoResumeAfterQuestion(); $a_values['fixed_modal'] = $this->object->isFixedModal(); + $a_values['csv_export_delimiter'] = $this->object->getCSVExportDelimiter(); $a_values["marker_for_students"]= $this->object->getMarkerForStudents(); $a_values["layout_width"] = $this->object->getLayoutWidth(); } @@ -3630,7 +3643,7 @@ public function completeCsvExport(): void $data = $simple->getScoreForAllQuestionsAndAllUser($this->obj_id); $csv = []; - $separator = ";"; + $separator = $this->object->getCSVExportDelimiter(); $head_row = []; array_push($head_row, $lng->txt('name')); @@ -3679,7 +3692,7 @@ public function exportMyComments(): void $data = $this->object->getCommentsTableDataByUserId(); $csv = []; - $separator = ";"; + $separator = $this->object->getCSVExportDelimiter(); $head_row = []; array_push($head_row, $lng->txt('id')); @@ -3688,6 +3701,7 @@ public function exportMyComments(): void array_push($head_row, $plugin->txt('comment_title')); array_push($head_row, $plugin->txt('comment')); array_push($head_row, $plugin->txt('visibility')); + array_push($head_row, $plugin->txt('is_private')); array_push($head_row, $plugin->txt('reply_to')); array_push($csv, ilCSVUtil::processCSVRow($head_row, TRUE, $separator) ); @@ -3719,7 +3733,7 @@ public function exportAllComments(): void $data = $this->object->getCommentsTableData(true, false, false, true); $csv = []; - $separator = ";"; + $separator = $this->object->getCSVExportDelimiter(); $head_row = []; diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index d62d065dc..4d5de3eba 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -35,7 +35,7 @@ cancel#:#Abbrechen sure_delete_comment#:#Sind Sie sicher, dass Sie den gewählten Kommentare/Fragen/Kapitel löschen möchten? missing_comment_text#:#Bitte geben Sie einen Kommentar ein. missing_stopping_point#:#Der Haltepunkt wurde nicht zum Server übertragen. Bitte versuchen Sie es erneut. -invalid_comment_ids#:#Einige Kommentare konnten nicht gefunden werden. +invalid_comment_ids#:#Einige Kommentare konnten nicht gefunden werden. comments_successfully_deleted#:#Die gewählten Kommentare wurden erfolgreich gelöscht. insert_comment#:#Neue Frage / Neuen Kommentar einfügen edit_comment#:#Kommentar bearbeiten @@ -129,7 +129,7 @@ crs_create_xvid#:#Interaktives Video anlegen cat_create_xvid#:#Interaktives Video anlegen root_create_xvid#:#Interaktives Video anlegen fold_create_xvid#:#Interaktives Video anlegen -rbac_create_xvid#:#Interaktives Video anlegen +rbac_create_xvid#:#Interaktives Video anlegen source#:#Quelle installed_version#:#Installierte Databank Version: %s, Datei Datenbank Version %s source_does_not_exist#:#Quelle existiert nicht mehr oder wurde in der Administration deaktiviert @@ -176,7 +176,7 @@ export_all_comments#:#Alle Kommentare exportieren question_image#:#Bild für Frage extract#:#Thumbnail aus Video erzeugen use_this_image#:#Dieses Bild verwenden -time_for_preview#:#Zeitpunkt: +time_for_preview#:#Zeitpunkt: comment_title_info#:#Der Titel wird im Kommentarstream angezeigt und ist für die Kursteilnehmer damit immer sichtbar. correct_answer#:#Richtig wrong_answer#:#Falsch @@ -262,3 +262,6 @@ beta#:#Beta activate_marker#:#Marker aktivieren activate_marker_info#:#Marker aktivieren no_comment_id_given#:#Ein problem ist aufgetreten, es existiert keine Kommentar-ID +export_section#:#Export +csv_export_delimiter#:#CSV-Exporttrennzeichen +csv_export_delimiter_info#:#Ändern Sie das Standardtrennzeichen für CSV-Exporte. diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 0369d62f6..4617c3cfe 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -81,7 +81,7 @@ send#:#Check close#:#Close question#:#Question is_anonymized#:#Anonymize Comments -is_anonymized_info#:#If enabled all comments are shown without usernames +is_anonymized_info#:#If enabled all comments are shown without usernames is_public#:#Publish All Comments is_public_info#:#If enabled all users are able to read all PUBLIC comments. Otherwise they are only able to see own comments and public comments created by administrators (in the tab "Questions, chapters and comments") correct_answered#:#Answered correctly @@ -101,7 +101,7 @@ feedback#:#Feedback already_answered#:#Question already answered. reflection#:#Reflective question answers#:#Answers -sure_update_question#:#Are you sure, you want to save the question? Existing user results will be deleted! +sure_update_question#:#Are you sure, you want to save the question? Existing user results will be deleted! question_type_info#:#You can choose between one of three available question types: a single choice, a multiple choice or a self-reflexion quertion. Self-reflexion questions do not have answer options and will be marked as "passed" once they have been shown to a user at least once. is_jump_correct_info#:#In case the question was answered correctly, you can select a jump label (time stamp) within the video to which the user can jump using a button. This button will be shown along with the feedback text. is_jump_wrong_info#:#In case the question was answered incorrectly, you can select a jump label (time stamp) within the video to which the user can jump using a button. This button will be shown along with the feedback text. @@ -131,7 +131,7 @@ crs_create_xvid#:#Create Interactive Video cat_create_xvid#:#Create Interactive Video root_create_xvid#:#Create Interactive Video fold_create_xvid#:#Create Interactive Video -rbac_create_xvid#:#Create Interactive Video +rbac_create_xvid#:#Create Interactive Video source#:#Source installed_version#:#Installed Database Version: %s, File Database Version %s source_does_not_exist#:#Source does not exist anymore or was disabled in the administration @@ -178,7 +178,7 @@ export_all_comments#:#Export All Comments question_image#:#Question image extract#:#Generate Thumbnail from Video use_this_image#:#Use this image -time_for_preview#:#Time: +time_for_preview#:#Time: comment_title_info#:#The title is always visible in the comment screen. correct_answer#:#Correct wrong_answer#:#Wrong @@ -262,4 +262,7 @@ layout_filter#:#Layout beta#:#Beta activate_marker#:#Activate marker activate_marker_info#:#Activate marker -no_comment_id_given#:#Something went wrong, the comment id is missing \ No newline at end of file +no_comment_id_given#:#Something went wrong, the comment id is missing +export_section#:#Export +csv_export_delimiter#:#CSV export delimiter +csv_export_delimiter_info#:#Change the default delimiter for CSV exports. diff --git a/plugin.php b/plugin.php index 119c572ba..22470f43d 100644 --- a/plugin.php +++ b/plugin.php @@ -3,7 +3,7 @@ $id = 'xvid'; // code version; must be changed for all code changes -$version = "3.5.2"; +$version = "3.5.3"; // ilias min and max version; must always reflect the versions that should // run with the plugin @@ -15,4 +15,4 @@ $responsible_mail = 'nahmad@databay.de / mjansen@databay.de / gvollbach@databay.de'; $learning_progress = true; -$supports_export = true; \ No newline at end of file +$supports_export = true; diff --git a/sql/dbupdate.php b/sql/dbupdate.php index bf71212c5..cd81945a9 100644 --- a/sql/dbupdate.php +++ b/sql/dbupdate.php @@ -186,7 +186,7 @@ 'length' => '4', 'notnull' => true ) - ); + ); $ilDB->createTable('rep_robj_xvid_question', $fields); $ilDB->addPrimaryKey('rep_robj_xvid_question', array('question_id')); $ilDB->createSequence('rep_robj_xvid_question'); @@ -414,15 +414,15 @@ ) ); } - + $res = $ilDB->queryF('SELECT comment_id FROM rep_robj_xvid_comments WHERE repeat_question = %s', array('integer'), array(1)); - + while($row = $ilDB->fetchAssoc($res)) { $comment_ids[] = $row['comment_id']; } - + $ilDB->manipulateF(' UPDATE rep_robj_xvid_question SET rep_robj_xvid_question.repeat_question = %s @@ -523,7 +523,7 @@ 'notnull' => true, 'default' => 0)); } - } + } ?> <#25> 1)); } ?> +<#84> +tableColumnExists('rep_robj_xvid_objects', 'csv_export_delimiter')) +{ + $ilDB->addTableColumn('rep_robj_xvid_objects', 'csv_export_delimiter', + array( + 'type' => 'text', + 'length' => 1, + 'notnull' => true, + 'default' => ";") + ); +} +?>