Skip to content

Commit ae5e5ad

Browse files
committed
Tweaks - Make a cookie for python version.
1 parent d91aafc commit ae5e5ad

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

lessons.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,19 @@
249249
"youtube" : "-iUA4cCKRlM"
250250
}
251251
],
252-
"lti" : {
252+
"lti" : [
253+
{
254+
"title" : "Autograder: Exercise 3.1",
255+
"launch" : "tools/pythonauto/index.php",
256+
"resource_link_id": "pythonauto_03_01",
257+
"custom" : [
258+
{
259+
"key": "exercise",
260+
"value": "3.1"
261+
}
262+
]
263+
},
264+
{
253265
"title" : "Autograder: Exercise 3.3",
254266
"launch" : "tools/pythonauto/index.php",
255267
"resource_link_id": "pythonauto_03_03",
@@ -260,6 +272,7 @@
260272
}
261273
]
262274
}
275+
]
263276
},
264277
{
265278
"title": "Functions",

tools/pythonauto/index.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@
4141
}
4242
$codemirror = $editor == 1;
4343

44+
$newpython3 = $python3;
4445
if ( isset($_GET['python3']) && ( $_GET['python3'] == '1' || $_GET['python3'] == '0' ) ) {
4546
$newpython3 = $_GET['python3']+0;
46-
if ( $python3 != $newpython3 ) {
47-
GradeUtil::gradeUpdateJson(array("python3" => $newpython3));
48-
$json['python3'] = $newpython3;
49-
$python3 = $newpython3;
50-
}
47+
setcookie("py4e_python_version",($newpython3+2)."", time()+3600*24*120, '/');
48+
} else if ( isset($_COOKIE["py4e_python_version"]) ) {
49+
$newpython3 = $_COOKIE["py4e_python_version"] - 2;
50+
}
51+
if ( $python3 != $newpython3 ) {
52+
GradeUtil::gradeUpdateJson(array("python3" => $newpython3));
53+
$json['python3'] = $newpython3;
54+
$python3 = $newpython3;
5155
}
5256

5357
// Switch to boolean

0 commit comments

Comments
 (0)