"Code" (Question Interface Type)
"Code" (Question Interface Type)
"Code"
provides an input field for writing code.
Properties
- In QuestionInterface["Code",props], props is an Association that supports the following keys:
-
"Prompt" None text asking the user a question - Additionally, options for InputField are supported, including:
-
Background Automatic input field background color FieldHint Null expression to display when the input field is empty ImageSize {Scaled[0.7],Automatic} the overall image size of the displayed input field
Corresponding AssessmentFunction
- "Code" is the automatically assigned interface type for an AssessmentFunction of the form AssessmentFunction[HoldPattern[c],"CodeEquivalence"].
Examples
open all close allBasic Examples (2)
QuestionObject[QuestionInterface["Code", "What is your favorite Wolfram Language symbol?"]]A coding question with assessment:
QuestionObject["Write code to create a list of five random integers between 1 and 5:", AssessmentFunction[HoldPattern[RandomInteger[5, 5]], "CodeEquivalence"]]Scope (2)
QuestionObject["...", AssessmentFunction[HoldPattern[Which[Mod[#, 15] == 0, "FizzBuzz", Mod[#, 3] == 0, "Fizz", Mod[#, 5] == 0, "Buzz", True, #]& /@ Range[1, 100]], "CodeEquivalence"]]Create an assessment with a hint using FieldHint:
QuestionObject[QuestionInterface["Code", <|"Prompt" -> "Insert an element between each of the elements of the list {1,2,3,4,5}.
The expected output should be similar to {1,x,2,x,...}.", ImageSize -> {Scaled[1], Automatic}, FieldSize -> {Automatic, Automatic}, FieldHint -> "(Consider using Riffle or Transpose)"|>], AssessmentFunction[HoldPattern[Riffle[Range[5], x]], "CodeEquivalence"]]See Also
QuestionInterface QuestionObject
Question Interface Types: ShortAnswer MultipleShortAnswers
Comparison Methods: CodeEquivalence