/PythonChecker

Feedback for Python syntax, style and semantic errors

Primary LanguagePython

QPED - Feedback tools for Python

Checkers

Certain parts of this project are referred to as checkers. A checker is a module that can be configured individually and has a specific analytical function for the submitted code. A Syntax Checker is for instance used to analyze the syntax of submitted code and generate feedback in that specific regard. Below you may find a list of currently implemented checkers and a sort description of each one.

Syntax Checker

Syntax checker has the ability to analyze Python code and report the encountered errors in friendly form for students with extra information.

You can see the list of syntax errors here.

Style Checker

Style checker is able to find and report common formatting violations that worsen code quality. Style errors are based on PEP8. The report also contains examples for fixing the violations.

You can see the list of style errors here.

Semantics Checker

Semantics checker analyzes the meaning of the code. For example, two typical semantic errors are the variable is not defined where it is used and two parameters in a function has the same name.

You can see the list of semantic errors here.

Configuration

The configuration uses JSON-syntax. Each configuration is located in a separate JSON-object. Because this checker can be used in Quarterfall, we use a file called qf.json which contains a 'qf' object.

In the case of the Python Checker, the qf object only requires including mainSettings object. Thanks to the mainSettings object, we can configure the global aspects of the feedback that is generated by the Python Checker. Possible variables and values are detailed below (default values are in bold).

Option Name Description Possible Values
styleNeeded Indicates if the feedback must provide style errors true or false
semanticNeeded Indicates if the feedback must provide semantic errors true or false
errorsCategorized Indicates if the feedback must provide errors separated in categories (i.e. syntax, style and semantic) true or false

Syntax errors

As you can see, there is not an option for syntax errors. Due to the importance of syntax errors, they are always provided.

An example of configuration, in Quarterfall, in which the three types of errors are asked to be provided with the feedback would be:

qf.mainSettings = {
	"styleNeeded":"true",
	"semanticNeeded":"true"
}

If it is desired that errors are provided in the order in which they are present in the code, instead of type, then the configuration is as follows:

qf.mainSettings = {
	"styleNeeded":"true",
	"semanticNeeded":"true",
	"errorsCategorized": "false"
}

Enabling Python Checker in Quarterfall

To use the Python Checker in Quarterfall, you must create a question and add two feedback actions. For this purpose, in Quarterfall's question designer you must open the tab Feedback and first add a Code action, then a Cloud Check action.

Important

The Code's panel must be on the top and the Cloud Check's panel must be on the bottom.

Code's panel

The Code's panel will contain the configuration for the Python Checker, which has been detailed previously. As said, the Python Checker tool is configured so that it uses a JSON object qf. Therefore the Code's panel must contain the content of the qf.json file. For this purpose write JavaScript code there, in the form qf.mainSettings = {}, whereby you must replace {} with the JSON object containing the configuration details.

Cloud Check's panel

The Cloud Check in turn must be configured as follows:

property value
Git url https://github.com/qped-eu/PythonChecker
Git branch main
Path
Git private SSH key