-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
296a5ab
commit ac1fbd2
Showing
2 changed files
with
132 additions
and
13 deletions.
There are no files selected for viewing
125 changes: 122 additions & 3 deletions
125
apps/web/src/components/math-skills/exercise-implementations/compare-growth.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,130 @@ | ||
import { SelfEvaluationExercise } from './self-evaluation-exercise' | ||
import { randomIntBetween } from '@/helper/random-int-between' | ||
import { randomItemFromArray } from '@/helper/random-item-from-array' | ||
|
||
const viraleVideos = [ | ||
'Kosmische Katze: Das epische Weltraumabenteuer', | ||
'Tanzende Pinguine übernehmen die Antarktis', | ||
'Taco Dienstag: Das Musical', | ||
'Babyotter lernen schwimmen', | ||
'Alien-Invasion Streich: Area 51 Edition', | ||
'Super Faultier rettet den Tag', | ||
"Zeitreisende Oma's Kochshow", | ||
'Roboterhund vs. Riesenhuhn: Kampf des Jahrhunderts', | ||
'Fliegende Schweine: Eine Dokumentation', | ||
"Einhorn's Anleitung zum Glücklichsein", | ||
] | ||
|
||
export function CompareGrowth() { | ||
return ( | ||
<SelfEvaluationExercise | ||
generator={() => null} | ||
renderTask={() => <></>} | ||
renderSolution={() => <></>} | ||
generator={() => { | ||
const isCrossing = randomItemFromArray([true, false]) | ||
|
||
let startA = 0, | ||
startB = 0, | ||
growthA = 0, | ||
growthB = 0 | ||
|
||
if (isCrossing) { | ||
startA = randomIntBetween(10, 200) | ||
startB = randomIntBetween(startA + 10, 400) | ||
|
||
growthA = randomIntBetween(200, 500) / 10 | ||
growthB = randomIntBetween(50, growthA * 10 - 5) / 10 | ||
} else { | ||
startA = randomIntBetween(10, 200) | ||
startB = randomIntBetween(startA + 10, 400) | ||
|
||
growthA = randomIntBetween(50, 200) / 10 | ||
growthB = randomIntBetween(growthA * 10 + 5, 400) / 10 | ||
} | ||
|
||
const swap = randomItemFromArray([true, false]) | ||
if (swap) { | ||
const t_start = startB | ||
const t_growth = growthB | ||
|
||
startB = startA | ||
growthB = growthA | ||
|
||
startA = t_start | ||
growthA = t_growth | ||
} | ||
|
||
const nameA = randomItemFromArray(viraleVideos) | ||
const nameB = randomItemFromArray( | ||
viraleVideos.filter((x) => x !== nameA) | ||
) | ||
|
||
const year = randomIntBetween(2015, 2023) | ||
|
||
return { | ||
startA, | ||
startB, | ||
growthA, | ||
growthB, | ||
nameA, | ||
nameB, | ||
isCrossing, | ||
year, | ||
swap, | ||
} | ||
}} | ||
renderTask={(data) => ( | ||
<> | ||
<p className="serlo-main-task"> | ||
Im Jahr {data.year} wurden zeitgleich die beiden viralen Videos | ||
"{data.nameA}" und "{data.nameB}" | ||
veröffentlicht. | ||
</p> | ||
<p className="serlo-main-task"> | ||
Am ersten Tag hatte "{data.nameA}" {data.startA} | ||
Aufrufe, die Anzahl der Aufrufe steigt täglich um{' '} | ||
{data.growthA.toLocaleString('de-De')} %. | ||
</p> | ||
<p className="serlo-main-task"> | ||
"{data.nameB}" hatte am ersten Tag {data.startB} | ||
Aufrufe, die Anzahl der Aufrufe steigt täglich um{' '} | ||
{data.growthB.toLocaleString('de-De')} %. | ||
</p> | ||
<p className="serlo-main-task"> | ||
Begründen Sie ohne Rechnung, dass{' '} | ||
{data.isCrossing ? ( | ||
<> | ||
es einen Zeitpunkt gibt, an dem das Video " | ||
{data.swap ? data.nameB : data.nameA}" mehr Aufrufe hat als | ||
" | ||
{data.swap ? data.nameA : data.nameB}" | ||
</> | ||
) : ( | ||
<> | ||
die beiden Videos zu keinem Zeitpunkt gleichviele Aufrufe haben | ||
können | ||
</> | ||
)} | ||
. | ||
</p> | ||
</> | ||
)} | ||
renderSolution={(data) => { | ||
if (data.isCrossing) { | ||
return ( | ||
<p className="serlo-highlight-green"> | ||
"{data.swap ? data.nameB : data.nameA}" hat die höhere | ||
Wachstums-Rate. Dieses Video wird trotz des niedrigeren | ||
Anfangswerts ab einem Zeitpunkt das andere Video überholen. | ||
</p> | ||
) | ||
} | ||
return ( | ||
<p className="serlo-highlight-green"> | ||
"{data.swap ? data.nameA : data.nameB}" hat die höhere | ||
Wachstums-Rate. Weil es von Anfang an auch mehr Aufrufe, wird es | ||
deshalb immer mehr Aufrufe haben als das andere Video. | ||
</p> | ||
) | ||
}} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters