Skip to content

Commit 9a43909

Browse files
authored
Initial commit
0 parents  commit 9a43909

File tree

11 files changed

+9254
-0
lines changed

11 files changed

+9254
-0
lines changed

.github/.keep

Whitespace-only changes.

.github/workflows/autograding.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: GitHub Classroom Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
- '!badges'
8+
9+
jobs:
10+
build:
11+
name: Autograding
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: DCI-EdTech/autograding-action@main
15+
id: autograder
16+
with:
17+
token: ${{ secrets.AUTOGRADING }}

.gitignore

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/react,node'
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=react,node'
3+
4+
### Node ###
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
.pnpm-debug.log*
13+
14+
# Diagnostic reports (https://nodejs.org/api/report.html)
15+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
16+
17+
# Runtime data
18+
pids
19+
*.pid
20+
*.seed
21+
*.pid.lock
22+
23+
# Directory for instrumented libs generated by jscoverage/JSCover
24+
lib-cov
25+
26+
# Coverage directory used by tools like istanbul
27+
coverage
28+
*.lcov
29+
30+
# nyc test coverage
31+
.nyc_output
32+
33+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
34+
.grunt
35+
36+
# Bower dependency directory (https://bower.io/)
37+
bower_components
38+
39+
# node-waf configuration
40+
.lock-wscript
41+
42+
# Compiled binary addons (https://nodejs.org/api/addons.html)
43+
build/Release
44+
45+
# Dependency directories
46+
node_modules/
47+
jspm_packages/
48+
49+
# Snowpack dependency directory (https://snowpack.dev/)
50+
web_modules/
51+
52+
# TypeScript cache
53+
*.tsbuildinfo
54+
55+
# Optional npm cache directory
56+
.npm
57+
58+
# Optional eslint cache
59+
.eslintcache
60+
61+
# Microbundle cache
62+
.rpt2_cache/
63+
.rts2_cache_cjs/
64+
.rts2_cache_es/
65+
.rts2_cache_umd/
66+
67+
# Optional REPL history
68+
.node_repl_history
69+
70+
# Output of 'npm pack'
71+
*.tgz
72+
73+
# Yarn Integrity file
74+
.yarn-integrity
75+
76+
# dotenv environment variables file
77+
.env
78+
.env.test
79+
.env.production
80+
81+
# parcel-bundler cache (https://parceljs.org/)
82+
.cache
83+
.parcel-cache
84+
85+
# Next.js build output
86+
.next
87+
out
88+
89+
# Nuxt.js build / generate output
90+
.nuxt
91+
dist
92+
93+
# Gatsby files
94+
.cache/
95+
# Comment in the public line in if your project uses Gatsby and not Next.js
96+
# https://nextjs.org/blog/next-9-1#public-directory-support
97+
# public
98+
99+
# vuepress build output
100+
.vuepress/dist
101+
102+
# Serverless directories
103+
.serverless/
104+
105+
# FuseBox cache
106+
.fusebox/
107+
108+
# DynamoDB Local files
109+
.dynamodb/
110+
111+
# TernJS port file
112+
.tern-port
113+
114+
# Stores VSCode versions used for testing VSCode extensions
115+
.vscode-test
116+
117+
# yarn v2
118+
.yarn/cache
119+
.yarn/unplugged
120+
.yarn/build-state.yml
121+
.yarn/install-state.gz
122+
.pnp.*
123+
124+
### Node Patch ###
125+
# Serverless Webpack directories
126+
.webpack/
127+
128+
### react ###
129+
.DS_*
130+
**/*.backup.*
131+
**/*.back.*
132+
133+
node_modules
134+
135+
*.sublime*
136+
137+
psd
138+
thumb
139+
sketch
140+
141+
# End of https://www.toptal.com/developers/gitignore/api/react,node

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# HTML table striping
2+
3+
Here you can practise techniques for applying more colorful striping to your tables!
4+
5+
## Task
6+
7+
Working in the files [index.html](./index.html) and [style.css](./style.css), create a website which meets the following requirements.
8+
9+
## Requirements
10+
11+
- Using the example image below as a reference, create an HTML data table shown using the `:first-child`, `:last-child`, `:nth-child` and `:not` pseudo classes
12+
- Use the data below to fill in your table
13+
- Apply background colors to the `<td>` elements
14+
- Use the colors: `#c0c0c0`, `#888888`, `#efefef`, `#ffbbbb`
15+
- Do NOT use deprecated HTML attributes. Style using CSS.
16+
17+
### Table Data
18+
19+
| First Name | Last Name | Role |
20+
| ---------- | --------- | --------- |
21+
| Scott | Gomez | Player |
22+
| Paul | Mackie | Coach |
23+
| Leoni | Cabrera | Assistant |
24+
| Gregor | Byrne | Player |
25+
| Francis | Shaffer | Manager |
26+
| Walter | Gale | Player |
27+
28+
## Reference Image
29+
30+
![Reference](/reference.png)

README_DE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Grundlegende Datenübungen
2+
3+
## Übung: Tabelle 4
4+
5+
**Anweisungen**:
6+
7+
1. Erstelle eine einfache HTML-Seite mit allen wichtigen Elementen, indem du die bereitgestellten Dateien `index.html` und `main.css` verwendest.
8+
2. Sieh dir die Mockup-Datei an und erstelle die abgebildete Tabelle mit den Pseudoklassen `:first-child`, `:last-child`, `:nth-child` und `:not`.
9+
3. Wende Hintergrundfarben auf die `<td>` Elemente an.
10+
4. Verwendete Farben sind: `#c0c0c0`, `#888888`, `#efefef`, `#ffbbbb`.
11+
5. Verwende KEINE veralteten HTML-Attribute. Style mit CSS.
12+
13+
![mockup-image](image/mockup.jpg)

__tests__/task.js

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
const puppeteer = require("puppeteer");
2+
const path = require("path");
3+
const fs = require("fs");
4+
5+
const browserOptions = {
6+
headless: true,
7+
ignoreHTTPSErrors: true,
8+
defaultViewport: null,
9+
devtools: false,
10+
};
11+
let browser;
12+
let page;
13+
14+
beforeAll(async () => {
15+
browser = await puppeteer.launch(browserOptions);
16+
page = await browser.newPage();
17+
await page.goto("file://" + path.resolve("./index.html"));
18+
}, 30000);
19+
20+
afterAll((done) => {
21+
try {
22+
this.puppeteer.close();
23+
} catch (e) {}
24+
done();
25+
});
26+
27+
describe("Table", () => {
28+
it("Table exists", async () => {
29+
const table = await page.$("table", (el) => el.innerHTML);
30+
expect(table).toBeTruthy();
31+
});
32+
33+
it("Table has table head", async () => {
34+
const tableHeaders = await page.$$("table th");
35+
expect(tableHeaders.length).toBeTruthy();
36+
});
37+
38+
it("Table has 'First Name', 'Last Name' and 'Role' column headers", async () => {
39+
const table = await page.$("table", (el) => el.innerHTML);
40+
const firstName = await table.$x(
41+
'//th[text()[contains(translate(., "FIRSTNAME", "firstname"),"first name")]]'
42+
);
43+
expect(firstName.length).toBeTruthy();
44+
const lastName = await table.$x(
45+
'//th[text()[contains(translate(., "LASTNAME", "lastname"),"last name")]]'
46+
);
47+
expect(lastName.length).toBeTruthy();
48+
const role = await table.$x(
49+
'//th[text()[contains(translate(., "ROLE", "role"),"role")]]'
50+
);
51+
expect(role.length).toBeTruthy();
52+
});
53+
54+
it("Table has 7 rows in total", async () => {
55+
const table = await page.$("table", (el) => el.innerHTML);
56+
const rows = await table.$$("tr");
57+
expect(rows.length).toBe(7);
58+
});
59+
60+
it("Table contains correct number cells", async () => {
61+
const table = await page.$("table", (el) => el.innerHTML);
62+
const cells = await table.$$("td");
63+
expect(cells.length).toBe(18);
64+
});
65+
});
66+
describe("Styling the table", () => {
67+
it("`:first-child` should be used to style the first row", async () => {
68+
// first row should has a different background color than the rest of the rows
69+
// get all computed styles for all rows
70+
const rows = await page.evaluate(() => {
71+
const allRows = document.querySelectorAll("tr");
72+
// get computed styles for each row
73+
const allComputedStyles = Array.from(allRows).map((row) =>
74+
window.getComputedStyle(row)
75+
);
76+
// return the first computed style for each row
77+
return allComputedStyles.map((style) =>
78+
style.getPropertyValue("background-color")
79+
);
80+
});
81+
// check that the first row has a different background color than the rest of the rows
82+
expect(rows[0]).not.toBe(rows[1]);
83+
// get main.css file as a string
84+
const style = fs.readFileSync(path.resolve("./main.css"), "utf8");
85+
// it should contain the `:first-child` selector
86+
expect(style).toContain(":first-child");
87+
});
88+
it("`style`, `class`, and `id` attributes should not be applied to the table's child elements", async () => {
89+
// get all table child elements
90+
const table = await page.$("table", (el) => el.innerHTML);
91+
const idAttr = await table.$$eval("*", (el) =>
92+
Array.from(el)
93+
.map(
94+
(child) =>
95+
child.getAttribute("id") ||
96+
child.getAttribute("class") ||
97+
child.getAttribute("style")
98+
)
99+
.filter((e) => e !== null)
100+
);
101+
expect(idAttr.length).toBe(0);
102+
});
103+
it("`:nth-child` should be used to style the rows", async () => {
104+
const style = fs.readFileSync(path.resolve("./main.css"), "utf8");
105+
// it should contain the `:nth-child` selector
106+
expect(style).toMatch(/tr:nth-child/i);
107+
});
108+
it("The table should use three different background colors", async () => {
109+
// get all background colors
110+
const backgroundColors = await page.evaluate(() => {
111+
const allRows = document.querySelectorAll("tbody tr, tbody td");
112+
// get computed styles for each row
113+
const allComputedStyles = Array.from(allRows).map((row) =>
114+
window.getComputedStyle(row)
115+
);
116+
// return the first computed style for each row
117+
return allComputedStyles.map((style) =>
118+
style.getPropertyValue("background-color")
119+
);
120+
});
121+
// remove duplicates
122+
const uniqueBackgroundColors = [...new Set(backgroundColors)];
123+
// check that there are three different background colors
124+
expect(uniqueBackgroundColors.length).toBeGreaterThanOrEqual(3);
125+
});
126+
});

index.html

Whitespace-only changes.

0 commit comments

Comments
 (0)