From 95c31e7e3bddeeed70e6cf997eed1461ebb6ae80 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 09:22:04 +0200 Subject: [PATCH 01/10] Add tutorlink in default renderer --- app/assets/javascripts/pythia_submission.ts | 13 ++++++----- .../renderers/feedback_table_renderer.rb | 13 +++++++++++ app/helpers/renderers/pythia_renderer.rb | 23 ------------------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/pythia_submission.ts b/app/assets/javascripts/pythia_submission.ts index a04d9fbdd5..c08e28ef5b 100644 --- a/app/assets/javascripts/pythia_submission.ts +++ b/app/assets/javascripts/pythia_submission.ts @@ -19,21 +19,22 @@ function initPythiaSubmissionShow(submissionCode: string, activityPath: string): function initTutorLinks(): void { document.querySelectorAll(".tutorlink").forEach(l => { - const group = l.closest(".group") as HTMLElement; - if (!(group.dataset.statements || group.dataset.stdin)) { + const tutorLink = l as HTMLLinkElement; + if (!(tutorLink.dataset.statements || tutorLink.dataset.stdin)) { l.remove(); } }); document.querySelectorAll(".tutorlink").forEach(l => l.addEventListener("click", e => { const exerciseId = (document.querySelector(".feedback-table") as HTMLElement).dataset.exercise_id; - const group = e.currentTarget.closest(".group"); - const stdin = group.dataset.stdin.slice(0, -1); - const statements = group.dataset.statements; + const tutorLink = e.currentTarget as HTMLLinkElement; + const group = tutorLink.closest(".group"); + const stdin = tutorLink.dataset.stdin.slice(0, -1); + const statements = tutorLink.dataset.statements; const files = { inline: {}, href: {} }; group.querySelectorAll(".contains-file").forEach(g => { - const content = JSON.parse(g.dataset.files); + const content = JSON.parse((g as HTMLElement).dataset.files); Object.values(content).forEach(value => { files[value["location"]][value["name"]] = value["content"]; diff --git a/app/helpers/renderers/feedback_table_renderer.rb b/app/helpers/renderers/feedback_table_renderer.rb index de1c3b23d1..631d520e4b 100644 --- a/app/helpers/renderers/feedback_table_renderer.rb +++ b/app/helpers/renderers/feedback_table_renderer.rb @@ -186,6 +186,19 @@ def tab_content(t) def group(g) @builder.div(class: "group #{g[:accepted] ? 'correct' : 'wrong'}") do + # Add a link to the debugger if there is data + if g[:data] && (g[:data][:statements] || g[:data][:stdin]) + @builder.div(class: 'tutor-strip tutorlink', + title: 'Start debugger', + 'data-statements': (g[:data][:statements]).to_s, + 'data-stdin': (g[:data][:stdin]).to_s + ) do + @builder.div(class: 'tutor-strip-icon') do + @builder.i('', class: 'mdi mdi-launch mdi-18') + end + end + end + if g[:description] @builder.div(class: 'row') do @builder.div(class: 'col-12 description') do diff --git a/app/helpers/renderers/pythia_renderer.rb b/app/helpers/renderers/pythia_renderer.rb index 3e2c105f2a..0a4d15ee67 100644 --- a/app/helpers/renderers/pythia_renderer.rb +++ b/app/helpers/renderers/pythia_renderer.rb @@ -59,29 +59,6 @@ def output_message(m) end end - def group(g) - if g.key?(:data) - @builder.div(class: "group #{g[:accepted] ? 'correct' : 'wrong'}", - 'data-statements': (g[:data][:statements]).to_s, - 'data-stdin': (g[:data][:stdin]).to_s) do - @builder.div(class: 'tutor-strip tutorlink', title: 'Start debugger') do - @builder.div(class: 'tutor-strip-icon') do - @builder.i('', class: 'mdi mdi-launch mdi-18') - end - end - if g[:description] - @builder.div(class: 'col-12 description') do - message(g[:description]) - end - end - messages(g[:messages]) - g[:groups]&.each { |tc| testcase(tc) } - end - else - super(g) - end - end - def testcase(tc) return super(tc) unless tc[:data] && tc[:data][:files] From dfd9b11e1a6bcc75bae02767f404b04b9fb8c4a7 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 09:46:36 +0200 Subject: [PATCH 02/10] Always init tutor links --- app/assets/javascripts/file_viewer.ts | 69 +++++++++++++++++ .../{pythia_submission.ts => tutor.ts} | 76 +------------------ .../renderers/feedback_table_renderer.rb | 33 ++++++++ app/helpers/renderers/pythia_renderer.rb | 33 +------- app/javascript/packs/pythia_submission.js | 7 +- app/javascript/packs/submission.js | 5 ++ 6 files changed, 116 insertions(+), 107 deletions(-) create mode 100644 app/assets/javascripts/file_viewer.ts rename app/assets/javascripts/{pythia_submission.ts => tutor.ts} (66%) diff --git a/app/assets/javascripts/file_viewer.ts b/app/assets/javascripts/file_viewer.ts new file mode 100644 index 0000000000..a5dd372ec1 --- /dev/null +++ b/app/assets/javascripts/file_viewer.ts @@ -0,0 +1,69 @@ +import { showInfoModal } from "./modal"; +import { fetch } from "utilities"; +import { html } from "lit"; + +function showInlineFile(name: string, content: string): void { + showInfoModal(name, html`
${content}
`); +} + +function showRealFile(name: string, activityPath: string, filePath: string): void { + const path = activityPath + "/" + filePath; + const random = Math.floor(Math.random() * 10000 + 1); + showInfoModal( + html`${name} `, + html`
Loading...
` + ); + + fetch(path, { + method: "GET" + }).then(response => { + if (response.ok) { + response.text().then(data => { + let lines = data.split("\n"); + const maxLines = 99; + if (lines.length > maxLines) { + lines = lines.slice(0, maxLines); + lines.push("..."); + } + + const table = document.createElement("table"); + table.className = "external-file"; + for (let i = 0; i < lines.length; i++) { + const tr = document.createElement("tr"); + + const number = document.createElement("td"); + number.className = "line-nr"; + number.textContent = (i === maxLines) ? "" : (i + 1).toString(); + tr.appendChild(number); + + const line = document.createElement("td"); + line.className = "line"; + // textContent is safe, html is not executed + line.textContent = lines[i]; + tr.appendChild(line); + table.appendChild(tr); + } + const fileView = document.getElementById(`file-${random}`); + fileView.innerHTML = ""; + fileView.appendChild(table); + }); + } + }); +} +export function initFileViewers(activityPath: string): void { + document.querySelectorAll("a.file-link").forEach(l => l.addEventListener("click", e => { + const link = e.currentTarget as HTMLLinkElement; + const fileName = link.innerText; + const tc = link.closest(".testcase.contains-file") as HTMLDivElement; + if (tc === null) { + return; + } + const files = JSON.parse(tc.dataset.files); + const file = files[fileName]; + if (file.location === "inline") { + showInlineFile(fileName, file.content); + } else if (file.location === "href") { + showRealFile(fileName, activityPath, file.content); + } + })); +} diff --git a/app/assets/javascripts/pythia_submission.ts b/app/assets/javascripts/tutor.ts similarity index 66% rename from app/assets/javascripts/pythia_submission.ts rename to app/assets/javascripts/tutor.ts index c08e28ef5b..fd11f11aa7 100644 --- a/app/assets/javascripts/pythia_submission.ts +++ b/app/assets/javascripts/tutor.ts @@ -1,12 +1,11 @@ import fscreen from "fscreen"; -import { showInfoModal } from "./modal"; import { fetch } from "utilities"; -import { html } from "lit"; +import { showInfoModal } from "modal"; +import { html } from "lit/development"; -function initPythiaSubmissionShow(submissionCode: string, activityPath: string): void { +export function initTutor(submissionCode: string): void { function init(): void { initTutorLinks(); - initFileViewers(activityPath); if (document.querySelectorAll(".tutormodal").length == 1) { initFullScreen(); } else { @@ -52,73 +51,6 @@ function initPythiaSubmissionShow(submissionCode: string, activityPath: string): })); } - function initFileViewers(activityPath: string): void { - document.querySelectorAll("a.file-link").forEach(l => l.addEventListener("click", e => { - const link = e.currentTarget as HTMLLinkElement; - const fileName = link.innerText; - const tc = link.closest(".testcase.contains-file") as HTMLDivElement; - if (tc === null) { - return; - } - const files = JSON.parse(tc.dataset.files); - const file = files[fileName]; - if (file.location === "inline") { - showInlineFile(fileName, file.content); - } else if (file.location === "href") { - showRealFile(fileName, activityPath, file.content); - } - })); - } - - function showInlineFile(name: string, content: string): void { - showInfoModal(name, html`
${content}
`); - } - - function showRealFile(name: string, activityPath: string, filePath: string): void { - const path = activityPath + "/" + filePath; - const random = Math.floor(Math.random() * 10000 + 1); - showInfoModal( - html`${name} `, - html`
Loading...
` - ); - - fetch(path, { - method: "GET" - }).then(response => { - if (response.ok) { - response.text().then(data => { - let lines = data.split("\n"); - const maxLines = 99; - if (lines.length > maxLines) { - lines = lines.slice(0, maxLines); - lines.push("..."); - } - - const table = document.createElement("table"); - table.className = "external-file"; - for (let i = 0; i < lines.length; i++) { - const tr = document.createElement("tr"); - - const number = document.createElement("td"); - number.className = "line-nr"; - number.textContent = (i === maxLines) ? "" : (i + 1).toString(); - tr.appendChild(number); - - const line = document.createElement("td"); - line.className = "line"; - // textContent is safe, html is not executed - line.textContent = lines[i]; - tr.appendChild(line); - table.appendChild(tr); - } - const fileView = document.getElementById(`file-${random}`); - fileView.innerHTML = ""; - fileView.appendChild(table); - }); - } - }); - } - function initFullScreen(): void { fscreen.addEventListener("fullscreenchange", resizeFullScreen); @@ -220,5 +152,3 @@ function initPythiaSubmissionShow(submissionCode: string, activityPath: string): init(); } - -export { initPythiaSubmissionShow }; diff --git a/app/helpers/renderers/feedback_table_renderer.rb b/app/helpers/renderers/feedback_table_renderer.rb index 631d520e4b..9eb2134d53 100644 --- a/app/helpers/renderers/feedback_table_renderer.rb +++ b/app/helpers/renderers/feedback_table_renderer.rb @@ -29,6 +29,7 @@ def initialize(submission, user) def parse if @result.present? + tutor_init @builder.div(class: 'feedback-table', 'data-exercise_id': @exercise.id) do if @result[:messages].present? @builder.div(class: 'feedback-table-messages') do @@ -408,4 +409,36 @@ def safe(html) sanitize html end end + + def tutor_init + # Initialize tutor javascript + @builder.script do + escaped = escape_javascript(@code.strip) + @builder << 'dodona.ready.then(function() {' + @builder << "document.body.append(document.getElementById('tutor'));" + @builder << "dodona.initTutor(\"#{escaped}\");});" + end + + # Tutor HTML + @builder.div(id: 'tutor', class: 'tutormodal') do + @builder.div(id: 'info-modal', class: 'modal fade', 'data-backdrop': true, tabindex: -1) do + @builder.div(class: 'modal-dialog modal-xl modal-fullscreen-lg-down tutor') do + @builder.div(class: 'modal-content') do + @builder.div(class: 'modal-header') do + @builder.h4(class: 'modal-title') {} + @builder.div(class: 'icons') do + @builder.button(id: 'fullscreen-button', type: 'button', class: 'btn btn-icon') do + @builder.i('', class: 'mdi mdi-fullscreen') + end + @builder.button(type: 'button', class: 'btn btn-icon', 'data-bs-dismiss': 'modal') do + @builder.i('', class: 'mdi mdi-close') + end + end + end + @builder.div(class: 'modal-body') {} + end + end + end + end + end end diff --git a/app/helpers/renderers/pythia_renderer.rb b/app/helpers/renderers/pythia_renderer.rb index 0a4d15ee67..eaa3dcd5e1 100644 --- a/app/helpers/renderers/pythia_renderer.rb +++ b/app/helpers/renderers/pythia_renderer.rb @@ -2,7 +2,7 @@ class PythiaRenderer < FeedbackTableRenderer include ActionView::Helpers::JavaScriptHelper def parse - tutor_init + file_viewer_init super end @@ -74,36 +74,11 @@ def testcase(tc) ## custom methods - def tutor_init - # Initialize tutor javascript + def file_viewer_init + # Initialize file viewers @builder.script do - escaped = escape_javascript(@code.strip) @builder << 'dodona.ready.then(function() {' - @builder << "document.body.append(document.getElementById('tutor'));" - @builder << "var code = \"#{escaped}\";" - @builder << "dodona.initPythiaSubmissionShow(code, '#{activity_path(nil, @exercise)}');});" - end - - # Tutor HTML - @builder.div(id: 'tutor', class: 'tutormodal') do - @builder.div(id: 'info-modal', class: 'modal fade', 'data-backdrop': true, tabindex: -1) do - @builder.div(class: 'modal-dialog modal-xl modal-fullscreen-lg-down tutor') do - @builder.div(class: 'modal-content') do - @builder.div(class: 'modal-header') do - @builder.h4(class: 'modal-title') {} - @builder.div(class: 'icons') do - @builder.button(id: 'fullscreen-button', type: 'button', class: 'btn btn-icon') do - @builder.i('', class: 'mdi mdi-fullscreen') - end - @builder.button(type: 'button', class: 'btn btn-icon', 'data-bs-dismiss': 'modal') do - @builder.i('', class: 'mdi mdi-close') - end - end - end - @builder.div(class: 'modal-body') {} - end - end - end + @builder << "dodona.initFileViewers('#{activity_path(nil, @exercise)}');});" end end diff --git a/app/javascript/packs/pythia_submission.js b/app/javascript/packs/pythia_submission.js index 7d7956f8f4..b821cc58ec 100644 --- a/app/javascript/packs/pythia_submission.js +++ b/app/javascript/packs/pythia_submission.js @@ -1,6 +1,3 @@ -import { initPythiaSubmissionShow } from "pythia_submission.ts"; +import { initFileViewers } from "file_viewer"; -window.dodona.initPythiaSubmissionShow = initPythiaSubmissionShow; - -// will automatically bind to window.iFrameResize() -require("iframe-resizer"); // eslint-disable-line no-undef +window.dodona.initFileViewers = initFileViewers; diff --git a/app/javascript/packs/submission.js b/app/javascript/packs/submission.js index cf8d3a78e9..b1757cc902 100644 --- a/app/javascript/packs/submission.js +++ b/app/javascript/packs/submission.js @@ -4,6 +4,7 @@ import { attachClipboard } from "copy"; import { evaluationState } from "state/Evaluations"; import codeListing from "code_listing"; import { annotationState } from "state/Annotations"; +import { initTutor } from "tutor"; window.dodona.initSubmissionShow = initSubmissionShow; window.dodona.codeListing = codeListing; @@ -14,3 +15,7 @@ window.dodona.initSubmissionHistory = initSubmissionHistory; window.dodona.setEvaluationId = id => evaluationState.id = id; window.dodona.setAnnotationVisibility = visibility => annotationState.visibility = visibility; window.dodona.showLastTab = showLastTab; +window.dodona.initTutor = initTutor; + +// will automatically bind to window.iFrameResize() +require("iframe-resizer"); // eslint-disable-line no-undef From 00b33da4161054a9cfeeca114cceaf1dcbc01c4f Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 09:57:18 +0200 Subject: [PATCH 03/10] Fix bug --- app/assets/javascripts/tutor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/tutor.ts b/app/assets/javascripts/tutor.ts index fd11f11aa7..d4e67242b7 100644 --- a/app/assets/javascripts/tutor.ts +++ b/app/assets/javascripts/tutor.ts @@ -1,7 +1,7 @@ import fscreen from "fscreen"; import { fetch } from "utilities"; import { showInfoModal } from "modal"; -import { html } from "lit/development"; +import { html } from "lit"; export function initTutor(submissionCode: string): void { function init(): void { From e16a5bf237da56f9de6f6247c93f149436f2e36c Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 10:11:18 +0200 Subject: [PATCH 04/10] Fix lint --- app/helpers/renderers/feedback_table_renderer.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/renderers/feedback_table_renderer.rb b/app/helpers/renderers/feedback_table_renderer.rb index 9eb2134d53..221b4e7b72 100644 --- a/app/helpers/renderers/feedback_table_renderer.rb +++ b/app/helpers/renderers/feedback_table_renderer.rb @@ -192,8 +192,7 @@ def group(g) @builder.div(class: 'tutor-strip tutorlink', title: 'Start debugger', 'data-statements': (g[:data][:statements]).to_s, - 'data-stdin': (g[:data][:stdin]).to_s - ) do + 'data-stdin': (g[:data][:stdin]).to_s) do @builder.div(class: 'tutor-strip-icon') do @builder.i('', class: 'mdi mdi-launch mdi-18') end From ebe7c7722b46af4cb40998bcba2b883e26697de9 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 10:14:47 +0200 Subject: [PATCH 05/10] Fix tests --- app/helpers/renderers/feedback_table_renderer.rb | 1 + app/helpers/renderers/pythia_renderer.rb | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/renderers/feedback_table_renderer.rb b/app/helpers/renderers/feedback_table_renderer.rb index 221b4e7b72..541c0d2ae5 100644 --- a/app/helpers/renderers/feedback_table_renderer.rb +++ b/app/helpers/renderers/feedback_table_renderer.rb @@ -1,4 +1,5 @@ class FeedbackTableRenderer + include ActionView::Helpers::JavaScriptHelper include Rails.application.routes.url_helpers include ApplicationHelper diff --git a/app/helpers/renderers/pythia_renderer.rb b/app/helpers/renderers/pythia_renderer.rb index eaa3dcd5e1..e10ab59010 100644 --- a/app/helpers/renderers/pythia_renderer.rb +++ b/app/helpers/renderers/pythia_renderer.rb @@ -1,6 +1,4 @@ class PythiaRenderer < FeedbackTableRenderer - include ActionView::Helpers::JavaScriptHelper - def parse file_viewer_init super From e7a15177ffe71ef2bc48883a95208a2a638b1838 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 10:23:51 +0200 Subject: [PATCH 06/10] Add debug-data to json format --- public/schemas/judge_output.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/schemas/judge_output.json b/public/schemas/judge_output.json index 31923a9f38..b22525baf4 100644 --- a/public/schemas/judge_output.json +++ b/public/schemas/judge_output.json @@ -51,7 +51,8 @@ "accepted": { "$ref": "#/definitions/accepted" }, "description": { "$ref": "#/definitions/message" }, "tests": { "type": "array", "items": { "$ref": "#/definitions/test" } }, - "messages": { "type": "array", "items": { "$ref": "#/definitions/message" } } + "messages": { "type": "array", "items": { "$ref": "#/definitions/message" } }, + "data": { "$ref": "#/definitions/debug-data" } } }, "test": { @@ -144,6 +145,14 @@ "severity": { "type": "string", "enum": ["error", "warning", "info"] + }, + "debug-data": { + "type": "object", + "description": "Debug data that can be used to debug the test case with the python tutor.", + "properties": { + "statements": { "type": "string", "description": "The statements that should be executed to mimic this testcase." }, + "input": { "type": "string", "description": "The input that should be used to mimic this testcase." } + } } } } From 2e4ea1670c26ede61018aa3067880bd8ddf63919 Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Thu, 19 Oct 2023 15:14:48 +0200 Subject: [PATCH 07/10] Support data in partial format --- app/runners/result_constructor.rb | 3 +- public/schemas/partial_output.json | 17 +++++++- test/runners/result_constructor_test.rb | 58 +++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/app/runners/result_constructor.rb b/app/runners/result_constructor.rb index 4d7761d01f..38f6a3b470 100644 --- a/app/runners/result_constructor.rb +++ b/app/runners/result_constructor.rb @@ -160,9 +160,10 @@ def close_testcase(accepted: nil) @level = :context end - def close_context(accepted: nil) + def close_context(accepted: nil, data: nil) check_level(:context, 'context closed') @context[:accepted] = accepted unless accepted.nil? + @context[:data] = data unless data.nil? @judgement[:accepted] &&= @context[:accepted] @hiddentab &&= @context[:accepted] (@tab[:groups] ||= []) << @context diff --git a/public/schemas/partial_output.json b/public/schemas/partial_output.json index 955e5936eb..7606aef24d 100644 --- a/public/schemas/partial_output.json +++ b/public/schemas/partial_output.json @@ -126,7 +126,8 @@ "required": ["command"], "properties": { "command": { "enum": ["close-context"] }, - "accepted": { "type": "boolean" } + "accepted": { "type": "boolean" }, + "data": { "$ref": "#/definitions/data" } } }, "close-tab": { @@ -218,6 +219,20 @@ "severity": { "type": "string", "enum": ["error", "warning", "info"] + }, + "data": { + "type": "object", + "description": "Metadata, currently used to enable the Python Tutor (only works for Python).", + "properties": { + "statements": { + "type": "string", + "description": "Block of code which is pasted below the submission to run a context." + }, + "stdin": { + "type": "string", + "description": "The stdin for this context, which will be provided to the Python Tutor." + } + } } } } diff --git a/test/runners/result_constructor_test.rb b/test/runners/result_constructor_test.rb index 451a01f665..0c6e7c241d 100644 --- a/test/runners/result_constructor_test.rb +++ b/test/runners/result_constructor_test.rb @@ -46,6 +46,64 @@ class ResultConstructorTest < ActiveSupport::TestCase end end + test 'metadata should be accepted' do + assert_equal({ + accepted: true, + status: 'correct', + description: 'Correct', + groups: [{ + description: 'Tab One', + badgeCount: 0, + groups: [{ + accepted: true, + groups: [{ + description: 'case 1', + accepted: true + }], + data: { + statements: 'case 1', + stdin: '123' + } + }, { + accepted: true, + groups: [{ + description: 'case 2', + accepted: true + }], + data: { + statements: 'case 2' + } + }, { + accepted: true, + groups: [{ + description: 'case 3', + accepted: true + }], + data: { + stdin: '3' + } + }] + }] + }, construct_result([ + '{ "command": "start-judgement" }', + '{ "command": "start-tab", "title": "Tab One" }', + '{ "command": "start-context" }', + '{ "command": "start-testcase", "description": "case 1" }', + '{ "command": "close-testcase" }', + '{ "command": "close-context", "data": { "statements": "case 1", "stdin": "123" } }', + '{ "command": "start-context" }', + '{ "command": "start-testcase", "description": "case 2" }', + '{ "command": "close-testcase" }', + '{ "command": "close-context", "data": { "statements": "case 2" } }', + '{ "command": "start-context" }', + '{ "command": "start-testcase", "description": "case 3" }', + '{ "command": "close-testcase" }', + '{ "command": "close-context", "data": { "stdin": "3" } }', + '{ "command": "close-tab" }', + '{ "command": "close-judgement" }' + ])) + end + test 'partial output should accumulated status' do assert_equal({ accepted: false, From a60fabd2bda1b7bd995a1481a5079578b04d5917 Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Thu, 19 Oct 2023 15:15:04 +0200 Subject: [PATCH 08/10] Move data to context level in full format --- public/schemas/judge_output.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/schemas/judge_output.json b/public/schemas/judge_output.json index b22525baf4..0da68f5023 100644 --- a/public/schemas/judge_output.json +++ b/public/schemas/judge_output.json @@ -40,7 +40,8 @@ "accepted": { "$ref": "#/definitions/accepted" }, "description": { "$ref": "#/definitions/message" }, "messages": { "type": "array", "items": { "$ref": "#/definitions/message" } }, - "groups": { "type": "array", "items": { "$ref": "#/definitions/testcase" } } + "groups": { "type": "array", "items": { "$ref": "#/definitions/testcase" } }, + "data": { "$ref": "#/definitions/data" } } }, "testcase": { @@ -51,8 +52,7 @@ "accepted": { "$ref": "#/definitions/accepted" }, "description": { "$ref": "#/definitions/message" }, "tests": { "type": "array", "items": { "$ref": "#/definitions/test" } }, - "messages": { "type": "array", "items": { "$ref": "#/definitions/message" } }, - "data": { "$ref": "#/definitions/debug-data" } + "messages": { "type": "array", "items": { "$ref": "#/definitions/message" } } } }, "test": { @@ -146,7 +146,7 @@ "type": "string", "enum": ["error", "warning", "info"] }, - "debug-data": { + "data": { "type": "object", "description": "Debug data that can be used to debug the test case with the python tutor.", "properties": { From 29413b8f3522b2d2e1533358b7fa23bf75429435 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 16:39:00 +0200 Subject: [PATCH 09/10] Rename to stdin --- public/schemas/judge_output.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/schemas/judge_output.json b/public/schemas/judge_output.json index 0da68f5023..71e55ad448 100644 --- a/public/schemas/judge_output.json +++ b/public/schemas/judge_output.json @@ -151,7 +151,7 @@ "description": "Debug data that can be used to debug the test case with the python tutor.", "properties": { "statements": { "type": "string", "description": "The statements that should be executed to mimic this testcase." }, - "input": { "type": "string", "description": "The input that should be used to mimic this testcase." } + "stdin": { "type": "string", "description": "The input that should be used to mimic this testcase." } } } } From 36188c8c82efa81d89e0c5d904911300fc3e644c Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 23 Oct 2023 10:01:31 +0200 Subject: [PATCH 10/10] Remove pythia_submissions pack --- app/javascript/packs/pythia_submission.js | 3 - app/javascript/packs/submission.js | 2 + app/views/activities/show.html.erb | 1 - app/views/feedbacks/show.html.erb | 88 ++++++++++----------- app/views/submissions/_description.html.erb | 1 - 5 files changed, 46 insertions(+), 49 deletions(-) delete mode 100644 app/javascript/packs/pythia_submission.js diff --git a/app/javascript/packs/pythia_submission.js b/app/javascript/packs/pythia_submission.js deleted file mode 100644 index b821cc58ec..0000000000 --- a/app/javascript/packs/pythia_submission.js +++ /dev/null @@ -1,3 +0,0 @@ -import { initFileViewers } from "file_viewer"; - -window.dodona.initFileViewers = initFileViewers; diff --git a/app/javascript/packs/submission.js b/app/javascript/packs/submission.js index b1757cc902..1ecb5eaf22 100644 --- a/app/javascript/packs/submission.js +++ b/app/javascript/packs/submission.js @@ -5,6 +5,7 @@ import { evaluationState } from "state/Evaluations"; import codeListing from "code_listing"; import { annotationState } from "state/Annotations"; import { initTutor } from "tutor"; +import { initFileViewers } from "file_viewer"; window.dodona.initSubmissionShow = initSubmissionShow; window.dodona.codeListing = codeListing; @@ -16,6 +17,7 @@ window.dodona.setEvaluationId = id => evaluationState.id = id; window.dodona.setAnnotationVisibility = visibility => annotationState.visibility = visibility; window.dodona.showLastTab = showLastTab; window.dodona.initTutor = initTutor; +window.dodona.initFileViewers = initFileViewers; // will automatically bind to window.iFrameResize() require("iframe-resizer"); // eslint-disable-line no-undef diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 855ecacab3..b8945018fe 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -9,7 +9,6 @@ window.dodona.initMathJax(); - <%= javascript_include_tag 'pythia_submission' if @activity.judge.renderer == PythiaRenderer %> <% end %> <% end %> <%= render 'navbar_links' %> diff --git a/app/views/feedbacks/show.html.erb b/app/views/feedbacks/show.html.erb index 4166afb55c..9ed03614e6 100644 --- a/app/views/feedbacks/show.html.erb +++ b/app/views/feedbacks/show.html.erb @@ -4,7 +4,6 @@ window.dodona.initMathJax(); - <%= javascript_include_tag 'pythia_submission' if @feedback.submission&.judge&.renderer == PythiaRenderer %> <% end %>
@@ -26,57 +25,58 @@
- <% if @feedback.total_attempts > 0 %> -
-
diff --git a/app/views/submissions/_description.html.erb b/app/views/submissions/_description.html.erb index 36e24fd815..0ef68b63f4 100644 --- a/app/views/submissions/_description.html.erb +++ b/app/views/submissions/_description.html.erb @@ -4,7 +4,6 @@ window.dodona.initMathJax(); - <%= javascript_include_tag 'pythia_submission' if submission.judge.renderer == PythiaRenderer %> <% end %>