Skip to content

Add functionality to deselect radio buttons for usage_by_lms #1882

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/assets/javascripts/tasks_form.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ready = ->
initializeFileTypeSelection()
initializeVisibilityWarning()
initializeNewFileTooltips()

initializeLoadSelect2 = ->
$('#task_programming_language_id').select2
Expand Down Expand Up @@ -32,6 +33,10 @@ initializeVisibilityWarning = ->
$('#task_access_level_public').on 'change', ->
warning_message.addClass('d-none')

initializeNewFileTooltips = ->
$(document).on "fields_added.nested_form_fields", (event, param) ->
$('[data-bs-toggle="tooltip"]').tooltip();

destroy_select2 = ->
$('#task_programming_language_id').select2('destroy');
$('.my-group').select2('destroy');
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/buttons-and-controls.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
width: 33%;
}

.radio-quarter {
width: 25%;
}

.radio-base {
border: #cccccc 1px solid;
padding: 5px;
Expand Down
2 changes: 2 additions & 0 deletions app/models/task_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class TaskFile < ApplicationRecord
validate :parent_validation_check
attr_accessor :use_attached_file, :file_marked_for_deletion, :parent_blob_id

normalizes :usage_by_lms, with: ->(usage_by_lms) { usage_by_lms.presence }

before_validation :attach_parent_blob, if: -> { attachment.blank? && task&.contribution? && parent.present? && parent_blob_id.present? }
before_save :remove_attachment

Expand Down
8 changes: 4 additions & 4 deletions app/views/account_links/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
= render('shared/form_errors', object: @account_link)
.field-element.form-group
= f.label :name, AccountLink.human_attribute_name('name'), class: 'form-label'
= f.text_field :name, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('.info.name'), class: 'form-control'
= f.text_field :name, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.info.name'), class: 'form-control'
.field-element.form-group
= f.label :push_url, AccountLink.human_attribute_name('push_url'), class: 'form-label'
= f.text_field :push_url, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('.info.push_url'), class: 'form-control'
= f.text_field :push_url, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.info.push_url'), class: 'form-control'
.field-element.form-group
= f.label :check_uuid_url, AccountLink.human_attribute_name('check_uuid_url'), class: 'form-label'
= f.text_field :check_uuid_url, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('.info.check_uuid_url'), class: 'form-control'
= f.text_field :check_uuid_url, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.info.check_uuid_url'), class: 'form-control'
.field-element.form-group
= f.label :api_key, AccountLink.human_attribute_name('api_key'), class: 'form-label'
.input-group
= f.text_field :api_key, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('.info.token'), class: 'form-control'
= f.text_field :api_key, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.info.token'), class: 'form-control'
= button_tag t('.button.generate'), type: 'button', class: 'generate-api-key-token btn btn-light'
.field-element.form-group
= f.label :proforma_version, AccountLink.human_attribute_name('proforma_version'), class: 'form-label'
Expand Down
20 changes: 12 additions & 8 deletions app/views/tasks/_file_config.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,46 @@
= file.label :used_by_grader, TaskFile.human_attribute_name('used_by_grader'), class: 'form-label w-auto me-2'
.radio-switch
= file.radio_button :used_by_grader, true, value: true, checked: true
= file.label :used_by_grader_true, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('common.button.yes'), class: 'radio-left small-radio radio-half' do
= file.label :used_by_grader_true, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('common.button.yes'), class: 'radio-left small-radio radio-half' do
span.fa-stack
i.fa-solid.fa-check.fa-stack-1x.fa-2x
= file.radio_button :used_by_grader, false, value: false
= file.label :used_by_grader_false, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('common.button.no'), class: 'radio-right small-radio radio-half' do
= file.label :used_by_grader_false, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('common.button.no'), class: 'radio-right small-radio radio-half' do
span.fa-stack
i.fa-solid.fa-xmark.fa-stack-1x.fa-2x

.form-control.placeholder
= file.label :used_by_grader, TaskFile.human_attribute_name('visible'), class: 'form-label w-auto me-2'
.radio-switch
= file.radio_button :visible, 'yes', value: 'yes', checked: true
= file.label :visible_yes, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('common.button.yes'), class: 'radio-left small-radio radio-third' do
= file.label :visible_yes, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('common.button.yes'), class: 'radio-left small-radio radio-third' do
span.fa-stack
i.fa-regular.fa-eye.fa-stack-1x.fa-2x
= file.radio_button :visible, 'no', value: 'no'
= file.label :visible_no, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('common.button.no'), class: 'radio-right radio-left small-radio radio-third' do
= file.label :visible_no, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('common.button.no'), class: 'radio-right radio-left small-radio radio-third' do
span.fa-stack
i.fa-regular.fa-eye-slash.fa-stack-1x.fa-2x
= file.radio_button :visible, 'delayed', value: 'delayed'
= file.label :visible_delayed, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('.delayed'), class: 'radio-right small-radio radio-third' do
= file.label :visible_delayed, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.delayed'), class: 'radio-right small-radio radio-third' do
span.fa-stack
i.fa-regular.fa-clock.fa-stack-1x.fa-2x

.form-control.placeholder
= file.label :usage_by_lms, TaskFile.human_attribute_name('usage_by_lms'), class: 'form-label w-auto me-2'
.radio-switch
= file.radio_button :usage_by_lms, 'edit', value: 'edit'
= file.label :usage_by_lms_edit, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('common.button.edit'), class: 'radio-left small-radio radio-third' do
= file.label :usage_by_lms_edit, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.edit'), class: 'radio-left small-radio radio-quarter' do
span.fa-stack
i.fa-solid.fa-pencil.fa-stack-1x.fa-2x
= file.radio_button :usage_by_lms, 'display', value: 'display'
= file.label :usage_by_lms_display, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('.display'), class: 'radio-right radio-left small-radio radio-third' do
= file.label :usage_by_lms_display, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.display'), class: 'radio-right radio-left small-radio radio-quarter' do
span.fa-stack
i.fa-regular.fa-eye.fa-stack-1x.fa-2x
= file.radio_button :usage_by_lms, 'download', value: 'download'
= file.label :usage_by_lms_download, data: {toggle: 'tooltip', placement: 'bottom'}, title: t('.download'), class: 'radio-right small-radio radio-third' do
= file.label :usage_by_lms_download, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.download'), class: 'radio-right radio-left small-radio radio-quarter' do
span.fa-stack
i.fa-solid.fa-download.fa-stack-1x.fa-2x
= file.radio_button :usage_by_lms, ''
= file.label :usage_by_lms_, data: {'bs-toggle': 'tooltip', placement: 'bottom'}, title: t('.no_value'), class: 'radio-right small-radio radio-quarter' do
span.fa-stack
i.fa-solid.fa-ban.fa-stack-1x.fa-2x
2 changes: 2 additions & 0 deletions config/locales/de/views/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ de:
delayed: Verzögert
display: Anzeigen
download: Herunterladen
edit: Bearbeiten
no_value: Kein Wert
form:
button:
add_model_solution: Musterlösung hinzufügen
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en/views/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ en:
delayed: delayed
display: display
download: download
edit: edit
no_value: no value
form:
button:
add_model_solution: Add Model Solution
Expand Down
Loading