-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatching.html
More file actions
304 lines (263 loc) · 11.7 KB
/
Copy pathmatching.html
File metadata and controls
304 lines (263 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Matching Activity</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f5f5f5;
margin: 0;
padding: 20px;
}
.container {
max-width: 95%;
margin: auto;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}
.columns {
display: flex;
gap: 20px;
flex-wrap: wrap;
}
.questions,
.answers {
flex: 1;
min-width: 250px;
}
ul {
list-style: none;
padding: 0;
}
li {
background: #eee;
padding: 10px;
margin-bottom: 10px;
border-radius: 6px;
cursor: pointer;
}
li.dragging {
opacity: 0.4;
}
li.selected {
background: #d0e4f1;
border: 2px solid #4798CA;
}
.correct {
background: #d3f9d8 !important;
}
#completedQuestions li {
width: 95%;
background: #d3f9d8 !important;
border-left: 6px solid #5a9d58;
margin-bottom: 12px;
list-style: none;
}
@keyframes popThenFade {
0% { transform: scale(1); opacity: 1; }
50% { transform: scale(0.8); opacity: 0.6; }
100% { transform: scale(0); opacity: 0; height: 0; margin: 0; padding: 0; }
}
.correct-anim {
animation: popThenFade 0.6s forwards ease;
}
.wrong {
background: #ffa8a8 !important;
}
@keyframes wiggle {
0%, 100% { transform: rotate(0deg); }
25% { transform: rotate(3deg); }
50% { transform: rotate(-3deg); }
75% { transform: rotate(3deg); }
}
.wiggle {
animation: wiggle 0.3s ease;
}
button {
margin-top: 20px;
padding: 12px 18px;
font-size: 1rem;
cursor: pointer;
border: none;
background: #024890;
color: white;
border-radius: 6px;
}
button:hover {
background: #0057AD;
}
</style>
</head>
<body>
<div class="container">
<h1>Matching Activity</h1>
<p>Match each question with the correct answer by dragging and dropping or tapping to select and match. To change your answer, simply drag a different answer to the question or tap another answer.</p>
<div id="completedQuestions"></div>
<div class="columns">
<div class="questions">
<h2>Questions</h2>
<ul id="questionList">
<li data-id="1">What is greenwashing?</li>
<li data-id="2">Why do companies engage in greenwashing?</li>
<li data-id="3">What is the primary risk of greenwashing for companies?</li>
<li data-id="4">What is selective disclosure in the context of greenwashing?
</li>
<li data-id="5">Name two common signs of greenwashing.
</li>
<li data-id="6">What role does third-party assurance play in preventing greenwashing?</li>
<li data-id="7">What is a materiality assessment?</li>
<li data-id="8">Why is materiality important for avoiding greenwashing?
</li>
<li data-id="9">What is the role of regulation in reducing greenwashing?
</li>
<li data-id="10">What is the difference between green marketing and greenwashing?</li>
<li data-id="11">How can sustainability managers help prevent greenwashing?
</li>
<li data-id="12">Why is greenwashing a significant barrier to sustainability transition?
</li>
</ul>
</div>
<div class="answers">
<h2>Answers</h2>
<ul id="answerList">
<li draggable="true" data-id="2">To enhance reputation, meet stakeholder expectations, attract investment, or comply superficially with sustainability trends especially when accountability or verification is weak.</li>
<li draggable="true" data-id="3">Reputational damage that can lead to customer loss, legal action, and decreased investor confidence.</li>
<li draggable="true" data-id="1">The practice of misleading stakeholders by exaggerating, overstating, or fabricating environmental or sustainability claims without corresponding substantive action.</li>
<li draggable="true" data-id="12">It erodes trust, misleads stakeholders, and diverts attention from real environmental challenges and legitimate sustainability innovations.</li>
<li draggable="true" data-id="8">It ensures organisations focus on genuine, high-impact sustainability issues rather than superficial or low-relevance initiatives.</li>
<li draggable="true" data-id="4">Highlighting minor positive impacts while omitting major negative environmental impacts to create a misleading impression of sustainability.</li>
<li draggable="true" data-id="11">By ensuring accurate reporting, aligning communication with operational performance, engaging in internal audits, and promoting transparency across the value chain.</li>
<li draggable="true" data-id="5">Vague environmental claims and lack of measurable, verified data.</li>
<li draggable="true" data-id="10">Green marketing communicates genuine sustainability efforts backed by data; greenwashing relies on misleading or unsubstantiated claims.</li>
<li draggable="true" data-id="6">It independently verifies the accuracy and completeness of sustainability claims, increasing trust and accountability.</li>
<li draggable="true" data-id="9">Regulations like the EU CSRD or Green Claims Directive standardise reporting, require evidence-based claims, and impose penalties for misleading information.</li>
<li draggable="true" data-id="7">A process used to identify and prioritise the most significant environmental, social, and governance issues relevant to a business and its stakeholders.</li>
</ul>
</div>
</div>
<p id="result"></p>
<button id="resetBtn">Redo Activity</button>
</div>
<script>
const answers = document.querySelectorAll("#answerList li");
const questions = document.querySelectorAll("#questionList li");
let selectedAnswer = null;
const originalAnswersHTML = document.getElementById("answerList").innerHTML;
// MOBILE TAP SELECTION
answers.forEach(ans => {
ans.addEventListener("click", () => {
if (selectedAnswer === ans) {
ans.classList.remove("selected");
selectedAnswer = null;
return;
}
if (selectedAnswer) selectedAnswer.classList.remove("selected");
ans.classList.add("selected");
selectedAnswer = ans;
});
});
// TAP ON QUESTION TO MATCH
questions.forEach(q => {
q.addEventListener("click", () => {
if (!selectedAnswer) return;
q.dataset.match = selectedAnswer.dataset.id;
q.textContent = q.textContent.split(" → ")[0] + " → " + selectedAnswer.textContent;
validateMatch(q);
selectedAnswer.classList.remove("selected");
selectedAnswer = null;
});
});
// Immediate correctness check on tap selection
function validateMatch(questionEl) {
if (questionEl.dataset.id === questionEl.dataset.match) {
questionEl.classList.add("correct");
questionEl.classList.remove("wrong");
const answerId = questionEl.dataset.match;
const answerEl = document.querySelector(`#answerList li[data-id="${answerId}"]`);
if (answerEl) {
answerEl.classList.add("correct-anim");
setTimeout(() => answerEl.remove(), 600);
}
// Move correct question to the completedQuestions block (full width)
const completed = document.getElementById("completedQuestions");
questionEl.classList.add("correct-full");
completed.appendChild(questionEl);
} else {
questionEl.classList.add("wrong");
questionEl.classList.add("wiggle");
setTimeout(() => questionEl.classList.remove("wiggle"), 300);
questionEl.classList.remove("correct");
}
}
// DESKTOP DRAG
answers.forEach(ans => {
ans.addEventListener("dragstart", () => ans.classList.add("dragging"));
ans.addEventListener("dragend", () => ans.classList.remove("dragging"));
});
questions.forEach(q => {
q.addEventListener("dragover", (e) => e.preventDefault());
q.addEventListener("drop", (e) => {
const dragging = document.querySelector(".dragging");
q.dataset.match = dragging.dataset.id;
q.textContent = q.textContent.split(" → ")[0] + " → " + dragging.textContent;
validateMatch(q);
});
});
// RESET / REDO ACTIVITY
document.getElementById("resetBtn").addEventListener("click", () => {
// Reset ALL questions (both in questionList and completedQuestions)
const allQuestions = document.querySelectorAll("#questionList li, #completedQuestions li");
allQuestions.forEach(q => {
q.dataset.match = "";
q.classList.remove("correct", "wrong", "correct-full");
q.textContent = q.textContent.split(" → ")[0]; // remove paired text
});
// Clear selected states and result text
if (selectedAnswer) selectedAnswer.classList.remove("selected");
selectedAnswer = null;
document.getElementById("result").textContent = "";
// Restore full answers list
const answerList = document.getElementById("answerList");
answerList.innerHTML = originalAnswersHTML;
// Move any completed questions back to questionList
const completed = document.getElementById("completedQuestions");
const questionList = document.getElementById("questionList");
Array.from(completed.children).forEach(item => {
questionList.appendChild(item);
});
// Shuffle the restored answers
function shuffleList(listEl) {
const items = Array.from(listEl.children);
for (let i = items.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
listEl.appendChild(items[j]);
items.splice(j, 1);
}
}
shuffleList(answerList);
// Rebind listeners to restored answer elements
const newAnswers = answerList.querySelectorAll("li");
// Tap selection
newAnswers.forEach(ans => {
ans.addEventListener("click", () => {
if (selectedAnswer === ans) {
ans.classList.remove("selected");
selectedAnswer = null;
return;
}
if (selectedAnswer) selectedAnswer.classList.remove("selected");
ans.classList.add("selected");
selectedAnswer = ans;
});
// Drag listeners
ans.addEventListener("dragstart", () => ans.classList.add("dragging"));
ans.addEventListener("dragend", () => ans.classList.remove("dragging"));
});
});
</script>
</body>
</html>