-
Notifications
You must be signed in to change notification settings - Fork 9
Improvement to the general models #89
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
Conversation
…ProblemSets and UserSets.
…sts to work (only in ET).
I realize there is git hub action error. It's a perlcritic thing and not sure how to avoid doing line 398 of |
…set_params to set_dates.
…store and set to the database. TEST: adding tests to ensure that only valid models are added to the store and set to the database.
FIX: cleanup and using true/false in tests.
you still cannot at a user. The name and role fields work, but the other fields (first and last name etc.) are closed and blank and submitting the new user raises a complaint that not all of the parameters have been supplied. |
the recent changes help. |
everything compiled after I pulled in the latest changes from PR#89 (in openwebwork/webwork3) adding users. It would be good to get the site user dashboard management system up and running soon, since it will interact substantially with the classlist manager. The data I entered (new user gage, as instructor) was saved in the database and I could log in to the class using the name gage and add problems to hmwk set #2. I don't know if this data is stored on the server in some way that it will stick around. running unit tests: prove -r t Got errors in 003_users_t (2 failures), 009_problems.t (3 failures) after rebuilding the database I got no errors in the unit tests, but I could no longer log in as gage. |
I reestablished myself as an instructor and added problems to hmwk set #2. Unit tests now give me: # Failed test 'The set_problems table is returned to its original state.' # Failed test 'check: Ensure that the set_problems table is restored.' |
how do you run the lint code base, unit tests and perltidy on the pull request? Is this done automatically? |
The tests require that you have a clean run of
Linting, perltidy, and the run of the tests are performed on a push to GitHub and you can see that the last commit ran successfully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to try to review this, see the few comments I left. However, there is something wrong with this branch. You need to merge main into this one. Hopefully that will fix it. Github's diff is not matching what I see when I look at actual diffs on the files.
.eslintrc.js
Outdated
'keyword-spacing': ['error'], | ||
'space-before-blocks': ['error', 'always'], | ||
'arrow-spacing': ['error'], | ||
'template-curly-spacing': ['error', 'never'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested merging main into this branch or merging this branch into main, and in either case this being added here results in this rule being duplicated. Clearly you need to merge the main branch into this one, and do some clean up.
It is good to group related rules, so it is better where the rule is in main up above by object-curly-spacing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged in main and deleted this.
lib/DB/Schema/Result/UserSet.pm
Outdated
); | ||
|
||
my $set_type = { | ||
our $set_type = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed to our
? Generally, in modern perl you don't want our
at all. Is this variable even used? It doesn't look like it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look at this again. There was some issue that it wasn't visible in a subclass I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get errors when it accesses line 166 of Result::UserSet.pm
, for reverse mapping the number of the subclass with the type.
If you have some other ways of doing this, I welcome them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, it is not an issue with our
versus my
. The $set_type
variable just needs to be deleted. It is not used anywhere. I deleted it, and all tests still pass. The front end still works as well as it currently does. Why is it here?
|
||
sub optional_fields_in_dates ($=) { | ||
return DB::Schema::Result::ProblemSet::HWSet::optional_fields_in_dates(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make any sense, and needs to be rethought. It doesn't make sense to have optional non-date fields in the dates.
The JSON column structure is going to need to be thought out better. Right now there are several bad design ideas going on with that. The original idea was for these to be for non-essential uncommon things. Not dates that are pretty well mapped out. Furthermore, this is making the implementation rather convoluted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the enable_reduced_scoring
into the date structure so checking date validity is self-contained for cases of reduced scoring. This solved the issue of needing to pass in enable_reduced_scoring
from the set_params
field to check the validity. In order to not hard-code this field into the dates, I added this other method.
Let me know if you have some better thoughts on this or we can revert back to the way I handled it before.
Although I'm crazy about having a non-date field inside this, it does make a lot of other things easier to handle now.
I'm not up to speed on WW3, but started to look around to get an idea what is going on. Why |
I feel like we're just getting started on some of the options like this for ww3. The overall structure is nearly there and is quite flexible, so if we need to adjust fields like this, it shouldn't be too difficult. |
} elsif (grep { $_ eq $key } @{ $config->{non_neg_float_fields} }) { | ||
$output->{$key} = 0 + $input->{$key} if defined($input->{$key}); | ||
} else { | ||
$output->{$key} = $input->{$key}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has bugged me for a while. Why is this part of the main lib
? It would be in the t
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can move this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is time that you start focusing your work. There is a whole mesh of changes here, most of which do not fall under the title of improving general models, and that is why so many files were changed.
There are a lot of changes to the JSON values that should have been in the pull request before related to that. So that pull request should have been completed before you started this one.
There are changes of double to single quotes. Finish that in a separate pull request next time.
It would make it much easier for us to review your work if it were focused on the real point.
I've been trying to get more focused on these PRs and will do better. I realize that such large PRs are hard to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
- remove
our $set_type
declaration fromlib/DB/Schema/Result/UserSet.pm
- move TestUtils.pm out of
lib/DB/
and intot/lib
? (will need touse
the testing lib directory) - dates remain in JSON field for now -- but we should all discuss pros/cons of this approach before getting into scoring (or other features that rely on dates)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good for now. I will merge it once the tests complete.
This builds on #88 which handles booleans on the server.
There are a number of related changes:
isValid
method which return a boolean on whether or not the model is valid. For example, if the username is 'the user' the methodisValid
will return false.CourseUser
model has avalidate
method which both validates any relevant field and otherwise returns a error string. This is helpful for adding users to courses (for example, via loading a file).enable_reducing_scoring
is moved from theset_params
of a HomeworkSet to theset_dates
field, since that is needed for determining homework dates are valid or not.