Nicolasmed26 commited on
Commit
c0dc35b
·
verified ·
1 Parent(s): 5deec3c

Deploy MedMembers OFT 2026

Browse files
Files changed (2) hide show
  1. static/css/main.css +11 -8
  2. static/js/questions.js +55 -10
static/css/main.css CHANGED
@@ -151,11 +151,12 @@ body {
151
  .question-number { width: 36px; height: 36px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
152
  .question-header h3 { font-size: 16px; font-weight: 600; }
153
 
154
- .enunciado { margin-bottom: 16px; line-height: 1.7; }
155
- .enunciado img, .gabarito-content img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
 
156
 
157
  .alternativas { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
158
- .alternativa { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; transition: all var(--transition); }
159
  .alternativa:hover { border-color: var(--selected); background: var(--selected-bg); }
160
  .alternativa.selected { border-color: var(--selected); background: var(--selected-bg); }
161
  .alternativa.correct { border-color: var(--correct); background: var(--correct-bg); }
@@ -169,16 +170,18 @@ body {
169
  .alternativa.wrong .alt-letter { background: var(--wrong); color: white; }
170
  .alternativa.correct-reveal .alt-letter { background: var(--correct); color: white; }
171
 
172
- .alt-text { flex: 1; padding-top: 4px; }
173
- .alt-text img { max-width: 100%; border-radius: 6px; margin-top: 4px; }
174
 
175
  .btn-solution { background: none; border: 2px solid var(--border); padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-sec); transition: all var(--transition); display: flex; align-items: center; gap: 6px; }
176
  .btn-solution:hover { border-color: var(--primary); color: var(--primary); }
177
 
178
- .gabarito { display: none; margin-top: 16px; padding: 20px; background: var(--correct-bg); border-radius: 8px; border-left: 4px solid var(--correct); }
179
  .gabarito.show { display: block; }
180
- .gabarito-header { font-weight: 700; color: var(--correct); margin-bottom: 12px; font-size: 16px; }
181
- .gabarito-content { line-height: 1.7; }
 
 
182
 
183
  .gabarito-video { margin-top: 16px; background: white; border-radius: 8px; padding: 16px; }
184
  .gabarito-video .video-title { font-weight: 600; margin-bottom: 12px; }
 
151
  .question-number { width: 36px; height: 36px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
152
  .question-header h3 { font-size: 16px; font-weight: 600; }
153
 
154
+ .enunciado { margin-bottom: 16px; line-height: 1.8; font-size: 16px; color: var(--text); }
155
+ .enunciado img, .gabarito-content img { max-width: 100%; border-radius: 8px; margin: 12px 0; display: block; }
156
+ .enunciado p, .gabarito-content p { margin-bottom: 10px; }
157
 
158
  .alternativas { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
159
+ .alternativa { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; transition: all var(--transition); font-size: 15px; }
160
  .alternativa:hover { border-color: var(--selected); background: var(--selected-bg); }
161
  .alternativa.selected { border-color: var(--selected); background: var(--selected-bg); }
162
  .alternativa.correct { border-color: var(--correct); background: var(--correct-bg); }
 
170
  .alternativa.wrong .alt-letter { background: var(--wrong); color: white; }
171
  .alternativa.correct-reveal .alt-letter { background: var(--correct); color: white; }
172
 
173
+ .alt-text { flex: 1; padding-top: 3px; line-height: 1.6; }
174
+ .alt-text img { max-width: 100%; border-radius: 6px; margin-top: 6px; }
175
 
176
  .btn-solution { background: none; border: 2px solid var(--border); padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-sec); transition: all var(--transition); display: flex; align-items: center; gap: 6px; }
177
  .btn-solution:hover { border-color: var(--primary); color: var(--primary); }
178
 
179
+ .gabarito { display: none; margin-top: 16px; padding: 24px; background: var(--correct-bg); border-radius: 10px; border-left: 4px solid var(--correct); }
180
  .gabarito.show { display: block; }
181
+ .gabarito-header { font-weight: 700; color: var(--correct); margin-bottom: 14px; font-size: 17px; }
182
+ .gabarito-content { line-height: 1.8; font-size: 15px; color: #1a1a1a; }
183
+ .gabarito-content .text-white { color: #1a1a1a !important; }
184
+ .gabarito-unavailable { color: var(--text-sec); font-style: italic; font-size: 14px; padding: 12px 0; }
185
 
186
  .gabarito-video { margin-top: 16px; background: white; border-radius: 8px; padding: 16px; }
187
  .gabarito-video .video-title { font-weight: 600; margin-bottom: 12px; }
static/js/questions.js CHANGED
@@ -98,18 +98,38 @@ const Questions = {
98
 
99
  // Extract images from enunciado HTML (img src references)
100
  let enunciadoHtml = q.enunciado || '';
101
- // Replace external image URLs with our proxy
102
  enunciadoHtml = enunciadoHtml.replace(
103
- /src="https?:\/\/[^"]*\/([^"\/]+\.(jpg|jpeg|png|gif|webp))"/gi,
104
  (match, filename) => `src="/api/images/${encodeURIComponent(filename)}?token=${token}"`
105
  );
 
 
 
 
 
106
 
107
  const alts = (q.alternativas || []).map(alt => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  return `
109
  <div class="alternativa" data-qid="${q.id}" data-letra="${alt.letra}"
110
  onclick="Questions.selectAlternative(this)">
111
  <div class="alt-letter">${alt.letra}</div>
112
- <div class="alt-text">${this.escapeHtml(alt.texto || '')}</div>
113
  </div>
114
  `;
115
  }).join('');
@@ -203,16 +223,41 @@ const Questions = {
203
  }
204
 
205
  // Process explanation HTML
206
- let gabTexto = sol.gabarito_texto || 'Sem explicacao disponivel.';
207
  const token = Auth.getToken();
208
- gabTexto = gabTexto.replace(
209
- /src="https?:\/\/[^"]*\/([^"\/]+\.(jpg|jpeg|png|gif|webp))"/gi,
210
- (match, filename) => `src="/api/images/${encodeURIComponent(filename)}?token=${token}"`
211
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
 
213
  gabEl.innerHTML = `
214
- <div class="gabarito-header">&#10003; Resposta Correta: ${sol.gabarito_correta || '?'}</div>
215
- <div class="gabarito-content">${gabTexto}</div>
216
  ${videosHtml}
217
  `;
218
 
 
98
 
99
  // Extract images from enunciado HTML (img src references)
100
  let enunciadoHtml = q.enunciado || '';
101
+ // Replace external image URLs with our proxy (multiple patterns)
102
  enunciadoHtml = enunciadoHtml.replace(
103
+ /src=["']https?:\/\/[^"']*\/([^"'\/]+\.(jpg|jpeg|png|gif|webp))[^"']*["']/gi,
104
  (match, filename) => `src="/api/images/${encodeURIComponent(filename)}?token=${token}"`
105
  );
106
+ // Also fix any remaining seudominio.com references
107
+ enunciadoHtml = enunciadoHtml.replace(
108
+ /https?:\/\/r2\.seudominio\.com\/([^"'?\s]+)/gi,
109
+ (match, path) => `/api/images/${encodeURIComponent(path)}?token=${token}`
110
+ );
111
 
112
  const alts = (q.alternativas || []).map(alt => {
113
+ let altTexto = alt.texto || '';
114
+ // If alt text contains HTML img tags, render as HTML (not escaped)
115
+ const hasHtml = /<img\s|<br|<p\s|<div\s|<span\s/i.test(altTexto);
116
+ if (hasHtml) {
117
+ altTexto = altTexto.replace(
118
+ /src=["']https?:\/\/[^"']*\/([^"'\/]+\.(jpg|jpeg|png|gif|webp))[^"']*["']/gi,
119
+ (match, filename) => `src="/api/images/${encodeURIComponent(filename)}?token=${token}"`
120
+ );
121
+ altTexto = altTexto.replace(
122
+ /https?:\/\/r2\.seudominio\.com\/([^"'?\s]+)/gi,
123
+ (match, path) => `/api/images/${encodeURIComponent(path)}?token=${token}`
124
+ );
125
+ } else {
126
+ altTexto = this.escapeHtml(altTexto);
127
+ }
128
  return `
129
  <div class="alternativa" data-qid="${q.id}" data-letra="${alt.letra}"
130
  onclick="Questions.selectAlternative(this)">
131
  <div class="alt-letter">${alt.letra}</div>
132
+ <div class="alt-text">${altTexto}</div>
133
  </div>
134
  `;
135
  }).join('');
 
223
  }
224
 
225
  // Process explanation HTML
226
+ let gabTexto = sol.gabarito_texto || '';
227
  const token = Auth.getToken();
228
+
229
+ // Check if explanation is a placeholder
230
+ const isPlaceholder = !gabTexto ||
231
+ gabTexto.includes('Carregando gabarito') ||
232
+ gabTexto.includes('Ver explicação') ||
233
+ gabTexto.trim().length < 20;
234
+
235
+ if (!isPlaceholder) {
236
+ // Fix image URLs in explanation
237
+ gabTexto = gabTexto.replace(
238
+ /src=["']https?:\/\/[^"']*\/([^"'\/]+\.(jpg|jpeg|png|gif|webp))[^"']*["']/gi,
239
+ (match, filename) => `src="/api/images/${encodeURIComponent(filename)}?token=${token}"`
240
+ );
241
+ gabTexto = gabTexto.replace(
242
+ /https?:\/\/r2\.seudominio\.com\/([^"'?\s]+)/gi,
243
+ (match, path) => `/api/images/${encodeURIComponent(path)}?token=${token}`
244
+ );
245
+ // Fix white text on light background
246
+ gabTexto = gabTexto.replace(/color:\s*white/gi, 'color: #1a1a1a');
247
+ gabTexto = gabTexto.replace(/color:\s*#fff(fff)?/gi, 'color: #1a1a1a');
248
+ }
249
+
250
+ const letraDisplay = sol.gabarito_correta || '?';
251
+ let contentHtml;
252
+ if (isPlaceholder) {
253
+ contentHtml = `<div class="gabarito-unavailable">Explicacao detalhada nao disponivel para esta questao.</div>`;
254
+ } else {
255
+ contentHtml = `<div class="gabarito-content">${gabTexto}</div>`;
256
+ }
257
 
258
  gabEl.innerHTML = `
259
+ <div class="gabarito-header">&#10003; Resposta Correta: ${letraDisplay}</div>
260
+ ${contentHtml}
261
  ${videosHtml}
262
  `;
263