## WeBWorK Main Forum

### Referencing "assignmentType" variable in a problem

Number of replies: 10
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)
...

might do it.

### Re: Referencing "assignmentType" variable in a problem

To be clear, adding that line to PGcourse.pl will remove knowlinks and accompanying text from the gateway-style assignments?

Thanks again!

### Re: Referencing "assignmentType" variable in a problem

by Davide Cervone -
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 PGcourse.pl, and not every one does.

### Re: Referencing "assignmentType" variable in a problem

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!

### Re: Referencing "assignmentType" variable in a problem

by Davide Cervone -
Right. They should no longer be inserted into the page at all.

### Re: Referencing "assignmentType" variable in a problem

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!

### Re: Referencing "assignmentType" variable in a problem

by Davide Cervone -
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.

### Re: Referencing "assignmentType" variable in a problem

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.

### Re: Referencing "assignmentType" variable in a problem

by Alex Jordan -
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.)