diff --git a/htdocs/js/DatePicker/datepicker.js b/htdocs/js/DatePicker/datepicker.js index 3cbe63dfc6..767d5ce99b 100644 --- a/htdocs/js/DatePicker/datepicker.js +++ b/htdocs/js/DatePicker/datepicker.js @@ -112,6 +112,14 @@ // input to fix that. this.altInput.after(this.input); + // Move the id of the now hidden input onto the added input so the labels still work. + this.altInput.id = this.input.id; + + // Remove the placeholder from the hidden input. Flatpickr has copied that to the added input, and + // that isn't valid on a hidden input. + this.input.removeAttribute('id'); + this.input.removeAttribute('placeholder'); + // Make the alternate input left-to-right even for right-to-left languages. this.altInput.dir = 'ltr'; diff --git a/htdocs/js/UserDetail/userdetail.js b/htdocs/js/UserDetail/userdetail.js index 5295406e3f..a1d990dc0b 100644 --- a/htdocs/js/UserDetail/userdetail.js +++ b/htdocs/js/UserDetail/userdetail.js @@ -24,22 +24,6 @@ } }); - // Make the date override checkboxes checked or unchecked appropriately - // as determined by the value of the date input when that value changes. - document - .querySelectorAll('input[type="text"][data-override],input[type="hidden"][data-override]') - .forEach((input) => { - const overrideCheck = document.getElementById(input.dataset.override); - if (!overrideCheck) return; - const changeHandler = () => (overrideCheck.checked = input.value != ''); - input.addEventListener('change', changeHandler); - // Attach the keyup and blur handlers to the flatpickr alternate input. - input.previousElementSibling?.addEventListener('keyup', changeHandler); - input.previousElementSibling?.addEventListener('blur', () => { - if (input.previousElementSibling.value == '') overrideCheck.checked = false; - }); - }); - // If the "Assign All Sets to Current User" button is clicked, then check all assignments. document.getElementsByName('assignAll').forEach((button) => { button.addEventListener('click', () => { diff --git a/lib/WeBWorK/ContentGenerator/Instructor/UserDetail.pm b/lib/WeBWorK/ContentGenerator/Instructor/UserDetail.pm index 9065ebf42a..dedfc7a163 100644 --- a/lib/WeBWorK/ContentGenerator/Instructor/UserDetail.pm +++ b/lib/WeBWorK/ContentGenerator/Instructor/UserDetail.pm @@ -31,7 +31,7 @@ use WeBWorK::Debug; use constant DATE_FIELDS => { open_date => x('Open:'), reduced_scoring_date => x('Reduced:'), - due_date => x('Closes:'), + due_date => x('Close:'), answer_date => x('Answer:') }; use constant DATE_FIELDS_ORDER => [qw(open_date reduced_scoring_date due_date answer_date )]; @@ -90,14 +90,11 @@ sub initialize ($c) { unless ($rh_dates->{error}) { # If no error update database for my $field (@{ DATE_FIELDS_ORDER() }) { - if (defined $c->param("set.$setID.$field.override") && $c->param("set.$setID.$field") ne '') { + if ($c->param("set.$setID.$field") && $c->param("set.$setID.$field") ne '') { $userSetRecord->$field($rh_dates->{$field}); } else { - $userSetRecord->$field(undef); #stop override - - # Update the parameters so the user interface reflects the changes made. - $c->param("set.$setID.$field.override", undef); - $c->param("set.$setID.$field", undef); + # Stop override + $userSetRecord->$field(undef); } } $db->putUserSet($userSetRecord); @@ -120,8 +117,8 @@ sub initialize ($c) { unless ($rh_dates->{error}) { for my $field (@{ DATE_FIELDS_ORDER() }) { $setVersionRecord->$field($rh_dates->{$field}) - if defined $c->param("set.$setID,v$ver.$field.override") - && $c->param("set.$setID,v$ver.$field") ne ''; + if ($c->param("set.$setID,v$ver.$field") + && $c->param("set.$setID,v$ver.$field") ne ''); } $db->putSetVersion($setVersionRecord); } @@ -182,7 +179,7 @@ sub checkDates ($c, $setRecord, $setID) { my %dates; for my $field (@{ DATE_FIELDS_ORDER() }) { $dates{$field} = - (defined $c->param("set.$setID.$field.override") && $c->param("set.$setID.$field") ne '') + ($c->param("set.$setID.$field") && $c->param("set.$setID.$field") ne '') ? $c->param("set.$setID.$field") : ($setID =~ /,v\d+$/ ? 0 : $setRecord->$field); } diff --git a/templates/ContentGenerator/Instructor/UserDetail/set_date_table.html.ep b/templates/ContentGenerator/Instructor/UserDetail/set_date_table.html.ep index 3a69c40412..3a6218e6ab 100644 --- a/templates/ContentGenerator/Instructor/UserDetail/set_date_table.html.ep +++ b/templates/ContentGenerator/Instructor/UserDetail/set_date_table.html.ep @@ -1,22 +1,22 @@ % my $setID = $globalRecord->set_id; % % # Modify set id to include the version if this is a versioned set. -% my $isVersioned = 0; -% if (defined $mergedRecord && $mergedRecord->assignment_type =~ /gateway/ && $mergedRecord->can('version_id')) { - % $setID .= ',v' . $mergedRecord->version_id; - % $isVersioned = 1; -% } +% my $isGateway = $globalRecord->assignment_type =~ /gateway/; +% my $isVersioned = $isGateway && defined $mergedRecord && $mergedRecord->can('version_id'); +% $setID .= ',v' . $mergedRecord->version_id if $isVersioned; % - - + % if (defined $userRecord) { + + % } + % unless ($isVersioned) { + + % } % for my $field (@$fields) { % # Skip reduced credit dates for sets which don't have them. @@ -28,33 +28,22 @@ % my $globalValue = $globalRecord->$field; % - - - + + % } + % unless ($isVersioned) { + + % } % }
- % if (defined $userRecord) { - <%= maketext("User overrides") =%> - % } - - <%= maketext("Set values") =%> - + <%= $isVersioned ? maketext(q{User's Test Version Dates}) : maketext('User Overrides') =%> + > + <%= $isGateway ? maketext('Test Dates') : maketext('Assignment Dates') =%> +
- % if (defined $userRecord) { - <%= label_for "set.$setID.$field.override_id" => maketext($fieldLabels->{$field}), - class => 'form-check-label' =%> - % } else { - <%= maketext($fieldLabels->{$field}) =%> - % } - - % if (defined $userRecord) { - <%= check_box "set.$setID.$field.override" => $field, - id => "set.$setID.$field.override_id", class => 'form-check-input', - (defined $mergedRecord ? $mergedRecord->$field : $globalValue) ne $globalValue - || ($isVersioned && $field ne 'reduced_scoring_date') - ? (checked => undef) - : () =%> - % } + <%= label_for "set.$setID.$field" . (defined $userRecord ? '_id' : '.class_value') => + maketext($fieldLabels->{$field}), + class => 'form-label mb-0' =%> - % if (defined $userRecord) { + % if (defined $userRecord) { +
<%= text_field "set.$setID.$field" => defined $userRecord ? $userRecord->$field : $globalValue, id => "set.$setID.${field}_id", - placeholder => maketext('None Specified'), class => 'form-control w-auto' . ($field eq 'open_date' ? ' datepicker-group' : ''), + placeholder => $isGateway + ? ($isVersioned ? maketext('Required') : maketext('Test Default')) + : maketext('Assignment Default'), + $isVersioned ? (required => undef) : (), data => { - override => "set.$setID.$field.override_id", input => undef, done_text => maketext('Done'), today_text => maketext('Today'), @@ -62,15 +51,22 @@ locale => $ce->{language}, timezone => $ce->{siteDefaults}{timezone} } =%> - + + +
- % } -
- - <%= $c->formatDateTime($globalValue, 'datetime_format_short') =%> - - + <%= text_field "set.$setID.$field.class_value" => + $c->formatDateTime($globalValue, 'datetime_format_short'), + id => "set.$setID.$field.class_value", readonly => undef, dir => 'ltr', + class => 'form-control form-control-sm w-auto', + defined $userRecord ? ('aria-labelledby' => "set.$setID.${field}_id") : () =%> +
diff --git a/templates/HelpFiles/InstructorUserDetail.html.ep b/templates/HelpFiles/InstructorUserDetail.html.ep index 557ccf7ea9..d7e2dc5ab3 100644 --- a/templates/HelpFiles/InstructorUserDetail.html.ep +++ b/templates/HelpFiles/InstructorUserDetail.html.ep @@ -27,7 +27,8 @@ . 'date in order to override the date. (You can copy the date format from the date in the right hand column ' . 'which indicates the date when the homework set is due for the whole class.) Note that you should ensure ' . 'that the close date is before the answer date. If the close date for a student is extended until after the ' - . 'class answer date for the set, then the answer date for the student must also be set to a later date. ') =%> + . 'class answer date for the set, then the answer date for the student must also be set to a later date. ' + . 'If a date is left empty, then the assignment default date will be used.') =%>

<%= maketext('Click on the homework set links to edit the grades for this individual student on the homework set. '