-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Patches to scaffold.pl so Preview does not modify which sections are open #506
base: develop
Are you sure you want to change the base?
Patches to scaffold.pl so Preview does not modify which sections are open #506
Conversation
Note the use of scaffolding where some "later" sections are intended to be open before some earlier ones is likely to have issues with this patch. In such cases, the new functionality should probably be disabled using the new control switch options for Scaffold. Support for such usage would probably require storing an array of open section numbers instead of just the number of the last open section. Whether there is sufficient need to consider implementing such can be determined in the future. |
No longer relevant. State is now in the database and not in a hidden form field and cannot be tampered with by the student. I have been thinking some about 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.
You have this set up to change the defaults to the new behavior that you are introducing. That should not be the case. There are instructors out there that depend on this default behavior. In fact @drdrew42 uses scaffolds in this way. His point is that he wants students to be able to use the preview button to work through the problem without ever having hit submit until all answers are entered. He wants this as it pertains to a certain achievement that tracks incorrect submissions. With your new settings the only way to progress to the next section is to hit submit and get that part correct. That means the unanswered latter parts are incorrect, and this achievement will note that.
This was originally posted as a proof of concept, but now that the defaults keep the existing behavior unchanged, the only reason to defer merging it is the hidden issue that tampering with the hidden form field can make trouble. Fixing that requires some method of preventing such tampering which is not something I think I can have ready in time for the release candidate of PG 2.16. As such I have marked this as |
@taniwallach Do we want to revisit this to get into 2.18? If so, need to fix the conflicts. |
5f66a78
to
fc7b992
Compare
fc7b992
to
0fa323d
Compare
0fa323d
to
00147ad
Compare
I need to fix this for a change made in #809 so it is marked as not ready to merge. |
00147ad
to
a73c76b
Compare
a73c76b
to
106b3a2
Compare
358de88
to
e3dc0ab
Compare
I made some additional changes so that when a MultiAnswer is in an unopened section and is using To see the behavior I think is not correct do a preview of the problem attached below (using a student account, not an instructor account) without the second section being opened before the changes of the second commit (or commenting out the line which sets With the new changes, that does not occur. Right now the new code sets @drgrice1 Do you have a better idea for how this can be done. There are 2 local files to use with the sample problem. All files were renamed to end with Files: Note: The A version of the problem which demonstrates the bug in code based on the current basis checker (marking incorrect answers as correct) is in:
1,2,1,2 It seems that there may be problems with the new features in this PR if a problem has answer blanks in an "always open" section which come after sections which are only open when the prior section was correct. I think not supporting that sort of use case for the features added is a relatively reasonable limitation. |
With this branch, when I first encounter a problem, I'm getting the following error:
I think this is because there is no data in the |
are open when Preview is called: (a) Allow preventing opening an additional section when all answers of the last open section are correct during processing a Preview render, and (b) Allow preventing scaffold closing previously open sections if an answer to a prior section became incorrect when processing a Preview render. Control switches control if these modified behaviors are used or not. The defaults maintain the prior behavior. Some contributions to a prior version of this code by Glenn Rice.
preview by setting boolean scaffold_past_open in the rh_ans hash of all answers in sections which were past the last open one.
e3dc0ab
to
d7778a2
Compare
@pstaabp I think I fixed that. I had moved some things around when working on the changes for multianswer but only tested on an old problem so did not see that error, and do not think I ever saw anything like that with the earlier versions of the branch. Could we try to merge the two PRs about |
@taniwallach If you make changes to #506, you can then rebase this branch onto that. The latest commit seems to have fixed the error I was seeing before. |
I have been rebasing, possible not in an efficient manner. Right now this is built on the most recent version of #809. |
@pstaabp Before you approved did you have a look at the changes to MultiAnswer preview handling for the |
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 mentioned that I don't like how in openwebwork/webwork2#1940 the problem_data
field is set even when answers are not submitted. I still don't think that is a good idea, and I am rather certain that what you are trying to accomplish in this pull request can be done without that. Furthermore, I think that there is a way to do this that doesn't even use the database. This causes rather inconsistent behavior when rendering problems in many of the various different ways that problems can be rendered. Your new problem_data
behavior was not implemented for the render_rpc
or html2xml
endpoints, it doesn't take into account instructor status, and in general does not seem to be fully thought out. There are other macros that preserve state without this problem_data
database column, and I am certain that what you are trying to accomplish can be done using similar techniques. Both Geogebra applets and MathQuill do that sort of thing using hidden inputs and the KEPT_EXTRA_ANSWERS
hash. The problem is that this is saving state and making it persistent in some cases where state should not be persistent.
When an instructor opens a scaffold problem in an assignment, then the "Check Answers" button is available and furthermore scaffolds can be manually opened by the instructors. This is not taken into account in what is done here, and results in some rather odd behavior of scaffolds. With or without this pull request and using your first sample problem (scaffold-sample-01.pg), if the instructor opens a later section, answers it correctly (other sections are left unanswered), and clicks "Check Answers", then that section comes back open and that section is colored green. The difference is in what happens if you next click "Preview My Answers". Without this pull request if you click preview then that last correctly answered section comes back still open and colored green. With this pull request, that section is closed and colored yellow. Only the first unanswered section is now open.
If the instructor is testing the problem on the homework set detail page or in the PG problem editor the new database column is not used, and completely different behavior is exhibited.
Another problem here is that this is just adding to the list of things that scaffold.pl does that are problem authoring decisions, that really should be instructor decisions. We have discussed this already several times during our meetings. Ultimately it is very confusing for a problem author what all of the options are and do that control when a scaffold is open or not. This is further compounded by the fact that authors are going to be testing the problem initially when writing the problem in either the PG problem editor or as an instructor, and the behavior will be inconsistent with what the student will see later in an actual set.
I think in general we need to have more discussion about what is really desired for scaffold behavior, and talk about a good way of implementing it that gives better consistency. I think that the saving of the problem_data
column should be rewritten to not occur unless answers are actually being saved. Although, I think we also need to review the KEPT_EXTRA_ANSWERS
and PERSISTENCE_HASH
. Are they both needed?
As to your changes for parserMultiAnswer.pl problems, that doesn't seem to be working. I tested this both as an instructor and as a student, and I see the same behavior. If "Preview My Answers" is clicked on your find_dim_basis.pg
problem, the results table still reveals information about the second part of the problem. In fact I see no difference at all for the behavior with or without this pull request.
occur due to a Preview, while when set to 1 sections will not be closed by | ||
Preview. | ||
 | ||
 |
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.
Please delete the extra empty line here. No multiple empty lines! perltidy removes the ones not in POD, but doesn't handle multiple empty lines in POD.
} elsif (($section_no < $prior_last_open) && $self->{prevent_close_by_preview}) { | ||
# This section was open before - AVOID closing it due to a change in prior sections and a Preview | ||
for my $name (@{ $self->{ans_names} }) { | ||
$self->{scores}{$name} = 1.0 if ($answers{$name}); # to prevent it from being closed |
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 1.0
? Perl doesn't distinguish between integer and floating point data types, so there is no need. Just use 1
.
$PG_ANSWERS_HASH->{$name}{ans_eval}{rh_ans}{scaffold_past_open} = 1 if ($section_no > $prior_last_open); | ||
} | ||
|
||
my $myLastSet; # we save the name of the last answer field whose score was set |
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.
$myLastSet
is a poor choice of variable name. my
is a reserve word used to declare a variable, it should not be part of the name. Just use $lastSet
. Although this is a confusing name. What was last set? Something more descriptive of what it means would be better.
# Allow hiding the the structure of the answer for an | ||
# answer in an unopened part of a scaffold problem. | ||
my $hide_preview = 0; | ||
$hide_preview = 1 if ($ans->{scaffold_past_open}); |
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 does this need to be here in this convoluted format?
: join($self->{tex_separator}, @latex)); | ||
$ans->{preview_text_string} = | ||
(defined($self->{format}) ? sprintf($self->{format}, @text) : join($self->{separator}, @text)); | ||
if ($hide_preview) { |
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 can't this just be if ($ans->{scaffold_past_open}) {
, with the part above deleted? (Although I don't think any of this is working anyway.)
Edited on 14-APR-2023 revised for current develop and with defaults set to retain prior behavior
The updated version depends on:
and should be merged only after those PRs.
This is at attempt to address the first issue from #478
Patches to:
The revised code stores the state about the last open section in the database using the code added in #809.
The current patch uses a hidden form field to provide the server with the "number" of the last scaffold section which was open. It does not have any mechanism to prevent a clever user from tampering with that value. As a result, the current implement can be abused to trick the system into opening additional sections if the value of the hidden field is modified to a large value.My plan is to fix that by adding additional hidden fields including a (random) "nonce" and a "signature" that verifies (together with some server side state information which should remain constant for the user of a given problem) that these hidden fields were not tampered with. Such an approach may not be 100% secure, but should make it quite hard to abuse these changes.However, the current draft code already provides the rough functionality I think we would like.Testing - using the PG file in scaffold-sample-01.zip and the files in scaffold-sample-new.zip
Before installing the patch:
desirednewly supported alternate behavior requires using "Submit Answers" to get the additional sections to open, and would not close open sections on use of "Preview My Answers" when the relevant settings are used.The defaults have been changed - so the testing instructions here are somewhat outdated. See below for revised testing instructions.
After installing the patch:
scaffold-sample-03.pg
should give exactly the same behavior as in the test before the patch, as it (explicitly) uses the settings to keep the behavior as it was.scaffold-sample-02.pg
should behave as follows (both settings are flipped):scaffold-sample-01.pg
should behave as follows (only opening by preview is disabled, but closing remains enabled.):