Skip to content

Commit

Permalink
add prompt language option
Browse files Browse the repository at this point in the history
  • Loading branch information
ettoreleandrotognoli committed Jun 28, 2023
1 parent 0a79656 commit 117cddf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/src/quiz.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ For example, you can make a mutable variable `x` by writing: `let mut x = 1`.

[[questions]]
type = "Tracing"
prompt.language="rust"
prompt.program = """
fn main() {
let x = 1;
Expand Down
2 changes: 2 additions & 0 deletions js/packages/quiz-schema/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { QuestionFields } from "./common";
export interface TracingPrompt {
/** The contents of the program to trace */
program: string;

language?: string;
}

export interface TracingAnswer {
Expand Down
6 changes: 5 additions & 1 deletion js/packages/quiz/src/questions/tracing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export let TracingMethods: QuestionMethods<TracingPrompt, TracingAnswer> = {
{/* If the program does not pass, indicate the last line number involved in the
compiler error. */}
</p>
<Snippet snippet={prompt.program} lineNumbers />
<Snippet
language={prompt.language}
snippet={prompt.program}
lineNumbers
/>
</>
),

Expand Down

0 comments on commit 117cddf

Please sign in to comment.