added functionality for hint generation and changed logging #107
No reviewers
Labels
No labels
accessibility
backport to lts
bug
code
critical
cygwin
documentation
duplicate
error reporting
external
feature
feedback
good first issue
help wanted
infrastructure
invalid
investigate
language spec
logs
lti
lts only
mac
maybe
qtype:bigbox
qtype:checkoff
qtype:expression
qtype:fileupload
qtype:multiexpression
qtype:multiplechoice
qtype:number
qtype:pythoncode
qtype:pythonic
qtype:pythonliteral
qtype:richtext
qtype:smallbox
question
question types
sandbox
security
syntax highlighting
ui/ux
wontfix
wsl
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
catsoop/catsoop!107
Loading…
Reference in a new issue
No description provided.
Delete branch "villac/catsoop:feature/hint-generation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds universal hint functionality through "view hint" with lots of context for any hint function.
Thanks for putting this in, @villac! I won't actually be able to do a full test of this for a little while (hopefully either this weekend or early next week), but I wanted to ask some initial questions and offer some initial suggestions from a quick look at the code. I'll have some more thoughts once I've been able to actually try it out.
@ -176,0 +176,4 @@if ("hint" in thisone) {document.getElementById(name + "_hint").innerHTML = thisone["hint"];catsoop.run_all_scripts(name + "_hint");}The formatting here looks a little funny. Can you try running Prettier on this file to make sure the formatting is consistent throughout?
I think this should be resolved now
@ -248,6 +252,7 @@ for (var i of ["viewanswer","clearanswer","viewexplanation","view_hint",I have a slight preference for naming this new action consistently with the existing ones (i.e.,
viewhintinstead ofview_hint).should be updated everywhere now.
@ -599,0 +613,4 @@Modeled after handle_viewanswer:param context: dict of pretty much the whole website relative to a user:param outdict: dict containing responses for each questionCatsoop formats docstrings a little differently from this. Please follow the docstring convention from, e.g., this file (for this one and for the other new functions here).
Docstrings were updated
@ -599,0 +632,4 @@q, args = context[_n("name_map")][name]defaults = q.get("defaults",{})# important to add default values, but don't want to overwrite thingsupdate_no_overwrite(args,defaults)I would probably have tackled this a little bit differently, to avoid the need for the
update_no_overwritehelper. We could instead do something like:and then use
infothroughout instead ofargs.great suggestion, used it.
@ -599,0 +642,4 @@fallback_default = lambda x: "no provided hints"hint_func = args.get("csq_hint", fallback_default)# default limit hints to 3 to limit # of API requests for LLM generated hintsLooking at some of the code below, it looks like this is really intended to work for LLM-generated hints first and foremost. I'm not a big LLM fan, but I'm fine with keeping things general here to allow for things like that. One thing I'm nervous about, though, is that I think it would be good to have an easy way to release multiple hard-coded hints.
For example, it would be nice to be able to specify a list of hard-coded, human-generated hints as well. With the current API, it feels like this will be a little painful; it feels like I would need to set something like the following for every question where i wanted to allow hints:
I'll need to do some more testing to know for sure, but it feels like we might be able to generalize the API here a bit
I've revamped the hint handling to allow for hard-coded hints. While my work is geared towards AI generated dynamic hints, I see the use of being able to set hard-coded hints easily as well. Additionally, there is support for a mix of the two approaches as well.
@ -599,0 +683,4 @@full_hint_html += language.source_transform_string(context, raw_html)# Add message that no more hints can be view if exceeding limitif len(current_hints) >= num_hints:Shouldn't this part short_circuit out earlier on? This will still invoke the hint function and add a new hint even if we're over the limit, won't it?
This just makes sure we make sure to display that no more hints can be shown. It won't trigger the creation of a new hint; it just adds text to the display.
@ -599,0 +710,4 @@count = len(h_list)current_hint_counts[n] = count# log submission in problemactionsMaybe this should say "log this action" or similar, since this isn't really a submission, per se.
@ -1578,0 +1746,4 @@error = "This question is not yet available."elif not _get(qargs, "csq_allow_view_hint", True, bool):error = "Viewing the hint is not allowed for this question."else:I feel like we're also missing an option here where we've already viewed the max number of hints; in that case, we should error out as well, I think.
You're right. I fixed that and also added handling for allowing viewing hints before submission based on flag settings.
@ -1578,0 +1750,4 @@lastlog = context[_n("last_log")]score = lastlog.get("scores", {}).get(name)if score is None:error = "You must submit an answer before viewing a hint."Hmmm, maybe this restriction is also one that we should put behind an option? Some people only allow a single submission for a question, in which case disallowing hints altogether might not be desirable.
I just now had a chance to read these comments. I don't think I'll be able to resolve these comments until after the IAP course I am working on concludes, but these are helpful comments. Once IAP is over/if I can find the time before then, I'll resolve these points and make some updates to other additions to the logging I have done since submitting this.
added functionality for hint generation and changed loggingto WIP: added functionality for hint generation and changed logging3a5bc51c1cto682c62d879WIP: added functionality for hint generation and changed loggingto added functionality for hint generation and changed loggingHi Adam, there have been some substantial revisions since you last viewed this pull request. I appreciated all your thoughts and implemented all your comments. I think the most notable change is the new Hint Handler class which abstracts hint handling more and allows for easier definition of hard-coded or function specific hints. It should be noted that this version of CAT-SOOP was used for the IAP 2026 offering of Practical Computational Thinking. I hope that if we can integrate this work it may be used in other classes as well.
682c62d879to4678a590b3f608ab6560toae904cddbfView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.