2.2.3.4 Code Questions

This section uses terminology described in the Glossary.

The following scenarios describe the process of creating different coding questions:

Code Completion

Code completion questions are code questions where some of the code is provided to the test taker. The test taker must add code to the code provided to achieve the desired output.

The user now wants to add some coding questions to the question database. The user clicks "Add Question" from the main database view. The Test Tool responds by opening the new question dialog. The user selects "Code" from the Type dropdown menu. The multiple choice bottom panel of the dialog is replaced by the panel for code questions, which is shown in Figure 1. The user enters a time of 20 minutes, difficulty of 8, "CSC 349" as the course and gfisher as the professor for this question.

Code question - empty

Figure 1 - Code question empty dialog

Like other question types, code questions have a question text, but unlike other types they do not have an answer text. In place of this answer text, code questions have "Provided Code" and an "Expected Output/ Test Script". The user enters "Write an algorithm which will print the max of two numbers passed. For example, the compiled program max may take two integers, ./max 1 2 and will return the greater integer 2." into the question text area. In the "Provided Code" text area the user enters the code shown in Figure 2, below. This code is provided to the test taker exactly as entered by the user. On this question the user would like to use a test script to automatically grade student answers. The user chooses "Use 'test script'" by clicking its radio button below the "Expected Output/ Test Script" text area and types "./a.out 1 2 = 2", "./a.out 1 100 = 100" and "./a.out 0 0 = 0", each followed by a new line, in the "Expected Output/ Test Script" text area. For this question, the user does not enter anything in the "Time Limit" text field, so the test taker's code may run until it finishes, rather than only running for a maximum amount of time.

Code completion question filled

Figure 2 - Code completion question filled

There are also several options affecting the test taker that are enabled by default, but the user may disable them. The first option enables or disables syntax highlighting while the test taker is entering code. The second option enables or disables a test taker to use an IDE to enter code. If the third option is enabled a test taker is allowed to run a test compilation of his or her code. If the option is disabled, the test taker cannot compile any code. The fourth option allows the test taker to compare the output of his or her code to the expected output or test script if either is provided by the user. For this question the user leaves all of these options enabled. Below these options is a dropdown menu with different programming languages. The programming languages listed are languages that are supported by the Test Tool software. The user selects "C++ (g++/ GNU GCC)" as the programming language to use on this question. The user clicks the "OK" button to add this question to the current question database.

Standard Coding

The user clicks "Add Question" from the main database view to add a new question. The user selects "Code" from the Type dropdown menu, as with the code completion question. The user selects a time of 15 minutes, a difficulty of 6 and "CPE 103" as the Course. The user types gfisher as the professor for this question.

To give a standard coding question the user leaves the "Provided Code" text area blank, so no code is provided to test takers. The user enteres "Write a pop() function for a linked list data structure." into the "Question Text" area. This time the user chooses not to have the question automatically graded. The user clicks the "Disable AutoGrader" radio button to disable automatic grading.

Standard Code Question filled

Figure 3 - Standard coding question filled

The user does not want test takers to have access to a debugger and un-checks "Allow debugger use." Since the user has disabled the AutoGrader, "Allow comparing output with test script" is automatically disabled. The user wants answers written in the C++ language and selects "C++ (g++/ GNU GCC)" from the Languages dropdown menu"


Prev: free response | Next: [none] | Up: functional | Top: index