how to make a question to check if student insert a comments

how to make a question to check if student insert a comments

by Kyriacos Iacovou -
Number of replies: 1

Question like this (Python 3)

Insert a comment in the program above the line name1 = "Juan" that will tell the reader the next piece of code will Define the three names.

In reply to Kyriacos Iacovou

Re: how to make a question to check if student insert a comments

by Richard Lobb -
If you start to create a new python3 question and click Customise you'll get to see the template for the default python3 question type. It includes the line

__student_answer__ = """{{ STUDENT_ANSWER | e('py') }}"""

which gives you a variable containing the student's submitted code. If you call splitlines() on that, you'll get all their code lines. So you can check the line(s) preceding your target line to see if it's a comment and perhaps if it contains various key words you might expect. But there's no easy way to check if it actually makes sense. You need an LLM for that!