bug fix : leak content python_expected_output
This commit is contained in:
parent
9cee4f2f74
commit
0ff56ed9d2
|
|
@ -61,12 +61,16 @@ export function processLanguageEvaluation(
|
||||||
pythonCode: string,
|
pythonCode: string,
|
||||||
data: LessonContent
|
data: LessonContent
|
||||||
): { isCorrect: boolean } {
|
): { isCorrect: boolean } {
|
||||||
if (!data.expected_output) return { isCorrect: true };
|
if (!data.expected_output && !data.expected_output_python) return { isCorrect: true };
|
||||||
|
|
||||||
const currentCCode = (currentLanguage === 'c') ? code : cCode;
|
const currentCCode = (currentLanguage === 'c') ? code : cCode;
|
||||||
const currentPythonCode = (currentLanguage === 'python') ? code : pythonCode;
|
const currentPythonCode = (currentLanguage === 'python') ? code : pythonCode;
|
||||||
const mergedCode = currentCCode + '\n' + currentPythonCode;
|
const mergedCode = currentCCode + '\n' + currentPythonCode;
|
||||||
|
|
||||||
const isCorrect = compileOutput.trim() === data.expected_output.trim() && checkKeyText(mergedCode, data.key_text ?? '');
|
const expected = (lang === 'python' && data.expected_output_python)
|
||||||
|
? data.expected_output_python
|
||||||
|
: data.expected_output;
|
||||||
|
|
||||||
|
const isCorrect = compileOutput.trim() === expected.trim() && checkKeyText(mergedCode, data.key_text ?? '');
|
||||||
return { isCorrect };
|
return { isCorrect };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export interface LessonContent {
|
||||||
lesson_content: string;
|
lesson_content: string;
|
||||||
exercise_content: string;
|
exercise_content: string;
|
||||||
expected_output: string;
|
expected_output: string;
|
||||||
|
expected_output_python: string;
|
||||||
expected_circuit_output: string;
|
expected_circuit_output: string;
|
||||||
key_text_circuit: string;
|
key_text_circuit: string;
|
||||||
lesson_info: string;
|
lesson_info: string;
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@
|
||||||
out.output = res.output;
|
out.output = res.output;
|
||||||
out.success = true;
|
out.success = true;
|
||||||
|
|
||||||
if (data.expected_output) {
|
if (data.expected_output || data.expected_output_python) {
|
||||||
const { isCorrect } = processLanguageEvaluation(res.output, code, lang, currentLanguage, cCode, pythonCode, data);
|
const { isCorrect } = processLanguageEvaluation(res.output, code, lang, currentLanguage, cCode, pythonCode, data);
|
||||||
if (isCorrect) {
|
if (isCorrect) {
|
||||||
if (lang === 'c') cPassed = true;
|
if (lang === 'c') cPassed = true;
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@
|
||||||
{/key}
|
{/key}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if data.expected_output}
|
{#if (currentLanguage === 'python' ? (data.expected_output_python || data.expected_output) : data.expected_output)}
|
||||||
<details class="expected-output">
|
<details class="expected-output">
|
||||||
<summary>Expected Output</summary>
|
<summary>Expected Output</summary>
|
||||||
<pre>{data.expected_output}</pre>
|
<pre>{currentLanguage === 'python' ? (data.expected_output_python || data.expected_output) : data.expected_output}</pre>
|
||||||
</details>
|
</details>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -229,8 +229,7 @@
|
||||||
height: 60vh;
|
height: 60vh;
|
||||||
}
|
}
|
||||||
.editor-area.mobile-full {
|
.editor-area.mobile-full {
|
||||||
height: 100vh;
|
height: 100dvh;
|
||||||
top: 0;
|
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
max-height: none;
|
max-height: none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ def api_lesson(filename):
|
||||||
lesson_html = parsed_data['lesson_html']
|
lesson_html = parsed_data['lesson_html']
|
||||||
exercise_html = parsed_data['exercise_html']
|
exercise_html = parsed_data['exercise_html']
|
||||||
expected_output = parsed_data['expected_output']
|
expected_output = parsed_data['expected_output']
|
||||||
|
expected_output_python = parsed_data.get('expected_output_python', '')
|
||||||
expected_circuit_output = parsed_data.get('expected_circuit_output', '')
|
expected_circuit_output = parsed_data.get('expected_circuit_output', '')
|
||||||
key_text_circuit = parsed_data.get('key_text_circuit', '')
|
key_text_circuit = parsed_data.get('key_text_circuit', '')
|
||||||
lesson_info = parsed_data['lesson_info']
|
lesson_info = parsed_data['lesson_info']
|
||||||
|
|
@ -120,6 +121,7 @@ def api_lesson(filename):
|
||||||
'lesson_content': lesson_html,
|
'lesson_content': lesson_html,
|
||||||
'exercise_content': exercise_html,
|
'exercise_content': exercise_html,
|
||||||
'expected_output': expected_output,
|
'expected_output': expected_output,
|
||||||
|
'expected_output_python': expected_output_python,
|
||||||
'expected_circuit_output': expected_circuit_output,
|
'expected_circuit_output': expected_circuit_output,
|
||||||
'lesson_info': lesson_info,
|
'lesson_info': lesson_info,
|
||||||
'initial_code': initial_code,
|
'initial_code': initial_code,
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,9 @@ def render_markdown_content(file_path):
|
||||||
expected_output, lesson_content = _extract_section(
|
expected_output, lesson_content = _extract_section(
|
||||||
lesson_content, '---EXPECTED_OUTPUT---', '---END_EXPECTED_OUTPUT---')
|
lesson_content, '---EXPECTED_OUTPUT---', '---END_EXPECTED_OUTPUT---')
|
||||||
|
|
||||||
|
expected_output_python, lesson_content = _extract_section(
|
||||||
|
lesson_content, '---EXPECTED_OUTPUT_PYTHON---', '---END_EXPECTED_OUTPUT_PYTHON---')
|
||||||
|
|
||||||
expected_circuit_output, lesson_content = _extract_section(
|
expected_circuit_output, lesson_content = _extract_section(
|
||||||
lesson_content, '---EXPECTED_CIRCUIT_OUTPUT---', '---END_EXPECTED_CIRCUIT_OUTPUT---')
|
lesson_content, '---EXPECTED_CIRCUIT_OUTPUT---', '---END_EXPECTED_CIRCUIT_OUTPUT---')
|
||||||
|
|
||||||
|
|
@ -388,6 +391,7 @@ def render_markdown_content(file_path):
|
||||||
'lesson_html': lesson_html,
|
'lesson_html': lesson_html,
|
||||||
'exercise_html': exercise_html,
|
'exercise_html': exercise_html,
|
||||||
'expected_output': expected_output,
|
'expected_output': expected_output,
|
||||||
|
'expected_output_python': expected_output_python,
|
||||||
'expected_circuit_output': expected_circuit_output,
|
'expected_circuit_output': expected_circuit_output,
|
||||||
'lesson_info': lesson_info_html,
|
'lesson_info': lesson_info_html,
|
||||||
'initial_code': initial_code,
|
'initial_code': initial_code,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue