Skip to content

Commit d285ecc

Browse files
committed
Merge branch 'master' of https://github.com/barbarer/py4e-int
2 parents 75d0bb9 + 501f91c commit d285ecc

26 files changed

+917
-716
lines changed

_sources/turtles/SE_turtle/index.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Python 3 Turtles Practice
44
Study Information
55
^^^^^^^^^^^^^^^^^^^^^^
66

7-
Hi, we are a team of researchers in Professor Ericson’s Lab at UMSI. You are invited to participate in a study to help CS entry-level learning.
8-
You must be at least 18 years old to participate into this study. Your participation will help more novice programmers become successful in introductory computing courses in a low-cost, scalable, and easily adopted way.
7+
Hi, we are a team of researchers in Professor Ericson’s Lab at UMSI. You are invited to participate in a study to help CS entry-level learning (UM IRB HUM00253438).
8+
Your participation will help more novice programmers become successful in introductory computing courses in a low-cost, scalable, and easily adopted way.
99

1010
This study has four parts. It will take approximately 40 minutes to complete it.
1111
Please do the parts in order and answer questions to the best of your ability without any outside help including ChatGPT.
@@ -18,12 +18,7 @@ The four parts are:
1818
- **Practice** - Complete four mixed-up puzzle pairs, followed by survey questions.
1919
- **Posttest** - Includes 10 multiple-choice / true-false / short-answer questions.
2020

21-
Only your anonymous log fles from this session will be used for this study. No identifiable information will be collected. Participating in this study is completely voluntary.
22-
23-
If you do not meet the eligibility criteria or if you choose to withdraw your consent and wish to have your **anonymous responses** deleted, please click to withdraw from the study.
24-
25-
.. poll:: withdrawal
26-
:option_1: I do not want to participate in this study.
21+
Only your anonymous log fles from this session will be used for this study. No identifiable information will be collected. You will not be graded on your performance.
2722

2823
If you have questions at any time about the study or the procedures, you may contact the researcher at email xyhou@umich.edu.
2924

_sources/turtles/SE_turtle/pp-intro-IE.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ You may need to indent the blocks as well. There may also be extra blocks that
1212
needed in a correct solution that you can leave on the left side. Click the "Check" button
1313
to check your solution.
1414

15-
See the video below for an example.
16-
17-
.. youtube:: Rf7oWHlo-e0
18-
:divid: iwgex1-parsons1-ppie
19-
:optional:
20-
:width: 500
21-
:height: 415
22-
:align: center
23-
2415
Try to solve the following mixed-up code problem. This problem doesn't require any indentation.
2516

2617
.. parsonsprob:: intro-simple-parsons-ppie-1

_sources/turtles/SE_turtle/pp-intro-PP.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ may need to indent the blocks as well. There may also be extra blocks that are
1313
needed in a correct solution that you can leave on the left side. Click the "Check" button
1414
to check your solution.
1515

16-
See the video below for an example.
17-
18-
.. youtube:: Rf7oWHlo-e0
19-
:divid: iwgex1-parsons1-ppnse
20-
:optional:
21-
:width: 500
22-
:height: 415
23-
:align: center
24-
2516
Try to solve the following mixed-up code problem. This problem doesn't require any indentation.
2617

2718
.. parsonsprob:: intro-simple-parsons-ppnse-1

_sources/turtles/SE_turtle/pp-intro-SE.rst

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ may need to indent the blocks as well. There may also be extra blocks that are
1313
needed in a correct solution that you can leave on the left side. Click the "Check" button
1414
to check your solution.
1515

16-
See the video below for an example.
17-
18-
.. youtube:: Rf7oWHlo-e0
19-
:divid: iwgex1-parsons1-ppse
20-
:optional:
21-
:width: 500
22-
:height: 415
23-
:align: center
24-
2516
Try to solve the following mixed-up code problem. This problem doesn't require any indentation.
2617

2718
.. parsonsprob:: intro-simple-parsons-ppse-1
@@ -100,21 +91,22 @@ The clicable area are those with a dark gray background and a border around them
10091
You will then receive a completed explanatoin of the solution you got from solving the mixed-up puzzle.
10192

10293

103-
<img src="https://i.postimg.cc/Kzgng2sJ/SE-introduction.png" width="500">
104-
94+
.. image:: https://i.postimg.cc/SmDGs7mZ/SE-introduction.png
95+
:width: 600
96+
:align: center
10597

10698
Four types of feedback will be provided for each option you select.
10799

108100
👉 Correct / Incorrect feedback
109101
If you see a feedback message like "You are correct!" or "Incorrect.", it means you have selected the correct or incorrect option.
110102

111-
👉 Detailed feedback on how many options you got correctly or incorrectly.
103+
👉 Detailed feedback on how many options you got correct or wrong.
112104
If you see a feedback message like "You clicked on 1 of the 2 correct elements and 0 of the 3 incorrect elements.", it tells you the number of correct and incorrect options you selected.
113105

114-
👉 Hints on how to correct the incorrectly selected options.
106+
👉 Hints on how to correct the wrong options.
115107
If you see a feedback message like "Think about the type of the input parameter.", it provides hints on how to correct the incorrect options you selected.
116108

117-
👉 Highlighted incorrectly selected options
109+
👉 Highlighted incorrect options
118110
The Incorrect options you selected will be highlighted in pink background with a red border. You need to deselect the incorrect options and select the correct options.
119111

120112

@@ -127,7 +119,9 @@ Try to solve the following explanation problem. You can click on the options to
127119
:feedback: (1) Think about the type of the input parameter. (2) Think about the operator used to concatenate two strings.
128120

129121
Here is a completed function:
130-
<img src="https://i.postimg.cc/fTbCh4Rc/join-Strings-solution.png" width="500">
122+
<img src="https://i.postimg.cc/fTbCh4Rc/join-Strings-solution.png" width="300">
123+
124+
131125

132126
(1) <b>Function Definition —— def joinStrings(str1, str2):</b>
133127
Defines a new function and takes two parameters as inputs: str1 and str2. Both parameters are <b style="background-color:#d9d9d9">[:click-correct:string:endclick: / :click-incorrect:list:endclick:]</b>.

_sources/turtles/SE_turtle/pps-IE-pp1.rst

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Practice Problems
55
:numbered: left
66
:adaptive:
77

8-
Create a function called ``create_T`` that takes in ``turtle`` as a parameter and moves the turtle to create the letter T.
8+
Create a function called ``create_T`` that takes in ``turtle_obj`` as a parameter and moves the turtle to create the letter T.
99
The width of the letter should be 100, and the height of the letter should be 150.
1010
-----
1111
from turtle import *
@@ -30,6 +30,8 @@ Practice Problems
3030
turtle_obj.forward(height)
3131

3232

33+
What to do next
34+
^^^^^^^^^^^^^^^
3335

3436
.. raw:: html
3537

@@ -39,44 +41,56 @@ Practice Problems
3941
.. raw:: html
4042

4143

42-
<script type="text/javascript">
44+
<script type="text/javascript">
4345
44-
// Initialize a counter variable at a higher scope
45-
let clickCount = 0;
46+
document.addEventListener('DOMContentLoaded', () => {
47+
let isC8 = false;
48+
49+
// Override the console.log function to capture the log event
50+
const originalConsoleLog = console.log;
51+
console.log = function (message) {
52+
// Call the original console.log function to ensure the message still appears in the console
53+
originalConsoleLog.apply(console, arguments);
54+
55+
// Check if the message contains the specific pattern
56+
if (message.includes('Save logging event')) {
57+
// Extract the JSON part from the log message
58+
const jsonString = message.substring(message.indexOf('{'));
59+
checkActValue(jsonString);
60+
}
61+
};
62+
63+
function checkActValue(loggingEvent) {
64+
try {
65+
const eventObj = JSON.parse(loggingEvent);
66+
const actValue = eventObj.act;
67+
const lastPart = actValue.split('|').pop();
68+
if (lastPart === "c8") {
69+
isC8 = true;
70+
}
71+
console.log(`Last part of act: ${lastPart}, isC8: ${isC8}`);
72+
} catch (error) {
73+
console.error('Error parsing the logging event:', error);
74+
}
75+
}
4676
47-
// Function to update the click count
48-
function updateClickCount() {
49-
clickCount++;
50-
document.getElementById('clickCount').textContent = `Times Clicked: ${clickCount}`;
51-
}
77+
function handleLinkClick(event) {
78+
const alertElement = document.querySelector('.alert');
79+
if ((alertElement && alertElement.textContent.includes('Perfect!')) || isC8) {
80+
return true;
81+
} else {
82+
event.preventDefault();
83+
alert('Please try again to complete the mixed-up puzzle first.' + "\n" + 'Remember, you can click the "Help me" button to remove an unnecessary block or combine two blocks.' + "\n" + 'You can skip the puzzle after 8 attempts.');
84+
return false;
85+
}
86+
}
5287
53-
// Function to check for presence of button and handle the link click
54-
function handleLinkClick(event) {
55-
// Check if an element with the class 'alert alert-info' contains the text 'Perfect!'
56-
const alertElement = document.querySelector('.alert');
57-
58-
if ((alertElement && alertElement.textContent.includes('Perfect!')) || clickCount >= 8) {
59-
// Allow the link to be followed
60-
return true;
88+
const linkElement = document.getElementById('ie1');
89+
if (linkElement) {
90+
linkElement.addEventListener('click', handleLinkClick);
6191
} else {
62-
// Prevent the default link action
63-
event.preventDefault();
64-
65-
// Display a popup window
66-
alert('Please try again to complete the mixed-up puzzle first.' + "\n" + 'Remember, you can click the "Help me" button to remove an unnecessary block or combine two blocks.' + "\n" + ' You can skip the puzzle after 8 attempts.');
67-
return false;
92+
console.error('Element with ID "ie1" not found.');
6893
}
69-
}
70-
71-
// Attach the click event handler to the link
72-
document.getElementById('ie1').addEventListener('click', handleLinkClick);
73-
74-
document.addEventListener('DOMContentLoaded', () => {
75-
// Get references to the button and the display element
76-
const checkButton = document.getElementById('parsons-1-check');
77-
78-
// Add an event listener to the button
79-
checkButton.addEventListener('click', updateClickCount);
8094
});
8195
8296
</script>

_sources/turtles/SE_turtle/pps-IE-pp2.rst

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ Practice Problems
1616
def create_hexagon(turtle):
1717
=====
1818
for i in range(0, 6):
19-
=====
2019
turtle.forward(50)
2120
=====
21+
for i in range(0, 6):
22+
turtle = turtle.forward(50) #paired
23+
=====
24+
for i in range(0, 7):
2225
turtle = turtle.forward(50) #paired
2326
=====
2427
turtle.left(60)
@@ -27,51 +30,67 @@ Practice Problems
2730
=====
2831
create_hexagon(alex)
2932

33+
34+
What to do next
35+
^^^^^^^^^^^^^^^
36+
3037
.. raw:: html
3138

3239
<p>Click on the following link to go to the explanation: <a id="ie2" href="pps-ie2.html"><font size="+1"><b>Explanation</b></font></a></p>
3340

3441

3542
.. raw:: html
3643

37-
<script type="text/javascript">
38-
39-
// Initialize a counter variable at a higher scope
40-
let clickCount = 0;
41-
42-
// Function to update the click count
43-
function updateClickCount() {
44-
clickCount++;
45-
document.getElementById('clickCount').textContent = `Times Clicked: ${clickCount}`;
46-
}
47-
48-
// Function to check for presence of button and handle the link click
49-
function handleLinkClick(event) {
50-
// Check if an element with the class 'alert alert-info' contains the text 'Perfect!'
51-
const alertElement = document.querySelector('.alert');
52-
53-
if ((alertElement && alertElement.textContent.includes('Perfect!')) || clickCount >= 5) {
54-
// Allow the link to be followed
55-
return true;
56-
} else {
57-
// Prevent the default link action
58-
event.preventDefault();
59-
60-
// Display a popup window
61-
alert('Please try again to complete the mixed-up puzzle first.' + "\n" + 'Remember, you can click the "Help me" button to remove an unnecessary block or combine two blocks.' + "\n" + ' You can skip the puzzle after 8 attempts.');
62-
return false;
44+
<script type="text/javascript">
45+
46+
document.addEventListener('DOMContentLoaded', () => {
47+
let isC8 = false;
48+
49+
// Override the console.log function to capture the log event
50+
const originalConsoleLog = console.log;
51+
console.log = function (message) {
52+
// Call the original console.log function to ensure the message still appears in the console
53+
originalConsoleLog.apply(console, arguments);
54+
55+
// Check if the message contains the specific pattern
56+
if (message.includes('Save logging event')) {
57+
// Extract the JSON part from the log message
58+
const jsonString = message.substring(message.indexOf('{'));
59+
checkActValue(jsonString);
60+
}
61+
};
62+
63+
function checkActValue(loggingEvent) {
64+
try {
65+
const eventObj = JSON.parse(loggingEvent);
66+
const actValue = eventObj.act;
67+
const lastPart = actValue.split('|').pop();
68+
if (lastPart === "c8") {
69+
isC8 = true;
70+
}
71+
console.log(`Last part of act: ${lastPart}, isC8: ${isC8}`);
72+
} catch (error) {
73+
console.error('Error parsing the logging event:', error);
74+
}
6375
}
64-
}
6576
66-
// Attach the click event handler to the link
67-
document.getElementById('ie2').addEventListener('click', handleLinkClick);
77+
function handleLinkClick(event) {
78+
const alertElement = document.querySelector('.alert');
79+
if ((alertElement && alertElement.textContent.includes('Perfect!')) || isC8) {
80+
return true;
81+
} else {
82+
event.preventDefault();
83+
alert('Please try again to complete the mixed-up puzzle first.' + "\n" + 'Remember, you can click the "Help me" button to remove an unnecessary block or combine two blocks.' + "\n" + 'You can skip the puzzle after 8 attempts.');
84+
return false;
85+
}
86+
}
6887
69-
document.addEventListener('DOMContentLoaded', () => {
70-
// Get references to the button and the display element
71-
const checkButton = document.getElementById('parsons-1-check');
72-
73-
// Add an event listener to the button
74-
checkButton.addEventListener('click', updateClickCount);
88+
const linkElement = document.getElementById('ie2');
89+
if (linkElement) {
90+
linkElement.addEventListener('click', handleLinkClick);
91+
} else {
92+
console.error('Element with ID "ie2" not found.');
93+
}
7594
});
7695
7796
</script>

0 commit comments

Comments
 (0)