Question Authors' Forum

Error in Graph checking

Error in Graph checking

by Jan Derriks -
Number of replies: 1


A strange thing happened with a simple check on a FSM graph: students are not allowed to drag edge labels or the default Python template will fail with error:

***Error***
Traceback (most recent call last):
  File "__tester__.python3", line 23, in <module>
    for id0, id1, edge_label in graph_rep['edges']:
ValueError: too many values to unpack (expected 3)


This is apparently caused by the extra X and Y values that are default not added to the edges:
edges":[[0,2,"2"],[2,3,"6"],[3,1,"9",{"x":434,"y":171}]]}

Is there a way to fix this? "Validate on Save" also fails if the answer box has edge labels with non-default Z-Y values.


In reply to Jan Derriks

Re: Error in Graph checking

by Richard Lobb -

Thanks for pointing out this bug (a regression introduced in V3.7.9).

The fix is to change the line

for id0, id1, edge_label in graph_rep['edges']:

to

for id0, id1, edge_label, *loc in graph_rep['edges']:

in BUILT_IN_PROTOTYPE_directed_graph and BUILT_IN_PROTOTYPE_undirected_graph. You need to have Moodle admin rights to edit those prototypes, which are in the CR_PROTOTYPES category at the system level in the question bank.

Alternatively you can customise the question or define your own derived question type with the same fix.

I've pushed the fix to github and it will appear in the next version released to the Moodle question type repository.