Improved asset download criteria
This commit is contained in:
@@ -62,6 +62,30 @@ export default function AssignmentCard({
|
|||||||
return resultModuleBandScores.length === 0 ? -1 : resultModuleBandScores.reduce((acc, curr) => acc + curr, 0) / results.length;
|
return resultModuleBandScores.length === 0 ? -1 : resultModuleBandScores.reduce((acc, curr) => acc + curr, 0) / results.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const uniqModules = uniqBy(exams, (x) => x.module);
|
||||||
|
|
||||||
|
const shouldRenderPDF = () => {
|
||||||
|
if(released && allowDownload) {
|
||||||
|
// in order to be downloadable, the assignment has to be released
|
||||||
|
// the component should have the allowDownload prop
|
||||||
|
// and the assignment should not have the level module
|
||||||
|
return uniqModules.every(({ module }) => module !== 'level');
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const shouldRenderExcel = () => {
|
||||||
|
if(released && allowExcelDownload) {
|
||||||
|
// in order to be downloadable, the assignment has to be released
|
||||||
|
// the component should have the allowExcelDownload prop
|
||||||
|
// and the assignment should have the level module
|
||||||
|
return uniqModules.some(({ module }) => module === 'level');
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
@@ -70,8 +94,8 @@ export default function AssignmentCard({
|
|||||||
<div className="flex flex-row justify-between">
|
<div className="flex flex-row justify-between">
|
||||||
<h3 className="text-xl font-semibold">{name}</h3>
|
<h3 className="text-xl font-semibold">{name}</h3>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
{allowDownload && released && renderPdfIcon(id, "text-mti-gray-dim", "text-mti-gray-dim")}
|
{shouldRenderPDF() && renderPdfIcon(id, "text-mti-gray-dim", "text-mti-gray-dim")}
|
||||||
{allowExcelDownload && released && renderExcelIcon(id, "text-mti-gray-dim", "text-mti-gray-dim")}
|
{shouldRenderExcel() && renderExcelIcon(id, "text-mti-gray-dim", "text-mti-gray-dim")}
|
||||||
{allowArchive && !archived && renderArchiveIcon("text-mti-gray-dim", "text-mti-gray-dim")}
|
{allowArchive && !archived && renderArchiveIcon("text-mti-gray-dim", "text-mti-gray-dim")}
|
||||||
{allowUnarchive && archived && renderUnarchiveIcon("text-mti-gray-dim", "text-mti-gray-dim")}
|
{allowUnarchive && archived && renderUnarchiveIcon("text-mti-gray-dim", "text-mti-gray-dim")}
|
||||||
{!released && renderReleaseIcon("text-mti-gray-dim", "text-mti-gray-dim")}
|
{!released && renderReleaseIcon("text-mti-gray-dim", "text-mti-gray-dim")}
|
||||||
@@ -94,7 +118,7 @@ export default function AssignmentCard({
|
|||||||
<span>Assigner: {getUserName(users.find((x) => x.id === assigner))}</span>
|
<span>Assigner: {getUserName(users.find((x) => x.id === assigner))}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="-md:mt-2 grid w-full grid-cols-4 place-items-start gap-2">
|
<div className="-md:mt-2 grid w-full grid-cols-4 place-items-start gap-2">
|
||||||
{uniqBy(exams, (x) => x.module).map(({module}) => (
|
{uniqModules.map(({module}) => (
|
||||||
<div
|
<div
|
||||||
key={module}
|
key={module}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
|||||||
Reference in New Issue
Block a user