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

Fill in empty dates with valid dates for date picker groups. #2351

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Mar 6, 2024

This builds on #2348, and was requested by @Alex-Jordan in that pull request (see #2348 (review)).

This makes it so that if a date is not filled in, then it will be filled by javascript with a date as needed to ensure it satisfies the usual date requirements on open, reduced scoring, close, and answer dates.

The class value is taken into account for this when editing a set for users.

This applies on both the problem set detail page and the user detail page. This javascript is also used on the sets manager page when editing set dates where this change does not apply, but it is designed to still work without conflict there.

@drgrice1
Copy link
Member Author

drgrice1 commented Mar 6, 2024

Note that once #2348 is merged you will see that there is not much to this pull request. Or just look at the last commit.

@drgrice1 drgrice1 force-pushed the empty-date-fill branch 3 times, most recently from 7238810 to dd3e928 Compare March 6, 2024 16:34
@pstaabp
Copy link
Member

pstaabp commented Mar 7, 2024

We have those variables $pg{assignOpenPriorToDue} and $pg{answersOpenAfterDueDate} that are updatable in the Course Configuration. I know those are variables in pg, but can we pass them to the javascript to do the filling of the due and answer dates and maybe set the reduced scoring to the due date?

@drgrice1
Copy link
Member Author

drgrice1 commented Mar 7, 2024

It does not make sense to use those variables in the JavaScript. Those are used to set the dates initially when an assignment is created. This for a global set, the changes made here are overriding those things, and the JavaScript should not presume otherwise. When editing a set for users, the values from the global set are used, and those variables also should not override that.

Copy link
Member

@pstaabp pstaabp left a comment

Choose a reason for hiding this comment

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

Works well.

@Alex-Jordan
Copy link
Contributor

I'm getting some strange behavior with this. I'm using Firefox, in case that matters.

  • In Instructor Tools, I select a student and click to "Edit assignments and dates for one user"
  • There is a set with coursewide Open/Close/Answer: 6/19/23, 11:59 PM, 6/26/24, 11:59 PM, 6/26/24, 11:59 PM
  • I click inside the override field for the close date, and type "4/1/25".

I'm not sure what I should expect at this point (not having entered a time) but when I click outside of the input, it changes to "4/6/24, 12:00 AM".

@drgrice1
Copy link
Member Author

The same thing happens with develop and WeBWorK 2.18. So that is not this pull request. That is because the date doesn't parse in the required format.

@drgrice1
Copy link
Member Author

This now changes the way that the fallback behavior works to address what @Alex-Jordan observed.

Currently if a date is entered into a datepicker input that does not parse with the format of the current locale (for example if a date is typed without a time), then a fallback is filled in. That fallback is the last displayed valid value if there was one. If there was an intial value in the input, then that fallback will initially be the input's initial value. It is then updated anytime a new valid value is entered. However, if there was no initial value for the input, the fallback ends up being set to the last visible date in what is shown when the calender popup opens. That is sommewhat unexpected behavior.

So this changes the way that the fallback works. If there is an initial value for the input (as will be the case when editing a set for the whole class), then that is still used for the initial fallback. However, if there is no initial value (as will be the case when editing the set for users), then the class value is used. In any case, the fallback will be updated to be the last valid value that is entered after that.

There is a last case in which the input does not have an initial value and there also is no class value. In that case the fallback is the current date and time. This usually won't be used on the set detail page, but applies to the import date shift input on the set list.

Copy link
Contributor

@Alex-Jordan Alex-Jordan left a comment

Choose a reason for hiding this comment

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

Thanks for that refinement. Works for me. Since @pstaabp only tested the other aspect of this PR I'll let him test again before merging (or let someone else test).

@drgrice1 drgrice1 force-pushed the empty-date-fill branch 2 times, most recently from dc98f91 to a51e7f7 Compare March 18, 2024 01:56
This builds on openwebwork#2348, and was requested by @Alex-Jordan in that pull
request (see openwebwork#2348 (review)).

This makes it so that if a date is not filled in, then it will be filled
by javascript with a date as needed to ensure it satisfies the usual
date requirements on open, reduced scoring, close, and answer dates.

The class value is taken into account for this when editing a set for
users.

This applies on both the problem set detail page and the user detail
page. This javascript is also used on the sets manager page when editing
set dates where this change does not apply, but it is designed to still
work without conflict there.
Currently if a date is entered into a datepicker input that does not
parse with the format of the current locale (for example if a date is
typed without a time), then a fallback is filled in.  That fallback is
the last displayed valid value if there was one.  If there was an intial
value in the input, then that fallback will initially be the input's
initial value.  It is then updated anytime a new valid value is entered.
However, if there was no initial value for the input, the fallback ends
up being set to the last visible date in what is shown when the calender
popup opens.  That is sommewhat unexpected behavior.

So this changes the way that the fallback works.  If there is an initial
value for the input (as will be the case when editing a set for the
whole class), then that is still used for the initial fallback.
However, if there is no initial value (as will be the case when editing
the set for users), then the class value is used.  In any case, the
fallback will be updated to be the last valid value that is entered
after that.

There is a last case in which the input does not have an initial value
and there also is no class value.  In that case the fallback is the
current date and time.  This usually won't be used on the set detail
page, but applies to the import date shift input on the set list.
@pstaabp
Copy link
Member

pstaabp commented Mar 20, 2024

Tested again. This still looks good to me. Will merge.

@pstaabp pstaabp merged commit 07e6c7b into openwebwork:develop Mar 20, 2024
2 checks passed
@drgrice1 drgrice1 deleted the empty-date-fill branch March 20, 2024 11:41
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.

3 participants