Skip to content

Commit 6b2d34b

Browse files
committed
Merge branch 'master' of https://github.com/barbarer/py4e-int
2 parents ae50c3b + bfa43cd commit 6b2d34b

File tree

7 files changed

+88
-65
lines changed

7 files changed

+88
-65
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Practice Problems
2+
============================
3+
4+
.. raw:: html
5+
6+
<h3>Loading...</h3>
7+
8+
<script type="text/javascript">
9+
10+
EXP_COOKIE = "mooc_nested";
11+
12+
// helper: set cookie
13+
function setCookie(name, value) {
14+
document.cookie = name + "=" + (value || "") + "; path=/";
15+
}
16+
17+
18+
// helper: get cookie
19+
function getCookie(name) {
20+
var cookieName = name + "=";
21+
var ca = document.cookie.split(';');
22+
for (var i = 0; i < ca.length; i++) {
23+
var c = ca[i].trim();
24+
if (c.indexOf(cookieName) === 0) return c.substring(cookieName.length);
25+
}
26+
return null;
27+
}
28+
29+
30+
window.onload = function() {
31+
32+
var href = '';
33+
// get prev set cookie
34+
var cond = getCookie(EXP_COOKIE);
35+
// if no prev set cookie: generate random condition and set cookie
36+
if (cond != 'nt' && cond != 'wt') {
37+
var v = Math.floor(Math.random() * 2);
38+
if (v < 1) {
39+
cond = 'nt';
40+
} else {
41+
cond = 'wt';
42+
}
43+
setCookie(EXP_COOKIE, cond); // expires at end of session
44+
}
45+
46+
if (cond == 'nt') {
47+
href = "mc_nested-nt.html"
48+
} else if (cond == 'wt') {
49+
href = "mc_nested-wt.html"
50+
}
51+
window.location.href = href;
52+
};
53+
</script>
54+

_sources/_hidden/mc_intro.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Solving Mixed-up Code Problems
88
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99

1010
If you see a problem like the one below you will need to put the mixed-up
11-
code in the correct order on the right side. You
12-
may need to indent the blocks as well. There may also be extra blocks that are not
11+
code in the correct order on the right side. You may need to indent the blocks as well. There may also be extra blocks that are not
1312
needed in a correct solution that you can leave on the left side. Click the "Check" button
1413
to check your solution.
1514

@@ -138,16 +137,26 @@ Finish writing the code for the following problem.
138137

139138

140139

141-
Solving Write Code Problems with an Adaptive Mixed-up Puzzle as Scaffolding
140+
Solving Write Code Problems with Pop-Up Mixed-up Code Puzzles to Help
142141
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
143142
If you see a problem like the one below, you will need to write code. You can go to the **toggle bar** above the problem description to open a mixed-up puzzle that will help you write the code.
144143
The mixed-up puzzle will have blocks of code that you can drag and drop to create a solution. You can also use the "Help me" button to get additional assistance within the puzzle if needed.
145144

145+
146+
.. youtube:: zz4ATp31_vk
147+
:optional:
148+
:divid: write-code-toggle-mooc_nested
149+
:width: 780
150+
:height: 498
151+
:align: center
152+
153+
146154
.. selectquestion:: intro-sample-toggle-mooc_nested
147155
:fromid: intro-sample-write-code-triple-mooc_nested, intro-sample-puzzle-mooc_nested
148156
:toggle: lock
149157

150158

159+
151160
What to do next
152161
===============
153162

_sources/_hidden/mc_nested-nt.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Practice
2-
=============
1+
Practice Problems
2+
============================
3+
34

45
.. activecode:: w1-mooc_nested
56
:autograde: unittest
@@ -22,9 +23,9 @@ Practice
2223
+======================================================================================+=======================================================================+
2324
|``add_quantity({"Fruits": ["Apples", "Bananas"], "Bakery": ["Bagels"]}, [3, 4, 6])`` | ``{"Fruits": {"Apples": 3, "Bananas": 4}, "Bakery": {"Bagels": 6}}`` |
2425
+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
25-
|``add_quantity({"Drinks": ["Coffee", "Tea", "Juice"]}, [10, 5, 7])`` | `` {"Drinks": {"Coffee": 10, "Tea": 5, "Juice": 7}}`` |
26+
|``add_quantity({"Drinks": ["Coffee", "Tea", "Juice"]}, [10, 5, 7])`` | ``{"Drinks": {"Coffee": 10, "Tea": 5, "Juice": 7}}`` |
2627
+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
27-
|``add_quantity({"Dairy": ["Milk"]}, [1])`` | `` {"Dairy": {"Milk": 1}}`` |
28+
|``add_quantity({"Dairy": ["Milk"]}, [1])`` | ``{"Dairy": {"Milk": 1}}`` |
2829
+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
2930

3031
~~~~

_sources/_hidden/mc_nested-wt.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Practice
2-
=============
1+
Practice Problems
2+
============================
3+
34

45

56
.. selectquestion:: t1-mooc_nested

_sources/_hidden/mc_pre_survey.rst

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -124,51 +124,17 @@ What to do next
124124

125125
.. raw:: html
126126

127-
<p>Click on the following link to go the practice problems: <b><a id="nested-practice"> <font size="+1">Practice</font></a></b></p>
127+
<p>Click on the following link to go the practice problems: <b><a id="mc_assign_more_practice"> <font size="+1">Practice</font></a></b></p>
128+
128129

129130
.. raw:: html
130131

131-
<script type="text/javascript">
132-
133-
function getCookie(cname) {
134-
let name = cname + "=";
135-
let decodedCookie = decodeURIComponent(document.cookie);
136-
let ca = decodedCookie.split(';');
137-
for(let i = 0; i <ca.length; i++) {
138-
let c = ca[i];
139-
while (c.charAt(0) == ' ') {
140-
c = c.substring(1);
141-
}
142-
if (c.indexOf(name) == 0) {
143-
return c.substring(name.length, c.length);
144-
}
145-
}
146-
return "";
147-
}
148-
149-
function setCookie(cname, cvalue) {
150-
document.cookie = cname + "=" + cvalue + ";";
151-
}
152-
153-
window.onload = function() {
154-
155-
a = document.getElementById("nested-practice")
156-
157-
// get prev set cookie
158-
var EXP_COOKIE = 'mooc_nested'
159-
var cond = getCookie(EXP_COOKIE);
160-
161-
// if no prev set cookie: generate random condition and set cookie
162-
if (cond != 'wt' && cond != 'nt') {
163-
var v = Math.random();
164-
cond = (v < 0.5) ? 'wt' : 'nt';
165-
setCookie(EXP_COOKIE, cond);
166-
}
167-
168-
if (cond == 'wt') {
169-
a.href = "mc_nested-wt.html"
170-
} else if (cond == 'nt') {
171-
a.href = "mc_nested-nt.html"
172-
}
173-
};
174-
</script>
132+
<script type="text/javascript" >
133+
134+
window.onload = function() {
135+
136+
a = document.getElementById("mc_assign_more_practice")
137+
a.href = "mc_assign_more_practice.html"
138+
};
139+
140+
</script>

_sources/_hidden/mc_start.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Rights
4444
^^^^^^^^^^^^^^^^^
4545
Your participation in this study is voluntary. You have the right to withdraw at any time without penalty. Refusal to participate or withdrawal of your consent or discontinued participation in the study will not result in any penalty or loss of benefits or rights to which you might otherwise be entitled.
4646

47-
If you have any questions about the study, please contact the research team at [email protected] or [email protected].
47+
If you have any questions about the study, please contact the research team at [email protected] or [email protected] or [email protected].
4848

4949
Voluntary Consent
5050
^^^^^^^^^^^^^^^^^
@@ -77,7 +77,7 @@ What to do next
7777
const consent_sent = document.getElementById('consent_sent');
7878
7979
if (!consent_sent) {
80-
alert('Please check the consent form before moving to the next.');
80+
alert('Please check the consent form before moving to the next. If it already appears as clicked, kindly re-click to confirm.');
8181
event.preventDefault();
8282
return false;
8383
}

_sources/index.rst

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,7 @@ Table of Contents
5858
:maxdepth: 2
5959

6060
_hidden/student_survey.rst
61-
_hidden/mc_intro.rst
62-
_hidden/mc_start.rst
63-
_hidden/mc_nested-nt.rst
64-
_hidden/mc_puzzle_bank.rst
65-
_hidden/mc_nested-wt.rst
66-
_hidden/mc_post_survey.rst
67-
_hidden/mc_posttest.rst
68-
_hidden/mc_pre_survey.rst
69-
_hidden/mc_review.rst
61+
7062

7163
Acknowledgements
7264
::::::::::::::::

0 commit comments

Comments
 (0)