Customized Questions vs Prototypes

Customized Questions vs Prototypes

von Michael Backus -
Anzahl Antworten: 3

I was able to get some code to use an HTML validator when created as a customized python3 question (attached as Simple Web Page). However, when I tried to create an HTML_via_python prototype, the exact same code failed when I tested questions based on the prototype (attached as h1). Any idea what is happening? Here's the code:

import json
import subprocess, sys

studentAnswerDictionary = json.loads(r"""{{ STUDENT_ANSWER }}""")
studentHTML = studentAnswerDictionary["crui_html"][0]

student_page = f"""<!DOCTYPE html><html lang="en-US"><head><title>Grade</title></head><body>{studentHTML}</body></html>"""

with open("page.html", "w") as src:
    print(student_page, file=src)

output = subprocess.check_output(["java", "-jar", "/usr/share/java/vnu.jar","--exit-zero-always","--stdout","page.html"],encoding='UTF-8')
if output == "":
    print("OK")
else:
    print(output)
Als Antwort auf Michael Backus

Re: Customized Questions vs Prototypes

von Richard Lobb -

Can you describe the failure mode, perhaps with a screen dump, when using a prototype, please?

Als Antwort auf Richard Lobb

Re: Customized Questions vs Prototypes

von Michael Backus -

Is this what you're looking for:

***Error***
Traceback (most recent call last):
  File "__tester__.python3", line 12, in <module>
    output = subprocess.check_output(["java", "-jar", "/usr/share/java/vnu.jar","--exit-zero-always","--stdout","page.html"],encoding='UTF-8')
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['java', '-jar', '/usr/share/java/vnu.jar', '--exit-zero-always', '--stdout', 'page.html']' returned non-zero exit status 1.

Als Antwort auf Michael Backus

Re: Customized Questions vs Prototypes

von Richard Lobb -

Sorry, I can't think of any reason why code that works in a customised question wouldn't work in the prototype. Unless the various sandbox limits (memorylimit, cpulimitsecs, numprocs, ...) are somehow different in the two questions? I'd suggest setting memorylimit to 0 (meaning no limit) and raising numprocs to some ridiculously large number like 500, just to check if that's where the problem lies. Beyond that I'm afraid you'll have to resort to more serious debugging techniques.

As a last resort, setting the sandbox debugging mode should result in the entire run being saved in /home/jobe/runs, and you can then explore what's going wrong in the run, assuming you have admin level access to the Jobe server. To set that mode, enter

{"debug": 1}

as the sandbox parameters under advanced customisation.