WeBWorK Problems

Difficulties creating digital logic problems

Difficulties creating digital logic problems

by Sean Fitzpatrick -
Number of replies: 3

I'm posting on behalf of my colleague. She tried creating her own account here, as "Uleth Nicole Wilson" (to differentiate herself from other people of the same name). She can get to the point of logging in with the temporary password that is created, but when she tries to update the password, there's a message about illegal characters in her user name, and she gets locked out.

(So unrelatedly, it would be great if there was a fix for that.)

Her question:

I am trying to create WeBWorK questions for a digital logic course.

This current template requires the question maker to indicate the input operands, output operands, and boolean expressions for the output operands in postfix format.

I have removed most of the sections from the attached template problem.

Students need to be able to enter 0, 1, X (don't care), or I (indeterminant) in various tables (truth tables, state tables, kmaps etc.)

I would like them to be able to enter boolean expressions like (A' + B) nand (A \oplus C) in the future.

Simple issue:

I have not been able to output a string variable containing latex and have it format properly (without HASH(0x....) appearing at the beginning. I have a work around of dropping things into a DataTable which is awkward at times.

Not sure how simple an issue:

This question has the following warning messages that I don't really understand how to fix:

Warning messages
  • Use of uninitialized value $string in pattern match (m//) at line 97 of [PG]/macros/core/Parser.pl.
  • Use of uninitialized value $string in pattern match (m//) at line 97 of [PG]/macros/core/Parser.pl.
  • Use of uninitialized value $string in pattern match (m//) at line 97 of [PG]/macros/core/Parser.pl.
  • Use of uninitialized value $string in pattern match (m//) at line 97 of [PG]/macros/core/Parser.pl.
 
Bigger issue:
I'm betting this isn't the best method to accomplish my goals but I'm not sure what the better approach would be.

The .pg file for the template is attached. In case it's relevant, she can get her code to run in Perl, but not on WeBWorK.

In reply to Sean Fitzpatrick

Re: Difficulties creating digital logic problems

by Andrew Parker -

The warning messages occur because of some error in the construction of `@boolArray`, and can be confirmed by adding a warn statement to the answer block as follows:

for (my $r = $numInputs; $r < $numInputs + $numOutputs; $r++) {
    for (my $c = 0; $c < $numRows; $c++) {
        warn("not found at $r, $c") if !defined($boolArray[$r][$c]);
        ANS(Compute($boolArray[$r][$c])->cmp());
    }
}

I did not attempt to trace back the issue, but did notice that there are other issues with `@boolArray` -- e.g. the first two correct answers are 2 and 3 (not very boolean), and other correct answers do not match the solution table.

In WW2.19, a booleanContext.pl macro was added, which may address your request for entering boolean expressions. I have attached a modified version of your provided problem which uses the new context -- though the context would be more relevant for entering logical expressions. I'd be happy to share more examples as well.

In reply to Andrew Parker

Re: Difficulties creating digital logic problems

by Sean Fitzpatrick -

Thanks! That helped her with the debugging. I think the boolean context doesn't quite fit her use case, because she's working in a context where she needs more than 0 and 1. For digital logic there is also X and I. (X means you don't care if it's 0 or 1. I forget what I means.)

In reply to Sean Fitzpatrick

Re: Difficulties creating digital logic problems

by Nicole Wilson -

I is for indeterminant and is only used in state tables, but I'd rather not have a special case for state tables since they are so similar to truth tables, in terms of creating/marking the table in a webwork question.

Thanks for your help with data validation and for the version you shared. I clearly need to figure out how to write subroutines!