Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -366,6 +366,13 @@ const TutorialTasks: React.FC = () => {
|
|
| 366 |
const navigate = useNavigate();
|
| 367 |
|
| 368 |
const weeks = [1, 2, 3, 4, 5, 6];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
|
| 370 |
const handleWeekChange = async (week: number) => {
|
| 371 |
setIsWeekTransitioning(true);
|
|
@@ -1121,6 +1128,20 @@ const TutorialTasks: React.FC = () => {
|
|
| 1121 |
);
|
| 1122 |
})}
|
| 1123 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1124 |
</div>
|
| 1125 |
|
| 1126 |
{/* Week Transition Loading Spinner */}
|
|
|
|
| 366 |
const navigate = useNavigate();
|
| 367 |
|
| 368 |
const weeks = [1, 2, 3, 4, 5, 6];
|
| 369 |
+
const isAdmin = (() => {
|
| 370 |
+
try {
|
| 371 |
+
const viewMode = (localStorage.getItem('viewMode')||'auto');
|
| 372 |
+
const role = JSON.parse(localStorage.getItem('user')||'{}').role;
|
| 373 |
+
return (viewMode !== 'student') && role === 'admin';
|
| 374 |
+
} catch { return false; }
|
| 375 |
+
})();
|
| 376 |
|
| 377 |
const handleWeekChange = async (week: number) => {
|
| 378 |
setIsWeekTransitioning(true);
|
|
|
|
| 1128 |
);
|
| 1129 |
})}
|
| 1130 |
</div>
|
| 1131 |
+
{isAdmin && (
|
| 1132 |
+
<div className="mt-2">
|
| 1133 |
+
<button
|
| 1134 |
+
onClick={async()=>{
|
| 1135 |
+
try {
|
| 1136 |
+
const base = (((api.defaults as any)?.baseURL as string)||'').replace(/\/$/,'');
|
| 1137 |
+
await fetch(`${base}/api/admin/weeks/tutorial/${selectedWeek}/visibility`,{ method:'PUT', headers:{ 'Content-Type':'application/json', 'Authorization': localStorage.getItem('token')?`Bearer ${localStorage.getItem('token')}`:'', 'user-role':'admin' }, body: JSON.stringify({ hidden: !!(tutorialWeek && tutorialWeek.tasks && tutorialWeek.tasks.length) }) });
|
| 1138 |
+
await fetchTutorialTasks(true);
|
| 1139 |
+
} catch (e) { console.error(e);}
|
| 1140 |
+
}}
|
| 1141 |
+
className="inline-flex items-center px-3 py-1.5 text-xs rounded-md border border-ui-border bg-white/70"
|
| 1142 |
+
>{(tutorialWeek && tutorialWeek.tasks && tutorialWeek.tasks.length)?'Hide this week from students':'Show this week to students'}</button>
|
| 1143 |
+
</div>
|
| 1144 |
+
)}
|
| 1145 |
</div>
|
| 1146 |
|
| 1147 |
{/* Week Transition Loading Spinner */}
|
client/src/pages/WeeklyPractice.tsx
CHANGED
|
@@ -216,6 +216,13 @@ const WeeklyPractice: React.FC = () => {
|
|
| 216 |
const [submissionCount, setSubmissionCount] = useState(0);
|
| 217 |
|
| 218 |
const weeks = [1, 2, 3, 4, 5, 6];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
|
| 220 |
const handleWeekChange = async (week: number) => {
|
| 221 |
setIsWeekTransitioning(true);
|
|
@@ -1452,6 +1459,20 @@ const WeeklyPractice: React.FC = () => {
|
|
| 1452 |
);
|
| 1453 |
})}
|
| 1454 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1455 |
</div>
|
| 1456 |
|
| 1457 |
{/* Week Transition Loading Spinner */}
|
|
|
|
| 216 |
const [submissionCount, setSubmissionCount] = useState(0);
|
| 217 |
|
| 218 |
const weeks = [1, 2, 3, 4, 5, 6];
|
| 219 |
+
const isAdmin = (() => {
|
| 220 |
+
try {
|
| 221 |
+
const viewMode = (localStorage.getItem('viewMode')||'auto');
|
| 222 |
+
const role = JSON.parse(localStorage.getItem('user')||'{}').role;
|
| 223 |
+
return (viewMode !== 'student') && role === 'admin';
|
| 224 |
+
} catch { return false; }
|
| 225 |
+
})();
|
| 226 |
|
| 227 |
const handleWeekChange = async (week: number) => {
|
| 228 |
setIsWeekTransitioning(true);
|
|
|
|
| 1459 |
);
|
| 1460 |
})}
|
| 1461 |
</div>
|
| 1462 |
+
{isAdmin && (
|
| 1463 |
+
<div className="mt-2">
|
| 1464 |
+
<button
|
| 1465 |
+
onClick={async()=>{
|
| 1466 |
+
try {
|
| 1467 |
+
const base = (((api.defaults as any)?.baseURL as string)||'').replace(/\/$/,'');
|
| 1468 |
+
await fetch(`${base}/api/admin/weeks/weekly-practice/${selectedWeek}/visibility`,{ method:'PUT', headers:{ 'Content-Type':'application/json', 'Authorization': localStorage.getItem('token')?`Bearer ${localStorage.getItem('token')}`:'', 'user-role':'admin' }, body: JSON.stringify({ hidden: !!(weeklyPractice && weeklyPractice.length) }) });
|
| 1469 |
+
await fetchWeeklyPractice(true);
|
| 1470 |
+
} catch (e) { console.error(e);}
|
| 1471 |
+
}}
|
| 1472 |
+
className="inline-flex items-center px-3 py-1.5 text-xs rounded-md border border-ui-border bg-white/70"
|
| 1473 |
+
>{(weeklyPractice && weeklyPractice.length)?'Hide this week from students':'Show this week to students'}</button>
|
| 1474 |
+
</div>
|
| 1475 |
+
)}
|
| 1476 |
</div>
|
| 1477 |
|
| 1478 |
{/* Week Transition Loading Spinner */}
|