Notice: Undefined index: correct in CqMapping->init() (line 47 of /home/adam/contrib/closedquestion/question/mapping/CqMapping.class.php).

Here's the XML for the question producing this notice:

<question type="fillblanks">
  <text>
    <p>This phrase is used to practice typing because it contains all 26 letters of the alphabet.<br/>Fill in the missing word!</p>
    <p><b>The quick brown <inlineChoice identifier="c" freeform="1"/> jumps over the lazy dog's tail</b></p>
  </text>
  <hint mintries="1">It's an animal.</hint>
  <hint mintries="2">The answer starts with an f.</hint>
  <hint mintries="3">The answer is f _ x.</hint>
  <mapping correct="1">
    <feedback>Very good!</feedback>
    <match inlinechoice="c" pattern="^(fox|Fox)$"/>
  </mapping>
  <mapping>
    <feedback>Wrong animal! Not a dog, dude.</feedback>
    <match inlinechoice="c" pattern="dog"/>
  </mapping>
</question>

I created this XML using the GUI editor after starting with the "Fillblanks question with math" template, then I inserted the line breaks and spaces manually.

Comments

adamdicarlo’s picture

I had a feeling what the problem was, so I changed <mapping> to <mapping correct="0"> and the notice went away.

The thing is, I can't seem to force the XML editor to include the correct attribute for incorrect values. I've tried changing the mapping element to incorrect, hitting Save mapping, and then changing it back -- the editor removes the attribute every time I hit Save mapping with correct set to 0.

So I still think this is a notice bug.

jvdkolk’s picture

Hi adamdicarlo,

the editor removes the attribute every time I hit Save mapping with correct set to 0.

I am not sure this is a bug: 'No' is the default setting for a mapping, so the editor indeed removes it.

Notice: Undefined index: correct in CqMapping->init() (line 47 of /home/adam/contrib/closedquestion/question/mapping/CqMapping.class.php).

I included a small patch to solve this. Are you able to test it?

adamdicarlo’s picture

Status: Active » Reviewed & tested by the community

Patch works for me... and pretty trivial so I'd call it RTBC.

jvdkolk’s picture

You are welcome.

I happen to know that the maintainer of ClosedQuestion is busy with another project for about 4 weeks, but after that, the patch will find its way to the dev version :)

HylkeVDS’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Thanks for the patch!
I've applied it to dev, both for the D6 and the D7 version.

adamdicarlo’s picture

Thank you @rekcor and @HylkeVDS!