simple Graph or SQL type gives "Sandbox Down" error

Re: simple Graph or SQL type gives "Sandbox Down" error

by Jan Derriks -
Number of replies: 0

Hi Richard,

thanks for the advice.

Using debug and custumize flags shows the following code where I used a simple print as a testcase and the answer was one node named 'F':

Debug: source code from all test runs

Run 1

import json

student_answer = """{\"edgeGeometry\":[],\"nodeGeometry\":[[134,81]],\"nodes\":[[\"F\",false]],\"edges\":[]}"""
SEPARATOR = "#<ab@17943918#@>#"

error_count = 0
def error(s):
    global error_count
    print(s)
    error_count += 1

try:
    graph_rep = json.loads(student_answer)
    node_id_to_name_map = {}
    for i, node in enumerate(graph_rep['nodes']):
        node_id_to_name_map[i] = node[0] if node[0] != '' else ('#' + str(i))
    #print("Nodes:", nodes)   BTW: DON'T uncomment this - it is an error in the default template code
    edges = graph_rep['edges']
    #print("Edges:", edges)
    graph = {}
    for node_id, node_name in sorted(node_id_to_name_map.items()):
        edges = []
        for id0, id1, edge_label in graph_rep['edges']:
            if id0 == node_id:
                edges.append((node_id_to_name_map[id1], edge_label))
            elif id1 == node_id:
                edges.append((node_id_to_name_map[id0], edge_label))
        edges.sort()
        graph[node_name] = edges

except json.JSONDecodeError as e:
    raise Exception("Oops. Illegal graph received (exception {}). Please report (unless you did something silly yourself)".format(e))


print('foobar')

 
When I copy+paste this in PyCharm it runs fine and prints "foobar", what I entered in the 'expected output' field.
But all I get is:
An unexpected error occurred. The sandbox may be down. Try again shortly.


The preview tech info is:


And the question is just to create one node named F.

Is there a step-by-step example of how to create such a simple graph question with all the right settings?

Regards,
Jan