I'm trying to set it up so that we can use the same problems for quizzes and homeworks but not include some knowlinks on the quizzes. Is there a way for me to call the "assignmentType" variable in the problem itself?
My current idea is to set it up as:
if($assignmentType!='gateway' && $coursenum == 110)
...
elsif($assigmentType!='gateway' && &coursenum == 1100)
...
else
{}
as this is close to the code I already have in place.
I've tried having problems print the assignmentType variable as text and neither in homework or on generated quizzes does it appear.
Any hints? Thanks!
There isn't a direct variable that lists this, but there are some indirect ways to tell. One is to use the
$QUIZ_PREFIX
variable, which is blank for non-quzzes and non-empty for quizzes. It would also be possible to look at the $setNumber
, which I think is actually the set name now; I think quizzes use special set names that include ",v" or something, so you could look for that.
One approach might be to use PGcourse.pl
to disable the know link macros during a quiz, so you don't have to write problems specifically to do that themselves. Something like
PG_restricted_eval("sub knowlLink {}") if $QUIZ_PREFIX;might do it.
Thanks for this answer!
To be clear, adding that line to PGcourse.pl will remove knowlinks and accompanying text from the gateway-style assignments?
Thanks again!
To be clear, adding that line to PGcourse.pl will remove knowlinks and accompanying text from the gateway-style assignments?
Thanks again!
I haven't tested it, so so I can't say for sure, but I think it will. Give it a try and let us know!
Note that it will only work if the problems actually do include
Note that it will only work if the problems actually do include
PGcourse.pl
, and not every one does.
I haven't had a chance to try this yet, but just for clarification, this should make the links and the accompanying text disappear, not just disable them, right?
Thanks!
Thanks!
Right. They should no longer be inserted into the page at all.
It looks like we don't have the pg_courses.pl file included in most of our problems, so it won't be easy for us to do this. I'm looking into other options now, but thanks for your help!
Note that the name is
PGcourse.pl
not pg_course.pl
. Many problems include it, but many do not, so it might not work for you.
I was just going from memory, sorry. It looks like most of the problems we're using don't have it though.
Thanks again for your suggestions, Davide.
Thanks again for your suggestions, Davide.
Are these OPL problems you are using? Or local problems?
You could consider using regex to insert the loading of PGcourse.pl into all of your problems. Although you maybe shouldn't do that to the OPL problems.
I don't know enough regex to offer specific code, but something that looked for "loadMacros(......);" and inserted ",'PGcourse.pl'," right before the closing paren would do it. It would have to match over multiple lines.
(Even fancier regex could make it only insert when PGcourse.pl wasn't already there. Although depending on what you put in PGcourse.pl, it may not matter to have it repeated.)
You could consider using regex to insert the loading of PGcourse.pl into all of your problems. Although you maybe shouldn't do that to the OPL problems.
I don't know enough regex to offer specific code, but something that looked for "loadMacros(......);" and inserted ",'PGcourse.pl'," right before the closing paren would do it. It would have to match over multiple lines.
(Even fancier regex could make it only insert when PGcourse.pl wasn't already there. Although depending on what you put in PGcourse.pl, it may not matter to have it repeated.)
I believe they're mostly or all local problems. I'd have to learn the regex to be able to do this, and I sadly don't think I have the time for that.
My boss and I have decided to look into using the Hint feature to try and solve the issue, but the problem (as I explain further in another post that I made) is that we'd like the display text to say something other than "HINT:" on the page.
Maybe the regex with PGcourse.pl would be the best practice, but we're trying to work towards a quick solution since we're trying to get these inserted before our students come to the problems without them. We've got a few weeks, but I'd still like to get started on a solution now, haha.
Thanks for your suggestion though!
My boss and I have decided to look into using the Hint feature to try and solve the issue, but the problem (as I explain further in another post that I made) is that we'd like the display text to say something other than "HINT:" on the page.
Maybe the regex with PGcourse.pl would be the best practice, but we're trying to work towards a quick solution since we're trying to get these inserted before our students come to the problems without them. We've got a few weeks, but I'd still like to get started on a solution now, haha.
Thanks for your suggestion though!