Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added soccer/mls_decision_errors/Chase_Stadium.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions soccer/mls_decision_errors/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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.

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".

The files in this repository are as follows:

- `mls_decision_errors.RProj`: R Project file for the module

- `index.qmd`: R Quarto file for the module

- `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.

- `training_facilities_glossary.csv`: Data glossary for the `training_facilities.csv` file.

- `Chase_Stadium.jpg`, `St._Louis_City_SC_logo.png`, and `Starfire_Sports_Complex.jpg`: Image files used in the `index.qmd` file.

- `webex.css` and `webex.js` are files used to help create the proper webexercises output that allows for interactivity.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
550 changes: 550 additions & 0 deletions soccer/mls_decision_errors/index.qmd

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions soccer/mls_decision_errors/mls_decision_errors.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
30 changes: 30 additions & 0 deletions soccer/mls_decision_errors/training_facilities.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
team,opened,points_per_match_2023,new
Atlanta United,2017,1.5,TRUE
Chicago Fire,2002,1.18,FALSE
FC Cincinnati,2019,2.03,TRUE
Colorado Rapids,2007,0.79,FALSE
Columbus Crew,1997,1.68,FALSE
FC Dallas,2005,1.35,FALSE
DC United,2020,1.18,TRUE
Houston Dynamo,2011,1.5,FALSE
Inter Miami,2020,1,TRUE
LA FC,2018,1.53,TRUE
LA Galaxy,2003,1.06,FALSE
Minnesota United,1990,1.21,FALSE
Montreal Impact,2016,1.21,TRUE
New England Revolution,2019,1.62,TRUE
NYC FC,2018,1.21,TRUE
NY Red Bulls,2013,1.26,FALSE
Orlando City,2019,1.85,TRUE
Philadelphia Union,2016,1.62,TRUE
Portland Timbers,2012,1.26,FALSE
Real Salt Lake,2017,1.47,TRUE
San Jose Earthquakes,2010,1.29,FALSE
Seattle Sounders,2003,1.56,FALSE
Sporting KC,2018,1.29,TRUE
Toronto FC,2012,0.65,FALSE
Vancouver Whitecaps,2017,1.41,TRUE
Nashville SC,2022,1.44,TRUE
Austin FC,2021,1.15,TRUE
Charlotte FC,2023,1.26,TRUE
St. Louis City,2022,1.65,TRUE
5 changes: 5 additions & 0 deletions soccer/mls_decision_errors/training_facilities_glossary.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Variable,Description
team,MLS Soccer Club
opened,Year that training facility (as of 2023) was opened
points_per_match_2023,Team's points per match played in the 2023 season
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."
119 changes: 119 additions & 0 deletions soccer/mls_decision_errors/webex.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
:root {
--incorrect: #983E82;
--incorrect_alpha: #edaddd;
--correct: #59935B;
--correct_alpha: #c0edc2;
--highlight: #467AAC;
}

.webex-check {}

.webex-box {
border: 2px solid var(--highlight);
padding: 0.5em 0.25em;
margin: 1em 0;
border-radius: .25em;
background-color: rgba(127, 127, 127, 0.05);
}

.webex-total_correct {
margin-left: 1em;
}

.unchecked .webex-total_correct {
display: none;
}

.unchecked .webex-incorrect,
.unchecked .webex-correct {
border: 2px dotted grey !important;
background-color: white !important;
}

/* styles for webex-solveme */
.webex-select, input.webex-solveme,
.unchecked .webex-radiogroup label.webex-incorrect,
.unchecked .webex-radiogroup label.webex-correct{
border: 2px dotted grey;
background-color: white;
border-radius: 0.25em;
}

.webex-incorrect,
input.webex-solveme.webex-incorrect,
.webex-radiogroup label.webex-incorrect {
border: 2px dotted var(--incorrect);
background-color: var(--incorrect_alpha);
color: black;
border-radius: 0.25em;
}
.webex-correct,
input.webex-solveme.webex-correct,
.webex-radiogroup label.webex-correct {
border: 2px solid var(--correct);
background-color: var(--correct_alpha);
color: black;
border-radius: 0.25em;
}

.unchecked .webex-incorrect span::before,
.unchecked .webex-incorrect + .webex-icon::after,
.unchecked .webex-correct span::before,
.unchecked .webex-correct + .webex-icon::after {
content: " ";
}

.webex-incorrect span::before,
.webex-incorrect + .webex-icon::after {
content: "\274C ";
}

.webex-correct span::before,
.webex-correct + .webex-icon::after {
content: "\2705 ";
}


/* styles for hidden solutions */
.webex-solution {
height: 2.5em;
overflow-y: hidden;
padding: 0.5em;
margin-bottom: 10px;
}
.webex-solution.open {
height: auto;
border: 2px solid var(--highlight);
border-radius: 5px;
}
.webex-solution button, .webex-check-button {
height: 2em;
margin-bottom: 0.5em;
border-radius: 0.5em;
background-color: var(--highlight);
color: white;
padding: 0 0.5em;
}
.webex-solution pre.sourceCode {
border-color: var(--correct);
}

.webex-radiogroup label {
margin-left: 2em;
text-indent: -1em;
padding-left: 0.5em;
font-weight: 400;
display: block;
border: 2px solid rgba(255, 255, 255, 0);
background-color: inherit;
border-radius: 0.25em;
}

.webex-radiogroup label input {
position: relative;
left: -1em;
}

.webex-radiogroup {
margin: 1em 0;
}
206 changes: 206 additions & 0 deletions soccer/mls_decision_errors/webex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<script>

/* update total correct if #webex-total_correct exists */
update_total_correct = function() {
console.log("webex: update total_correct");

var t = document.getElementsByClassName("webex-total_correct");
for (var i = 0; i < t.length; i++) {
p = t[i].parentElement;
var correct = p.getElementsByClassName("webex-correct").length;
var solvemes = p.getElementsByClassName("webex-solveme").length;
var radiogroups = p.getElementsByClassName("webex-radiogroup").length;
var selects = p.getElementsByClassName("webex-select").length;

t[i].innerHTML = correct + " of " + (solvemes + radiogroups + selects) + " correct";
}
}

/* webex-solution button toggling function */
b_func = function() {
console.log("webex: toggle hide");

var cl = this.parentElement.classList;
if (cl.contains('open')) {
cl.remove("open");
} else {
cl.add("open");
}
}

/* check answers */
check_func = function() {
console.log("webex: check answers");

var cl = this.parentElement.classList;
if (cl.contains('unchecked')) {
cl.remove("unchecked");
this.innerHTML = "Hide Answers";
} else {
cl.add("unchecked");
this.innerHTML = "Show Answers";
}
}

/* function for checking solveme answers */
solveme_func = function(e) {
console.log("webex: check solveme");

var real_answers = JSON.parse(this.dataset.answer);
var my_answer = this.value;
var cl = this.classList;
if (cl.contains("ignorecase")) {
my_answer = my_answer.toLowerCase();
}
if (cl.contains("nospaces")) {
my_answer = my_answer.replace(/ /g, "")
}

if (my_answer == "") {
cl.remove("webex-correct");
cl.remove("webex-incorrect");
} else if (real_answers.includes(my_answer)) {
cl.add("webex-correct");
cl.remove("webex-incorrect");
} else {
cl.add("webex-incorrect");
cl.remove("webex-correct");
}

// match numeric answers within a specified tolerance
if(this.dataset.tol > 0){
var tol = JSON.parse(this.dataset.tol);
var matches = real_answers.map(x => Math.abs(x - my_answer) < tol)
if (matches.reduce((a, b) => a + b, 0) > 0) {
cl.add("webex-correct");
} else {
cl.remove("webex-correct");
}
}

// added regex bit
if (cl.contains("regex")){
answer_regex = RegExp(real_answers.join("|"))
if (answer_regex.test(my_answer)) {
cl.add("webex-correct");
}
}

update_total_correct();
}

/* function for checking select answers */
select_func = function(e) {
console.log("webex: check select");

var cl = this.classList

/* add style */
cl.remove("webex-incorrect");
cl.remove("webex-correct");
if (this.value == "answer") {
cl.add("webex-correct");
} else if (this.value != "blank") {
cl.add("webex-incorrect");
}

update_total_correct();
}

/* function for checking radiogroups answers */
radiogroups_func = function(e) {
console.log("webex: check radiogroups");

var checked_button = document.querySelector('input[name=' + this.id + ']:checked');
var cl = checked_button.parentElement.classList;
var labels = checked_button.parentElement.parentElement.children;

/* get rid of styles */
for (i = 0; i < labels.length; i++) {
labels[i].classList.remove("webex-incorrect");
labels[i].classList.remove("webex-correct");
}

/* add style */
if (checked_button.value == "answer") {
cl.add("webex-correct");
} else {
cl.add("webex-incorrect");
}

update_total_correct();
}

window.onload = function() {
console.log("webex onload");
/* set up solution buttons */
var buttons = document.getElementsByTagName("button");

for (var i = 0; i < buttons.length; i++) {
if (buttons[i].parentElement.classList.contains('webex-solution')) {
buttons[i].onclick = b_func;
}
}

var check_sections = document.getElementsByClassName("webex-check");
console.log("check:", check_sections.length);
for (var i = 0; i < check_sections.length; i++) {
check_sections[i].classList.add("unchecked");

let btn = document.createElement("button");
btn.innerHTML = "Show Answers";
btn.classList.add("webex-check-button");
btn.onclick = check_func;
check_sections[i].appendChild(btn);

let spn = document.createElement("span");
spn.classList.add("webex-total_correct");
check_sections[i].appendChild(spn);
}

/* set up webex-solveme inputs */
var solveme = document.getElementsByClassName("webex-solveme");

for (var i = 0; i < solveme.length; i++) {
/* make sure input boxes don't auto-anything */
solveme[i].setAttribute("autocomplete","off");
solveme[i].setAttribute("autocorrect", "off");
solveme[i].setAttribute("autocapitalize", "off");
solveme[i].setAttribute("spellcheck", "false");
solveme[i].value = "";

/* adjust answer for ignorecase or nospaces */
var cl = solveme[i].classList;
var real_answer = solveme[i].dataset.answer;
if (cl.contains("ignorecase")) {
real_answer = real_answer.toLowerCase();
}
if (cl.contains("nospaces")) {
real_answer = real_answer.replace(/ /g, "");
}
solveme[i].dataset.answer = real_answer;

/* attach checking function */
solveme[i].onkeyup = solveme_func;
solveme[i].onchange = solveme_func;

solveme[i].insertAdjacentHTML("afterend", " <span class='webex-icon'></span>")
}

/* set up radiogroups */
var radiogroups = document.getElementsByClassName("webex-radiogroup");
for (var i = 0; i < radiogroups.length; i++) {
radiogroups[i].onchange = radiogroups_func;
}

/* set up selects */
var selects = document.getElementsByClassName("webex-select");
for (var i = 0; i < selects.length; i++) {
selects[i].onchange = select_func;
selects[i].insertAdjacentHTML("afterend", " <span class='webex-icon'></span>")
}

update_total_correct();
}

</script>