Skip to content

Commit f7c0104

Browse files
committed
MBS-10583: Fixes after CR
1 parent e4184c7 commit f7c0104

16 files changed

+184
-219
lines changed

amd/build/regenerate.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/regenerate.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/regenerate.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import Ajax from 'core/ajax';
2626
import Notification from 'core/notification';
27+
import {add as addToast} from 'core/toast';
2728
import {get_string as getString} from 'core/str';
2829
import Pending from 'core/pending';
2930

@@ -64,15 +65,9 @@ export const init = (assignmentId, userId) => {
6465
}])[0];
6566

6667
if (result.success) {
67-
Notification.addNotification({
68-
message: result.message,
69-
type: 'success',
70-
});
68+
addToast(result.message, {type: 'success'});
7169
} else {
72-
Notification.addNotification({
73-
message: result.message,
74-
type: 'error',
75-
});
70+
addToast(result.message, {type: 'danger'});
7671
}
7772
} catch (error) {
7873
Notification.exception(error);

classes/aif.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2929
*/
3030
class aif {
31-
/** @var int The context ID for AI requests. */
3231
/** @var int The context ID for AI requests. */
3332
protected int $contextid;
3433

@@ -48,7 +47,7 @@ public function __construct(int $contextid) {
4847
* via \core\di::set(ai_request_provider::class, $mock).
4948
*
5049
* @param string $prompt The prompt to send to the AI.
51-
* @param string|null $purpose The purpose of the request (for local_ai_manager). If null, uses config.
50+
* @param string|null $purpose The purpose of the request (for local_ai_manager). Defaults to 'feedback'.
5251
* @param array $options Additional options (e.g., 'image' for ITT requests).
5352
* @param int $userid The user to attribute the AI request to. Defaults to current $USER.
5453
* @return string The AI response.
@@ -62,9 +61,8 @@ public function perform_request(string $prompt, ?string $purpose = null, array $
6261

6362
$provider = \core\di::get(ai_request_provider::class);
6463

65-
// Get purpose from config if not provided.
6664
if ($purpose === null) {
67-
$purpose = get_config('assignfeedback_aif', 'purpose') ?: 'feedback';
65+
$purpose = 'feedback';
6866
}
6967

7068
$backend = get_config('assignfeedback_aif', 'backend') ?: 'core_ai_subsystem';

classes/event/observer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace assignfeedback_aif\event;
1818

19-
use assignfeedback_aif\task\process_feedback_rubric_adhoc;
19+
use assignfeedback_aif\task\process_feedback_adhoc;
2020
use core\task\manager;
2121

2222
/**
@@ -59,14 +59,15 @@ private static function queue_feedback_generation(\mod_assign\event\assessable_s
5959
}
6060

6161
// Queue the ad-hoc task.
62-
$task = new process_feedback_rubric_adhoc();
62+
$task = new process_feedback_adhoc();
6363
$task->set_custom_data([
6464
'assignment' => $assignmentid,
6565
'users' => [$userid],
6666
'action' => 'generate',
6767
'triggeredby' => 'auto',
6868
]);
69-
$task->set_userid(get_admin()->id);
69+
// Run as the submitting user so quota and availability checks are correct.
70+
$task->set_userid($userid);
7071
manager::queue_adhoc_task($task, true);
7172
}
7273

classes/external/regenerate_feedback.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use core_external\external_function_parameters;
2121
use core_external\external_single_structure;
2222
use core_external\external_value;
23-
use assignfeedback_aif\task\process_feedback_rubric_adhoc;
23+
use assignfeedback_aif\task\process_feedback_adhoc;
2424
use core\context\module as context_module;
2525
use core\task\manager;
2626

@@ -73,7 +73,7 @@ public static function execute(int $assignmentid, int $userid): array {
7373
require_capability('mod/assign:grade', $context);
7474

7575
// Queue the ad-hoc task for this single user.
76-
$task = new process_feedback_rubric_adhoc();
76+
$task = new process_feedback_adhoc();
7777
$task->set_custom_data([
7878
'assignment' => $params['assignmentid'],
7979
'users' => [$params['userid']],

classes/local/hook_callbacks.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ public static function handle_purpose_usage(\local_ai_manager\hook\purpose_usage
4040
'assignfeedback_aif',
4141
get_string('purposeplacedescription_feedback', 'assignfeedback_aif')
4242
);
43-
$hook->add_purpose_usage_description(
44-
'translate',
45-
'assignfeedback_aif',
46-
get_string('purposeplacedescription_translate', 'assignfeedback_aif')
47-
);
4843
$hook->add_purpose_usage_description(
4944
'itt',
5045
'assignfeedback_aif',

0 commit comments

Comments
 (0)