local-instance: simulate a teacher, and run the files-storage consumer
`scripts/simulate-teacher.mjs` creates, edits and deletes what teachers create — course, room, topic, task, board, columns, cards, rich text, link, Etherpad pad, folder, files — so the MCP server can be exercised against content the real account has never held. It is the only thing here that writes to a Schulcloud and refuses any non-localhost address. `scripts/mcp-env.sh` points the server and CLI at the instance. Two gaps it exposed in the stack itself: The files-storage AMQP consumer is a separate entrypoint, and we were running only the HTTP one. Nothing was bound to the `files-storage` exchange, so `TaskService.delete` — which awaits deleteFilesOfParent over AMQP before touching the task — hung until the request timeout. Deleting any task or topic answered 408 with the entity still there. The demo data is dated 2017-2018 and the v3 endpoints filter on those dates, so a student saw no tasks at all. seed.sh now brings courses and homework into the present, which is the difference between a fixture that exercises the student-facing surface and one that looks empty. Teams turn out to be uncreatable through the API (the legacy service registers no `create`, v3 has no route), and a new board is unpublished and 403s for students, so the simulation adopts a seeded team and leaves one board a draft on purpose. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,43 @@ SECRET=$(curl -fsS -X POST "$MGMT/encrypt-plain-text" \
|
||||
print(' schools linked to the provider: ' + r.modifiedCount);
|
||||
"
|
||||
|
||||
# The demo data is dated 2017-2018, and the v3 endpoints filter on those dates:
|
||||
# a course that has ended shows a student no tasks, and a task whose due date
|
||||
# passed years ago is in neither the open nor the finished list and has dropped
|
||||
# off the course page. The result is a student account that looks empty for
|
||||
# reasons that have nothing to do with whatever is being tested against it.
|
||||
#
|
||||
# So move the stale data into the present. Courses get a term around today.
|
||||
# Homework is shifted by one offset per date cluster, which keeps the relative
|
||||
# order — and so which tasks are past due, the ones carrying the graded
|
||||
# submissions — while landing the newest of them two weeks ago.
|
||||
echo "==> dating the demo data to the present"
|
||||
"${COMPOSE[@]}" exec -T mongo mongosh schulcloud --quiet --eval "
|
||||
const now = new Date();
|
||||
const courses = db.courses.updateMany({ untilDate: { \$lt: now } }, { \$set: {
|
||||
startDate: new Date(now.getTime() - 180 * 86400000),
|
||||
untilDate: new Date(now.getTime() + 185 * 86400000),
|
||||
} });
|
||||
print(' courses given a current term: ' + courses.modifiedCount);
|
||||
|
||||
let moved = 0;
|
||||
for (let pass = 0; pass < 10; pass++) {
|
||||
const cutoff = new Date(Date.now() - 365 * 86400000);
|
||||
const newest = db.homeworks.find({ dueDate: { \$lt: cutoff } }).sort({ dueDate: -1 }).limit(1).toArray()[0];
|
||||
if (!newest) break;
|
||||
const offset = (Date.now() - 14 * 86400000) - newest.dueDate.getTime();
|
||||
db.homeworks.find({ dueDate: { \$lt: cutoff } }).forEach((h) => {
|
||||
const set = {};
|
||||
for (const field of ['dueDate', 'availableDate', 'createdAt', 'updatedAt']) {
|
||||
if (h[field] instanceof Date) set[field] = new Date(h[field].getTime() + offset);
|
||||
}
|
||||
db.homeworks.updateOne({ _id: h._id }, { \$set: set });
|
||||
moved++;
|
||||
});
|
||||
}
|
||||
print(' homework brought forward: ' + moved);
|
||||
"
|
||||
|
||||
cat <<'ACCOUNTS'
|
||||
|
||||
==> ready — http://localhost:4400
|
||||
|
||||
Reference in New Issue
Block a user