Skip to content

change unity-course.php prompts - #766

Merged
simonLeary42 merged 1 commit into
mainfrom
tweak-unity-course
Aug 21, 2026
Merged

change unity-course.php prompts#766
simonLeary42 merged 1 commit into
mainfrom
tweak-unity-course

Conversation

@simonLeary42

@simonLeary42 simonLeary42 commented Aug 21, 2026

Copy link
Copy Markdown
Member

before:

  • prompt for "course ID" (example: cs123)
  • prompt for "cn" (example: cs123_org1_test)
  • extract org from cn

after:

  • prompt for "course ID" (example: cs123)
  • prompt for org (example: org1_test)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the unity-course.php worker’s interactive prompts to ask for the organization directly (instead of asking for a full cn and extracting the org), and adjusts the functional test to match the new prompt sequence.

Changes:

  • Removed cn-based org extraction and now prompts for org explicitly.
  • Added basic input validation for course ID and organization before constructing the cn.
  • Updated WorkerUnityCourseTest stdin inputs to reflect the new prompt order.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
workers/unity-course.php Changes the prompt flow to ask for org directly, constructs cn from course ID + org, and adds input validation.
test/functional/WorkerUnityCourseTest.php Updates functional test stdin lines to match the new worker prompt sequence.
Suppressed comments (1)

workers/unity-course.php:34

  • The organization validation reports “contains invalid characters” when the input is empty. Adding an explicit required/empty check first would produce a more accurate error for missing input.
$org_gid = strtolower(trim(readline("Please enter the organization (example: umass_edu): ")));
if (!_preg_match("/^[a-z0-9_]+$/", $org_gid)) {
    _die("error: organization '$org_gid' contains invalid characters", 1);
}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread workers/unity-course.php
Comment on lines 26 to +29
$givenName = trim(readline("Enter the course ID (example: CS123): "));
if (!_preg_match("/^[a-zA-Z0-9_-]+$/", $givenName)) {
_die("error: course ID '$givenName' contains invalid characters", 1);
}
Comment thread workers/unity-course.php
Comment on lines +27 to +35
if (!_preg_match("/^[a-zA-Z0-9_-]+$/", $givenName)) {
_die("error: course ID '$givenName' contains invalid characters", 1);
}
$sn = trim(readline("Enter the year and semester of the course (example: Fall 2025): "));
$cn = strtolower(
trim(readline("Please enter the cn to be used for the course (example: cs123_umass_edu): ")),
);
$org_gid = strtolower(trim(readline("Please enter the organization (example: umass_edu): ")));
if (!_preg_match("/^[a-z0-9_]+$/", $org_gid)) {
_die("error: organization '$org_gid' contains invalid characters", 1);
}
$cn = implode("_", [strtolower($givenName), $org_gid]);
@simonLeary42
simonLeary42 merged commit 6df09cc into main Aug 21, 2026
5 checks passed
@simonLeary42
simonLeary42 deleted the tweak-unity-course branch August 21, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants