Skip to content

Add opt-out for publishing results + codeword field - #753

Merged
horcsinbalint merged 9 commits into
developmentfrom
application-codeword
Jul 23, 2025
Merged

horcsinbalint merged 9 commits into
developmentfrom
application-codeword

Conversation

@BertalanD

Copy link
Copy Markdown
Member

No description provided.

@BertalanD
BertalanD requested a review from a team as a code owner July 23, 2025 12:53
This commit fixes the style issues introduced in 974810d according to the output
from PHP CS Fixer.

Details: #753
@coderabbitai

coderabbitai Bot commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@horcsinbalint has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 52 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 6f41864 and 79c9817.

📒 Files selected for processing (6)
  • app/Exports/ApplicantsExport.php (4 hunks)
  • app/Livewire/ParentChildForm.php (1 hunks)
  • app/Utils/ApplicationHandler.php (2 hunks)
  • resources/views/auth/application/questions.blade.php (2 hunks)
  • resources/views/components/input/checkbox.blade.php (1 hunks)
  • resources/views/user/study-line-selector.blade.php (2 hunks)
📝 Walkthrough

Walkthrough

This update introduces two new fields—publication_consent and pseudonym—to the application process. Model, migration, validation, Blade views, and tests have been updated to support these fields. Conditional logic ensures that either publication consent is granted or a pseudonym is provided before considering the application complete. Validation and UI behaviour have been adjusted accordingly.

Changes

File(s) Change Summary
app/Models/Application.php Added publication_consent (bool) and pseudonym (string) properties; updated $fillable and $casts; modified logic in missingData().
app/Utils/ApplicationHandler.php Extended validation in storeQuestionsData to include publication_consent and pseudonym with new validation rules.
database/migrations/2025_07_23_140346_application_codeword.php Migration adds publication_consent (boolean, default false) and codeword (nullable string, max 20) columns to applications table.
resources/lang/en/validation.php, resources/lang/hu/validation.php Added attribute label/translation for pseudonym in both English and Hungarian validation files.
resources/views/auth/application/application.blade.php Refactored anchor tag for user name; conditionally displays pseudonym if no consent and pseudonym is set.
resources/views/auth/application/questions.blade.php Added checkbox for publication consent and input for pseudonym; JavaScript toggles pseudonym field visibility dynamically.
tests/Feature/ApplicationTest.php Test updated to include publication_consent in application submission payload.
app/Exports/ApplicantsExport.php Added "Jelige" column header and mapped pseudonym field to export output.
app/Http/Controllers/Secretariat/UserController.php Modified validation rule for collegist alumni field to allow empty string (no validation) instead of required.
app/Livewire/ParentChildForm.php Modified mount method to initialize $items from old input if available; updated $hidden condition accordingly.
resources/views/components/input/checkbox.blade.php Changed checkbox checked condition to use dynamic $id key instead of fixed 'recurring' key for old input check.
resources/views/user/study-line-selector.blade.php Changed semester selection to use filtered list up to current semester instead of all semesters.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ApplicationForm
    participant Server
    participant Database

    User->>ApplicationForm: Opens application questions page
    ApplicationForm->>User: Shows publication consent checkbox and pseudonym input (toggled by JS)
    User->>ApplicationForm: Submits form with publication_consent and/or pseudonym
    ApplicationForm->>Server: Sends POST request with data
    Server->>Database: Validates and stores publication_consent and pseudonym
    Server->>User: Returns success or validation errors
Loading

Estimated code review effort

2 (~20 minutes)

Possibly related PRs

  • Filter applications export #626: Extends ApplicantsExport class by adding other export columns; related due to modifying export functionality in the same file.

Suggested labels

priority

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@BertalanD
BertalanD force-pushed the application-codeword branch from c0511a3 to b422a74 Compare July 23, 2025 12:59

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e398a5 and b422a74.

📒 Files selected for processing (8)
  • app/Models/Application.php (3 hunks)
  • app/Utils/ApplicationHandler.php (1 hunks)
  • database/migrations/2025_07_23_140346_application_codeword.php (1 hunks)
  • resources/lang/en/validation.php (1 hunks)
  • resources/lang/hu/validation.php (1 hunks)
  • resources/views/auth/application/application.blade.php (1 hunks)
  • resources/views/auth/application/questions.blade.php (2 hunks)
  • tests/Feature/ApplicationTest.php (1 hunks)
🧠 Learnings (2)
resources/views/auth/application/application.blade.php (1)

Learnt from: kdmnk
PR: #607
File: resources/views/errors/minimal.blade.php:9-11
Timestamp: 2024-08-06T12:48:49.276Z
Learning: When separating CSS into an external file, name it app.blade.php as specified by the user.

app/Utils/ApplicationHandler.php (1)

Learnt from: viktorcsimma
PR: #542
File: app/Http/Controllers/Secretariat/SemesterEvaluationController.php:161-161
Timestamp: 2024-06-13T19:25:19.821Z
Learning: 'anonymous_questions' is a section name in the 'secretariat.evaluation-form.app' view and does not require handling in the store method of SemesterEvaluationController.php.

🧬 Code Graph Analysis (1)
app/Utils/ApplicationHandler.php (2)
app/Models/Application.php (1)
  • user (126-129)
app/Models/User.php (1)
  • application (255-258)
🧰 Additional context used
🧠 Learnings (2)
resources/views/auth/application/application.blade.php (1)

Learnt from: kdmnk
PR: #607
File: resources/views/errors/minimal.blade.php:9-11
Timestamp: 2024-08-06T12:48:49.276Z
Learning: When separating CSS into an external file, name it app.blade.php as specified by the user.

app/Utils/ApplicationHandler.php (1)

Learnt from: viktorcsimma
PR: #542
File: app/Http/Controllers/Secretariat/SemesterEvaluationController.php:161-161
Timestamp: 2024-06-13T19:25:19.821Z
Learning: 'anonymous_questions' is a section name in the 'secretariat.evaluation-form.app' view and does not require handling in the store method of SemesterEvaluationController.php.

🧬 Code Graph Analysis (1)
app/Utils/ApplicationHandler.php (2)
app/Models/Application.php (1)
  • user (126-129)
app/Models/User.php (1)
  • application (255-258)
🔇 Additional comments (12)
resources/lang/en/validation.php (1)

74-75: Excellent addition to the validation attributes.

The 'codeword' attribute mapping follows the established pattern perfectly and will ensure proper localisation of validation error messages for the new field.

resources/lang/hu/validation.php (1)

74-75: Proper Hungarian localisation implemented.

The translation 'jelige' for 'codeword' is appropriate and maintains consistency with the English validation file structure.

resources/views/auth/application/application.blade.php (2)

81-81: Clean consolidation of the anchor tag.

The refactoring to a single line improves readability whilst maintaining the same functionality.


85-87: Well-implemented conditional codeword display.

The logic correctly shows the codeword in grey parentheses only when publication consent is declined and a codeword is provided. The inline styling is consistent with the existing patterns throughout this template.

database/migrations/2025_07_23_140346_application_codeword.php (2)

11-17: Excellently structured migration implementation.

The column definitions are spot-on: publication_consent appropriately defaults to false for privacy-first behaviour, whilst codeword has a sensible 20-character limit and nullable constraint. The column positioning ensures logical database structure.


22-28: Proper rollback implementation.

The down method correctly removes both columns, ensuring clean migration reversal capability.

app/Models/Application.php (4)

37-38: Proper property annotations added.

The property annotations are correctly documented with appropriate types.


91-92: Fields properly added to fillable array.

Both new fields are correctly included in the fillable array, maintaining consistency with the existing structure.


99-100: Appropriate casting for publication_consent.

The boolean casting for publication_consent is correct. Note that codeword appropriately remains uncast as it should stay as a string.


421-423: Well-implemented conditional business logic.

The conditional logic correctly implements the requirement: either publication consent must be granted or a codeword must be provided. The logic is clear and follows the established pattern in the method.

resources/views/auth/application/questions.blade.php (2)

157-167: Excellent UI implementation with proper form binding.

The form elements are well-structured with:

  • Clear, descriptive text for the publication consent checkbox
  • Proper model binding using the application properties
  • Validation attributes that match the backend rules
  • Helpful explanatory text for the codeword field

183-196: Robust JavaScript implementation for dynamic behaviour.

The JavaScript logic is well-implemented:

  • Properly handles the inverse relationship (shows codeword when consent is NOT given)
  • Includes both DOM ready and change event listeners
  • Uses clear, semantic function and variable names
  • Correctly manipulates display styles for the wrapper element

Comment thread app/Utils/ApplicationHandler.php Outdated
'question_1' => ['answer 1'],
'question_2' => 'answer 2',
'question_3' => 'answer 3',
'publication_consent' => '1',

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.

🛠️ Refactor suggestion

Good addition for publication consent testing.

The test now properly includes the publication_consent field, ensuring the happy path is covered.

However, I'd strongly recommend adding comprehensive test coverage for the complete feature:

  1. Test scenario where publication_consent is false and codeword is provided
  2. Test codeword validation rules (uniqueness, length constraints)
  3. Test the conditional requirement logic between consent and codeword
  4. Test codeword display logic in the view

Would you like me to generate additional test cases to ensure robust coverage of this feature?

🤖 Prompt for AI Agents
In tests/Feature/ApplicationTest.php at line 343, the current test includes the
publication_consent field but lacks coverage for other important scenarios. Add
new test cases to cover when publication_consent is false and codeword is
provided, validate codeword rules like uniqueness and length constraints, verify
the conditional logic between consent and codeword, and check that the codeword
is correctly displayed in the view. This will ensure comprehensive testing of
the feature.

@horcsinbalint
horcsinbalint force-pushed the application-codeword branch from 3dbba66 to f7b96c3 Compare July 23, 2025 14:39

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7b96c3 and afb2d65.

📒 Files selected for processing (2)
  • app/Exports/ApplicantsExport.php (2 hunks)
  • app/Http/Controllers/Secretariat/UserController.php (1 hunks)
🧬 Code Graph Analysis (2)
app/Http/Controllers/Secretariat/UserController.php (2)
app/helpers.php (1)
  • user (15-23)
app/Models/User.php (1)
  • isCollegist (753-770)
app/Exports/ApplicantsExport.php (1)
app/Models/User.php (1)
  • application (255-258)
🧰 Additional context used
🧬 Code Graph Analysis (2)
app/Http/Controllers/Secretariat/UserController.php (2)
app/helpers.php (1)
  • user (15-23)
app/Models/User.php (1)
  • isCollegist (753-770)
app/Exports/ApplicantsExport.php (1)
app/Models/User.php (1)
  • application (255-258)
🔇 Additional comments (2)
app/Exports/ApplicantsExport.php (2)

62-63: Well implemented addition of the pseudonym header.

The addition of "Jelige" to the export headers is quite proper and aligns perfectly with the PR objectives for adding pseudonym functionality.


96-97: Excellent implementation of pseudonym field mapping.

The inclusion of $application->pseudonym in the export data mapping is spot on and maintains consistency with the newly added header. This properly supports the opt-out publication feature described in the PR objectives.

Comment on lines +163 to +166
$requiredForCollegist = $user->isCollegist(alumni: true) ? "" : "nullable";
/*
If a field is omitted from the input, the request should succeed.
*/

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.

🛠️ Refactor suggestion

Consider using 'nullable' rather than an empty string for validation rules.

I must say, using an empty string "" as a validation rule is rather unconventional and may not behave as intended. In Laravel, validation rules should typically be either "required" for mandatory fields or "nullable" for optional ones. An empty string might not be processed correctly by Laravel's validation system.

If the intention is to make fields optional for collegist alumni whilst allowing omitted fields to pass validation, I'd strongly recommend using "nullable" instead:

-$requiredForCollegist = $user->isCollegist(alumni: true) ? "" : "nullable";
+$requiredForCollegist = $user->isCollegist(alumni: true) ? "nullable" : "nullable";

Or if you truly wish to differentiate between collegist and non-collegist users:

-$requiredForCollegist = $user->isCollegist(alumni: true) ? "" : "nullable";
+$requiredForCollegist = $user->isCollegist(alumni: true) ? "nullable" : "required";

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In app/Http/Controllers/Secretariat/UserController.php around lines 163 to 166,
replace the empty string "" used as a validation rule with "nullable" to
correctly indicate optional fields in Laravel validation. Change the assignment
so that $requiredForCollegist is set to "nullable" when the user is a collegist
alumni, ensuring the validation system properly handles omitted fields without
errors.

@horcsinbalint
horcsinbalint force-pushed the application-codeword branch from f06ea34 to 092b6c6 Compare July 23, 2025 15:46
@horcsinbalint
horcsinbalint force-pushed the application-codeword branch from 6f41864 to 79c9817 Compare July 23, 2025 15:56
@horcsinbalint
horcsinbalint merged commit 4029054 into development Jul 23, 2025
horcsinbalint pushed a commit that referenced this pull request Jul 23, 2025
This commit fixes the style issues introduced in 974810d according to the output
from PHP CS Fixer.

Details: #753
@horcsinbalint
horcsinbalint deleted the application-codeword branch July 23, 2025 16:00
BertalanD added a commit that referenced this pull request Jul 23, 2025
This was obsoleted by pseudonyms in applications (#753).
BertalanD pushed a commit that referenced this pull request Jul 24, 2025
This commit fixes the style issues introduced in 974810d according to the output
from PHP CS Fixer.

Details: #753
BertalanD added a commit that referenced this pull request Jul 24, 2025
This was obsoleted by pseudonyms in applications (#753).
@coderabbitai coderabbitai Bot mentioned this pull request Apr 28, 2026
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