diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab3f526..45a0827 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -198,6 +198,7 @@ jobs: env: DB: ${{ matrix.database }} MOODLE_BRANCH: ${{ matrix.moodle-branch }} + MUSTACHE_IGNORE_NAMES: 'mobile_*.mustache' - name: PHP Lint if: ${{ always() }} diff --git a/classes/external/save_feedback.php b/classes/external/save_feedback.php index 3c21304..4cc052c 100644 --- a/classes/external/save_feedback.php +++ b/classes/external/save_feedback.php @@ -52,15 +52,12 @@ class_alias('external_api', 'mod_journal\external\journal_external_api_base'); * @copyright 2026 Adrian Sarmas adrian.emanuel.sarmas@gmail.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class save_feedback extends journal_external_api_base -{ - +class save_feedback extends journal_external_api_base { /** * Parameters. * @return external_function_parameters */ - public static function execute_parameters(): external_function_parameters - { + public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ 'cmid' => new external_value(PARAM_INT, 'Course module id'), 'entryid' => new external_value(PARAM_INT, 'Journal entry id'), @@ -71,8 +68,33 @@ public static function execute_parameters(): external_function_parameters ]); } - public static function execute(int $cmid, int $entryid, int $userid, int $grade, string $feedback = '', int $itemid = 0): array - { + /** + * Execute. + * + * @param int $cmid + * @param int $entryid + * @param int $userid + * @param int $grade + * @param string $feedback + * @param int $itemid + * @return array + * @throws \coding_exception + * @throws \core_external\restricted_context_exception + * @throws \dml_exception + * @throws \dml_transaction_exception + * @throws \moodle_exception + * @throws \require_login_exception + * @throws \required_capability_exception + * @throws invalid_parameter_exception + */ + public static function execute( + int $cmid, + int $entryid, + int $userid, + int $grade, + string $feedback = '', + int $itemid = 0 + ): array { global $DB, $USER; $params = self::validate_parameters(self::execute_parameters(), [ @@ -160,8 +182,12 @@ public static function execute(int $cmid, int $entryid, int $userid, int $grade, ]; } - public static function execute_returns(): external_single_structure - { + /** + * Return structure. + * + * @return external_single_structure + */ + public static function execute_returns(): external_single_structure { return new external_single_structure([ 'status' => new external_value(PARAM_ALPHA, 'ok'), 'changed' => new external_value(PARAM_INT, '1 if something changed, else 0'), diff --git a/classes/external/set_text.php b/classes/external/set_text.php index 8e22427..29123e8 100644 --- a/classes/external/set_text.php +++ b/classes/external/set_text.php @@ -101,6 +101,7 @@ public static function execute_returns(): external_single_structure { * @param int $journalid Journal course module ID * @param string $text Text parameter * @param int|string $format Format constant for the string + * @param int $itemid Item id for draft area (files) * @return array */ public static function execute(int $journalid, string $text, $format, int $itemid = 0) { @@ -111,7 +112,7 @@ public static function execute(int $journalid, string $text, $format, int $itemi ['journalid' => $journalid, 'text' => $text, 'format' => $format, 'itemid' => $itemid] ); - if (!$cm = get_coursemodule_from_instance('journal', $params['journalid'])) { + if (!$cm = get_coursemodule_from_id('journal', $params['journalid'])) { throw new invalid_parameter_exception(get_string('incorrectcmid', 'journal')); } @@ -142,9 +143,9 @@ public static function execute(int $journalid, string $text, $format, int $itemi } else { // Create a record first to get an ID for file storage. $tempentry = clone $newentry; - $tempentry->text = ''; + $tempentry->text = ''; $newentry->id = $DB->insert_record('journal_entries', $tempentry); - $entry = $newentry; + $entry = $newentry; } // Handle File Drafts. @@ -186,10 +187,10 @@ public static function execute(int $journalid, string $text, $format, int $itemi $completion->update_state($cm, COMPLETION_COMPLETE); } - // Return array matching execute_returns + // Return array matching execute_returns. return [ 'status' => 'ok', - 'text' => $newentry->text + 'text' => $newentry->text, ]; } } diff --git a/classes/external/view_journal.php b/classes/external/view_journal.php index 16b42c2..ea53f29 100644 --- a/classes/external/view_journal.php +++ b/classes/external/view_journal.php @@ -25,7 +25,7 @@ global $CFG; -// Dynamic Class Logic +// Dynamic Class Logic. if (!class_exists('mod_journal\external\journal_external_api_base')) { if (class_exists('core_external\external_api')) { class_alias('core_external\external_api', 'mod_journal\external\journal_external_api_base'); @@ -49,7 +49,6 @@ class_alias('external_api', 'mod_journal\external\journal_external_api_base'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class view_journal extends journal_external_api_base { - /** * Parameters. * @return external_function_parameters @@ -100,4 +99,4 @@ public static function execute($journalid) { public static function execute_returns() { return null; } -} \ No newline at end of file +} diff --git a/classes/output/mobile.php b/classes/output/mobile.php index de789d0..fc6a956 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -33,7 +33,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mobile { - /** * Returns the template and data for the main course view in the mobile app. * @@ -77,13 +76,13 @@ public static function mobile_course_view($args) { $canadd = has_capability('mod/journal:addentries', $context); $canmanage = has_capability('mod/journal:manageentries', $context); - // --- TEACHER VIEW LOGIC --- + // TEACHER VIEW LOGIC. if ($canmanage) { $data['isteacher'] = true; // Determine grouping. $currentgroup = groups_get_activity_group($cm, true); - + // Get list of users who have submitted entries. $users = journal_get_users_done($journal, $currentgroup); $submissions = []; @@ -155,7 +154,7 @@ public static function mobile_course_view($args) { $data['submissions'] = $submissions; } - // --- STUDENT VIEW LOGIC --- + // STUDENT VIEW LOGIC. // Calculate open/close dates. $timenow = time(); $timestart = 0; @@ -189,7 +188,7 @@ public static function mobile_course_view($args) { if ($entry) { $data['hasentry'] = true; $data['lastedited'] = userdate($entry->modified); - + // Rewrite files for display. $text = file_rewrite_pluginfile_urls( (string) $entry->text, @@ -204,7 +203,7 @@ public static function mobile_course_view($args) { // Check for feedback. if (!empty($entry->entrycomment) || (!empty($entry->rating) && $entry->rating != -1)) { $data['hasfeedback'] = true; - + $feedbacktext = file_rewrite_pluginfile_urls( (string) $entry->entrycomment, 'pluginfile.php', @@ -262,7 +261,7 @@ public static function mobile_course_view($args) { /** * Student entry editor page. - * + * * This page is opened via core-site-plugins-new-content from the main view. * It provides a simple textarea for the student to write their entry. * diff --git a/db/mobile.php b/db/mobile.php index 4b886fb..7bd71b9 100644 --- a/db/mobile.php +++ b/db/mobile.php @@ -55,10 +55,10 @@ ['entries', 'mod_journal'], ['noentriesmanagers', 'mod_journal'], ['entry', 'mod_journal'], - ['gradedby', 'moodle'], + ['gradedby', 'mod_journal'], ['nograde', 'mod_journal'], ['changessaved', 'mod_journal'], ], 'css' => $CFG->wwwroot . '/mod/journal/styles.css', ], -]; \ No newline at end of file +]; diff --git a/db/services.php b/db/services.php index 2f794b4..232ea0a 100644 --- a/db/services.php +++ b/db/services.php @@ -57,4 +57,4 @@ 'ajax' => true, 'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE], ], -]; \ No newline at end of file +]; diff --git a/lang/en/journal.php b/lang/en/journal.php index e376ef3..a9c7e2b 100755 --- a/lang/en/journal.php +++ b/lang/en/journal.php @@ -28,6 +28,7 @@ $string['accessdenied'] = 'Access denied'; $string['alwaysopen'] = 'Always open'; $string['blankentry'] = 'Blank entry'; +$string['changessaved'] = 'Changes saved'; $string['completiondetail:completion_create_entry'] = 'Create a journal entry'; $string['couldnotupdatejournal'] = 'Could not update your journal'; $string['countnotinsertjournalentry'] = 'Could not insert a new journal entry'; @@ -52,10 +53,13 @@ $string['eventjournaldeleted'] = 'Journal deleted'; $string['eventjournalviewed'] = 'Journal viewed'; $string['failedupdate'] = 'Failed to update the journal feedback for {$a}'; +$string['feedback'] = 'Feedback'; $string['feedbackupdated'] = 'Feedback updated for {$a} entries'; $string['feedbackupdatedforuser'] = 'Feedback updated for {$a}'; $string['firstnameasc'] = 'Firstname Ascending'; $string['firstnamedesc'] = 'Firstname Descending'; +$string['grade'] = 'Grade'; +$string['gradedby'] = 'Graded by'; $string['gradeingradebook'] = 'Current grade in gradebook'; $string['incorrectcmid'] = 'Course module ID is incorrect'; $string['incorrectcourseid'] = 'Course ID is incorrect'; @@ -66,11 +70,6 @@ $string['journal:addentries'] = 'Add journal entries'; $string['journal:addinstance'] = 'Add a new journal'; $string['journal:manageentries'] = 'Manage journal entries'; -$string['grade'] = 'Grade'; -$string['feedback'] = 'Feedback'; -$string['savechanges'] = 'Save changes'; -$string['nograde'] = 'No grade'; -$string['changessaved'] = 'Changes saved'; // Updated Plain Text Template. $string['journalmail'] = 'Hi {$a->student}, @@ -128,6 +127,7 @@ $string['nodeadline'] = 'Always open'; $string['noentriesmanagers'] = 'There are no teachers'; $string['noentry'] = 'No entry'; +$string['nograde'] = 'No grade'; $string['noratinggiven'] = 'No rating given'; $string['notifystudents'] = 'Notify students'; $string['notifystudents_default'] = 'Notify students by default'; @@ -154,6 +154,7 @@ $string['removeentries'] = 'Remove all entries'; $string['removemessages'] = 'Remove all Journal entries'; $string['saveallfeedback'] = 'Save all my feedback'; +$string['savechanges'] = 'Save changes'; $string['savefeedback'] = 'Save feedback'; $string['search:activity'] = 'Journal - activity information'; $string['search:entry'] = 'Journal - entries'; diff --git a/lib.php b/lib.php index ddcc8bd..4a422e8 100644 --- a/lib.php +++ b/lib.php @@ -1095,7 +1095,8 @@ function journal_print_user_entry($course, $user, $entry, $teachers, $grades, $c $options, $fpoptions ); - echo "