Skip to content

Commit 68c2e58

Browse files
caswelltomclaude
andcommitted
v3.0.2: Survey editor, specific source pills, rating scale labels
Survey question editor: - New admin page (survey_admin.php) for editing survey questions - Supports global default and per-course survey overrides - Add, edit, delete, reorder questions via drag or arrow buttons - Question types: multiple choice (with options editor), open text, rating scale - Rating scale supports min/max labels (e.g. "Not at all" / "Very happy") - Live preview button shows how students will see the survey - Course scope selector to switch between global and per-course surveys - Reset to defaults / remove course override actions - Registered in Moodle admin menu, linked from plugin settings Rating question fix: - Question 5 now reads "(1 = not at all, 5 = very happy)" - Rating UI shows min/max text labels next to the number buttons - DB migration updates existing surveys with scale labels Specific source attribution: - Source pills show activity name instead of generic "From: Course Materials" - AI cites specific activities using cmid from course structure - SSE meta event includes modules map for URL/title lookup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5a92837 commit 68c2e58

File tree

8 files changed

+665
-7
lines changed

8 files changed

+665
-7
lines changed

amd/build/ui.min.js

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/build/ui.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/ui.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4160,10 +4160,17 @@ define([
41604160
inputs.push({type: 'multiple_choice', index: idx, container: optContainer});
41614161

41624162
} else if (q.type === 'rating') {
4163+
var ratingWrap = document.createElement('div');
41634164
var ratingRow = document.createElement('div');
41644165
ratingRow.style.cssText = 'display:flex;gap:8px;align-items:center';
41654166
var min = q.min || 1;
41664167
var max = q.max || 5;
4168+
if (q.min_label) {
4169+
var minLbl = document.createElement('span');
4170+
minLbl.style.cssText = 'font-size:11px;color:#94a3b8;white-space:nowrap';
4171+
minLbl.textContent = q.min_label;
4172+
ratingRow.appendChild(minLbl);
4173+
}
41674174
for (var r = min; r <= max; r++) {
41684175
(function(val) {
41694176
var btn = document.createElement('button');
@@ -4185,7 +4192,14 @@ define([
41854192
ratingRow.appendChild(btn);
41864193
})(r);
41874194
}
4188-
qDiv.appendChild(ratingRow);
4195+
if (q.max_label) {
4196+
var maxLbl = document.createElement('span');
4197+
maxLbl.style.cssText = 'font-size:11px;color:#94a3b8;white-space:nowrap';
4198+
maxLbl.textContent = q.max_label;
4199+
ratingRow.appendChild(maxLbl);
4200+
}
4201+
ratingWrap.appendChild(ratingRow);
4202+
qDiv.appendChild(ratingWrap);
41894203
inputs.push({type: 'rating', index: idx, container: ratingRow});
41904204

41914205
} else {

classes/survey_manager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ class survey_manager {
5252
],
5353
[
5454
'type' => 'rating',
55-
'text' => 'Overall, how happy were you with the AI tutor?',
55+
'text' => 'Overall, how happy were you with the AI tutor? (1 = not at all, 5 = very happy)',
5656
'min' => 1,
5757
'max' => 5,
58+
'min_label' => 'Not at all',
59+
'max_label' => 'Very happy',
5860
],
5961
];
6062

db/upgrade.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,31 @@ function xmldb_local_ai_course_assistant_upgrade($oldversion) {
299299
upgrade_plugin_savepoint(true, 2026031200, 'local', 'ai_course_assistant');
300300
}
301301

302+
// v3.0.2: Update default survey rating question to include scale labels.
303+
if ($oldversion < 2026031202) {
304+
$surveys = $DB->get_records('local_ai_course_assistant_surveys');
305+
foreach ($surveys as $survey) {
306+
$questions = json_decode($survey->questions, true);
307+
if (!is_array($questions)) {
308+
continue;
309+
}
310+
$changed = false;
311+
foreach ($questions as &$q) {
312+
if (($q['type'] ?? '') === 'rating' && strpos($q['text'], '1 = ') === false) {
313+
$q['text'] = $q['text'] . ' (1 = not at all, 5 = very happy)';
314+
$q['min_label'] = 'Not at all';
315+
$q['max_label'] = 'Very happy';
316+
$changed = true;
317+
}
318+
}
319+
unset($q);
320+
if ($changed) {
321+
$DB->set_field('local_ai_course_assistant_surveys', 'questions',
322+
json_encode($questions), ['id' => $survey->id]);
323+
}
324+
}
325+
upgrade_plugin_savepoint(true, 2026031202, 'local', 'ai_course_assistant');
326+
}
327+
302328
return true;
303329
}

settings.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,8 @@
675675
$settings->add(new admin_setting_heading(
676676
'local_ai_course_assistant/survey_heading',
677677
'Student Survey',
678-
'Configure the in-chat student experience survey. Surveys can be customized per course via the analytics dashboard.'
678+
'Configure the in-chat student experience survey. '
679+
. '<a href="' . (new moodle_url('/local/ai_course_assistant/survey_admin.php'))->out() . '" class="btn btn-sm btn-outline-primary ml-2">Edit Survey Questions &rarr;</a>'
679680
));
680681

681682
$settings->add(new admin_setting_configcheckbox(
@@ -716,6 +717,14 @@
716717
'moodle/site:config'
717718
));
718719

720+
// Register the Survey Editor admin page.
721+
$ADMIN->add('localplugins', new admin_externalpage(
722+
'local_ai_course_assistant_survey',
723+
'SOLA Survey Editor',
724+
new moodle_url('/local/ai_course_assistant/survey_admin.php'),
725+
'moodle/site:config'
726+
));
727+
719728
// Register the RAG admin page as a separate entry in the admin menu.
720729
$ADMIN->add('localplugins', new admin_externalpage(
721730
'local_ai_course_assistant_ragadmin',

0 commit comments

Comments
 (0)