openHPI / codeharbor

Exchange of Programming Exercises acrossdiverse Code Assessment Systems through CodeHarbor
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

Add more fine granular rating system with sub-categories #1574

Closed MrSerth closed 2 weeks ago

MrSerth commented 1 month ago

to be written

Closes #1483

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.12%. Comparing base (beb5df3) to head (e195759). Report is 10 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1574 +/- ## ========================================== + Coverage 94.08% 94.12% +0.04% ========================================== Files 123 123 Lines 2990 2998 +8 ========================================== + Hits 2813 2822 +9 + Misses 177 176 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Mathis-Z commented 1 month ago

Do you know if lib/templates/slim/scaffold/_form.html.slim.erb is still needed? The commit that added the file is very old and it has not been changed since then. Also the safe delete function of RubyMine does not find any uses?

Edit: I decided to remove the file.

MrSerth commented 1 month ago

Do you know if lib/templates/slim/scaffold/_form.html.slim.erb is still needed? The commit that added the file is very old and it has not been changed since then. Also the safe delete function of RubyMine does not find any uses?

Edit: I decided to remove the file.

The file is still used, at least somehow 😁

Rails features so-called generators, which allow someone to add another resource quickly. These generators can either be used for specific parts (like a migration, model, controller, views, tests, ...) or altogether. For example, the following introduces a new model Repository and all related files. It already specifies that a repository should have three attributes and one association:

rails generate scaffold repository name:string description:text remote:string group:references
Details

```log invoke active_record create db/migrate/20240812125339_create_repositories.rb create app/models/repository.rb invoke test_unit create test/models/repository_test.rb create test/fixtures/repositories.yml invoke resource_route route resources :repositories invoke scaffold_controller create app/controllers/repositories_controller.rb invoke slim exist app/views/repositories create app/views/repositories/index.html.slim create app/views/repositories/edit.html.slim create app/views/repositories/show.html.slim create app/views/repositories/new.html.slim create app/views/repositories/_form.html.slim create app/views/repositories/_repository.html.slim invoke resource_route invoke test_unit create test/controllers/repositories_controller_test.rb create test/system/repositories_test.rb invoke helper create app/helpers/repositories_helper.rb invoke test_unit invoke jbuilder create app/views/repositories/index.json.jbuilder create app/views/repositories/show.json.jbuilder create app/views/repositories/_repository.json.jbuilder ```

As part of this generation (specifically for app/views/repositories/_form.html.slim) the lib/templates/slim/scaffold/_form.html.slim.erb is used. Hence, the resulting file will look like this:

= simple_form_for(@repository) do |f|
  = f.error_notification

  .form-inputs
    = f.input :name
    = f.input :description
    = f.input :remote
    = f.association :group

  .form-actions
    = f.button :submit

As you can see, this really much instantiates the template you deleted. The resulting page doesn't look too nice yet, but is fully functional (especially the reference!):

Bildschirmfoto 2024-08-12 um 15 05 51

All of that was magically created by Rails 🪄


That having said, I have to admit that we aren't using generators often and they also lack the latest changes. For example, no pundit policy is generated or considered in the controller, the styling is off, and errors are also caught differently than expected.

Invalid record

![Bildschirmfoto 2024-08-12 um 15 09 32](https://github.com/user-attachments/assets/33c6e927-5897-4ca0-b5cb-c0276b6ef9e7)

Without the file, the view for adding or editing entries looks different (mostly better, I would say)

Bildschirmfoto 2024-08-12 um 15 17 30

The only downside is that the "nice" dropdown for the group is lost and replaced with a text field (which expects a group ID). Long story short: I think, I am fine with removing the file, but would wish for a backlog ticket to fix the Rails generators (views, policies, ...) and verify them.

MrSerth commented 1 month ago

Ah, one further thing I wanted to share: About two weeks ago, online ratings were subject of a trial at the German Federal Court of Justice (BGH). The question was whether an online platform needs to show the distribution of ratings for the different star levels. In the ruling, the court decided that this information doesn't need to be revealed, since the average user should be aware of the potential discrepancy of individual ratings.

Sources: Press Release, Ruling

MrSerth commented 2 weeks ago

We just merged this branch and included all changes for the rating with af875c7dda08f50f40c4a7e4499711e325afb2d6.