Skip to content

Commit 0a23a30

Browse files
authored
Merge pull request #260 from makeopensource/88-matching-table
88 matching table
2 parents 390d4af + cfd80ed commit 0a23a30

File tree

2 files changed

+87
-35
lines changed

2 files changed

+87
-35
lines changed

devU-client/src/components/pages/Multiplechoice/MatchStudent.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,25 @@ const MatchingTableStudent: React.FC<MatchingTableProps> = ({
121121
{matchItems.map((item, index) => {
122122
const isMatched = !!selectedOptions[item.id];
123123
const isActive = activePrompt === item.id;
124-
const itemClass = `prompt-item ${isActive ? 'active' : ''} ${isMatched ? 'matched' : ''}`;
125-
126124
return (
127-
<div key={item.id} className={itemClass}onClick={() => handlePromptClick(item.id)}>
128-
<div className={styles['item-number']}>{index}</div>
129-
<div className={styles['item-content']}>{item.prompt}</div>
130-
{isMatched && !readOnly && (
131-
<button
125+
<div
126+
key={item.id}
127+
className={`${styles['prompt-item']} ${isActive ? styles['active'] : ''} ${isMatched ? styles['matched'] : ''}`}
128+
onClick={() => handlePromptClick(item.id)}
129+
>
130+
<div className={styles['prompt-box']}>
131+
<div className={styles['item-number']}>{index}</div>
132+
<div className={styles['item-content']}>{item.prompt}</div>
133+
{isMatched && !readOnly && (
134+
<button
132135
className={styles['remove-answer-btn']}
133136
onClick={(e) => handleRemoveAnswer(item.id, e)}
134137
aria-label="Remove match"
135138
>
136139
137140
</button>
138-
)}
141+
)}
142+
</div>
139143
</div>
140144
);
141145
})}
@@ -147,14 +151,16 @@ const MatchingTableStudent: React.FC<MatchingTableProps> = ({
147151
const isUsed = Object.values(selectedOptions).includes(option);
148152

149153
return (
150-
<div
151-
key={option}
152-
className={`option-item ${isUsed ? 'used' : ''}`}
153-
onClick={() => handleOptionClick(option)}
154-
>
154+
<div
155+
key={option}
156+
className={`${styles['option-item']} ${isUsed ? styles['used'] : ''} ${activePrompt && selectedOptions[activePrompt] === option ? styles['active'] : ''}`}
157+
onClick={() => handleOptionClick(option)}
158+
>
159+
<div className={styles['response-box']}>
155160
<div className={styles['item-number']}>{index}</div>
156161
<div className={styles['item-content']}>{option}</div>
157-
</div>
162+
</div>
163+
</div>
158164
);
159165
})}
160166
</div>

devU-client/src/components/pages/Multiplechoice/StudentPage.scss

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@
5656
margin-bottom: 1.5rem;
5757
padding-bottom: 0.5rem;
5858
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
59+
position: relative;
60+
left: 125px;
5961
}
6062

61-
.prompt-item,
6263
.prompt-item,
6364
.option-item {
6465
display: flex;
@@ -68,7 +69,7 @@
6869
margin-bottom: 1rem;
6970
border-radius: 0.75rem;
7071
border: 2px solid rgba(0, 0, 0, 0.1);
71-
background-color: #ede9fe;
72+
background-color: #f4e9ff;
7273
cursor: pointer;
7374
transition: all 0.2s ease;
7475

@@ -91,7 +92,7 @@
9192
}
9293

9394
&.used {
94-
opacity: 0.6;
95+
opacity: 1;
9596
}
9697
}
9798

@@ -116,26 +117,12 @@
116117
font-size: 1.1rem;
117118
align-content: center;
118119
position: relative;
119-
left: 54px;
120-
bottom: 27px;
120+
position: relative;
121+
left: 3px;
122+
bottom: 3px;
121123
}
122124

123125

124-
.remove-answer-btn {
125-
background: transparent;
126-
border: none;
127-
color: rgba(255, 255, 255, 0.7);
128-
font-size: 1.2rem;
129-
cursor: pointer;
130-
padding: 0.25rem;
131-
margin-left: 0.5rem;
132-
border-radius: 50%;
133-
134-
&:hover {
135-
background-color: rgba(255, 255, 255, 0.1);
136-
color: white;
137-
}
138-
}
139126

140127
.matching-instructions {
141128
margin-top: 2rem;
@@ -199,4 +186,63 @@
199186
background-color: #6b7280;
200187
}
201188
}
202-
}
189+
}
190+
191+
.prompt-item, .option-item {
192+
margin-bottom: 1rem;
193+
border-radius: 8px;
194+
padding: 0.75rem;
195+
display: flex;
196+
align-items: center;
197+
transition: background-color 0.2s ease;
198+
cursor: pointer;
199+
}
200+
201+
.prompt-box {
202+
display: flex;
203+
align-items: center;
204+
gap: 1rem;
205+
width: 100%;
206+
word-break: break-word;
207+
}
208+
209+
.prompt-item.active, .option-item.active {
210+
background-color: #3787d2;
211+
border: 2px solid #0077cc;
212+
}
213+
214+
.prompt-item.matched {
215+
background-color: #02cc02;
216+
}
217+
218+
.option-item.used {
219+
opacity: 0.6;
220+
}
221+
222+
.option-item {
223+
margin-bottom: 1rem;
224+
border-radius: 8px;
225+
padding: 0.75rem;
226+
display: flex;
227+
align-items: center;
228+
transition: background-color 0.2s ease;
229+
cursor: pointer;
230+
}
231+
232+
.option-item.active {
233+
background-color: #62a5e4;
234+
border: 2px solid #0077cc;
235+
}
236+
237+
.option-item.used {
238+
opacity: 0.6;
239+
}
240+
241+
.response-box {
242+
display: flex;
243+
align-items: center;
244+
gap: 1rem;
245+
width: 100%;
246+
word-break: break-word;
247+
}
248+

0 commit comments

Comments
 (0)