Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ jobs:
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
MUSTACHE_IGNORE_NAMES: 'mobile_*.mustache'

- name: PHP Lint
if: ${{ always() }}
Expand Down
44 changes: 35 additions & 9 deletions classes/external/save_feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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(), [
Expand Down Expand Up @@ -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'),
Expand Down
11 changes: 6 additions & 5 deletions classes/external/set_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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'));
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
];
}
}
5 changes: 2 additions & 3 deletions classes/external/view_journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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
Expand Down Expand Up @@ -100,4 +99,4 @@ public static function execute($journalid) {
public static function execute_returns() {
return null;
}
}
}
13 changes: 6 additions & 7 deletions classes/output/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand Down Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions db/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
];
];
2 changes: 1 addition & 1 deletion db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
'ajax' => true,
'services' => [MOODLE_OFFICIAL_MOBILE_SERVICE],
],
];
];
11 changes: 6 additions & 5 deletions lang/en/journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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},
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,8 @@ function journal_print_user_entry($course, $user, $entry, $teachers, $grades, $c
$options,
$fpoptions
);
echo "<p><div>".get_string('feedback', 'journal').":</div><textarea id=\"c$entry->id[text]\" name=\"c$entry->id[text]\" rows=\"7\" $feedbackdisabledstr>";
echo "<p><div>" . get_string('feedback', 'journal') .
":</div><textarea id=\"c$entry->id[text]\" name=\"c$entry->id[text]\" rows=\"7\" $feedbackdisabledstr>";
p($feedbacktext);
echo '</textarea></p>';

Expand Down
Loading