Skip to content

Commit 003b8a8

Browse files
authored
Merge pull request #8 from SCOREnetworkorg/schuckers-patch-2
adding mls decision errors module
2 parents c815d87 + 1044b4d commit 003b8a8

10 files changed

+940
-0
lines changed
379 KB
Loading

soccer/mls_decision_errors/README

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This repository contains files for a SCORE module for teaching about decision errors using data for about MLS training facilities and their points per match played. This module is designed for students just being introduced to hypothesis testing or for supplemental self-study. It does not require knowledge or usage of any programming language.
2+
3+
This module is best viewed in HTML format. A preprint version of this module can be viewed at https://kgfitzgerald.github.io/baylor_apu_score/soccer/mls_decision_errors/. The module can also be viewed locally by opening the R Project mls_decision_errors.RProj, then opening the R Quarto file index.qmd, and then clicking "Render".
4+
5+
The files in this repository are as follows:
6+
7+
- `mls_decision_errors.RProj`: R Project file for the module
8+
9+
- `index.qmd`: R Quarto file for the module
10+
11+
- `training_facilities.csv`: Data file for the module containing information about when MLS training facilities were built and the teams points per match played in 2023. The information on the training facilities was obtained from https://www.mlssoccer.com/news/facts-figures-and-images-every-mls-training-facility and individual research on newer facilities. The information on points per match played was obtained from https://fbref.com/en/comps/22/2023/2023-Major-League-Soccer-Stats#all_league_summary. This data was combined into one file for the module.
12+
13+
- `training_facilities_glossary.csv`: Data glossary for the `training_facilities.csv` file.
14+
15+
- `Chase_Stadium.jpg`, `St._Louis_City_SC_logo.png`, and `Starfire_Sports_Complex.jpg`: Image files used in the `index.qmd` file.
16+
17+
- `webex.css` and `webex.js` are files used to help create the proper webexercises output that allows for interactivity.
137 KB
Loading
1.88 MB
Loading

soccer/mls_decision_errors/index.qmd

Lines changed: 550 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
team,opened,points_per_match_2023,new
2+
Atlanta United,2017,1.5,TRUE
3+
Chicago Fire,2002,1.18,FALSE
4+
FC Cincinnati,2019,2.03,TRUE
5+
Colorado Rapids,2007,0.79,FALSE
6+
Columbus Crew,1997,1.68,FALSE
7+
FC Dallas,2005,1.35,FALSE
8+
DC United,2020,1.18,TRUE
9+
Houston Dynamo,2011,1.5,FALSE
10+
Inter Miami,2020,1,TRUE
11+
LA FC,2018,1.53,TRUE
12+
LA Galaxy,2003,1.06,FALSE
13+
Minnesota United,1990,1.21,FALSE
14+
Montreal Impact,2016,1.21,TRUE
15+
New England Revolution,2019,1.62,TRUE
16+
NYC FC,2018,1.21,TRUE
17+
NY Red Bulls,2013,1.26,FALSE
18+
Orlando City,2019,1.85,TRUE
19+
Philadelphia Union,2016,1.62,TRUE
20+
Portland Timbers,2012,1.26,FALSE
21+
Real Salt Lake,2017,1.47,TRUE
22+
San Jose Earthquakes,2010,1.29,FALSE
23+
Seattle Sounders,2003,1.56,FALSE
24+
Sporting KC,2018,1.29,TRUE
25+
Toronto FC,2012,0.65,FALSE
26+
Vancouver Whitecaps,2017,1.41,TRUE
27+
Nashville SC,2022,1.44,TRUE
28+
Austin FC,2021,1.15,TRUE
29+
Charlotte FC,2023,1.26,TRUE
30+
St. Louis City,2022,1.65,TRUE
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Variable,Description
2+
team,MLS Soccer Club
3+
opened,Year that training facility (as of 2023) was opened
4+
points_per_match_2023,Team's points per match played in the 2023 season
5+
new,"Measure of whether a team was using a ""new"" or ""old"" training facility. Facilities opened with 10 years of 2023 (2014-2023) are deemed new. Value is ""TRUE"" if the facility is new and ""FALSE"" if the facility is old."
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
:root {
2+
--incorrect: #983E82;
3+
--incorrect_alpha: #edaddd;
4+
--correct: #59935B;
5+
--correct_alpha: #c0edc2;
6+
--highlight: #467AAC;
7+
}
8+
9+
.webex-check {}
10+
11+
.webex-box {
12+
border: 2px solid var(--highlight);
13+
padding: 0.5em 0.25em;
14+
margin: 1em 0;
15+
border-radius: .25em;
16+
background-color: rgba(127, 127, 127, 0.05);
17+
}
18+
19+
.webex-total_correct {
20+
margin-left: 1em;
21+
}
22+
23+
.unchecked .webex-total_correct {
24+
display: none;
25+
}
26+
27+
.unchecked .webex-incorrect,
28+
.unchecked .webex-correct {
29+
border: 2px dotted grey !important;
30+
background-color: white !important;
31+
}
32+
33+
/* styles for webex-solveme */
34+
.webex-select, input.webex-solveme,
35+
.unchecked .webex-radiogroup label.webex-incorrect,
36+
.unchecked .webex-radiogroup label.webex-correct{
37+
border: 2px dotted grey;
38+
background-color: white;
39+
border-radius: 0.25em;
40+
}
41+
42+
.webex-incorrect,
43+
input.webex-solveme.webex-incorrect,
44+
.webex-radiogroup label.webex-incorrect {
45+
border: 2px dotted var(--incorrect);
46+
background-color: var(--incorrect_alpha);
47+
color: black;
48+
border-radius: 0.25em;
49+
}
50+
.webex-correct,
51+
input.webex-solveme.webex-correct,
52+
.webex-radiogroup label.webex-correct {
53+
border: 2px solid var(--correct);
54+
background-color: var(--correct_alpha);
55+
color: black;
56+
border-radius: 0.25em;
57+
}
58+
59+
.unchecked .webex-incorrect span::before,
60+
.unchecked .webex-incorrect + .webex-icon::after,
61+
.unchecked .webex-correct span::before,
62+
.unchecked .webex-correct + .webex-icon::after {
63+
content: " ";
64+
}
65+
66+
.webex-incorrect span::before,
67+
.webex-incorrect + .webex-icon::after {
68+
content: "\274C ";
69+
}
70+
71+
.webex-correct span::before,
72+
.webex-correct + .webex-icon::after {
73+
content: "\2705 ";
74+
}
75+
76+
77+
/* styles for hidden solutions */
78+
.webex-solution {
79+
height: 2.5em;
80+
overflow-y: hidden;
81+
padding: 0.5em;
82+
margin-bottom: 10px;
83+
}
84+
.webex-solution.open {
85+
height: auto;
86+
border: 2px solid var(--highlight);
87+
border-radius: 5px;
88+
}
89+
.webex-solution button, .webex-check-button {
90+
height: 2em;
91+
margin-bottom: 0.5em;
92+
border-radius: 0.5em;
93+
background-color: var(--highlight);
94+
color: white;
95+
padding: 0 0.5em;
96+
}
97+
.webex-solution pre.sourceCode {
98+
border-color: var(--correct);
99+
}
100+
101+
.webex-radiogroup label {
102+
margin-left: 2em;
103+
text-indent: -1em;
104+
padding-left: 0.5em;
105+
font-weight: 400;
106+
display: block;
107+
border: 2px solid rgba(255, 255, 255, 0);
108+
background-color: inherit;
109+
border-radius: 0.25em;
110+
}
111+
112+
.webex-radiogroup label input {
113+
position: relative;
114+
left: -1em;
115+
}
116+
117+
.webex-radiogroup {
118+
margin: 1em 0;
119+
}
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
<script>
2+
3+
/* update total correct if #webex-total_correct exists */
4+
update_total_correct = function() {
5+
console.log("webex: update total_correct");
6+
7+
var t = document.getElementsByClassName("webex-total_correct");
8+
for (var i = 0; i < t.length; i++) {
9+
p = t[i].parentElement;
10+
var correct = p.getElementsByClassName("webex-correct").length;
11+
var solvemes = p.getElementsByClassName("webex-solveme").length;
12+
var radiogroups = p.getElementsByClassName("webex-radiogroup").length;
13+
var selects = p.getElementsByClassName("webex-select").length;
14+
15+
t[i].innerHTML = correct + " of " + (solvemes + radiogroups + selects) + " correct";
16+
}
17+
}
18+
19+
/* webex-solution button toggling function */
20+
b_func = function() {
21+
console.log("webex: toggle hide");
22+
23+
var cl = this.parentElement.classList;
24+
if (cl.contains('open')) {
25+
cl.remove("open");
26+
} else {
27+
cl.add("open");
28+
}
29+
}
30+
31+
/* check answers */
32+
check_func = function() {
33+
console.log("webex: check answers");
34+
35+
var cl = this.parentElement.classList;
36+
if (cl.contains('unchecked')) {
37+
cl.remove("unchecked");
38+
this.innerHTML = "Hide Answers";
39+
} else {
40+
cl.add("unchecked");
41+
this.innerHTML = "Show Answers";
42+
}
43+
}
44+
45+
/* function for checking solveme answers */
46+
solveme_func = function(e) {
47+
console.log("webex: check solveme");
48+
49+
var real_answers = JSON.parse(this.dataset.answer);
50+
var my_answer = this.value;
51+
var cl = this.classList;
52+
if (cl.contains("ignorecase")) {
53+
my_answer = my_answer.toLowerCase();
54+
}
55+
if (cl.contains("nospaces")) {
56+
my_answer = my_answer.replace(/ /g, "")
57+
}
58+
59+
if (my_answer == "") {
60+
cl.remove("webex-correct");
61+
cl.remove("webex-incorrect");
62+
} else if (real_answers.includes(my_answer)) {
63+
cl.add("webex-correct");
64+
cl.remove("webex-incorrect");
65+
} else {
66+
cl.add("webex-incorrect");
67+
cl.remove("webex-correct");
68+
}
69+
70+
// match numeric answers within a specified tolerance
71+
if(this.dataset.tol > 0){
72+
var tol = JSON.parse(this.dataset.tol);
73+
var matches = real_answers.map(x => Math.abs(x - my_answer) < tol)
74+
if (matches.reduce((a, b) => a + b, 0) > 0) {
75+
cl.add("webex-correct");
76+
} else {
77+
cl.remove("webex-correct");
78+
}
79+
}
80+
81+
// added regex bit
82+
if (cl.contains("regex")){
83+
answer_regex = RegExp(real_answers.join("|"))
84+
if (answer_regex.test(my_answer)) {
85+
cl.add("webex-correct");
86+
}
87+
}
88+
89+
update_total_correct();
90+
}
91+
92+
/* function for checking select answers */
93+
select_func = function(e) {
94+
console.log("webex: check select");
95+
96+
var cl = this.classList
97+
98+
/* add style */
99+
cl.remove("webex-incorrect");
100+
cl.remove("webex-correct");
101+
if (this.value == "answer") {
102+
cl.add("webex-correct");
103+
} else if (this.value != "blank") {
104+
cl.add("webex-incorrect");
105+
}
106+
107+
update_total_correct();
108+
}
109+
110+
/* function for checking radiogroups answers */
111+
radiogroups_func = function(e) {
112+
console.log("webex: check radiogroups");
113+
114+
var checked_button = document.querySelector('input[name=' + this.id + ']:checked');
115+
var cl = checked_button.parentElement.classList;
116+
var labels = checked_button.parentElement.parentElement.children;
117+
118+
/* get rid of styles */
119+
for (i = 0; i < labels.length; i++) {
120+
labels[i].classList.remove("webex-incorrect");
121+
labels[i].classList.remove("webex-correct");
122+
}
123+
124+
/* add style */
125+
if (checked_button.value == "answer") {
126+
cl.add("webex-correct");
127+
} else {
128+
cl.add("webex-incorrect");
129+
}
130+
131+
update_total_correct();
132+
}
133+
134+
window.onload = function() {
135+
console.log("webex onload");
136+
/* set up solution buttons */
137+
var buttons = document.getElementsByTagName("button");
138+
139+
for (var i = 0; i < buttons.length; i++) {
140+
if (buttons[i].parentElement.classList.contains('webex-solution')) {
141+
buttons[i].onclick = b_func;
142+
}
143+
}
144+
145+
var check_sections = document.getElementsByClassName("webex-check");
146+
console.log("check:", check_sections.length);
147+
for (var i = 0; i < check_sections.length; i++) {
148+
check_sections[i].classList.add("unchecked");
149+
150+
let btn = document.createElement("button");
151+
btn.innerHTML = "Show Answers";
152+
btn.classList.add("webex-check-button");
153+
btn.onclick = check_func;
154+
check_sections[i].appendChild(btn);
155+
156+
let spn = document.createElement("span");
157+
spn.classList.add("webex-total_correct");
158+
check_sections[i].appendChild(spn);
159+
}
160+
161+
/* set up webex-solveme inputs */
162+
var solveme = document.getElementsByClassName("webex-solveme");
163+
164+
for (var i = 0; i < solveme.length; i++) {
165+
/* make sure input boxes don't auto-anything */
166+
solveme[i].setAttribute("autocomplete","off");
167+
solveme[i].setAttribute("autocorrect", "off");
168+
solveme[i].setAttribute("autocapitalize", "off");
169+
solveme[i].setAttribute("spellcheck", "false");
170+
solveme[i].value = "";
171+
172+
/* adjust answer for ignorecase or nospaces */
173+
var cl = solveme[i].classList;
174+
var real_answer = solveme[i].dataset.answer;
175+
if (cl.contains("ignorecase")) {
176+
real_answer = real_answer.toLowerCase();
177+
}
178+
if (cl.contains("nospaces")) {
179+
real_answer = real_answer.replace(/ /g, "");
180+
}
181+
solveme[i].dataset.answer = real_answer;
182+
183+
/* attach checking function */
184+
solveme[i].onkeyup = solveme_func;
185+
solveme[i].onchange = solveme_func;
186+
187+
solveme[i].insertAdjacentHTML("afterend", " <span class='webex-icon'></span>")
188+
}
189+
190+
/* set up radiogroups */
191+
var radiogroups = document.getElementsByClassName("webex-radiogroup");
192+
for (var i = 0; i < radiogroups.length; i++) {
193+
radiogroups[i].onchange = radiogroups_func;
194+
}
195+
196+
/* set up selects */
197+
var selects = document.getElementsByClassName("webex-select");
198+
for (var i = 0; i < selects.length; i++) {
199+
selects[i].onchange = select_func;
200+
selects[i].insertAdjacentHTML("afterend", " <span class='webex-icon'></span>")
201+
}
202+
203+
update_total_correct();
204+
}
205+
206+
</script>

0 commit comments

Comments
 (0)