change unity-course.php prompts - #766
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 fororgexplicitly. - Added basic input validation for course ID and organization before constructing the
cn. - Updated
WorkerUnityCourseTeststdin 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 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 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]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
before:
after: