Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskContributions #1103

Merged
merged 111 commits into from
Oct 2, 2024
Merged

TaskContributions #1103

merged 111 commits into from
Oct 2, 2024

Conversation

florian-str
Copy link
Contributor

@florian-str florian-str commented Nov 21, 2023

This PR adds initial support for TaskContributions.
Currently, this includes:

  • Option to create, accept, deny TaskContributions
  • Email notification for requests, approved and denied contributions
  • The required abilities and checks

There are still some tests missing which I need to add before these changes can be merged. However, a review of the implementation is still possible.

  • unique_pending_contribution
  • can %i[update destroy], TaskContribution do |contrib|*
  • ParentValidation if parent_entry.blank?
  • TransferValues

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Attention: Patch coverage is 99.09366% with 3 lines in your changes missing coverage. Please review.

Project coverage is 94.77%. Comparing base (efc1d24) to head (5289a69).
Report is 114 commits behind head on master.

Files with missing lines Patch % Lines
app/models/concerns/transfer_values.rb 91.66% 2 Missing ⚠️
app/models/task.rb 98.61% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1103      +/-   ##
==========================================
+ Coverage   94.21%   94.77%   +0.56%     
==========================================
  Files         123      130       +7     
  Lines        3042     3330     +288     
==========================================
+ Hits         2866     3156     +290     
+ Misses        176      174       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MrSerth

This comment was marked as resolved.

MrSerth

This comment was marked as resolved.

MrSerth

This comment was marked as resolved.

config/locales/en/models.yml Outdated Show resolved Hide resolved
config/locales/en/models.yml Outdated Show resolved Hide resolved
app/views/tasks/show.html.slim Show resolved Hide resolved
MrSerth

This comment was marked as resolved.

@florian-str

This comment was marked as resolved.

app/controllers/task_contributions_controller.rb Outdated Show resolved Hide resolved
app/views/task_contributions/_task_contributions.html.slim Outdated Show resolved Hide resolved
app/views/task_contributions/_task_contributions.html.slim Outdated Show resolved Hide resolved
app/policies/task_contribution_policy.rb Outdated Show resolved Hide resolved
app/policies/task_contribution_policy.rb Outdated Show resolved Hide resolved
app/policies/task_policy.rb Outdated Show resolved Hide resolved
app/controllers/task_contributions_controller.rb Outdated Show resolved Hide resolved
app/policies/task_contribution_policy.rb Outdated Show resolved Hide resolved
app/policies/task_contribution_policy.rb Outdated Show resolved Hide resolved
app/views/task_contributions/new.html.slim Outdated Show resolved Hide resolved
db/migrate/20240610061157_fix_parent_id_format.rb Outdated Show resolved Hide resolved
app/views/task_contributions/new.html.slim Outdated Show resolved Hide resolved
app/views/task_contribution_mailer/approval_info.html.slim Outdated Show resolved Hide resolved
app/views/task_contributions/new.html.slim Outdated Show resolved Hide resolved
config/locales/de/controllers/task_contributions.yml Outdated Show resolved Hide resolved
config/locales/de/controllers/task_contributions.yml Outdated Show resolved Hide resolved
config/locales/de/controllers/task_contributions.yml Outdated Show resolved Hide resolved
config/locales/de/models.yml Outdated Show resolved Hide resolved
config/locales/de/views/task_contributions.yml Outdated Show resolved Hide resolved
spec/mailers/task_contribution_mailer_spec.rb Show resolved Hide resolved
@MrSerth

This comment was marked as outdated.

@MrSerth

This comment was marked as resolved.

MrSerth

This comment was marked as resolved.

app/views/tasks/show.html.slim Outdated Show resolved Hide resolved
app/views/tasks/show.html.slim Outdated Show resolved Hide resolved
app/views/tasks/show.html.slim Outdated Show resolved Hide resolved
app/views/tasks/show.html.slim Outdated Show resolved Hide resolved
app/views/tasks/show.html.slim Show resolved Hide resolved
MrSerth and others added 23 commits October 2, 2024 13:02
* Make method private
* Reduce parameters and avoid passing strings of class names
* Overwrite for file specifically
For now, we decided to keep the current behavior. Further investigations should happen in the future, for which we will create a new GitHub issue.
Also, use the newer syntax, so that the code is already compatible with Rails 7.2 and higher.
We recently discovered an issue where an old attachment would be incorrectly linked to an updated file after validation errors occurred. Specifically, the reproduction scenario is as follows:

1. Create a new task with a native file attached that passes all validations.
2. Edit this task and introduce a validation error that is unrelated to the file. For example, remove the task's title or language.
3. Select another native file attachment for the already existing TaskFile.
4. Attempt to save the changes
5. As expected, a validation error regarding the change is shown (title, language). Furthermore, the upload field has been cleared, since the file attachment was changed and the newly selected file was not yet saved on the server.
6. Fix the validation error and (without re-selecting the file attachment) save the task again.
7. Now, the task was saved again, despite the "missing" file attachment. However, it was expected that another validation error regarding the missing file attachment is shown. Unfortunately, the existing TaskFile also gets updated with the name of the previously selected file name (new file name, old content).

During our investigation, we identified that the attachment param of TaskParameters#file_params was simply missing, despite `use_attached_file=true`. Consequentially, assigning the params as attributes to the task (and the task file respectively) did not modify the existing `attachment` relationship, so that the previously saved attachment was still "connected". With the commit at hand, we therefore set the `attachment` param to `nil` explicitly, when it is not yet present (indicating that no file was sent by the browser) and the `parent_blob_id` is not present either (indicating that the file attachment got touched in one of the previous attempts to save changes).
Since we changed the file association in 9d9ac23, the `files` method might return an array of files. For transferring values, however, we need a ActiveRecord::CollectionProxy to perform actual changes on the records. With this commit, we add an exception for the transfer of values to fix that behavior.
@MrSerth MrSerth marked this pull request as ready for review October 2, 2024 11:03
Copy link
Member

@MrSerth MrSerth left a comment

Choose a reason for hiding this comment

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

What a huge improvement to CodeHarbor! 👏 I super happy about these changes and can't wait to see what our users will do with contributions. From my conversations with teachers, MOOC instructors and university professors, I am confident that this work can ease their workflows and support in better teaching 💪

Thank you so much for your countless and tireless work on this topic! 💐

@MrSerth MrSerth enabled auto-merge (rebase) October 2, 2024 11:07
@MrSerth MrSerth merged commit 0b3f7af into master Oct 2, 2024
11 checks passed
@MrSerth MrSerth deleted the fs_task_contrib branch October 2, 2024 11:08
@MrSerth MrSerth mentioned this pull request Oct 20, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement javascript Pull requests that update Javascript code ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants