Skip to content

Commit 98ee7eb

Browse files
authored
Use a multilines string as evalution criteria (#24)
* Use a multilines string as evalution criteria * docstring * Ensure evaluation criteria type
1 parent b13ea13 commit 98ee7eb

3 files changed

Lines changed: 10 additions & 35 deletions

File tree

‎examples/matplotlib_exercices.ipynb‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@
4949
"metadata": {
5050
"deletable": true,
5151
"editable": true,
52-
"evaluation_criteria": [
53-
"Typo Correction: Correct 'np.linsapce' typo to 'np.linspace'.",
54-
"Plot Output: Ensure the Sine and Cosine waves plot is correctly rendered without runtime errors."
55-
],
52+
"evaluation_criteria": "Typo Correction: Correct 'np.linsapce' typo to 'np.linspace'.\nPlot Output: Ensure the Sine and Cosine waves plot is correctly rendered without runtime errors."
53+
,
5654
"reference_solution": "vzcbeg zngcybgyvo.clcybg nf cyg\nvzcbeg ahzcl nf ac\nk = ac.yvafcnpr(0, 2 * ac.cv, 100)\nsvt, nk = cyg.fhocybgf(svtfvmr=(8, 4))\nnk.cybg(k, ac.fva(k), ynory='fva(k)', pbybe='eblnyoyhr')\nnk.cybg(k, ac.pbf(k), ynory='pbf(k)', pbybe='gbzngb', yvarfglyr='--')\nnk.frg_gvgyr('Fvar naq Pbfvar Jnirf')\nnk.frg_kynory('k')\nnk.frg_lynory('l')\nnk.yrtraq()\nnk.tevq(Gehr, nycun=0.3)\ncyg.gvtug_ynlbhg()\ncyg.fubj()",
5755
"slideshow": {
5856
"slide_type": ""
@@ -101,11 +99,7 @@
10199
"metadata": {
102100
"deletable": true,
103101
"editable": true,
104-
"evaluation_criteria": [
105-
"Bar chart creation: Uses ax.bar with categories and values.",
106-
"Aesthetics & Colors: Applies a different color to each bar.",
107-
"Value Labels: Correctly loops over the bars to add text scores above each bar."
108-
],
102+
"evaluation_criteria": "Bar chart creation: Uses ax.bar with categories and values.\nAesthetics & Colors: Applies a different color to each bar.\nValue Labels: Correctly loops over the bars to add text scores above each bar.",
109103
"reference_solution": "pngrtbevrf = ['Clguba', 'WninFpevcg', 'Ehfg', 'Tb', 'Whyvn']\ninyhrf = [85, 72, 58, 45, 30]\nsvt, nk = cyg.fhocybgf(svtfvmr=(8, 4))\npbybef = ['eblnyoyhr', 'gbzngb', 'zrqvhzfrnterra', 'benatr', 'zrqvhzchecyr']\nonef = nk.one(pngrtbevrf, inyhrf, pbybe=pbybef)\nnk.frg_gvgyr('Cebtenzzvat Ynathntr Fpberf')\nnk.frg_lynory('Fpber')\nsbe one va onef:\n liny = one.trg_urvtug()\n nk.grkg(one.trg_k() + one.trg_jvqgu()/2.0, liny + 1, fge(liny), un='pragre', in='obggbz')\ncyg.gvtug_ynlbhg()\ncyg.fubj()",
110104
"slideshow": {
111105
"slide_type": ""
@@ -163,11 +157,7 @@
163157
"metadata": {
164158
"deletable": true,
165159
"editable": true,
166-
"evaluation_criteria": [
167-
"Random data seed: Fails to set random seed 42, generating incorrect data coordinates.",
168-
"Colorbar & Labels: Missing colorbar, title, grid, or x/y labels on the axes.",
169-
"Scatter aesthetic parameters: Fails to set alpha=0.6, colormap='viridis', size mapping, or color mapping."
170-
],
160+
"evaluation_criteria": "Random data seed: Fails to set random seed 42, generating incorrect data coordinates.\nColorbar & Labels: Missing colorbar, title, grid, or x/y labels on the axes.\nScatter aesthetic parameters: Fails to set alpha=0.6, colormap='viridis', size mapping, or color mapping.",
171161
"reference_solution": "ac.enaqbz.frrq(42)\na = 150\nk = ac.enaqbz.enaqa(a)\nl = ac.enaqbz.enaqa(a)\nfvmrf = ac.enaqbz.havsbez(20, 200, a)\npbybef = ac.enaqbz.enaq(a)\nsvt, nk = cyg.fhocybgf(svtfvmr=(8, 6))\nfpnggre = nk.fpnggre(k, l, p=pbybef, f=fvmrf, pznc='ivevqvf', nycun=0.6)\ncyg.pbybeone(fpnggre, nk=nk, ynory='Pbybe inyhr')\nnk.frg_gvgyr('Enaqbz Fpnggre Cybg')\nnk.frg_kynory('K inyhrf')\nnk.frg_lynory('L inyhrf')\nnk.tevq(Gehr, nycun=0.3)\ncyg.gvtug_ynlbhg()\ncyg.fubj()",
172162
"slideshow": {
173163
"slide_type": ""

‎src/index.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { infoIcon } from '@jupyterlab/ui-components';
1919

2020
import { clearItem, stopItem } from './components';
2121
import { TUTOR_USER, TutorChatModel } from './model';
22-
import { decodeRot13, formatEvaluationCriteria, isContinuous } from './utils';
22+
import { decodeRot13, isContinuous } from './utils';
2323

2424
const INFO_ICON_BASE_64 = btoa(infoIcon.svgstr);
2525

@@ -281,9 +281,10 @@ const plugin: JupyterFrontEndPlugin<void> = {
281281
const referenceSolution =
282282
typeof rawSolution === 'string' ? decodeRot13(rawSolution) : '';
283283

284-
// Retrieve and format evaluation_criteria from metadata
285-
const rawCriteria = cell.model.getMetadata('evaluation_criteria');
286-
const evaluationCriteria = formatEvaluationCriteria(rawCriteria);
284+
// Retrieve evaluation_criteria from metadata
285+
const evaluationCriteria = cell.model.getMetadata(
286+
'evaluation_criteria'
287+
);
287288

288289
const question = errorSection
289290
? 'Explain code and error'
@@ -299,7 +300,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
299300
if (referenceSolution) {
300301
formattedBody += `\n\n<reference_solution>\n${referenceSolution}\n</reference_solution>`;
301302
}
302-
if (evaluationCriteria) {
303+
if (evaluationCriteria && typeof evaluationCriteria === 'string') {
303304
formattedBody += `\n\n<evaluation_criteria>\n${evaluationCriteria}\n</evaluation_criteria>`;
304305
}
305306

‎src/utils.ts‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,3 @@ export function decodeRot13(str: string): string {
2121
return String.fromCharCode(((c.charCodeAt(0) - base + 13) % 26) + base);
2222
});
2323
}
24-
25-
export function formatEvaluationCriteria(criteriaData: unknown): string {
26-
if (!criteriaData) {
27-
return '';
28-
}
29-
if (typeof criteriaData === 'string') {
30-
return criteriaData;
31-
}
32-
if (Array.isArray(criteriaData)) {
33-
return criteriaData
34-
.map(item => (typeof item === 'string' ? `- ${item.trim()}` : ''))
35-
.filter(Boolean)
36-
.join('\n');
37-
}
38-
return '';
39-
}

0 commit comments

Comments
 (0)