"use strict";
(self["webpackChunkgrader_labextension"] = self["webpackChunkgrader_labextension"] || []).push([["lib_index_js-webpack_sharing_consume_default_jupyterlab_translation-webpack_sharing_consume_d-c41005"],{

/***/ "./lib/components/assignment/assignment-status.js":
/*!********************************************************!*\
  !*** ./lib/components/assignment/assignment-status.js ***!
  \********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AssignmentStatus: () => (/* binding */ AssignmentStatus)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_icons_material_ChatRounded__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/icons-material/ChatRounded */ "./node_modules/@mui/icons-material/ChatRounded.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.



/**
 * Renders the assignment status stepper.
 * @param props props of assignment status component
 */
const AssignmentStatus = (props) => {
    //const [activeStep, setActiveStep] = React.useState(0);
    /**
     * Calculates what the current step of the student assignment is.
     */
    //const getActiveStep = async () => {
    //  const hasFeedback = props.submissions.reduce(
    //    (accum: boolean, curr: Submission) => accum || curr.feedback_available,
    //    false
    //  );
    //  if (hasFeedback) {
    //    return 3;
    //  }
    //  if (props.submissions.length > 0) {
    //    return 1;
    //  }
    //  return 0;
    //};
    const fontSize = 14;
    const steps = [
        {
            label: 'Pulled',
            description: (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { fontSize } }, "You pulled from the release repository and can now work on the assignment. If you are happy with your solution you can submit it. Before the deadline you can always resubmit until you are happy with the solution."))
        },
        {
            label: 'Submitted',
            description: (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { fontSize } },
                "You have submitted the assignment ",
                props.submissions.length,
                " time",
                props.submissions.length == 1 ? '' : 's',
                ". The instructor can review each submission, but will most likely prioritise the latest."))
        },
        {
            label: 'Feedback available',
            description: (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { fontSize } },
                "You received feedback for one or more of your submissions! You can view the feedback in the list of submission when clicking on the",
                ' ',
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_ChatRounded__WEBPACK_IMPORTED_MODULE_2__["default"], { sx: { fontSize } }),
                " icon. Within the deadline you can make more submissions, regardless of whether you already received feedback."))
        }
    ];
    //getActiveStep().then(s => setActiveStep(s));
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Card, { elevation: 0 },
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.CardContent, { sx: { overflowY: 'auto' } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stepper, { activeStep: props.activeStep, orientation: "horizontal" }, steps.map((step) => (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Step, { key: step.label },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.StepLabel, null, step.label))))),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { mt: 2, ml: 2, maxWidth: '50%' } }, steps[props.activeStep < 2 ? props.activeStep : 2].description))));
};


/***/ }),

/***/ "./lib/components/assignment/assignment.js":
/*!*************************************************!*\
  !*** ./lib/components/assignment/assignment.js ***!
  \*************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AssignmentComponent: () => (/* binding */ AssignmentComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _submission_list__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./submission-list */ "./lib/components/assignment/submission-list.js");
/* harmony import */ var _util_overlay__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../util/overlay */ "./lib/components/util/overlay.js");
/* harmony import */ var _feedback__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./feedback */ "./lib/components/assignment/feedback.js");
/* harmony import */ var _assignment_status__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./assignment-status */ "./lib/components/assignment/assignment-status.js");
/* harmony import */ var _files_files__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./files/files */ "./lib/components/assignment/files/files.js");
/* harmony import */ var _mui_icons_material_Warning__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @mui/icons-material/Warning */ "./node_modules/@mui/icons-material/Warning.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../services/file.service */ "./lib/services/file.service.js");
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var _services_storage_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../services/storage.service */ "./lib/services/storage.service.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../util/dialog-provider */ "./lib/components/util/dialog-provider.js");
/* harmony import */ var _util_repo_type__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../util/repo-type */ "./lib/components/util/repo-type.js");
/* harmony import */ var _mui_icons_material_PublishRounded__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @mui/icons-material/PublishRounded */ "./node_modules/@mui/icons-material/PublishRounded.js");
/* harmony import */ var _mui_icons_material_RestartAlt__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @mui/icons-material/RestartAlt */ "./node_modules/@mui/icons-material/RestartAlt.js");
/* harmony import */ var _mui_icons_material_Grading__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @mui/icons-material/Grading */ "./node_modules/@mui/icons-material/Grading.js");
/* harmony import */ var _mui_icons_material_FileDownload__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @mui/icons-material/FileDownload */ "./node_modules/@mui/icons-material/FileDownload.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.





















const calculateActiveStep = (submissions) => {
    const hasFeedback = submissions.reduce((accum, curr) => accum || curr.feedback_available, false);
    if (hasFeedback) {
        return 3;
    }
    if (submissions.length > 0) {
        return 1;
    }
    return 0;
};
/**
 * Renders the components available in the extended assignment modal view
 * @param props props of assignment modal component
 */
const AssignmentComponent = (props) => {
    const { lecture, assignment, submissions } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('assignment');
    /* Get the assignment id from router */
    const params = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useParams)();
    const assignmentId = +params["aid"];
    /* Copy assignments out of assignment submissions array */
    const [assignmentState, setAssignment] = react__WEBPACK_IMPORTED_MODULE_0__.useState(assignment);
    /* Now we can divvy this into a useReducer  */
    const [allSubmissions, setSubmissions] = react__WEBPACK_IMPORTED_MODULE_0__.useState(submissions);
    const [displayAssignment, setDisplayAssignment] = react__WEBPACK_IMPORTED_MODULE_0__.useState((0,_services_storage_service__WEBPACK_IMPORTED_MODULE_4__.loadNumber)('a-opened-assignment') === assignment.id || false);
    const [hasFeedback, setHasFeedback] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [files, setFiles] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]);
    const [bestScore, setBestScore] = react__WEBPACK_IMPORTED_MODULE_0__.useState('-');
    const [activeStatus, setActiveStatus] = react__WEBPACK_IMPORTED_MODULE_0__.useState(0);
    const [showFeedback, setShowFeedback] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [feedbackSubmission, setFeedbackSubmission] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);
    /**
     * Opens the feedback view.
     * @param submission submission which feedback will be displayed
     */
    const openFeedback = (submission) => {
        setFeedbackSubmission(submission);
        setShowFeedback(true);
    };
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_5__.getAllSubmissions)(lecture.id, assignment.id, 'none', false).then(response => {
            setSubmissions(response);
            const feedback = response.reduce((accum, curr) => accum || curr.feedback_available, false);
            setHasFeedback(feedback);
        });
        (0,_services_file_service__WEBPACK_IMPORTED_MODULE_6__.getFiles)(`${_services_file_service__WEBPACK_IMPORTED_MODULE_6__.lectureBasePath}${lecture.code}/assignments/${assignment.id}`).then(files => {
            // TODO: make it really explicit where & who pulls the asssignment
            // files! 
            //if (files.length === 0) {
            //    pullAssignment(lecture.id, assignment.id, 'assignment');
            //}
            setFiles(files);
        });
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_5__.getAllSubmissions)(lecture.id, assignment.id, 'best', false).then(submissions => {
            if (submissions.length > 0 && submissions[0].score) {
                setBestScore(submissions[0].score.toString());
            }
        });
        let active_step = calculateActiveStep(submissions);
        setActiveStatus(active_step);
    }, [props]);
    /**
     * Executed on assignment modal close.
     */
    const onAssignmentClose = async () => {
        setDisplayAssignment(false);
        (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_4__.deleteKey)('a-opened-assignment');
        setAssignment(await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_7__.getAssignment)(lecture.id, assignment.id));
        const submissions = await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_5__.getAllSubmissions)(lecture.id, assignment.id, 'none', false);
        setSubmissions(submissions);
    };
    const resetAssignmentHandler = async () => {
        (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_8__.showDialog)('Reset Assignment', 'This action will delete your current progress and reset the assignment!', async () => {
            try {
                await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_7__.pushAssignment)(lecture.id, assignment.id, 'assignment', 'Pre-Reset');
                await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_7__.resetAssignment)(lecture, assignment);
                await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_7__.pullAssignment)(lecture.id, assignment.id, 'assignment');
                (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('Successfully Reset Assignment', {
                    variant: 'success'
                });
            }
            catch (e) {
                if (e instanceof Error) {
                    (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('Error Reset Assignment: ' + e.message, {
                        variant: 'error'
                    });
                }
                else {
                    console.error('Error: cannot interpret type unkown as error', e);
                }
            }
        });
    };
    /**
     * Pushes the student submission and submits the assignment
     */
    const submitAssignmentHandler = async () => {
        (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_8__.showDialog)('Submit Assignment', 'This action will submit your current notebooks!', async () => {
            await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_5__.submitAssignment)(lecture, assignment, true).then(response => {
                console.log("Submitted");
                setSubmissions(oldSubmissions => [
                    ...oldSubmissions,
                    response
                ]);
                (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('Successfully Submitted Assignment', {
                    variant: 'success'
                });
            }, error => {
                (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
                    variant: 'error'
                });
            });
        });
    };
    const pushAssignmentHandler = async () => {
        await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_7__.pushAssignment)(lecture.id, assignment.id, _util_repo_type__WEBPACK_IMPORTED_MODULE_9__.RepoType.ASSIGNMENT).then(() => (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('Successfully Pushed Assignment', {
            variant: 'success'
        }), error => (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        }));
    };
    /**
    * Pulls from given repository by sending a request to the grader git service.
    * @param repo input which repository should be fetched
    */
    const fetchAssignmentHandler = async (repo) => {
        await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_7__.pullAssignment)(lecture.id, assignment.id, repo).then(() => (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('Successfully Pulled Repo', {
            variant: 'success'
        }), error => (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        }));
    };
    const isDeadlineOver = () => {
        if (assignment.due_date === null) {
            return false;
        }
        const time = new Date(assignment.due_date).getTime();
        return time < Date.now();
    };
    const isAssignmentCompleted = () => {
        return assignment.status === 'complete';
    };
    const isMaxSubmissionReached = () => {
        if (assignment.max_submissions === null) {
            return false;
        }
        else {
            return assignment.max_submissions <= submissions.length;
        }
    };
    const isAssignmentFetched = () => {
        return files.length > 0 ? true : false;
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { height: '95%', overflow: 'auto' } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, null,
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { mt: 6 } },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, { variant: 'h6', sx: { ml: 2 } }, "Status"),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_assignment_status__WEBPACK_IMPORTED_MODULE_10__.AssignmentStatus, { activeStep: activeStatus, submissions: submissions })),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { mt: 4 } },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, { variant: 'h6', sx: { ml: 2 } }, "Files"),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_files_files__WEBPACK_IMPORTED_MODULE_11__.Files, { lecture: lecture, assignment: assignment }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Stack, { direction: 'row', spacing: 1, sx: { m: 1, ml: 2 } },
                    assignment.type === 'group' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Push Changes' },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { variant: 'outlined', size: 'small', onClick: pushAssignmentHandler },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_PublishRounded__WEBPACK_IMPORTED_MODULE_12__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                            "Push"))),
                    assignment.type === 'group' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Pull from Remote' },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { variant: 'outlined', size: 'small', onClick: () => fetchAssignmentHandler('assignment') },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_FileDownload__WEBPACK_IMPORTED_MODULE_13__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                            "Pull"))),
                    !isAssignmentFetched() ?
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Fetch Assignment' },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { variant: 'outlined', color: 'primary', size: 'small', onClick: () => fetchAssignmentHandler("release") },
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_FileDownload__WEBPACK_IMPORTED_MODULE_13__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                                "Fetch"))
                        : null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Submit Files in Assignment' },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { variant: 'outlined', color: 'success', size: 'small', disabled: isDeadlineOver() ||
                                isMaxSubmissionReached() ||
                                isAssignmentCompleted() ||
                                files.length == 0, onClick: () => submitAssignmentHandler() },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Grading__WEBPACK_IMPORTED_MODULE_14__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                            "Submit")),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Reset Assignment to Released Version' },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { variant: 'outlined', size: 'small', color: 'error', onClick: () => resetAssignmentHandler() },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_RestartAlt__WEBPACK_IMPORTED_MODULE_15__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                            "Reset")))),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_2__.Outlet, null)),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { mt: 4 } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, { variant: 'h6', sx: { ml: 2, mt: 3 } },
                "Submissions",
                assignment.max_submissions !== null ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Chip, { sx: { ml: 2 }, size: "medium", icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Warning__WEBPACK_IMPORTED_MODULE_16__["default"], null), label: assignment.max_submissions -
                        submissions.length +
                        ' submissions left' })) : null),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_submission_list__WEBPACK_IMPORTED_MODULE_17__.SubmissionList, { submissions: submissions, openFeedback: openFeedback, sx: { m: 2, mt: 1 } })),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_overlay__WEBPACK_IMPORTED_MODULE_18__["default"], { onClose: () => setShowFeedback(false), open: showFeedback, container: props.root },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_feedback__WEBPACK_IMPORTED_MODULE_19__.Feedback, { lecture: lecture, assignment: assignment, submission: feedbackSubmission }))));
};


/***/ }),

/***/ "./lib/components/assignment/assignmentmanage.component.js":
/*!*****************************************************************!*\
  !*** ./lib/components/assignment/assignmentmanage.component.js ***!
  \*****************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AssignmentManageComponent: () => (/* binding */ AssignmentManageComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_material_Box__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/material/Box */ "./node_modules/@mui/material/Box/Box.js");
/* harmony import */ var _util_table__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/table */ "./lib/components/util/table.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.






const LectureTable = (props) => {
    const navigate = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useNavigate)();
    const headers = [
        { name: 'ID', width: 100 },
        { name: 'Name' },
        { name: 'Code' }
    ];
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_table__WEBPACK_IMPORTED_MODULE_3__.GraderTable, { headers: headers, rows: props.rows, rowFunc: row => {
            return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableRow, { key: row.name, component: _util_table__WEBPACK_IMPORTED_MODULE_3__.ButtonTr, onClick: () => navigate(`/lecture/${row.id}`) },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, { style: { width: 100 }, component: "th", scope: "row" }, row.id),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, null, row.name),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, null, row.code)));
        } }));
};
/**
 * Renders the lectures which the student addends.
 * @param props Props of the lecture file components
 */
const AssignmentManageComponent = () => {
    const allLectures = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useRouteLoaderData)("root");
    const [showComplete, setShowComplete] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: "course-list" },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Box__WEBPACK_IMPORTED_MODULE_4__["default"], { sx: { m: 5 } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, { direction: 'row', spacing: 2 },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { variant: "h6", sx: { mb: 1 } }, "Lectures"),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.FormGroup, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Switch, { checked: showComplete, onChange: ev => setShowComplete(ev.target.checked) }), label: "Completed Lectures" }))),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(LectureTable, { rows: showComplete ? allLectures.completedLectures : allLectures.lectures }))));
};


/***/ }),

/***/ "./lib/components/assignment/feedback.js":
/*!***********************************************!*\
  !*** ./lib/components/assignment/feedback.js ***!
  \***********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   Feedback: () => (/* binding */ Feedback)
/* harmony export */ });
/* harmony import */ var _util_section_title__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/section-title */ "./lib/components/util/section-title.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var _services_gradebook__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../services/gradebook */ "./lib/services/gradebook.js");
/* harmony import */ var _util_file_list__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../util/file-list */ "./lib/components/util/file-list.js");
/* harmony import */ var _coursemanage_overview_util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../coursemanage/overview/util */ "./lib/components/coursemanage/overview/util.js");
/* harmony import */ var _mui_icons_material_OpenInBrowser__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @mui/icons-material/OpenInBrowser */ "./node_modules/@mui/icons-material/OpenInBrowser.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../services/file.service */ "./lib/services/file.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.









/**
 * Renders the feedback of a student submission.
 * @param props Props of the feedback component
 */
const Feedback = (props) => {
    const [gradeBook, setGradeBook] = react__WEBPACK_IMPORTED_MODULE_1__.useState(null);
    const [path, setPath] = react__WEBPACK_IMPORTED_MODULE_1__.useState(null);
    react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => {
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_2__.getProperties)(props.lecture.id, props.assignment.id, props.submission.id).then(properties => {
            const gradeBook = new _services_gradebook__WEBPACK_IMPORTED_MODULE_3__.GradeBook(properties);
            setGradeBook(gradeBook);
        });
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_2__.pullFeedback)(props.lecture, props.assignment, props.submission).then(() => {
            const feedbackPath = `${_services_file_service__WEBPACK_IMPORTED_MODULE_4__.lectureBasePath}${props.lecture.code}/feedback/${props.assignment.id}/${props.submission.id}`;
            setPath(feedbackPath);
        });
    }, [props.lecture, props.assignment, props.submission]);
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, null,
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_section_title__WEBPACK_IMPORTED_MODULE_5__.SectionTitle, { title: 'Feedback for ' + props.assignment.name }),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { m: 2, mt: 12 } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: "row", spacing: 2, sx: { ml: 2 } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { sx: { mt: 0.5 } },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: "right", color: "text.secondary", sx: { fontSize: 12, height: 35 } }, "Lecture"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: "right", color: "text.secondary", sx: { fontSize: 12, height: 35 } }, "Assignment"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: "right", color: "text.secondary", sx: { fontSize: 12, height: 35 } }, "Points"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: "right", color: "text.secondary", sx: { fontSize: 12, height: 35 } }, "Extra Credit")),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, null,
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: "text.primary", sx: { display: 'inline-block', fontSize: 16, height: 35 } }, props.lecture.name),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: "text.primary", sx: { display: 'inline-block', fontSize: 16, height: 35 } },
                        props.assignment.name,
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: "text.secondary", sx: {
                                display: 'inline-block',
                                fontSize: 14,
                                ml: 2,
                                height: 35
                            } }, props.assignment.type)),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: "text.primary", sx: { display: 'inline-block', fontSize: 16, height: 35 } },
                        gradeBook?.getPoints(),
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: "text.secondary", sx: { display: 'inline-block', fontSize: 14, ml: 0.25 } },
                            "/",
                            gradeBook?.getMaxPoints())),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: "text.primary", sx: { display: 'inline-block', fontSize: 16, height: 35 } }, gradeBook?.getExtraCredits())))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { m: 2, mb: 0 } },
            "Feedback Files",
            path !== null && (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { sx: { mt: -1, ml: 2 }, variant: "outlined", size: "small", color: 'primary', onClick: () => (0,_coursemanage_overview_util__WEBPACK_IMPORTED_MODULE_6__.openBrowser)(path) },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_OpenInBrowser__WEBPACK_IMPORTED_MODULE_7__["default"], { fontSize: "small", sx: { mr: 1 } }),
                "Show in Filebrowser"))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_file_list__WEBPACK_IMPORTED_MODULE_8__.FilesList, { path: path, sx: { m: 2 } })));
};


/***/ }),

/***/ "./lib/components/assignment/files/file-view.js":
/*!******************************************************!*\
  !*** ./lib/components/assignment/files/file-view.js ***!
  \******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   FileView: () => (/* binding */ FileView)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _util_section_title__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../util/section-title */ "./lib/components/util/section-title.js");
/* harmony import */ var _files__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./files */ "./lib/components/assignment/files/files.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);





const FileView = () => {
    const { lecture, assignments } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('lecture');
    const { assignment, allSubmissions, latestSubmissions } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('assignment');
    const [assignmentState, setAssignmentState] = react__WEBPACK_IMPORTED_MODULE_1__.useState(assignment);
    const [submissionsState, setSubmissions] = react__WEBPACK_IMPORTED_MODULE_1__.useState(latestSubmissions);
    return react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, null,
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_section_title__WEBPACK_IMPORTED_MODULE_3__.SectionTitle, { title: 'Files' }),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { ml: 3, mr: 3, mb: 3, mt: 3 } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Grid, { container: true, spacing: 2, alignItems: 'stretch' },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Grid, { item: true, xs: 12, md: 6, lg: 5 },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_files__WEBPACK_IMPORTED_MODULE_4__.Files, { lecture: lecture, assignment: assignmentState })))));
};


/***/ }),

/***/ "./lib/components/assignment/files/files.js":
/*!**************************************************!*\
  !*** ./lib/components/assignment/files/files.js ***!
  \**************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   Files: () => (/* binding */ Files)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _util_file_list__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../util/file-list */ "./lib/components/util/file-list.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../services/file.service */ "./lib/services/file.service.js");
/* harmony import */ var _coursemanage_overview_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../coursemanage/overview/util */ "./lib/components/coursemanage/overview/util.js");
/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../.. */ "./lib/index.js");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! moment */ "webpack/sharing/consume/default/moment/moment");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_1__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.






/**
 * Renders the file view and additional buttons to submit, push, pull or reset the assignment.
 * @param props Props of the assignment files component
 */
const Files = (props) => {
    const path = `${_services_file_service__WEBPACK_IMPORTED_MODULE_2__.lectureBasePath}${props.lecture.code}/assignments/${props.assignment.id}`;
    /**
     * Opens file assignment folder directly by rendering page.
    */
    (0,_coursemanage_overview_util__WEBPACK_IMPORTED_MODULE_3__.openBrowser)(path);
    const [srcChangedTimestamp, setSrcChangeTimestamp] = react__WEBPACK_IMPORTED_MODULE_0__.useState(moment__WEBPACK_IMPORTED_MODULE_1___default()().valueOf());
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        ___WEBPACK_IMPORTED_MODULE_4__.GlobalObjects.docManager.services.contents.fileChanged.connect((sender, change) => {
            const { oldValue, newValue } = change;
            if (!newValue.path.includes(path)) {
                return;
            }
            const modified = moment__WEBPACK_IMPORTED_MODULE_1___default()(newValue.last_modified).valueOf();
            if (srcChangedTimestamp === null || srcChangedTimestamp < modified) {
                setSrcChangeTimestamp(modified);
            }
        }, undefined);
    });
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_file_list__WEBPACK_IMPORTED_MODULE_5__.FilesList, { path: path, sx: { m: 2, mt: 1 } })));
};


/***/ }),

/***/ "./lib/components/assignment/lecture.js":
/*!**********************************************!*\
  !*** ./lib/components/assignment/lecture.js ***!
  \**********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   LectureComponent: () => (/* binding */ LectureComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_material_colors__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/material/colors */ "./node_modules/@mui/material/colors/blue.js");
/* harmony import */ var _mui_material_colors__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @mui/material/colors */ "./node_modules/@mui/material/colors/grey.js");
/* harmony import */ var _mui_material_colors__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @mui/material/colors */ "./node_modules/@mui/material/colors/green.js");
/* harmony import */ var _mui_material_colors__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @mui/material/colors */ "./node_modules/@mui/material/colors/red.js");
/* harmony import */ var _mui_icons_material_RestartAlt__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @mui/icons-material/RestartAlt */ "./node_modules/@mui/icons-material/RestartAlt.js");
/* harmony import */ var _mui_icons_material_EditNoteOutlined__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @mui/icons-material/EditNoteOutlined */ "./node_modules/@mui/icons-material/EditNoteOutlined.js");
/* harmony import */ var _mui_icons_material_Done__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @mui/icons-material/Done */ "./node_modules/@mui/icons-material/Done.js");
/* harmony import */ var _mui_icons_material_Close__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @mui/icons-material/Close */ "./node_modules/@mui/icons-material/Close.js");
/* harmony import */ var _mui_icons_material_Search__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @mui/icons-material/Search */ "./node_modules/@mui/icons-material/Search.js");
/* harmony import */ var _mui_icons_material_FileDownload__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @mui/icons-material/FileDownload */ "./node_modules/@mui/icons-material/FileDownload.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _util_table__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../util/table */ "./lib/components/util/table.js");
/* harmony import */ var _util_deadline__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../util/deadline */ "./lib/components/util/deadline.js");
/* harmony import */ var _model_assignment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../model/assignment */ "./lib/model/assignment.js");
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util/dialog-provider */ "./lib/components/util/dialog-provider.js");
/* harmony import */ var _mui_icons_material_EditOff__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @mui/icons-material/EditOff */ "./node_modules/@mui/icons-material/EditOff.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../services/file.service */ "./lib/services/file.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.


















const EditButton = (props) => {
    const [assignmentPulled, setAssignmentPulled] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const fetchAssignmentHandler = async (repo) => {
        await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_4__.pullAssignment)(props.lecture.id, props.assignment.id, repo).then(() => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('Successfully Pulled Repo', {
                variant: 'success'
            });
        }, error => (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        }));
    };
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        (0,_services_file_service__WEBPACK_IMPORTED_MODULE_5__.getFiles)(`${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${props.lecture.code}/assignments/${props.assignment.id}`).then(files => {
            console.log(files);
            if (files.length > 0) {
                setAssignmentPulled(true);
            }
        });
    });
    if (assignmentPulled === false) {
        return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.IconButton, { onClick: (e) => {
                (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_6__.showDialog)('Pull Assignment', 'Do you really want to pull this assignment?', async () => {
                    await fetchAssignmentHandler('assignment');
                });
                e.stopPropagation();
            } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_FileDownload__WEBPACK_IMPORTED_MODULE_7__["default"], { sx: { color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_8__["default"][500] } })));
    }
    const time = new Date(props.assignment.due_date).getTime();
    if ((props.assignment.due_date !== null && time < Date.now()) || props.status === _model_assignment__WEBPACK_IMPORTED_MODULE_9__.Assignment.StatusEnum.Complete) {
        return react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_EditOff__WEBPACK_IMPORTED_MODULE_10__["default"], { sx: { color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_11__["default"][500] } });
    }
    else
        return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.IconButton, null,
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_EditNoteOutlined__WEBPACK_IMPORTED_MODULE_12__["default"], { sx: { color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_13__["default"][500] } })));
};
;
const FeedbackIcon = (props) => {
    if (props.feedback_available) {
        return react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Done__WEBPACK_IMPORTED_MODULE_14__["default"], { sx: { color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_13__["default"][500] } });
    }
    return react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Close__WEBPACK_IMPORTED_MODULE_15__["default"], { sx: { color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_16__["default"][500] } });
};
const AssignmentTable = (props) => {
    const navigate = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useNavigate)();
    const headers = [
        { name: 'Name' },
        { name: 'Points', width: 100 },
        { name: 'Deadline', width: 200 },
        { name: 'Edit', width: 75 },
        { name: 'Reset', width: 75 },
        { name: 'Detail View', width: 75 },
        { name: 'Feedback Available', width: 80 }
    ];
    ;
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_table__WEBPACK_IMPORTED_MODULE_17__.GraderTable, { headers: headers, rows: props.rows, rowFunc: row => {
                return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableRow, { key: row.name, component: _util_table__WEBPACK_IMPORTED_MODULE_17__.ButtonTr, onClick: () => navigate(`/lecture/${props.lecture.id}/assignment/${row.id}`) },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, { component: 'th', scope: 'row' },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { variant: 'subtitle2', sx: { fontSize: 16 } }, row.name)),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, { style: { width: 34 } }, row.points),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, null,
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_deadline__WEBPACK_IMPORTED_MODULE_18__.DeadlineComponent, { component: 'chip', due_date: row.due_date, compact: true })),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, { style: { width: 55 } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(EditButton, { status: row.status, lecture: props.lecture, assignment: row })),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, { style: { width: 55 } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.IconButton, { "aria-label": 'reset', size: 'small', onClick: (e) => {
                                (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_6__.showDialog)('Reset Assignment', 'Do you really want to reset this assignment?', async () => {
                                    try {
                                        await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_4__.resetAssignment)(props.lecture, props.rows.find(a => a.id === row.id));
                                        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('Assignment reset successfully', {
                                            variant: 'success'
                                        });
                                    }
                                    catch (error) {
                                        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
                                            variant: 'error'
                                        });
                                    }
                                });
                                e.stopPropagation();
                            } },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_RestartAlt__WEBPACK_IMPORTED_MODULE_19__["default"], { sx: { color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_8__["default"][500] } }))),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, { style: { width: 55 } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.IconButton, { "aria-label": 'detail view', size: 'small' },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Search__WEBPACK_IMPORTED_MODULE_20__["default"], null))),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, { style: { width: 55 } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(FeedbackIcon, { feedback_available: row.feedback_available }))));
            } })));
};
/*
    * Scan all submissions return true if feedback is available for that assignment.
    * */
const feedbackAvailable = (submissions) => {
    /* Find the submissions equal to the assignmentId */
    if (submissions === undefined) {
        return false;
    }
    /* If we have a submission, check if it has feedback */
    for (const submission of submissions) {
        if (submission.feedback_available === true) {
            return true;
        }
    }
    return false;
};
/*
    * Transform the AssignmentDetail array into an AssignmentStudent array
    * iterate over the submissions for each assignment, check if there is
    * feedback available for any, then use this to set a flag in the
    * AssignmentStudent object */
const transformAssignments = (assignments) => {
    const result = [];
    for (const assignment of assignments) {
        /* Get any existing submissions */
        const existingSubmissions = assignment.submissions;
        let feedback_available = false;
        /* If there are any submissions, check for feedback! */
        if ((existingSubmissions !== undefined) || (existingSubmissions.length > 0)) {
            feedback_available = feedbackAvailable(existingSubmissions);
        }
        /* Construct the AssignmentStudent object */
        const assignmentStudent = {
            ...assignment,
            feedback_available: feedback_available
        };
        result.push(assignmentStudent);
    }
    return result;
};
/**
 * Renders the lecture card which contains its assignments.
 */
const LectureComponent = () => {
    const { lecture, assignments } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useRouteLoaderData)('lecture');
    const navigation = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useNavigation)();
    const newAssignmentSubmissions = transformAssignments(assignments);
    const [lectureState, setLecture] = react__WEBPACK_IMPORTED_MODULE_0__.useState(lecture);
    const [assignmentsState, setAssignments] = react__WEBPACK_IMPORTED_MODULE_0__.useState(newAssignmentSubmissions);
    if (navigation.state === 'loading') {
        return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null,
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Card, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.LinearProgress, null))));
    }
    /**
     * Toggles collapsable in the card body.
     */
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, { direction: 'column', sx: { m: 5 } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { variant: 'h2', sx: { mb: 2 } },
            lectureState.name,
            lectureState.complete ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { sx: {
                    display: 'inline-block',
                    ml: 0.75,
                    fontSize: 16,
                    color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_16__["default"][400]
                } }, "complete")) : null),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, null,
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { variant: 'h6' }, "Assignments")),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(AssignmentTable, { lecture: lectureState, rows: assignmentsState })));
};


/***/ }),

/***/ "./lib/components/assignment/routes.js":
/*!*********************************************!*\
  !*** ./lib/components/assignment/routes.js ***!
  \*********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   getRoutes: () => (/* binding */ getRoutes),
/* harmony export */   loadAssignment: () => (/* binding */ loadAssignment),
/* harmony export */   loadLecture: () => (/* binding */ loadLecture),
/* harmony export */   loadPermissions: () => (/* binding */ loadPermissions),
/* harmony export */   loadSubmissions: () => (/* binding */ loadSubmissions)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material_Box__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/material/Box */ "./node_modules/@mui/material/Box/Box.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _util_breadcrumbs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../util/breadcrumbs */ "./lib/components/util/breadcrumbs.js");
/* harmony import */ var _util_error__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../util/error */ "./lib/components/util/error.js");
/* harmony import */ var _services_permission_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../services/permission.service */ "./lib/services/permission.service.js");
/* harmony import */ var _services_lectures_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../services/lectures.service */ "./lib/services/lectures.service.js");
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _assignmentmanage_component__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./assignmentmanage.component */ "./lib/components/assignment/assignmentmanage.component.js");
/* harmony import */ var _lecture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./lecture */ "./lib/components/assignment/lecture.js");
/* harmony import */ var _assignment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./assignment */ "./lib/components/assignment/assignment.js");
/* harmony import */ var _files_file_view__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./files/file-view */ "./lib/components/assignment/files/file-view.js");















const loadPermissions = async () => {
    try {
        await _services_permission_service__WEBPACK_IMPORTED_MODULE_4__.UserPermissions.loadPermissions();
        const [lectures, completedLectures] = await Promise.all([
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_5__.getAllLectures)(),
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_5__.getAllLectures)(true)
        ]);
        return { lectures, completedLectures };
    }
    catch (error) {
        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        });
        throw new Error("Could not load data!");
    }
};
const loadLecture = async (lectureId) => {
    try {
        const [lecture, assignments] = await Promise.all([
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_5__.getLecture)(lectureId),
            (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_6__.getAllAssignments)(lectureId, false, true)
        ]);
        return { lecture, assignments };
    }
    catch (error) {
        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        });
        throw new Error("Could not load data!");
    }
};
/*
 * Load submissions for all assignments in a lecture
 * */
const loadSubmissions = async (lecture, assignments) => {
    try {
        const submissions = await Promise.all(assignments.map(async (assignment) => {
            const submissions = await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_7__.getAllSubmissions)(lecture.id, assignment.id, 'none', false);
            return { assignment, submissions };
        }));
        return submissions;
    }
    catch (error) {
        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        });
        throw new Error("Could not load data!");
    }
};
const loadAssignment = async (lectureId, assignmentId) => {
    try {
        const [lecture, assignment, submissions] = await Promise.all([
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_5__.getLecture)(lectureId),
            (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_6__.getAssignment)(lectureId, assignmentId),
            (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_7__.getAllSubmissions)(lectureId, assignmentId, 'none', false)
        ]);
        return { lecture, assignment, submissions };
    }
    catch (error) {
        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        });
        throw error;
    }
};
function ExamplePage({ to }) {
    const navigation = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useNavigation)(); // router navigates to new route (and loads data)
    const loading = navigation.state === 'loading';
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Box__WEBPACK_IMPORTED_MODULE_8__["default"], null,
        !loading ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, null, "This is an example page where the link below can be used for naviagation.")) : (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, null, "Loading...")),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, "Next Page: "),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_breadcrumbs__WEBPACK_IMPORTED_MODULE_9__.LinkRouter, { underline: 'hover', color: 'inherit', to: to, key: to }, to)));
}
// TODO: remove test code
const testFetchAssignment = async (lectureId, assignmentId) => {
    console.log(lectureId, assignmentId);
    const { lecture } = await loadLecture(lectureId);
    // throw lecture;
    return {
        assignment: { id: assignmentId, name: 'Introduction to Python' },
        lecture: lecture
    };
};
const getRoutes = (root) => {
    const routes = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.createRoutesFromElements)(
    // this is a layout route without a path (see: https://reactrouter.com/en/main/start/concepts#layout-routes)
    react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_breadcrumbs__WEBPACK_IMPORTED_MODULE_9__.Page, { id: 'assignment-manage' }), errorElement: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_error__WEBPACK_IMPORTED_MODULE_10__["default"], { id: 'assignment-manage' }) },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { id: 'root', path: '/*', loader: loadPermissions, handle: {
                crumb: (data) => 'Lectures',
                link: (params) => '/'
            } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { index: true, element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_assignmentmanage_component__WEBPACK_IMPORTED_MODULE_11__.AssignmentManageComponent, null) }),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { id: 'lecture', path: 'lecture/:lid/*', loader: ({ params }) => loadLecture(+params.lid), handle: {
                    // functions in handle have to handle undefined data (error page is displayed afterwards)
                    crumb: (data) => data?.lecture.name,
                    link: (params) => `lecture/${params?.lid}/`
                } },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { index: true, element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lecture__WEBPACK_IMPORTED_MODULE_12__.LectureComponent, null) }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { id: 'assignment', path: 'assignment/:aid/*', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_assignment__WEBPACK_IMPORTED_MODULE_13__.AssignmentComponent, { root: root }), loader: ({ params }) => loadAssignment(+params.lid, +params.aid), handle: {
                        crumb: (data) => data?.assignment.name,
                        link: (params) => `assignment/${params?.aid}/`
                    } },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { path: 'files', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_files_file_view__WEBPACK_IMPORTED_MODULE_14__.FileView, null), handle: {
                            crumb: (data) => 'Files',
                            link: (params) => 'files/'
                        } }))))));
    return routes;
};


/***/ }),

/***/ "./lib/components/assignment/submission-list.js":
/*!******************************************************!*\
  !*** ./lib/components/assignment/submission-list.js ***!
  \******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   SubmissionList: () => (/* binding */ SubmissionList)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_icons_material_ChatRounded__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/icons-material/ChatRounded */ "./node_modules/@mui/icons-material/ChatRounded.js");
/* harmony import */ var _services_datetime_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../services/datetime.service */ "./lib/services/datetime.service.js");
/* harmony import */ var _mui_icons_material_CloudDoneRounded__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/icons-material/CloudDoneRounded */ "./node_modules/@mui/icons-material/CloudDoneRounded.js");
/* harmony import */ var _mui_material_colors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @mui/material/colors */ "./node_modules/@mui/material/colors/grey.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.






/**
 * Renders student submissions in a list
 * @param props Props of submission list component
 */
const SubmissionList = (props) => {
    /**
     * Generates submission items which will be rendered in the list
     * and will be fed using the IIterator from the FilterFileBrowserModel
     * @param submissions student submissions
     *
     */
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        console.log("Triggered rerender");
    }, [props.submissions]);
    const generateItems = (submissions) => {
        return submissions
            .sort((a, b) => (0,_services_datetime_service__WEBPACK_IMPORTED_MODULE_2__.utcToTimestamp)(a.submitted_at) > (0,_services_datetime_service__WEBPACK_IMPORTED_MODULE_2__.utcToTimestamp)(b.submitted_at) ? -1 : 1)
            .map(value => (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, null,
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.ListItem, { disablePadding: true, secondaryAction: value.feedback_available ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { startIcon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_ChatRounded__WEBPACK_IMPORTED_MODULE_3__["default"], null), size: "small", onClick: () => props.openFeedback(value) }, "Open feedback")) : null },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.ListItemIcon, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_CloudDoneRounded__WEBPACK_IMPORTED_MODULE_4__["default"], { sx: { ml: 1 } })),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.ListItemText, { primary: (0,_services_datetime_service__WEBPACK_IMPORTED_MODULE_2__.utcToLocalFormat)(value.submitted_at), secondary: value.feedback_available
                        ? `${value.score} Point` + (value.score === 1 ? '' : 's')
                        : null })))));
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Paper, { elevation: 0, sx: props.sx },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Card, { sx: { mt: 1 }, variant: "outlined" }, props.submissions.length === 0 ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, { variant: 'body1', color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_5__["default"][500], sx: { ml: 1 } }, "No Submissions Yet")) : (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.List, { dense: false }, generateItems(props.submissions))))));
};


/***/ }),

/***/ "./lib/components/coursemanage/assignment-modal.js":
/*!*********************************************************!*\
  !*** ./lib/components/coursemanage/assignment-modal.js ***!
  \*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AssignmentModalComponent: () => (/* binding */ AssignmentModalComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_icons_material_Dashboard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/icons-material/Dashboard */ "./node_modules/@mui/icons-material/Dashboard.js");
/* harmony import */ var _mui_icons_material_Folder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/icons-material/Folder */ "./node_modules/@mui/icons-material/Folder.js");
/* harmony import */ var _mui_icons_material_FormatListNumbered__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @mui/icons-material/FormatListNumbered */ "./node_modules/@mui/icons-material/FormatListNumbered.js");
/* harmony import */ var _mui_icons_material_QueryStats__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @mui/icons-material/QueryStats */ "./node_modules/@mui/icons-material/QueryStats.js");
/* harmony import */ var _mui_icons_material_Settings__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @mui/icons-material/Settings */ "./node_modules/@mui/icons-material/Settings.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.








function a11yProps(index) {
    return {
        id: `vertical-tab-${index}`,
        'aria-controls': `vertical-tabpanel-${index}`
    };
}
const AssignmentModalComponent = () => {
    const { lecture, assignments, users } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('lecture');
    const { assignment, allSubmissions, latestSubmissions } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('assignment');
    const params = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useParams)();
    const match = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useMatch)(`/lecture/${params.lid}/assignment/${params.aid}/*`);
    const tab = match.params['*'];
    let value;
    if (tab === '') {
        value = 0;
    }
    else if (tab === 'files') {
        value = 1;
    }
    else if (tab.includes('submissions')) {
        value = 2;
    }
    else if (tab === 'stats') {
        value = 3;
    }
    else if (tab === 'settings') {
        value = 4;
    }
    else {
        console.warn(`Unknown tab ${tab}... navigating to overview page!`);
        value = 0;
    }
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { height: '95%', overflowY: 'auto' } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { height: '100%', bgcolor: 'background.paper', display: 'flex' } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tabs, { orientation: 'vertical', value: value, sx: { borderRight: 1, borderColor: 'divider', minWidth: '200px', marginTop: 5 } },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, { label: 'Overview', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Dashboard__WEBPACK_IMPORTED_MODULE_3__["default"], null), iconPosition: 'start', sx: { justifyContent: 'flex-start' }, ...a11yProps(0), component: react_router_dom__WEBPACK_IMPORTED_MODULE_2__.Link, to: '' }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, { label: 'Files', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Folder__WEBPACK_IMPORTED_MODULE_4__["default"], null), iconPosition: 'start', sx: { justifyContent: 'flex-start' }, ...a11yProps(1), component: react_router_dom__WEBPACK_IMPORTED_MODULE_2__.Link, to: 'files' }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, { label: 'Submissions', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Badge, { color: 'secondary', badgeContent: latestSubmissions?.length, showZero: latestSubmissions !== null },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_FormatListNumbered__WEBPACK_IMPORTED_MODULE_5__["default"], null)), iconPosition: 'start', sx: { justifyContent: 'flex-start' }, ...a11yProps(2), component: react_router_dom__WEBPACK_IMPORTED_MODULE_2__.Link, to: 'submissions' }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, { label: 'Stats', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_QueryStats__WEBPACK_IMPORTED_MODULE_6__["default"], null), iconPosition: 'start', sx: { justifyContent: 'flex-start' }, ...a11yProps(3), component: react_router_dom__WEBPACK_IMPORTED_MODULE_2__.Link, to: 'stats' }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, { label: 'Settings', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Settings__WEBPACK_IMPORTED_MODULE_7__["default"], null), iconPosition: 'start', sx: { justifyContent: 'flex-start' }, ...a11yProps(4), component: react_router_dom__WEBPACK_IMPORTED_MODULE_2__.Link, to: 'settings' })),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { flexGrow: 1, overflowX: 'auto' } },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_2__.Outlet, null)))));
};


/***/ }),

/***/ "./lib/components/coursemanage/coursemanage.component.js":
/*!***************************************************************!*\
  !*** ./lib/components/coursemanage/coursemanage.component.js ***!
  \***************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   CourseManageComponent: () => (/* binding */ CourseManageComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_material_Box__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/material/Box */ "./node_modules/@mui/material/Box/Box.js");
/* harmony import */ var _util_table__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/table */ "./lib/components/util/table.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.






const LectureTable = (props) => {
    const navigate = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useNavigate)();
    const headers = [
        { name: 'ID', width: 50 },
        { name: 'Name' },
        { name: 'Code' }
    ];
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_table__WEBPACK_IMPORTED_MODULE_3__.GraderTable, { headers: headers, rows: props.rows, rowFunc: row => {
            return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableRow, { key: row.name, component: _util_table__WEBPACK_IMPORTED_MODULE_3__.ButtonTr, onClick: () => navigate(`/lecture/${row.id}`) },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, { style: { width: 50 }, component: 'th', scope: 'row' }, row.id),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { variant: 'subtitle2', sx: { fontSize: 16 } }, row.name)),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TableCell, null, row.code)));
        } }));
};
const CourseManageComponent = () => {
    const allLectures = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useRouteLoaderData)('root');
    const [showComplete, setShowComplete] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: 'course-list' },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, { direction: 'row', justifyContent: 'center' },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { variant: 'h4' }, "Course Management")),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Box__WEBPACK_IMPORTED_MODULE_4__["default"], { sx: { m: 5 } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, { direction: 'row', justifyContent: 'space-between' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { variant: 'h6', sx: { mb: 1 } }, "Lectures"),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.FormGroup, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Switch, { checked: showComplete, onChange: ev => setShowComplete(ev.target.checked) }), label: 'Completed Lectures' }))),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(LectureTable, { rows: showComplete ? allLectures.completedLectures : allLectures.lectures }))));
};


/***/ }),

/***/ "./lib/components/coursemanage/files/file-view.js":
/*!********************************************************!*\
  !*** ./lib/components/coursemanage/files/file-view.js ***!
  \********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   FileView: () => (/* binding */ FileView)
/* harmony export */ });
/* harmony import */ var _files__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./files */ "./lib/components/coursemanage/files/files.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);



const FileView = () => {
    const { lecture, assignments, users } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useRouteLoaderData)('lecture');
    const { assignment, allSubmissions, latestSubmissions } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useRouteLoaderData)('assignment');
    const [assignmentState, setAssignmentState] = react__WEBPACK_IMPORTED_MODULE_0__.useState(assignment);
    const onAssignmentChange = (assignment) => {
        setAssignmentState(assignment);
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_files__WEBPACK_IMPORTED_MODULE_2__.Files, { lecture: lecture, assignment: assignmentState, onAssignmentChange: onAssignmentChange }));
};


/***/ }),

/***/ "./lib/components/coursemanage/files/files.js":
/*!****************************************************!*\
  !*** ./lib/components/coursemanage/files/files.js ***!
  \****************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   Files: () => (/* binding */ Files)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _mui_icons_material_GetAppRounded__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @mui/icons-material/GetAppRounded */ "./node_modules/@mui/icons-material/GetAppRounded.js");
/* harmony import */ var _util_dialog__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../util/dialog */ "./lib/components/util/dialog.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @mui/icons-material/Replay */ "./node_modules/@mui/icons-material/Replay.js");
/* harmony import */ var _mui_icons_material_OpenInBrowser__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @mui/icons-material/OpenInBrowser */ "./node_modules/@mui/icons-material/OpenInBrowser.js");
/* harmony import */ var _mui_icons_material_Terminal__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @mui/icons-material/Terminal */ "./node_modules/@mui/icons-material/Terminal.js");
/* harmony import */ var _mui_icons_material_Add__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @mui/icons-material/Add */ "./node_modules/@mui/icons-material/Add.js");
/* harmony import */ var _mui_icons_material_Check__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @mui/icons-material/Check */ "./node_modules/@mui/icons-material/Check.js");
/* harmony import */ var _mui_icons_material_ErrorOutline__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @mui/icons-material/ErrorOutline */ "./node_modules/@mui/icons-material/ErrorOutline.js");
/* harmony import */ var _util_file_list__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../util/file-list */ "./lib/components/util/file-list.js");
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../index */ "./lib/index.js");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! moment */ "webpack/sharing/consume/default/moment/moment");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _overview_util__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../overview/util */ "./lib/components/coursemanage/overview/util.js");
/* harmony import */ var _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @jupyterlab/coreutils */ "webpack/sharing/consume/default/@jupyterlab/coreutils");
/* harmony import */ var _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _mui_icons_material_PublishRounded__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @mui/icons-material/PublishRounded */ "./node_modules/@mui/icons-material/PublishRounded.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../services/file.service */ "./lib/services/file.service.js");
/* harmony import */ var _util_repo_type__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../util/repo-type */ "./lib/components/util/repo-type.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _git_log__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./git-log */ "./lib/components/coursemanage/files/git-log.js");
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../util/dialog-provider */ "./lib/components/util/dialog-provider.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.























/**
 * Renders in a file list the assignment files.
 * @param props props of the file component
 */
const Files = (props) => {
    const [assignment, setAssignment] = react__WEBPACK_IMPORTED_MODULE_0__.useState(props.assignment);
    const [lecture, setLecture] = react__WEBPACK_IMPORTED_MODULE_0__.useState(props.lecture);
    const [selectedDir, setSelectedDir] = react__WEBPACK_IMPORTED_MODULE_0__.useState('source');
    const [gitLogs, setGitLog] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]);
    const [assignmentState, setAssignmentState] = react__WEBPACK_IMPORTED_MODULE_0__.useState(assignment);
    const updateGitLog = () => {
        (0,_services_file_service__WEBPACK_IMPORTED_MODULE_5__.getGitLog)(lecture, assignment, _util_repo_type__WEBPACK_IMPORTED_MODULE_6__.RepoType.SOURCE, 10).then(logs => setGitLog(logs));
    };
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        updateGitLog();
    }, [assignmentState]);
    (0,_overview_util__WEBPACK_IMPORTED_MODULE_7__.openBrowser)(`${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${lecture.code}/${selectedDir}/${assignment.id}`);
    const [reloadFilesToggle, setReloadFiles] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [repoStatus, setRepoStatus] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);
    const [srcChangedTimestamp, setSrcChangeTimestamp] = react__WEBPACK_IMPORTED_MODULE_0__.useState(moment__WEBPACK_IMPORTED_MODULE_2___default()().valueOf()); // now
    const [generateTimestamp, setGenerateTimestamp] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);
    const serverRoot = _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_3__.PageConfig.getOption('serverRoot');
    const isCommitOverwrite = () => repoStatus === 'pull_needed' || repoStatus === 'divergent';
    const isPullOverwrite = () => repoStatus === 'push_needed' || repoStatus === 'divergent';
    (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
        const srcPath = `${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${lecture.code}/source/${assignment.id}`;
        _index__WEBPACK_IMPORTED_MODULE_8__.GlobalObjects.docManager.services.contents.fileChanged.connect((sender, change) => {
            const { oldValue, newValue } = change;
            if (!newValue.path.includes(srcPath)) {
                return;
            }
            const modified = moment__WEBPACK_IMPORTED_MODULE_2___default()(newValue.last_modified).valueOf();
            if (srcChangedTimestamp === null || srcChangedTimestamp < modified) {
                setSrcChangeTimestamp(modified);
            }
        }, undefined);
        (0,_services_file_service__WEBPACK_IMPORTED_MODULE_5__.getRemoteStatus)(props.lecture, props.assignment, _util_repo_type__WEBPACK_IMPORTED_MODULE_6__.RepoType.SOURCE).then(status => {
            setRepoStatus(status);
        });
    }, [props.assignment, props.lecture]);
    /**
     * Reload file view.
     */
    const reloadFiles = () => {
        setReloadFiles(!reloadFilesToggle);
        (0,_services_file_service__WEBPACK_IMPORTED_MODULE_5__.getRemoteStatus)(lecture, assignment, _util_repo_type__WEBPACK_IMPORTED_MODULE_6__.RepoType.SOURCE).then(status => {
            setRepoStatus(status);
        });
    };
    /**
     * Switches between source and release directory.
     * @param dir dir which should be switched to
     */
    const handleSwitchDir = async (dir) => {
        if (dir === 'release' &&
            (generateTimestamp === null || generateTimestamp < srcChangedTimestamp)) {
            await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_9__.generateAssignment)(lecture.id, assignment)
                .then(() => {
                (0,notistack__WEBPACK_IMPORTED_MODULE_4__.enqueueSnackbar)('Generated Student Version Notebooks', {
                    variant: 'success'
                });
                setGenerateTimestamp(moment__WEBPACK_IMPORTED_MODULE_2___default()().valueOf());
                setSelectedDir(dir);
            })
                .catch(error => {
                console.log(error);
                (0,notistack__WEBPACK_IMPORTED_MODULE_4__.enqueueSnackbar)('Error Generating Student Version Notebooks: ' + error.message, {
                    variant: 'error'
                });
            });
        }
        else {
            setSelectedDir(dir);
        }
    };
    /**
     * Pushes files to the source und release repo.
     * @param commitMessage the commit message
     */
    const handlePushAssignment = async (commitMessage) => {
        (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_10__.showDialog)('Push Assignment', `Do you want to push ${assignment.name}? This updates the state of the assignment on the server with your local state.`, async () => {
            try {
                // Note: has to be in this order (release -> source)
                await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_9__.pushAssignment)(lecture.id, assignment.id, 'release');
                await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_9__.pushAssignment)(lecture.id, assignment.id, 'source', commitMessage);
                (0,notistack__WEBPACK_IMPORTED_MODULE_4__.enqueueSnackbar)('Successfully Pushed Assignment', {
                    variant: 'success'
                });
            }
            catch (err) {
                if (err instanceof Error) {
                    (0,notistack__WEBPACK_IMPORTED_MODULE_4__.enqueueSnackbar)('Error Pushing Assignment: ' + err.message, {
                        variant: 'error'
                    });
                }
                else {
                    console.error('Error cannot interpret unknown as error', err);
                }
                return;
            }
        });
    };
    /**
     * Sets the repo status text.
     * @param status repo status
     */
    const getRemoteStatusText = (status) => {
        if (status === 'up_to_date') {
            return 'The local files are up to date with the remote repository.';
        }
        else if (status === 'pull_needed') {
            return 'The remote repository has new changes. Pull now to load them.';
        }
        else if (status === 'push_needed') {
            return 'You have made changes to your local repository which you can push.';
        }
        else {
            return 'The local and remote files are divergent.';
        }
    };
    const getStatusChip = (status) => {
        if (status === 'up_to_date') {
            return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Chip, { sx: { mb: 1.0 }, label: 'Up To Date', color: 'success', size: 'small', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Check__WEBPACK_IMPORTED_MODULE_11__["default"], null) }));
        }
        else if (status === 'pull_needed') {
            return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Chip, { sx: { mb: 1.0 }, label: 'Pull Needed', color: 'warning', size: 'small', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_GetAppRounded__WEBPACK_IMPORTED_MODULE_12__["default"], null) }));
        }
        else if (status === 'push_needed') {
            return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Chip, { sx: { mb: 1.0 }, label: 'Push Needed', color: 'warning', size: 'small', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_PublishRounded__WEBPACK_IMPORTED_MODULE_13__["default"], null) }));
        }
        else {
            return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Chip, { sx: { mb: 1.0 }, label: 'Divergent', color: 'error', size: 'small', icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_ErrorOutline__WEBPACK_IMPORTED_MODULE_14__["default"], null) }));
        }
    };
    /**
     * Pulls changes from source repository.
     */
    const handlePullAssignment = () => {
        (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_10__.showDialog)('Pull Assignment', `Do you want to pull ${assignment.name}? This updates your assignment with the state of the server and overwrites all changes.`, async () => {
            try {
                await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_9__.pullAssignment)(lecture.id, assignment.id, 'source');
                reloadFiles();
                (0,_services_file_service__WEBPACK_IMPORTED_MODULE_5__.getRemoteStatus)(props.lecture, props.assignment, _util_repo_type__WEBPACK_IMPORTED_MODULE_6__.RepoType.SOURCE, true).then(status => {
                    setRepoStatus(status);
                });
                (0,notistack__WEBPACK_IMPORTED_MODULE_4__.enqueueSnackbar)('Successfully Pulled Assignment', {
                    variant: 'success'
                });
            }
            catch (err) {
                if (err instanceof Error) {
                    (0,notistack__WEBPACK_IMPORTED_MODULE_4__.enqueueSnackbar)('Error Pulling Assignment: ' + err.message, {
                        variant: 'error'
                    });
                }
                else {
                    console.error('Error cannot intepret unkown as error', err);
                }
            }
        });
    };
    const newUntitled = async () => {
        const res = await _index__WEBPACK_IMPORTED_MODULE_8__.GlobalObjects.docManager.newUntitled({
            type: 'notebook',
            path: `${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${lecture.code}/source/${assignment.id}`
        });
        await _index__WEBPACK_IMPORTED_MODULE_8__.GlobalObjects.docManager.openOrReveal(res.path);
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Card, { elevation: 3, sx: { overflowX: 'auto', m: 3, height: '90%', display: 'flex', flexDirection: 'column' } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardHeader, { title: 'Files', titleTypographyProps: { display: 'inline' }, action: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Reload' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.IconButton, { "aria-label": 'reload', onClick: () => reloadFiles() },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_15__["default"], null))), subheader: repoStatus !== null && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: getRemoteStatusText(repoStatus) }, getStatusChip(repoStatus))), subheaderTypographyProps: { display: 'inline', ml: 2 } }),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardContent, { sx: { overflow: 'auto' } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tabs, { variant: 'fullWidth', value: selectedDir, onChange: (e, dir) => handleSwitchDir(dir) },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, { label: 'Source', value: 'source' }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, { label: 'Release', value: 'release' })),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { height: 200 },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_file_list__WEBPACK_IMPORTED_MODULE_16__.FilesList, { path: `${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${props.lecture.code}/${selectedDir}/${props.assignment.id}`, reloadFiles: reloadFilesToggle }))),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardActions, { sx: { marginTop: 'auto' } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_dialog__WEBPACK_IMPORTED_MODULE_17__.CommitDialog, { handleCommit: msg => handlePushAssignment(msg) },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: `Commit Changes${isCommitOverwrite() ? ' (Overwrites remote files!)' : ''}` },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { sx: { mt: -1, mr: 1 }, variant: 'outlined', size: 'small', color: isCommitOverwrite() ? 'error' : 'primary' },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_PublishRounded__WEBPACK_IMPORTED_MODULE_13__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                        "Push"))),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: `Pull from Remote${isPullOverwrite() ? ' (Overwrites local changes!)' : ''}` },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { color: isPullOverwrite() ? 'error' : 'primary', sx: { mt: -1 }, onClick: () => handlePullAssignment(), variant: 'outlined', size: 'small' },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_GetAppRounded__WEBPACK_IMPORTED_MODULE_12__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                    "Pull")),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Create new notebook.' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { variant: 'outlined', size: 'small', sx: { mt: -1 }, onClick: newUntitled },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Add__WEBPACK_IMPORTED_MODULE_18__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                    "Add new")),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_git_log__WEBPACK_IMPORTED_MODULE_19__.GitLogModal, { gitLogs: gitLogs }),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Show in File-Browser' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.IconButton, { sx: { mt: -1, pt: 0, pb: 0 }, color: 'primary', onClick: () => (0,_overview_util__WEBPACK_IMPORTED_MODULE_7__.openBrowser)(`${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${lecture.code}/${selectedDir}/${assignment.id}`) },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_OpenInBrowser__WEBPACK_IMPORTED_MODULE_20__["default"], null))),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { title: 'Open in Terminal' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.IconButton, { sx: { mt: -1, pt: 0, pb: 0 }, color: 'primary', onClick: () => (0,_overview_util__WEBPACK_IMPORTED_MODULE_7__.openTerminal)(`${serverRoot}/${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${lecture.code}/${selectedDir}/${assignment.id}`) },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Terminal__WEBPACK_IMPORTED_MODULE_21__["default"], null))))));
};


/***/ }),

/***/ "./lib/components/coursemanage/files/git-log.js":
/*!******************************************************!*\
  !*** ./lib/components/coursemanage/files/git-log.js ***!
  \******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GitLogModal: () => (/* binding */ GitLogModal)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_datetime_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../services/datetime.service */ "./lib/services/datetime.service.js");
/* harmony import */ var _mui_icons_material_GitHub__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/icons-material/GitHub */ "./node_modules/@mui/icons-material/GitHub.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.




const style = {
    position: 'absolute',
    top: '50%',
    left: '50%',
    transform: 'translate(-50%, -50%)',
    width: 400,
    bgcolor: 'background.paper',
    boxShadow: 3,
    pt: 2,
    px: 4,
    pb: 3
};
const getTimelineItem = (logItem) => {
    const date = (0,_services_datetime_service__WEBPACK_IMPORTED_MODULE_2__.utcToLocalFormat)(logItem.date);
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, null,
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.ListItem, null,
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.ListItemText, { primary: logItem.commit_msg, secondary: 'Author: ' + logItem.author + ', Date: ' + date })),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Divider, null)));
};
const GitLogModal = (props) => {
    const [gitLogs, setGitLogs] = react__WEBPACK_IMPORTED_MODULE_1__.useState(props.gitLogs);
    react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => {
        setGitLogs(props.gitLogs);
    }, [props.gitLogs]);
    const [open, setOpen] = react__WEBPACK_IMPORTED_MODULE_1__.useState(false);
    const handleOpen = () => {
        setOpen(true);
    };
    const handleClose = () => {
        setOpen(false);
    };
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(react__WEBPACK_IMPORTED_MODULE_1__.Fragment, null,
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Tooltip, { title: 'Show Git Log' },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { onClick: handleOpen, variant: 'outlined', size: "small", sx: { mt: -1 } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_GitHub__WEBPACK_IMPORTED_MODULE_3__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                "Git Log")),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Modal, { open: open, onClose: handleClose },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { ...style } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.CardHeader, { title: "Git Log" }),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Card, { elevation: 0 },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.CardContent, { sx: { height: '300px', overflowY: 'auto' } },
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.List, { sx: { ml: 1, mr: 1 } }, gitLogs.length > 0 ? (gitLogs.map(log => getTimelineItem(log))) : (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Paper, { variant: 'outlined' },
                            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, null, "No commits yet!")))))),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { sx: { mt: 2 }, onClick: handleClose }, "Close")))));
};


/***/ }),

/***/ "./lib/components/coursemanage/grading/create-submission.js":
/*!******************************************************************!*\
  !*** ./lib/components/coursemanage/grading/create-submission.js ***!
  \******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   CreateSubmission: () => (/* binding */ CreateSubmission)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _util_file_list__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../util/file-list */ "./lib/components/util/file-list.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../services/file.service */ "./lib/services/file.service.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../util/dialog-provider */ "./lib/components/util/dialog-provider.js");
/* harmony import */ var _mui_material_Autocomplete__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @mui/material/Autocomplete */ "./node_modules/@mui/material/Autocomplete/Autocomplete.js");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! moment */ "webpack/sharing/consume/default/moment/moment");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../index */ "./lib/index.js");
/* harmony import */ var _overview_util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../overview/util */ "./lib/components/coursemanage/overview/util.js");
/* harmony import */ var _mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/icons-material/Replay */ "./node_modules/@mui/icons-material/Replay.js");











const CreateSubmission = () => {
    const { assignment, rows, setRows, } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useOutletContext)();
    const { lecture, assignments, users } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('lecture');
    const path = `${_services_file_service__WEBPACK_IMPORTED_MODULE_4__.lectureBasePath}${lecture.code}/edit/${assignment.id}/create`;
    const submissionsLink = `/lecture/${lecture.id}/assignment/${assignment.id}/submissions`;
    const [srcChangedTimestamp, setSrcChangeTimestamp] = react__WEBPACK_IMPORTED_MODULE_1__.useState(moment__WEBPACK_IMPORTED_MODULE_3___default()().valueOf()); // now
    react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => {
        const srcPath = `${_services_file_service__WEBPACK_IMPORTED_MODULE_4__.lectureBasePath}${lecture.code}/edit/${assignment.id}/create`;
        _index__WEBPACK_IMPORTED_MODULE_5__.GlobalObjects.docManager.services.contents.fileChanged.connect((sender, change) => {
            const { oldValue, newValue } = change;
            if (!newValue.path.includes(srcPath)) {
                return;
            }
            const modified = moment__WEBPACK_IMPORTED_MODULE_3___default()(newValue.last_modified).valueOf();
            if (srcChangedTimestamp === null || srcChangedTimestamp < modified) {
                setSrcChangeTimestamp(modified);
            }
        }, undefined);
    });
    (0,_overview_util__WEBPACK_IMPORTED_MODULE_6__.openBrowser)(`${_services_file_service__WEBPACK_IMPORTED_MODULE_4__.lectureBasePath}${lecture.code}/edit/${assignment.id}/create`);
    const createSubmission = async () => {
    };
    const [reloadFilesToggle, setReloadFiles] = react__WEBPACK_IMPORTED_MODULE_1__.useState(false);
    const reloadFiles = () => {
        setReloadFiles(!reloadFilesToggle);
    };
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'column', sx: { flex: '1 1 100%' } },
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Alert, { severity: "info", sx: { m: 2 } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.AlertTitle, null, "Info"),
            "If you want to create a submission for a student manually, make sure to follow these steps: ",
            react__WEBPACK_IMPORTED_MODULE_1__.createElement("br", null),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement("br", null),
            "1. \u2002 By loading this page, directory 'edit/create/' is automatically opened in File Browser on your left-hand side.",
            react__WEBPACK_IMPORTED_MODULE_1__.createElement("br", null),
            "2. \u2002 Upload the desired files here. They will automatically appear in the Submission Files below.",
            react__WEBPACK_IMPORTED_MODULE_1__.createElement("br", null),
            "3. \u2002 Choose the student for whom you want to create the submission.",
            react__WEBPACK_IMPORTED_MODULE_1__.createElement("br", null),
            "4. \u2002 Push the submission."),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { m: 2, mb: 0 } }, "Select a student"),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Autocomplete__WEBPACK_IMPORTED_MODULE_7__["default"], { id: "country-select-demo", options: users["students"], autoHighlight: true, sx: { m: 2 }, renderInput: (params) => (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.TextField, { ...params, label: "Choose Student", inputProps: {
                    ...params.inputProps,
                    autoComplete: 'new-password',
                } })) }),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', justifyContent: 'flex-start', alignItems: 'center', spacing: 2, sx: { ml: 2 } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, null, "Submission Files"),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Tooltip, { title: 'Reload Files' },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.IconButton, { "aria-label": 'reload', onClick: () => reloadFiles() },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_8__["default"], null)))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_file_list__WEBPACK_IMPORTED_MODULE_9__.FilesList, { path: path, sx: { m: 2 } }),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', sx: { ml: 2 }, spacing: 2 },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { variant: 'outlined', color: 'success', onClick: async () => {
                    (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_10__.showDialog)('Manual Submission', 'Do you want to push new submission?', async () => {
                        await createSubmission();
                    });
                }, sx: { ml: 2 } }, "Push Submission")),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { sx: { ml: 2, mt: 3, mb: 5 }, direction: 'row' },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { variant: 'outlined', component: react_router_dom__WEBPACK_IMPORTED_MODULE_2__.Link, to: submissionsLink }, "Back"))));
};


/***/ }),

/***/ "./lib/components/coursemanage/grading/edit-submission.js":
/*!****************************************************************!*\
  !*** ./lib/components/coursemanage/grading/edit-submission.js ***!
  \****************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   EditSubmission: () => (/* binding */ EditSubmission)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var _util_file_list__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../util/file-list */ "./lib/components/util/file-list.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _overview_util__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../overview/util */ "./lib/components/coursemanage/overview/util.js");
/* harmony import */ var _mui_lab__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/lab */ "webpack/sharing/consume/default/@mui/lab/@mui/lab");
/* harmony import */ var _mui_lab__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_lab__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../services/file.service */ "./lib/services/file.service.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _mui_material_Toolbar__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @mui/material/Toolbar */ "./node_modules/@mui/material/Toolbar/Toolbar.js");
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../util/dialog-provider */ "./lib/components/util/dialog-provider.js");











const EditSubmission = () => {
    const { lecture, assignment, rows, setRows, manualGradeSubmission, setManualGradeSubmission } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_4__.useOutletContext)();
    const path = `${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${lecture.code}/edit/${assignment.id}/${manualGradeSubmission.id}`;
    const submissionsLink = `/lecture/${lecture.id}/assignment/${assignment.id}/submissions`;
    const [submission, setSubmission] = react__WEBPACK_IMPORTED_MODULE_1__.useState(manualGradeSubmission);
    const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1__.useState(false);
    const pushEditedFiles = async () => {
        await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_6__.pushSubmissionFiles)(lecture, assignment, submission).then(response => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully Pushed Edited Submission', {
                variant: 'success'
            });
        }, err => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(err.message, {
                variant: 'error'
            });
        });
    };
    const handlePullEditedSubmission = async () => {
        await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_6__.pullSubmissionFiles)(lecture, assignment, submission).then(response => {
            (0,_overview_util__WEBPACK_IMPORTED_MODULE_7__.openBrowser)(path);
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully Pulled Submission', {
                variant: 'success'
            });
        }, err => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(err.message, {
                variant: 'error'
            });
        });
    };
    const setEditRepository = async () => {
        await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_6__.createOrOverrideEditRepository)(lecture.id, assignment.id, submission.id).then(response => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully Created Edit Repository', {
                variant: 'success'
            });
            setSubmission(response);
        }, err => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(err.message, {
                variant: 'error'
            });
        });
    };
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'column', sx: { flex: '1 1 100%' } },
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { m: 2, mt: 5 } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', spacing: 2, sx: { ml: 2 } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { sx: { mt: 0.5 } },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: 'right', color: 'text.secondary', sx: { fontSize: 12, height: 35 } }, "Username"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: 'right', color: 'text.secondary', sx: { fontSize: 12, height: 35 } }, "Assignment")),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, null,
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { display: 'inline-block', fontSize: 16, height: 35 } }, submission.username),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { display: 'inline-block', fontSize: 16, height: 35 } }, assignment.name)))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { m: 2, mb: 0 } }, "Submission Files"),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_file_list__WEBPACK_IMPORTED_MODULE_8__.FilesList, { path: path, sx: { m: 2 } }),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', sx: { ml: 2 }, spacing: 2 },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_lab__WEBPACK_IMPORTED_MODULE_3__.LoadingButton, { loading: loading, color: submission.edited ? 'error' : 'primary', variant: 'outlined', onClick: async () => {
                    setLoading(true);
                    await setEditRepository();
                    setLoading(false);
                } },
                submission.edited ? 'Reset ' : 'Create ',
                "Edit Repository"),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_lab__WEBPACK_IMPORTED_MODULE_3__.LoadingButton, { loading: loading, color: 'primary', variant: 'outlined', disabled: !submission.edited, onClick: async () => {
                    setLoading(true);
                    await handlePullEditedSubmission();
                    setLoading(false);
                } }, "Pull Submission"),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { variant: 'outlined', color: 'success', disabled: !submission.edited, onClick: async () => {
                    (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_9__.showDialog)('Edit Submission', 'Do you want to push your submission changes?', async () => {
                        await pushEditedFiles();
                    });
                }, sx: { ml: 2 } }, "Push Edited Submission")),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { flex: '1 1 100%' } }),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Toolbar__WEBPACK_IMPORTED_MODULE_10__["default"], null,
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { variant: 'outlined', component: react_router_dom__WEBPACK_IMPORTED_MODULE_4__.Link, to: submissionsLink }, "Back"))));
};


/***/ }),

/***/ "./lib/components/coursemanage/grading/grading.js":
/*!********************************************************!*\
  !*** ./lib/components/coursemanage/grading/grading.js ***!
  \********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GradingComponent: () => (/* binding */ GradingComponent),
/* harmony export */   "default": () => (/* binding */ GradingTable),
/* harmony export */   getAutogradeChip: () => (/* binding */ getAutogradeChip),
/* harmony export */   getFeedbackChip: () => (/* binding */ getFeedbackChip),
/* harmony export */   getManualChip: () => (/* binding */ getManualChip)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material_Box__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @mui/material/Box */ "./node_modules/@mui/material/Box/Box.js");
/* harmony import */ var _mui_material_Table__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @mui/material/Table */ "./node_modules/@mui/material/Table/Table.js");
/* harmony import */ var _mui_material_TableBody__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @mui/material/TableBody */ "./node_modules/@mui/material/TableBody/TableBody.js");
/* harmony import */ var _mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @mui/material/TableCell */ "./node_modules/@mui/material/TableCell/TableCell.js");
/* harmony import */ var _mui_material_TableContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @mui/material/TableContainer */ "./node_modules/@mui/material/TableContainer/TableContainer.js");
/* harmony import */ var _mui_material_TableHead__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/material/TableHead */ "./node_modules/@mui/material/TableHead/TableHead.js");
/* harmony import */ var _mui_material_TablePagination__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @mui/material/TablePagination */ "./node_modules/@mui/material/TablePagination/TablePagination.js");
/* harmony import */ var _mui_material_TableRow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @mui/material/TableRow */ "./node_modules/@mui/material/TableRow/TableRow.js");
/* harmony import */ var _mui_material_TableSortLabel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/material/TableSortLabel */ "./node_modules/@mui/material/TableSortLabel/TableSortLabel.js");
/* harmony import */ var _mui_material_Typography__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @mui/material/Typography */ "./node_modules/@mui/material/Typography/Typography.js");
/* harmony import */ var _mui_material_Paper__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @mui/material/Paper */ "./node_modules/@mui/material/Paper/Paper.js");
/* harmony import */ var _mui_material_Checkbox__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @mui/material/Checkbox */ "./node_modules/@mui/material/Checkbox/Checkbox.js");
/* harmony import */ var _mui_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @mui/utils */ "./node_modules/@mui/utils/esm/visuallyHidden.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_datetime_service__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../../services/datetime.service */ "./lib/services/datetime.service.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _util_section_title__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../util/section-title */ "./lib/components/util/section-title.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var _table_toolbar__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./table-toolbar */ "./lib/components/coursemanage/grading/table-toolbar.js");
/* harmony import */ var _mui_icons_material_EditNoteOutlined__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @mui/icons-material/EditNoteOutlined */ "./node_modules/@mui/icons-material/EditNoteOutlined.js");
/* harmony import */ var _mui_material_colors__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @mui/material/colors */ "./node_modules/@mui/material/colors/green.js");
/* harmony import */ var _mui_icons_material_Add__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @mui/icons-material/Add */ "./node_modules/@mui/icons-material/Add.js");
























/**
 * Calculates chip color based on submission status.
 * @param value submission status
 * @return chip color
 */
const getColor = (value) => {
    if (value === 'not_graded') {
        return 'warning';
    }
    else if (value === 'automatically_graded' ||
        value === 'manually_graded') {
        return 'success';
    }
    else if (value === 'grading_failed') {
        return 'error';
    }
    return 'primary';
};
const getAutogradeChip = (submission) => {
    return react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Chip, { sx: { textTransform: 'capitalize' }, variant: 'outlined', label: submission.auto_status.split('_').join(' '), color: getColor(submission.auto_status) });
};
const getManualChip = (submission) => {
    return react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Chip, { sx: { textTransform: 'capitalize' }, variant: 'outlined', label: submission.manual_status.split('_').join(' '), color: getColor(submission.manual_status) });
};
const getFeedbackChip = (submission) => {
    return react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Chip, { variant: 'outlined', label: submission.feedback_available ? 'Generated' : 'Not Generated', color: submission.feedback_available ? 'success' : 'error' });
};
function descendingComparator(a, b, orderBy) {
    if (b[orderBy] < a[orderBy]) {
        return -1;
    }
    if (b[orderBy] > a[orderBy]) {
        return 1;
    }
    return 0;
}
function getComparator(order, orderBy) {
    return order === 'desc'
        ? (a, b) => descendingComparator(a, b, orderBy)
        : (a, b) => -descendingComparator(a, b, orderBy);
}
// Since 2020 all major browsers ensure sort stability with Array.prototype.sort().
// stableSort() brings sort stability to non-modern browsers (notably IE11). If you
// only support modern browsers you can replace stableSort(exampleArray, exampleComparator)
// with exampleArray.slice().sort(exampleComparator)
function stableSort(array, comparator) {
    const stabilizedThis = array.map((el, index) => [el, index]);
    stabilizedThis.sort((a, b) => {
        const order = comparator(a[0], b[0]);
        if (order !== 0) {
            return order;
        }
        return a[1] - b[1];
    });
    return stabilizedThis.map((el) => el[0]);
}
const headCells = [
    {
        id: 'id',
        numeric: true,
        disablePadding: true,
        label: 'ID'
    },
    {
        id: 'username',
        numeric: false,
        disablePadding: false,
        label: 'User'
    },
    {
        id: 'submitted_at',
        numeric: true,
        disablePadding: false,
        label: 'Date'
    },
    {
        id: 'auto_status',
        numeric: false,
        disablePadding: false,
        label: 'Autograde-Status'
    },
    {
        id: 'manual_status',
        numeric: false,
        disablePadding: false,
        label: 'Manualgrade-Status'
    },
    {
        id: 'feedback_available',
        numeric: false,
        disablePadding: false,
        label: 'Feedback generated'
    },
    {
        id: 'score',
        numeric: true,
        disablePadding: false,
        label: 'Score'
    },
    {
        id: 'edit',
        numeric: false,
        disablePadding: false,
        label: 'Edit'
    }
];
function EnhancedTableHead(props) {
    const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } = props;
    const createSortHandler = (property) => (event) => {
        onRequestSort(event, property);
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableHead__WEBPACK_IMPORTED_MODULE_4__["default"], null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableRow__WEBPACK_IMPORTED_MODULE_5__["default"], null,
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { padding: 'checkbox' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Checkbox__WEBPACK_IMPORTED_MODULE_7__["default"], { color: 'primary', indeterminate: numSelected > 0 && numSelected < rowCount, checked: rowCount > 0 && numSelected === rowCount, onChange: onSelectAllClick, inputProps: {
                        'aria-label': 'select all desserts'
                    } })),
            headCells.map((headCell) => (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { key: headCell.id, align: headCell.numeric ? 'right' : 'left', padding: headCell.disablePadding ? 'none' : 'normal', sortDirection: orderBy === headCell.id ? order : false }, headCell.id !== 'edit'
                ? react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableSortLabel__WEBPACK_IMPORTED_MODULE_8__["default"], { active: orderBy === headCell.id, direction: orderBy === headCell.id ? order : 'asc', onClick: createSortHandler(headCell.id) },
                    headCell.label,
                    orderBy === headCell.id ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Box__WEBPACK_IMPORTED_MODULE_9__["default"], { component: 'span', sx: _mui_utils__WEBPACK_IMPORTED_MODULE_10__["default"] }, order === 'desc' ? 'sorted descending' : 'sorted ascending')) : null)
                : headCell.label))))));
}
function GradingTable() {
    const navigate = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useNavigate)();
    const { lecture, assignment, rows, setRows, manualGradeSubmission, setManualGradeSubmission } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useOutletContext)();
    const [order, setOrder] = react__WEBPACK_IMPORTED_MODULE_0__.useState('asc');
    const [orderBy, setOrderBy] = react__WEBPACK_IMPORTED_MODULE_0__.useState('id');
    const [selected, setSelected] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]);
    const [page, setPage] = react__WEBPACK_IMPORTED_MODULE_0__.useState(0);
    const [rowsPerPage, setRowsPerPage] = react__WEBPACK_IMPORTED_MODULE_0__.useState(5);
    const [shownSubmissions, setShownSubmissions] = react__WEBPACK_IMPORTED_MODULE_0__.useState('none');
    const [showLogs, setShowLogs] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [logs, setLogs] = react__WEBPACK_IMPORTED_MODULE_0__.useState(undefined);
    /**
     * Opens log dialog which contain autograded logs from grader service.
     * @param event the click event
     * @param submissionId submission for which to show logs
     */
    const openLogs = (event, submissionId) => {
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_11__.getLogs)(lecture.id, assignment.id, submissionId).then(logs => {
            setLogs(logs);
            setShowLogs(true);
        }, error => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('No logs for submission', {
                variant: 'error'
            });
        });
        event.stopPropagation();
    };
    const updateSubmissions = (filter) => {
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_11__.getAllSubmissions)(lecture.id, assignment.id, filter, true, true).then(response => {
            setRows(response);
        });
    };
    const switchShownSubmissions = (event, value) => {
        if (value !== null) {
            setShownSubmissions(value);
            updateSubmissions(value);
        }
        else {
            updateSubmissions(shownSubmissions); // implicit reload
        }
    };
    const handleRequestSort = (event, property) => {
        const isAsc = orderBy === property && order === 'asc';
        setOrder(isAsc ? 'desc' : 'asc');
        setOrderBy(property);
    };
    const handleSelectAllClick = (event) => {
        if (event.target.checked) {
            const newSelected = rows.map((n) => n.id);
            setSelected(newSelected);
            return;
        }
        setSelected([]);
    };
    const handleClick = (event, id) => {
        const selectedIndex = selected.indexOf(id);
        let newSelected = [];
        if (selectedIndex === -1) {
            newSelected = newSelected.concat(selected, id);
        }
        else if (selectedIndex === 0) {
            newSelected = newSelected.concat(selected.slice(1));
        }
        else if (selectedIndex === selected.length - 1) {
            newSelected = newSelected.concat(selected.slice(0, -1));
        }
        else if (selectedIndex > 0) {
            newSelected = newSelected.concat(selected.slice(0, selectedIndex), selected.slice(selectedIndex + 1));
        }
        setSelected(newSelected);
        event.stopPropagation();
    };
    const handleChangePage = (event, newPage) => {
        setPage(newPage);
    };
    const handleChangeRowsPerPage = (event) => {
        setRowsPerPage(parseInt(event.target.value, 10));
        setPage(0);
    };
    const isSelected = (id) => selected.indexOf(id) !== -1;
    // Avoid a layout jump when reaching the last page with empty rows.
    const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0;
    const visibleRows = react__WEBPACK_IMPORTED_MODULE_0__.useMemo(() => stableSort(rows, getComparator(order, orderBy)).slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage), [order, orderBy, page, rowsPerPage, rows]);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Box__WEBPACK_IMPORTED_MODULE_9__["default"], { sx: { flex: '1 1 100%', ml: 5, mr: 5 } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, { direction: 'row', justifyContent: 'flex-end', alignItems: 'center', spacing: 2, sx: { mb: 2 } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Tooltip, { title: 'Manually add new submission' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Button, { onClick: (event) => {
                        event.stopPropagation();
                        navigate("create");
                    }, variant: 'outlined', size: "small", sx: { whiteSpace: 'nowrap' } },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Add__WEBPACK_IMPORTED_MODULE_12__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                    "New"))),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Paper__WEBPACK_IMPORTED_MODULE_13__["default"], { sx: { width: '100%', mb: 2 } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_table_toolbar__WEBPACK_IMPORTED_MODULE_14__.EnhancedTableToolbar, { lecture: lecture, assignment: assignment, rows: rows, clearSelection: () => setSelected([]), selected: selected, shownSubmissions: shownSubmissions, switchShownSubmissions: switchShownSubmissions }),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableContainer__WEBPACK_IMPORTED_MODULE_15__["default"], null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Table__WEBPACK_IMPORTED_MODULE_16__["default"], { sx: { minWidth: 750 }, "aria-labelledby": 'tableTitle' },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(EnhancedTableHead, { numSelected: selected.length, order: order, orderBy: orderBy, onSelectAllClick: handleSelectAllClick, onRequestSort: handleRequestSort, rowCount: rows.length }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableBody__WEBPACK_IMPORTED_MODULE_17__["default"], null,
                        visibleRows.map((row, index) => {
                            const isItemSelected = isSelected(row.id);
                            const labelId = `enhanced-table-checkbox-${index}`;
                            return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableRow__WEBPACK_IMPORTED_MODULE_5__["default"], { hover: true, onClick: (event) => {
                                    setManualGradeSubmission(row);
                                    navigate('manual');
                                }, role: 'button', "aria-checked": isItemSelected, tabIndex: -1, key: row.id, selected: isItemSelected, sx: { cursor: 'pointer' } },
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { padding: 'checkbox' },
                                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Checkbox__WEBPACK_IMPORTED_MODULE_7__["default"], { color: 'primary', checked: isItemSelected, inputProps: {
                                            'aria-labelledby': labelId
                                        }, onClick: (event) => handleClick(event, row.id) })),
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { component: 'th', id: labelId, scope: 'row', padding: 'none', align: 'right' }, row.id),
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { align: 'left' }, row.username),
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { align: 'right' }, (0,_services_datetime_service__WEBPACK_IMPORTED_MODULE_18__.utcToLocalFormat)(row.submitted_at)),
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { align: 'left' },
                                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Chip, { sx: { textTransform: 'capitalize' }, variant: 'outlined', label: row.auto_status.split('_').join(' '), color: getColor(row.auto_status), clickable: true, onClick: (event) => openLogs(event, row.id) })),
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { align: 'left' }, getManualChip(row)),
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { align: 'left' }, getFeedbackChip(row)),
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { align: 'right' }, row.score),
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { style: { width: 55 } },
                                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.IconButton, { "aria-label": 'Edit', size: 'small', onClick: (event) => {
                                            event.stopPropagation();
                                            setManualGradeSubmission(row);
                                            navigate("edit");
                                        } },
                                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_EditNoteOutlined__WEBPACK_IMPORTED_MODULE_19__["default"], { sx: { color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_20__["default"][500] } })))));
                        }),
                        emptyRows > 0 && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableRow__WEBPACK_IMPORTED_MODULE_5__["default"], { style: {
                                height: 53 * emptyRows
                            } },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TableCell__WEBPACK_IMPORTED_MODULE_6__["default"], { colSpan: 6 })))))),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_TablePagination__WEBPACK_IMPORTED_MODULE_21__["default"], { rowsPerPageOptions: [5, 10, 25], component: 'div', count: rows.length, rowsPerPage: rowsPerPage, page: page, onPageChange: handleChangePage, onRowsPerPageChange: handleChangeRowsPerPage })),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Dialog, { open: showLogs, onClose: () => setShowLogs(false), "aria-labelledby": 'alert-dialog-title', "aria-describedby": 'alert-dialog-description' },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.DialogTitle, { id: 'alert-dialog-title' }, 'Logs'),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.DialogContent, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Typography__WEBPACK_IMPORTED_MODULE_22__["default"], { id: 'alert-dialog-description', sx: { fontSize: 10, fontFamily: '\'Roboto Mono\', monospace' } }, logs)),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.DialogActions, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Button, { onClick: () => setShowLogs(false) }, "Close")))));
}
const GradingComponent = () => {
    const { lecture, assignments, users } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useRouteLoaderData)('lecture');
    const { assignment, allSubmissions, latestSubmissions } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useRouteLoaderData)('assignment');
    const [rows, setRows] = react__WEBPACK_IMPORTED_MODULE_0__.useState(allSubmissions);
    const [manualGradeSubmission, setManualGradeSubmission] = react__WEBPACK_IMPORTED_MODULE_0__.useState(undefined);
    return react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, { direction: 'column', sx: { height: '100%' } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_section_title__WEBPACK_IMPORTED_MODULE_23__.SectionTitle, { title: 'Grading' }),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Outlet, { context: { lecture, assignment, rows, setRows, manualGradeSubmission, setManualGradeSubmission } }));
};


/***/ }),

/***/ "./lib/components/coursemanage/grading/manual-grading.js":
/*!***************************************************************!*\
  !*** ./lib/components/coursemanage/grading/manual-grading.js ***!
  \***************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ManualGrading: () => (/* binding */ ManualGrading)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var _services_gradebook__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../services/gradebook */ "./lib/services/gradebook.js");
/* harmony import */ var _services_grading_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../services/grading.service */ "./lib/services/grading.service.js");
/* harmony import */ var _util_file_list__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../util/file-list */ "./lib/components/util/file-list.js");
/* harmony import */ var _mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @mui/icons-material/Replay */ "./node_modules/@mui/icons-material/Replay.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _overview_util__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../overview/util */ "./lib/components/coursemanage/overview/util.js");
/* harmony import */ var _mui_lab__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/lab */ "webpack/sharing/consume/default/@mui/lab/@mui/lab");
/* harmony import */ var _mui_lab__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_lab__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../services/file.service */ "./lib/services/file.service.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _services_datetime_service__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../services/datetime.service */ "./lib/services/datetime.service.js");
/* harmony import */ var _mui_material_Toolbar__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @mui/material/Toolbar */ "./node_modules/@mui/material/Toolbar/Toolbar.js");
/* harmony import */ var _mui_icons_material_ArrowForward__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @mui/icons-material/ArrowForward */ "./node_modules/@mui/icons-material/ArrowForward.js");
/* harmony import */ var _mui_icons_material_ArrowBack__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @mui/icons-material/ArrowBack */ "./node_modules/@mui/icons-material/ArrowBack.js");
/* harmony import */ var _grading__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./grading */ "./lib/components/coursemanage/grading/grading.js");
/* harmony import */ var _table_toolbar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./table-toolbar */ "./lib/components/coursemanage/grading/table-toolbar.js");
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../util/dialog-provider */ "./lib/components/util/dialog-provider.js");



















const ManualGrading = () => {
    const { lecture, assignment, rows, setRows, manualGradeSubmission, setManualGradeSubmission } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_4__.useOutletContext)();
    const submission = manualGradeSubmission;
    const manualPath = `${_services_file_service__WEBPACK_IMPORTED_MODULE_5__.lectureBasePath}${lecture.code}/manualgrade/${assignment.id}/${submission.id}`;
    const rowIdx = rows.findIndex(s => s.id === submission.id);
    const submissionsLink = `/lecture/${lecture.id}/assignment/${assignment.id}/submissions`;
    const [gradeBook, setGradeBook] = react__WEBPACK_IMPORTED_MODULE_1__.useState(null);
    const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1__.useState(false);
    react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => {
        reloadProperties();
    }, []);
    const handleAutogradeSubmission = async () => {
        await (0,_table_toolbar__WEBPACK_IMPORTED_MODULE_6__.autogradeSubmissionsDialog)(async () => {
            try {
                await (0,_services_grading_service__WEBPACK_IMPORTED_MODULE_7__.autogradeSubmission)(lecture, assignment, submission);
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Autograding submission!', {
                    variant: 'success'
                });
            }
            catch (err) {
                console.error(err);
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Error Autograding Submission', {
                    variant: 'error'
                });
            }
        });
    };
    const handleGenerateFeedback = async () => {
        await (0,_table_toolbar__WEBPACK_IMPORTED_MODULE_6__.generateFeedbackDialog)(async () => {
            try {
                await (0,_services_grading_service__WEBPACK_IMPORTED_MODULE_7__.generateFeedback)(lecture.id, assignment.id, submission.id);
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Generating feedback for submission!', {
                    variant: 'success'
                });
            }
            catch (err) {
                console.error(err);
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Error Generating Feedback', {
                    variant: 'error'
                });
            }
        });
    };
    const openFinishDialog = () => {
        (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_8__.showDialog)('Confirm Grading', 'Do you want to save the assignment grading?', finishGrading);
    };
    const finishGrading = () => {
        submission.manual_status = 'manually_graded';
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_9__.updateSubmission)(lecture.id, assignment.id, submission.id, submission).then(response => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully Graded Submission', {
                variant: 'success'
            });
        }, err => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(err.message, {
                variant: 'error'
            });
        });
    };
    const reloadProperties = () => {
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_9__.getProperties)(lecture.id, assignment.id, submission.id).then(properties => {
            const gradeBook = new _services_gradebook__WEBPACK_IMPORTED_MODULE_10__.GradeBook(properties);
            setGradeBook(gradeBook);
        });
    };
    const handlePullSubmission = async () => {
        (0,_services_grading_service__WEBPACK_IMPORTED_MODULE_7__.createManualFeedback)(lecture.id, assignment.id, submission.id).then(response => {
            (0,_overview_util__WEBPACK_IMPORTED_MODULE_11__.openBrowser)(manualPath);
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully Pulled Submission', {
                variant: 'success'
            });
        }, err => {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(err.message, {
                variant: 'error'
            });
        });
    };
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'column', sx: { flex: '1 1 100%' } },
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { m: 2, mt: 5 } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', spacing: 2, sx: { ml: 2 } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { sx: { mt: 0.5 } },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: 'right', color: 'text.secondary', sx: { fontSize: 12, height: 35 } }, "User"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: 'right', color: 'text.secondary', sx: { fontSize: 12, height: 35 } }, "Submitted at"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: 'right', color: 'text.secondary', sx: { fontSize: 12, height: 35 } }, "Points"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { textAlign: 'right', color: 'text.secondary', sx: { fontSize: 12, height: 35 } }, "Extra Credit")),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, null,
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { display: 'inline-block', fontSize: 16, height: 35 } }, submission.username),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { display: 'inline-block', fontSize: 16, height: 35 } }, (0,_services_datetime_service__WEBPACK_IMPORTED_MODULE_12__.utcToLocalFormat)(submission.submitted_at)),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { display: 'inline-block', fontSize: 16, height: 35 } },
                        gradeBook?.getPoints(),
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.secondary', sx: { display: 'inline-block', fontSize: 14, ml: 0.25 } },
                            "/",
                            gradeBook?.getMaxPoints())),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { display: 'inline-block', fontSize: 16, height: 35 } }, gradeBook?.getExtraCredits()))),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', spacing: 2 },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { flex: 'auto' } },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { fontSize: 14 } },
                        "Autograde Status: ",
                        (0,_grading__WEBPACK_IMPORTED_MODULE_13__.getAutogradeChip)(submission))),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { flex: 'auto' } },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { fontSize: 14 } },
                        "Manualgrade Status: ",
                        (0,_grading__WEBPACK_IMPORTED_MODULE_13__.getManualChip)(submission))),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { flex: 'auto' } },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { color: 'text.primary', sx: { fontSize: 14 } },
                        "Feedback: ",
                        (0,_grading__WEBPACK_IMPORTED_MODULE_13__.getFeedbackChip)(submission))))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { m: 2, mb: 0 } }, "Submission Files"),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_file_list__WEBPACK_IMPORTED_MODULE_14__.FilesList, { path: manualPath, sx: { m: 2 } }),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', sx: { ml: 2, mr: 2 }, spacing: 2 },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Tooltip, { title: 'Reload' },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.IconButton, { "aria-label": 'reload', onClick: () => reloadProperties() },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_15__["default"], null))),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_lab__WEBPACK_IMPORTED_MODULE_3__.LoadingButton, { size: 'small', loading: loading, color: 'primary', variant: 'outlined', onClick: async () => {
                    setLoading(true);
                    await handlePullSubmission();
                    setLoading(false);
                }, sx: { whiteSpace: 'nowrap', minWidth: 'auto' } }, "Pull Submission"),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { size: 'small', variant: 'outlined', color: 'success', onClick: openFinishDialog, sx: { whiteSpace: 'nowrap', minWidth: 'auto' } }, "Finish Manual Grading"),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { flex: '1 1 100%' } }),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { size: 'small', variant: 'outlined', color: 'primary', onClick: handleAutogradeSubmission, sx: { whiteSpace: 'nowrap', minWidth: 'auto' } }, "Autograde"),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { size: 'small', variant: 'outlined', color: 'primary', onClick: handleGenerateFeedback, sx: { whiteSpace: 'nowrap', minWidth: 'auto' } }, "Generate Feedback")),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { flex: '1 1 100%' } }),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Toolbar__WEBPACK_IMPORTED_MODULE_16__["default"], null,
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { variant: 'outlined', component: react_router_dom__WEBPACK_IMPORTED_MODULE_4__.Link, to: submissionsLink }, "Back"),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { flex: '1 1 100%' } }),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.IconButton, { "aria-label": 'previous', disabled: rowIdx === 0, color: 'primary', onClick: () => {
                    const prevSub = rows[rowIdx - 1];
                    setManualGradeSubmission(prevSub);
                } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_ArrowBack__WEBPACK_IMPORTED_MODULE_17__["default"], null)),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.IconButton, { "aria-label": 'next', disabled: rowIdx === rows.length - 1, color: 'primary', onClick: () => {
                    const nextSub = rows[rowIdx + 1];
                    setManualGradeSubmission(nextSub);
                } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_ArrowForward__WEBPACK_IMPORTED_MODULE_18__["default"], null)))));
};


/***/ }),

/***/ "./lib/components/coursemanage/grading/table-toolbar.js":
/*!**************************************************************!*\
  !*** ./lib/components/coursemanage/grading/table-toolbar.js ***!
  \**************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   EnhancedTableToolbar: () => (/* binding */ EnhancedTableToolbar),
/* harmony export */   autogradeSubmissionsDialog: () => (/* binding */ autogradeSubmissionsDialog),
/* harmony export */   generateFeedbackDialog: () => (/* binding */ generateFeedbackDialog)
/* harmony export */ });
/* harmony import */ var _mui_material_Toolbar__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/material/Toolbar */ "./node_modules/@mui/material/Toolbar/Toolbar.js");
/* harmony import */ var _mui_material_styles__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @mui/material/styles */ "webpack/sharing/consume/default/@mui/system/@mui/system?72a8");
/* harmony import */ var _mui_material_styles__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_mui_material_styles__WEBPACK_IMPORTED_MODULE_9__);
/* harmony import */ var _mui_material_Typography__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @mui/material/Typography */ "./node_modules/@mui/material/Typography/Typography.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_icons_material_FileDownload__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @mui/icons-material/FileDownload */ "./node_modules/@mui/icons-material/FileDownload.js");
/* harmony import */ var _mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @mui/icons-material/Replay */ "./node_modules/@mui/icons-material/Replay.js");
/* harmony import */ var _mui_icons_material_CloudSync__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @mui/icons-material/CloudSync */ "./node_modules/@mui/icons-material/CloudSync.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @jupyterlab/coreutils */ "webpack/sharing/consume/default/@jupyterlab/coreutils");
/* harmony import */ var _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _services_grading_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../services/grading.service */ "./lib/services/grading.service.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../services/file.service */ "./lib/services/file.service.js");
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../util/dialog-provider */ "./lib/components/util/dialog-provider.js");














const autogradeSubmissionsDialog = async (handleAgree) => {
    (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_4__.showDialog)('Autograde Selected Submissions', 'Do you wish to autograde the selected submissions?', handleAgree);
};
const generateFeedbackDialog = async (handleAgree) => {
    (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_4__.showDialog)('Generate Feedback', 'Do you wish to generate Feedback of the selected submissions?', handleAgree);
};
function EnhancedTableToolbar(props) {
    const { lecture, assignment, rows, selected, shownSubmissions, switchShownSubmissions, clearSelection } = props;
    const numSelected = selected.length;
    const ltiEnabled = _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_3__.PageConfig.getOption('enable_lti_features') === 'true';
    const optionName = () => {
        if (props.shownSubmissions === 'latest') {
            return 'Latest';
        }
        else if (props.shownSubmissions === 'best') {
            return 'Best';
        }
        else {
            return 'All';
        }
    };
    const handleSyncSubmission = async () => {
        (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_4__.showDialog)('LTI Sync Submission', 'Do you wish to sync Submissions?', async () => {
            await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_5__.ltiSyncSubmissions)(lecture.id, assignment.id)
                .then(response => {
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully matched ' +
                    response.syncable_users +
                    ' submissions with learning platform', { variant: 'success' });
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully synced latest submissions with feedback of ' +
                    response.synced_user +
                    ' users', { variant: 'success' });
            })
                .catch(error => {
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Error while trying to sync submissions:' + error.message, { variant: 'error' });
            });
        });
    };
    const handleExportSubmissions = async () => {
        try {
            await (0,_services_grading_service__WEBPACK_IMPORTED_MODULE_6__.saveSubmissions)(lecture, assignment, shownSubmissions);
            await (0,_services_file_service__WEBPACK_IMPORTED_MODULE_7__.openFile)(`${_services_file_service__WEBPACK_IMPORTED_MODULE_7__.lectureBasePath}${lecture.code}/submissions.csv`);
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully exported submissions', {
                variant: 'success'
            });
        }
        catch (err) {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Error Exporting Submissions', {
                variant: 'error'
            });
        }
    };
    const handleAutogradeSubmissions = async () => {
        await autogradeSubmissionsDialog(async () => {
            try {
                await Promise.all(selected.map(async (id) => {
                    const row = rows.find(value => value.id === id);
                    row.auto_status = 'pending';
                    await (0,_services_grading_service__WEBPACK_IMPORTED_MODULE_6__.autogradeSubmission)(lecture, assignment, row);
                }));
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(`Autograding ${numSelected} submissions!`, {
                    variant: 'success'
                });
            }
            catch (err) {
                console.error(err);
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Error Autograding Submissions', {
                    variant: 'error'
                });
            }
            clearSelection();
        });
    };
    const handleGenerateFeedback = async () => {
        await generateFeedbackDialog(async () => {
            try {
                await Promise.all(selected.map(async (id) => {
                    const row = rows.find(value => value.id === id);
                    await (0,_services_grading_service__WEBPACK_IMPORTED_MODULE_6__.generateFeedback)(lecture.id, assignment.id, row.id);
                }));
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(`Generating feedback for ${numSelected} submissions!`, {
                    variant: 'success'
                });
            }
            catch (err) {
                console.error(err);
                (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Error Generating Feedback', {
                    variant: 'error'
                });
            }
            clearSelection();
        });
    };
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(react__WEBPACK_IMPORTED_MODULE_1__.Fragment, null,
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Toolbar__WEBPACK_IMPORTED_MODULE_8__["default"], { sx: {
                pl: { sm: 2 },
                pr: { xs: 1, sm: 1 },
                ...(numSelected > 0 && {
                    bgcolor: (theme) => (0,_mui_material_styles__WEBPACK_IMPORTED_MODULE_9__.alpha)(theme.palette.primary.main, theme.palette.action.activatedOpacity)
                })
            } },
            numSelected > 0 ? (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Typography__WEBPACK_IMPORTED_MODULE_10__["default"], { sx: { flex: '1 1 100%' }, color: 'inherit', variant: 'subtitle1', component: 'div' },
                numSelected,
                " selected")) : (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Typography__WEBPACK_IMPORTED_MODULE_10__["default"], { sx: { flex: '1 1 100%' }, variant: 'h6', id: 'tableTitle', component: 'div' }, "Submissions")),
            numSelected > 0 ? (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.ButtonGroup, { size: 'small', "aria-label": 'autograde feedback buttons' },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { key: 'autograde', sx: { whiteSpace: 'nowrap', minWidth: 'auto' }, onClick: handleAutogradeSubmissions }, "Autograde"),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { key: 'feedback', sx: { whiteSpace: 'nowrap', minWidth: 'auto' }, onClick: handleGenerateFeedback }, 'Generate Feedback'))) : (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', spacing: 2 },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { size: 'small', startIcon: react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_FileDownload__WEBPACK_IMPORTED_MODULE_11__["default"], null), sx: { whiteSpace: 'nowrap', minWidth: 'auto' }, onClick: handleExportSubmissions }, `Export ${optionName()} Submissions`),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { size: 'small', startIcon: react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_CloudSync__WEBPACK_IMPORTED_MODULE_12__["default"], null), sx: { whiteSpace: 'nowrap', minWidth: 'auto' }, disabled: !ltiEnabled, onClick: handleSyncSubmission }, "LTI Sync Grades"),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.ToggleButtonGroup, { size: 'small', color: 'primary', value: shownSubmissions, exclusive: true, onChange: switchShownSubmissions, "aria-label": 'shown submissions' },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.ToggleButton, { value: 'none' }, "All"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.ToggleButton, { value: 'latest' }, "Latest"),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.ToggleButton, { value: 'best' }, "Best")),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.IconButton, { "aria-label": 'reload', onClick: ev => switchShownSubmissions(ev, shownSubmissions) },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_13__["default"], null)))))));
}


/***/ }),

/***/ "./lib/components/coursemanage/lecture.js":
/*!************************************************!*\
  !*** ./lib/components/coursemanage/lecture.js ***!
  \************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   LectureComponent: () => (/* binding */ LectureComponent)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _util_dialog__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../util/dialog */ "./lib/components/util/dialog.js");
/* harmony import */ var _services_lectures_service__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../services/lectures.service */ "./lib/services/lectures.service.js");
/* harmony import */ var _mui_material_colors__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @mui/material/colors */ "./node_modules/@mui/material/colors/red.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _services_storage_service__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../services/storage.service */ "./lib/services/storage.service.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _util_table__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/table */ "./lib/components/util/table.js");
/* harmony import */ var _util_deadline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/deadline */ "./lib/components/util/deadline.js");
/* harmony import */ var _mui_icons_material_Close__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @mui/icons-material/Close */ "./node_modules/@mui/icons-material/Close.js");
/* harmony import */ var _mui_icons_material_Search__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @mui/icons-material/Search */ "./node_modules/@mui/icons-material/Search.js");
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../util/dialog-provider */ "./lib/components/util/dialog-provider.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.














const AssignmentTable = (props) => {
    const navigate = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_3__.useNavigate)();
    const headers = [
        { name: 'Name' },
        { name: 'Points', width: 100 },
        { name: 'Deadline', width: 200 },
        { name: 'Status', width: 130 },
        { name: 'Show Details', width: 75 },
        { name: 'Delete Assignment', width: 100 }
    ];
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(react__WEBPACK_IMPORTED_MODULE_1__.Fragment, null,
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_table__WEBPACK_IMPORTED_MODULE_4__.GraderTable, { headers: headers, rows: props.rows, rowFunc: row => {
                return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.TableRow, { key: row.name, component: _util_table__WEBPACK_IMPORTED_MODULE_4__.ButtonTr, onClick: () => navigate(`/lecture/${props.lecture.id}/assignment/${row.id}`) },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.TableCell, { component: 'th', scope: 'row' },
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { variant: 'subtitle2', sx: { fontSize: 16 } }, row.name)),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.TableCell, null, row.points),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.TableCell, null,
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_deadline__WEBPACK_IMPORTED_MODULE_5__.DeadlineComponent, { component: 'chip', due_date: row.due_date, compact: true })),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.TableCell, null, row.status),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.TableCell, null,
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.IconButton, { "aria-label": 'detail view', size: 'small' },
                            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Search__WEBPACK_IMPORTED_MODULE_6__["default"], null))),
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.TableCell, null,
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.IconButton, { "aria-label": 'delete assignment', size: 'small', onClick: (e) => {
                                (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_7__.showDialog)('Delete Assignment', 'Do you wish to delete this assignment?', async () => {
                                    try {
                                        await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_8__.deleteAssignment)(props.lecture.id, row.id);
                                        (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Successfully Deleted Assignment', {
                                            variant: 'success'
                                        });
                                    }
                                    catch (error) {
                                        (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(error.message, {
                                            variant: 'error'
                                        });
                                    }
                                });
                                e.stopPropagation();
                            } },
                            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Close__WEBPACK_IMPORTED_MODULE_9__["default"], { sx: { color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_10__["default"][500] } })))));
            } })));
};
const LectureComponent = () => {
    const { lecture, assignments, users } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_3__.useRouteLoaderData)('lecture');
    const navigation = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_3__.useNavigation)();
    const [lectureState, setLecture] = react__WEBPACK_IMPORTED_MODULE_1__.useState(lecture);
    const [assignmentsState, setAssignments] = react__WEBPACK_IMPORTED_MODULE_1__.useState(assignments);
    const onAssignmentDelete = () => {
        (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_8__.getAllAssignments)(lectureState.id).then(response => {
            setAssignments(response);
        });
        (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_11__.deleteKey)('cm-opened-assignment');
    };
    if (navigation.state === 'loading') {
        return (react__WEBPACK_IMPORTED_MODULE_1__.createElement("div", null,
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Card, null,
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.LinearProgress, null))));
    }
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'column', sx: { m: 5 } },
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { variant: 'h4', sx: { mr: 2 } },
            lectureState.name,
            lectureState.complete ? (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: {
                    display: 'inline-block',
                    ml: 0.75,
                    fontSize: 16,
                    color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_10__["default"][400]
                } }, "complete")) : null),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, { direction: 'row', justifyContent: 'flex-end', alignItems: 'center', spacing: 2, sx: { mb: 1 } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_dialog__WEBPACK_IMPORTED_MODULE_12__.CreateDialog, { lecture: lectureState, handleSubmit: assigment => {
                    setAssignments((oldAssignments) => [
                        ...oldAssignments,
                        assigment
                    ]);
                } }),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_dialog__WEBPACK_IMPORTED_MODULE_12__.EditLectureDialog, { lecture: lectureState, handleSubmit: updatedLecture => {
                    (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_13__.updateLecture)(updatedLecture).then(response => {
                        setLecture(response);
                    }, error => {
                        (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(error.message, {
                            variant: 'error'
                        });
                    });
                } })),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stack, null,
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { variant: 'h6' }, "Assignments")),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(AssignmentTable, { lecture: lectureState, rows: assignmentsState })));
};


/***/ }),

/***/ "./lib/components/coursemanage/overview/assignment-status.js":
/*!*******************************************************************!*\
  !*** ./lib/components/coursemanage/overview/assignment-status.js ***!
  \*******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AssignmentStatus: () => (/* binding */ AssignmentStatus)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_icons_material_NewReleasesRounded__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @mui/icons-material/NewReleasesRounded */ "./node_modules/@mui/icons-material/NewReleasesRounded.js");
/* harmony import */ var _mui_icons_material_Task__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/icons-material/Task */ "./node_modules/@mui/icons-material/Task.js");
/* harmony import */ var _mui_icons_material_Undo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @mui/icons-material/Undo */ "./node_modules/@mui/icons-material/Undo.js");
/* harmony import */ var _mui_icons_material_Terminal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/icons-material/Terminal */ "./node_modules/@mui/icons-material/Terminal.js");
/* harmony import */ var _util_dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../util/dialog */ "./lib/components/util/dialog.js");
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _util_deadline__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../util/deadline */ "./lib/components/util/deadline.js");
/* harmony import */ var _util_dialog_provider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../util/dialog-provider */ "./lib/components/util/dialog-provider.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.











/**
 * Calculates step of stepper based on assignment status
 * @param status assignment status
 */
const getActiveStep = (status) => {
    switch (status) {
        case 'created':
            return 0;
        case 'pushed':
            return 0;
        case 'released':
            return 1;
        case 'complete':
            return 2;
    }
};
/**
 * Renders the assignment status and instructions for the end user.
 * @param props props of assignment status
 */
const AssignmentStatus = (props) => {
    const [assignment, setAssignment] = react__WEBPACK_IMPORTED_MODULE_1__.useState(props.assignment);
    /**
     * Updates assignment status.
     * @param status assignment status
     * @param success alert color if successful
     * @param error alert color if not successful
     */
    const updateAssignmentStatus = async (status, success, error) => {
        try {
            let a = assignment;
            a.status = status;
            a = await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_3__.updateAssignment)(props.lecture.id, a);
            setAssignment(a);
            props.onAssignmentChange(a);
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(success, {
                variant: 'success'
            });
        }
        catch (err) {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)(error, {
                variant: 'error'
            });
        }
    };
    /**
     * Handles assignment status change to "released" status
     */
    const handleReleaseAssignment = async () => {
        await updateAssignmentStatus('released', 'Successfully Released Assignment', 'Error Releasing Assignment');
    };
    /**
     * Handles assignment status change to "pushed" status
     */
    const handlePushAssignment = async (commitMessage) => {
        try {
            // Note: has to be in this order (release -> source)
            await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_3__.pushAssignment)(props.lecture.id, assignment.id, 'release');
            await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_3__.pushAssignment)(props.lecture.id, assignment.id, 'source', commitMessage);
        }
        catch (err) {
            (0,notistack__WEBPACK_IMPORTED_MODULE_2__.enqueueSnackbar)('Error Pushing Assignment', {
                variant: 'error'
            });
            return;
        }
        await updateAssignmentStatus('pushed', 'Successfully Pushed Assignment', 'Error Updating Assignment');
    };
    const fontSize = 16;
    const steps = [
        {
            label: 'Edit',
            description: (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, null,
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { fontSize } },
                    "The assignment has been created and files can now be added to be pushed. You can commit and pull changes from the remote file repository through the file view or can work directly with the underlying git repositories by opening the assignment in the terminal (",
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Terminal__WEBPACK_IMPORTED_MODULE_4__["default"], { color: 'primary', fontSize: 'inherit' }),
                    "). After you are done working on the files you can release the assignment, which makes a final commit with the current state of the assignment."),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_dialog__WEBPACK_IMPORTED_MODULE_5__.ReleaseDialog, { assignment: assignment, handleCommit: handlePushAssignment, handleRelease: handleReleaseAssignment },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Tooltip, { title: 'Release Assignment for Students' },
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { sx: { mt: 1 }, variant: 'outlined', size: 'small' },
                            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_NewReleasesRounded__WEBPACK_IMPORTED_MODULE_6__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                            "Release")))))
        },
        {
            label: 'Released',
            description: (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, null,
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { fontSize } }, "The assignment has been released to students and it is not advised to push further changes to the repository. If the assignment is over you can mark it as complete in the edit menu or right here. Undoing the release of the assignment will hide the assignment from students again but their local files are unaffected by this action. When re-releasing the assignment after significant changes a new commit will be made and you will have to instruct users to reset their progress thus far or work with separate versions later on."),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Tooltip, { title: 'Hide Released Assignment from Students' },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { sx: { mt: 1, mr: 1 }, onClick: () => updateAssignmentStatus('pushed', 'Successfully Revoked Assignment', 'Error Revoking Assignment'), variant: 'outlined', size: 'small' },
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Undo__WEBPACK_IMPORTED_MODULE_7__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                        "Undo Release")),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Tooltip, { title: 'Mark Assignment as Complete' },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { sx: { mt: 1 }, onClick: () => completeAssignment(), variant: 'outlined', size: 'small' },
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Task__WEBPACK_IMPORTED_MODULE_8__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                        "Complete"))))
        },
        {
            label: 'Assignment Completed',
            description: (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, null,
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { fontSize } }, "The assignment has been completed and is not visible to students anymore but all their progress will be saved. When re-activating the assignment it will again show up in the assignment view and new submissions can be made given the deadline is set accordingly."),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Tooltip, { title: 'Undo Complete and Release Assignment' },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Button, { sx: { mt: 1 }, onClick: () => updateAssignmentStatus('released', 'Successfully Released Assignment', 'Error Releasing Assignment'), variant: 'outlined', size: 'small' },
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Undo__WEBPACK_IMPORTED_MODULE_7__["default"], { fontSize: 'small', sx: { mr: 1 } }),
                        "Undo Complete"))))
        }
    ];
    /**
     * Handles assignment status change to "complete" status
     */
    const completeAssignment = async () => {
        (0,_util_dialog_provider__WEBPACK_IMPORTED_MODULE_9__.showDialog)('Complete Assignment', `Do you want to mark ${assignment.name} as complete? This action will hide the assignment for all students!`, async () => {
            await updateAssignmentStatus('complete', 'Successfully Updated Assignment', 'Error Updating Assignment');
        });
    };
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: {
            alignItems: { xs: 'center' },
            minWidth: '150px',
            overflowY: 'auto'
        } },
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { fontSize: 24 }, " Overview "),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Stepper, { activeStep: getActiveStep(assignment.status), orientation: 'vertical' }, steps.map((step, index) => (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Step, { key: step.label },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.StepLabel, { optional: index === 2 ? (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { variant: 'caption' }, "Last step")) : null }, step.label),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.StepContent, null,
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, null, steps[getActiveStep(assignment.status)].description)))))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { mt: 5, fontSize: 24 } }, " Deadline "),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_deadline__WEBPACK_IMPORTED_MODULE_10__.DeadlineComponent, { due_date: props.assignment.due_date, compact: false, component: 'chip', sx: { mt: 2 } })));
};


/***/ }),

/***/ "./lib/components/coursemanage/overview/overview-card.js":
/*!***************************************************************!*\
  !*** ./lib/components/coursemanage/overview/overview-card.js ***!
  \***************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   OverviewCard: () => (/* binding */ OverviewCard)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _model_assignment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../model/assignment */ "./lib/model/assignment.js");
/* harmony import */ var _mui_icons_material_Group__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/icons-material/Group */ "./node_modules/@mui/icons-material/Group.js");
/* harmony import */ var _mui_icons_material_Checklist__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/icons-material/Checklist */ "./node_modules/@mui/icons-material/Checklist.js");
/* harmony import */ var _mui_icons_material_Grade__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @mui/icons-material/Grade */ "./node_modules/@mui/icons-material/Grade.js");
/* harmony import */ var _mui_icons_material_QuestionMark__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @mui/icons-material/QuestionMark */ "./node_modules/@mui/icons-material/QuestionMark.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.







const OverviewCard = (props) => {
    let gradingBehaviour = 'No Automatic Grading';
    if (props.assignment.automatic_grading === _model_assignment__WEBPACK_IMPORTED_MODULE_2__.Assignment.AutomaticGradingEnum.Auto) {
        gradingBehaviour = 'Automatic Grading';
    }
    else if (props.assignment.automatic_grading ===
        _model_assignment__WEBPACK_IMPORTED_MODULE_2__.Assignment.AutomaticGradingEnum.FullAuto) {
        gradingBehaviour = 'Fully Automatic Grading';
    }
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Grid, { container: true, spacing: 2 },
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Grid, { item: true, xs: 6 },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Paper, { elevation: 3, sx: {
                    height: "205px",
                    textAlign: "center",
                    overflowY: 'auto',
                    padding: "10px"
                } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { textAlign: "left", fontSize: 24 } }, "Students"),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Group__WEBPACK_IMPORTED_MODULE_3__["default"], { color: "primary", sx: { fontSize: 80, ml: 1 } }),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { textAlign: "left", mr: 0.5, ml: 0.5 } }, 'Overall number of students in this lecture: ' + props.users?.students.length))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Grid, { item: true, xs: 6 },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Paper, { elevation: 3, sx: {
                    height: "205px",
                    textAlign: "center",
                    overflowY: 'auto',
                    padding: "10px"
                } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { textAlign: "left", fontSize: 24 } }, "Submissions"),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Checklist__WEBPACK_IMPORTED_MODULE_4__["default"], { color: "primary", sx: { fontSize: 80, ml: 1 } }),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { textAlign: "left", mr: 0.5, ml: 0.5 } }, 'Total number of submissions: ' + props.allSubmissions.length))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Grid, { item: true, xs: 12 },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Divider, null)),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Grid, { item: true, xs: 6 },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Paper, { elevation: 3, sx: {
                    height: "205px",
                    textAlign: "center",
                    overflowY: 'auto',
                    padding: "10px"
                } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { textAlign: "left", fontSize: 24 } }, "Grading behaviour"),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Grade__WEBPACK_IMPORTED_MODULE_5__["default"], { color: "primary", sx: { fontSize: 80, ml: 1 } }),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { mr: 0.5, ml: 0.5 } }, gradingBehaviour))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Grid, { item: true, xs: 6 },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Paper, { elevation: 3, sx: {
                    height: "205px",
                    textAlign: "center",
                    overflowY: 'auto',
                    padding: "10px"
                } },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { textAlign: "left", fontSize: 24 } }, "Assignment type"),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_QuestionMark__WEBPACK_IMPORTED_MODULE_6__["default"], { color: "primary", sx: { fontSize: 80, ml: 1 } }),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { sx: { mr: 0.5, ml: 0.5 } }, props.assignment.type === 'user' ? 'User' : 'Group')))));
};


/***/ }),

/***/ "./lib/components/coursemanage/overview/overview.js":
/*!**********************************************************!*\
  !*** ./lib/components/coursemanage/overview/overview.js ***!
  \**********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   OverviewComponent: () => (/* binding */ OverviewComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _util_section_title__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../util/section-title */ "./lib/components/util/section-title.js");
/* harmony import */ var _overview_card__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./overview-card */ "./lib/components/coursemanage/overview/overview-card.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _assignment_status__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./assignment-status */ "./lib/components/coursemanage/overview/assignment-status.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.






const OverviewComponent = () => {
    const { lecture, assignments, users } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('lecture');
    const { assignment, allSubmissions, latestSubmissions } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('assignment');
    const [assignmentState, setAssignmentState] = react__WEBPACK_IMPORTED_MODULE_0__.useState(assignment);
    const onAssignmentChange = (assignment) => {
        setAssignmentState(assignment);
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_section_title__WEBPACK_IMPORTED_MODULE_3__.SectionTitle, { title: assignmentState.name }),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { ml: 3, mr: 3, mb: 3, mt: 3 } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { container: true, spacing: 3 },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true, md: 12, xs: 7, lg: 6, xl: 7 },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_assignment_status__WEBPACK_IMPORTED_MODULE_4__.AssignmentStatus, { lecture: lecture, assignment: assignmentState, onAssignmentChange: onAssignmentChange })),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true, md: 12, xs: 12, lg: 6, xl: 5 },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_overview_card__WEBPACK_IMPORTED_MODULE_5__.OverviewCard, { lecture: lecture, assignment: assignmentState, allSubmissions: allSubmissions, latestSubmissions: latestSubmissions, users: users }))))));
};


/***/ }),

/***/ "./lib/components/coursemanage/overview/util.js":
/*!******************************************************!*\
  !*** ./lib/components/coursemanage/overview/util.js ***!
  \******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   openBrowser: () => (/* binding */ openBrowser),
/* harmony export */   openTerminal: () => (/* binding */ openTerminal)
/* harmony export */ });
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../index */ "./lib/index.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_0__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.


let terminalSession = null;
const openTerminal = async (path) => {
    console.log('Opening terminal at: ' + path.replace(' ', '\\ '));
    let args = {};
    if (terminalSession !== null &&
        terminalSession.connectionStatus === 'connected') {
        args = { name: terminalSession.name };
    }
    const main = (await _index__WEBPACK_IMPORTED_MODULE_1__.GlobalObjects.commands.execute('terminal:open', args));
    if (main) {
        const terminal = main.content;
        terminalSession = terminal.session;
    }
    try {
        terminalSession.send({
            type: 'stdin',
            content: ['cd ' + path.replace(' ', '\\ ') + '\n']
        });
    }
    catch (e) {
        (0,notistack__WEBPACK_IMPORTED_MODULE_0__.enqueueSnackbar)('Error Opening Terminal', {
            variant: 'error'
        });
        main.dispose();
    }
};
const openBrowser = async (path) => {
    _index__WEBPACK_IMPORTED_MODULE_1__.GlobalObjects.commands
        .execute('filebrowser:go-to-path', {
        path
    })
        .catch(e => {
        (0,notistack__WEBPACK_IMPORTED_MODULE_0__.enqueueSnackbar)(e.message, {
            variant: 'error'
        });
    });
};


/***/ }),

/***/ "./lib/components/coursemanage/routes.js":
/*!***********************************************!*\
  !*** ./lib/components/coursemanage/routes.js ***!
  \***********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   getRoutes: () => (/* binding */ getRoutes)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material_Box__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/material/Box */ "./node_modules/@mui/material/Box/Box.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _util_breadcrumbs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../util/breadcrumbs */ "./lib/components/util/breadcrumbs.js");
/* harmony import */ var _util_error__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../util/error */ "./lib/components/util/error.js");
/* harmony import */ var _coursemanage_component__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./coursemanage.component */ "./lib/components/coursemanage/coursemanage.component.js");
/* harmony import */ var _services_permission_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../services/permission.service */ "./lib/services/permission.service.js");
/* harmony import */ var _services_lectures_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../services/lectures.service */ "./lib/services/lectures.service.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _lecture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./lecture */ "./lib/components/coursemanage/lecture.js");
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var _assignment_modal__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./assignment-modal */ "./lib/components/coursemanage/assignment-modal.js");
/* harmony import */ var _overview_overview__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./overview/overview */ "./lib/components/coursemanage/overview/overview.js");
/* harmony import */ var _grading_grading__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grading/grading */ "./lib/components/coursemanage/grading/grading.js");
/* harmony import */ var _stats_stats__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./stats/stats */ "./lib/components/coursemanage/stats/stats.js");
/* harmony import */ var _settings_settings__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./settings/settings */ "./lib/components/coursemanage/settings/settings.js");
/* harmony import */ var _files_file_view__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./files/file-view */ "./lib/components/coursemanage/files/file-view.js");
/* harmony import */ var _grading_manual_grading__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./grading/manual-grading */ "./lib/components/coursemanage/grading/manual-grading.js");
/* harmony import */ var _grading_edit_submission__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./grading/edit-submission */ "./lib/components/coursemanage/grading/edit-submission.js");
/* harmony import */ var _grading_create_submission__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./grading/create-submission */ "./lib/components/coursemanage/grading/create-submission.js");






















const loadPermissions = async () => {
    try {
        await _services_permission_service__WEBPACK_IMPORTED_MODULE_4__.UserPermissions.loadPermissions();
        const [lectures, completedLectures] = await Promise.all([
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_5__.getAllLectures)(),
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_5__.getAllLectures)(true)
        ]);
        return { lectures, completedLectures };
    }
    catch (error) {
        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        });
        throw new Error("Could not load data!");
    }
};
const loadLecture = async (lectureId) => {
    try {
        const [lecture, assignments, users] = await Promise.all([
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_5__.getLecture)(lectureId),
            (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_6__.getAllAssignments)(lectureId),
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_5__.getUsers)(lectureId)
        ]);
        return { lecture, assignments, users };
    }
    catch (error) {
        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        });
        throw new Error("Could not load data!");
    }
};
const loadAssignment = async (lectureId, assignmentId) => {
    try {
        const [assignment, allSubmissions, latestSubmissions] = await Promise.all([
            (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_6__.getAssignment)(lectureId, assignmentId),
            (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_7__.getAllSubmissions)(lectureId, assignmentId, 'none', true),
            (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_7__.getAllSubmissions)(lectureId, assignmentId, 'latest', true)
        ]);
        return { assignment, allSubmissions, latestSubmissions };
    }
    catch (error) {
        (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
            variant: 'error'
        });
        throw new Error("Could not load data!");
    }
};
function ExamplePage({ to }) {
    const navigation = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useNavigation)(); // router navigates to new route (and loads data)
    const loading = navigation.state === 'loading';
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Box__WEBPACK_IMPORTED_MODULE_8__["default"], null,
        !loading ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, null, "This is an example page where the link below can be used for naviagation.")) : (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, null, "Loading...")),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, "Next Page: "),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_breadcrumbs__WEBPACK_IMPORTED_MODULE_9__.LinkRouter, { underline: 'hover', color: 'inherit', to: to, key: to }, to)));
}
const getRoutes = () => {
    const routes = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.createRoutesFromElements)(
    // this is a layout route without a path (see: https://reactrouter.com/en/main/start/concepts#layout-routes)
    react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_breadcrumbs__WEBPACK_IMPORTED_MODULE_9__.Page, { id: 'course-manage' }), errorElement: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_error__WEBPACK_IMPORTED_MODULE_10__["default"], { id: 'course-manage' }) },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { id: 'root', path: '/*', loader: loadPermissions, handle: {
                crumb: (data) => 'Lectures',
                link: (params) => '/'
            } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { index: true, element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_coursemanage_component__WEBPACK_IMPORTED_MODULE_11__.CourseManageComponent, null) }),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { id: 'lecture', path: 'lecture/:lid/*', loader: ({ params }) => loadLecture(+params.lid), handle: {
                    // functions in handle have to handle undefined data (error page is displayed afterwards)
                    crumb: (data) => data?.lecture.name,
                    link: (params) => `lecture/${params?.lid}/`
                } },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { index: true, element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_lecture__WEBPACK_IMPORTED_MODULE_12__.LectureComponent, null) }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { id: 'assignment', path: 'assignment/:aid/*', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_assignment_modal__WEBPACK_IMPORTED_MODULE_13__.AssignmentModalComponent, null), loader: ({ params }) => loadAssignment(+params.lid, +params.aid), handle: {
                        // functions in handle have to handle undefined data (error page is displayed afterwards)
                        crumb: (data) => data?.assignment.name,
                        link: (params) => `assignment/${params.aid}/`
                    } },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { index: true, path: '', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_overview_overview__WEBPACK_IMPORTED_MODULE_14__.OverviewComponent, null), handle: {
                            crumb: (data) => 'Overview',
                            link: (params) => ''
                        } }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { path: 'files', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_files_file_view__WEBPACK_IMPORTED_MODULE_15__.FileView, null), handle: {
                            crumb: (data) => 'Files',
                            link: (params) => 'files/'
                        } }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { id: 'submissions/*', path: 'submissions', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_grading_grading__WEBPACK_IMPORTED_MODULE_16__.GradingComponent, null), handle: {
                            crumb: (data) => 'Submissions',
                            link: (params) => 'submissions/'
                        } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { index: true, path: '', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_grading_grading__WEBPACK_IMPORTED_MODULE_16__["default"], null) }),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { path: 'manual', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_grading_manual_grading__WEBPACK_IMPORTED_MODULE_17__.ManualGrading, null), handle: {
                                crumb: (data) => 'Grading View',
                                link: (params) => `manual/`
                            } }),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { path: 'edit', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_grading_edit_submission__WEBPACK_IMPORTED_MODULE_18__.EditSubmission, null), handle: {
                                crumb: (data) => 'Edit Submission',
                                link: (params) => `edit/`
                            } }),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { path: 'create', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_grading_create_submission__WEBPACK_IMPORTED_MODULE_19__.CreateSubmission, null), handle: {
                                crumb: (data) => 'Create Submission',
                                link: (params) => `create/`
                            } })),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { path: 'stats', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_stats_stats__WEBPACK_IMPORTED_MODULE_20__.StatsComponent, null), handle: {
                            crumb: (data) => 'Stats',
                            link: (params) => 'stats/'
                        } }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Route, { path: 'settings', element: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_settings_settings__WEBPACK_IMPORTED_MODULE_21__.SettingsComponent, null), handle: {
                            crumb: (data) => 'Settings',
                            link: (params) => 'settings/'
                        } }))))));
    return routes;
};


/***/ }),

/***/ "./lib/components/coursemanage/settings/settings.js":
/*!**********************************************************!*\
  !*** ./lib/components/coursemanage/settings/settings.js ***!
  \**********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   SettingsComponent: () => (/* binding */ SettingsComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var formik__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! formik */ "webpack/sharing/consume/default/formik/formik");
/* harmony import */ var formik__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(formik__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_x_date_pickers_LocalizationProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/x-date-pickers/LocalizationProvider */ "./node_modules/@mui/x-date-pickers/LocalizationProvider/LocalizationProvider.js");
/* harmony import */ var _mui_x_date_pickers_AdapterDateFns__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @mui/x-date-pickers/AdapterDateFns */ "./node_modules/@mui/x-date-pickers/AdapterDateFns/AdapterDateFns.js");
/* harmony import */ var _mui_x_date_pickers_DateTimePicker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @mui/x-date-pickers/DateTimePicker */ "./node_modules/@mui/x-date-pickers/DateTimePicker/DateTimePicker.js");
/* harmony import */ var _mui_icons_material_HelpOutlineOutlined__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @mui/icons-material/HelpOutlineOutlined */ "./node_modules/@mui/icons-material/HelpOutlineOutlined.js");
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var yup__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! yup */ "webpack/sharing/consume/default/yup/yup");
/* harmony import */ var yup__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(yup__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _util_section_title__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../util/section-title */ "./lib/components/util/section-title.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_5__);












const gradingBehaviourHelp = `Specifies the behaviour when a students submits an assignment.\n
No Automatic Grading: No action is taken on submit.\n
Automatic Grading: The assignment is being autograded as soon as the students makes a submission.\n
Fully Automatic Grading: The assignment is autograded and feedback is generated as soon as the student makes a submission. 
(requires all scores to be based on autograde results)`;
const validationSchema = yup__WEBPACK_IMPORTED_MODULE_4__.object({
    name: yup__WEBPACK_IMPORTED_MODULE_4__.string()
        .min(4, 'Name should be 4-50 character length')
        .max(50, 'Name should be 4-50 character length')
        .required('Name is required'),
    due_date: yup__WEBPACK_IMPORTED_MODULE_4__.date()
        .min(new Date(), 'Deadline must be set in the future')
        .nullable(),
    type: yup__WEBPACK_IMPORTED_MODULE_4__.mixed().oneOf(['user', 'group']),
    automatic_grading: yup__WEBPACK_IMPORTED_MODULE_4__.mixed().oneOf(['unassisted', 'auto', 'full_auto']),
    max_submissions: yup__WEBPACK_IMPORTED_MODULE_4__.number()
        .nullable()
        .min(1, 'Students must be able to at least submit once')
});
//export interface ISettingsProps {
//  root: HTMLElement;
//}
const SettingsComponent = () => {
    const { lecture, assignments } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_5__.useRouteLoaderData)('lecture');
    const { assignment, allSubmissions, latestSubmissions } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_5__.useRouteLoaderData)('assignment');
    const [checked, setChecked] = react__WEBPACK_IMPORTED_MODULE_0__.useState(assignment.due_date !== null);
    const [checkedLimit, setCheckedLimit] = react__WEBPACK_IMPORTED_MODULE_0__.useState(Boolean(assignment.max_submissions));
    const formik = (0,formik__WEBPACK_IMPORTED_MODULE_1__.useFormik)({
        initialValues: {
            name: assignment.name,
            due_date: assignment.due_date !== null
                ? new Date(assignment.due_date)
                : null,
            type: assignment.type,
            automatic_grading: assignment.automatic_grading,
            max_submissions: assignment.max_submissions || null,
            allow_files: assignment.allow_files || false
        },
        validationSchema: validationSchema,
        onSubmit: values => {
            if (values.max_submissions !== null) {
                values.max_submissions = +values.max_submissions;
            }
            const updatedAssignment = Object.assign(assignment, values);
            (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_6__.updateAssignment)(lecture.id, updatedAssignment).then(response => {
                (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)('Successfully Updated Assignment', {
                    variant: 'success'
                });
            }, (error) => {
                (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)(error.message, {
                    variant: 'error'
                });
            });
        }
    });
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Box, { ml: '50px', mr: '50px' },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_section_title__WEBPACK_IMPORTED_MODULE_7__.SectionTitle, { title: "Settings" }),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement("form", { onSubmit: formik.handleSubmit },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, { spacing: 2, sx: { ml: 2, mr: 2 } },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TextField, { variant: "outlined", fullWidth: true, id: "name", name: "name", label: "Assignment Name", value: formik.values.name, onChange: formik.handleChange, error: formik.touched.name && Boolean(formik.errors.name), helperText: formik.touched.name && formik.errors.name }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_x_date_pickers_LocalizationProvider__WEBPACK_IMPORTED_MODULE_8__.LocalizationProvider, { dateAdapter: _mui_x_date_pickers_AdapterDateFns__WEBPACK_IMPORTED_MODULE_9__.AdapterDateFns },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Checkbox, { checked: checked, onChange: async (e) => {
                                setChecked(e.target.checked);
                                if (!e.target.checked) {
                                    await formik.setFieldValue('due_date', null);
                                }
                                else {
                                    await formik.setFieldValue('due_date', new Date());
                                }
                            } }), label: "Set Deadline" }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_x_date_pickers_DateTimePicker__WEBPACK_IMPORTED_MODULE_10__.DateTimePicker, { ampm: false, disabled: !checked, label: "DateTimePicker", disablePast: true, value: formik.values.due_date, onChange: (date) => {
                            formik.setFieldValue('due_date', date);
                        } })),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Checkbox, { checked: checkedLimit, onChange: async (e) => {
                            setCheckedLimit(e.target.checked);
                            if (!e.target.checked) {
                                await formik.setFieldValue('max_submissions', null);
                            }
                            else {
                                await formik.setFieldValue('max_submissions', 1);
                            }
                        } }), label: "Limit Number of Submissions" }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TextField, { variant: "outlined", fullWidth: true, disabled: !checkedLimit, type: 'number', id: "max-submissions", name: "max_submissions", placeholder: "Submissions", value: formik.values.max_submissions || null, InputProps: { inputProps: { min: 1 } }, onChange: e => {
                        formik.setFieldValue('max_submissions', +e.target.value);
                    }, helperText: formik.touched.max_submissions && formik.errors.max_submissions, error: Boolean(formik.values.max_submissions) &&
                        formik.values.max_submissions < 1 }),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.InputLabel, { id: "demo-simple-select-label-auto" },
                    "Auto-Grading Behaviour",
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Tooltip, { title: gradingBehaviourHelp },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_HelpOutlineOutlined__WEBPACK_IMPORTED_MODULE_11__["default"], { fontSize: 'small', sx: { ml: 1.5, mt: 1.0 } }))),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.TextField, { select: true, id: "assignment-type-select", value: formik.values.automatic_grading, label: "Auto-Grading Behaviour", placeholder: "Grading", onChange: e => {
                        formik.setFieldValue('automatic_grading', e.target.value);
                    } },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.MenuItem, { value: 'auto' }, "Automatic Grading"),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.MenuItem, { value: 'full_auto' }, "Fully Automatic Grading"),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.MenuItem, { value: 'unassisted' }, "No Automatic Grading")),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Checkbox, { checked: formik.values.allow_files, onChange: async (e) => {
                            console.log(e.target.checked);
                            await formik.setFieldValue('allow_files', e.target.checked);
                        } }), label: "Allow file upload by students" })),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Button, { color: "primary", variant: "contained", type: "submit" }, "Save changes"))));
};


/***/ }),

/***/ "./lib/components/coursemanage/stats/assignment-score.js":
/*!***************************************************************!*\
  !*** ./lib/components/coursemanage/stats/assignment-score.js ***!
  \***************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AssignmentScore: () => (/* binding */ AssignmentScore)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! recharts */ "webpack/sharing/consume/default/recharts/recharts");
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(recharts__WEBPACK_IMPORTED_MODULE_2__);



const AssignmentScoreTooltip = ({ active, payload, label }) => {
    if (active && payload && payload.length) {
        return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { className: "custom-tooltip" },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", { className: "recharts-tooltip-label" },
                react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", null, "File: "),
                react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", { style: { color: payload[0].payload.fill } }, payload[0].payload.notebook)),
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", { className: "recharts-tooltip-label" }, `${payload[0].value} Point${payload[0].value === 1 ? '' : 's'}`)));
    }
    return null;
};
const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042'];
const getData = (gb) => {
    if (gb === null) {
        return [];
    }
    return gb.getNotebooks().map((n, i) => {
        return {
            notebook: n,
            points: gb.getNotebookMaxPointsCells(n),
            fill: COLORS[i % COLORS.length]
        };
    });
};
const AssignmentScore = (props) => {
    const [data, setData] = react__WEBPACK_IMPORTED_MODULE_0___default().useState([]);
    react__WEBPACK_IMPORTED_MODULE_0___default().useEffect(() => {
        const d = getData(props.gb);
        setData(d);
    }, [props.gb]);
    return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Card, { sx: { height: 300, width: '100%' } },
        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardHeader, { sx: { pb: 0 }, title: 'Total Points', subheader: 'by notebooks', subheaderTypographyProps: { variant: 'caption' } }),
        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardContent, { sx: {
                height: '70%'
            } },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { height: '100%' } },
                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.ResponsiveContainer, { width: "100%", height: "100%" },
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.PieChart, { cx: "50%", cy: "50%" },
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement("text", { fontSize: 40, x: '50%', y: '50%', dy: 12, textAnchor: "middle" }, `${data.reduce((acc, v) => acc + v.points, 0).toFixed(2)}`),
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.Tooltip, { content: react__WEBPACK_IMPORTED_MODULE_0___default().createElement(AssignmentScoreTooltip, null) }),
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.Pie, { data: data, dataKey: "points", nameKey: "notebook", innerRadius: '65%', outerRadius: '80%', paddingAngle: 5 })))))));
};


/***/ }),

/***/ "./lib/components/coursemanage/stats/grading-progress.js":
/*!***************************************************************!*\
  !*** ./lib/components/coursemanage/stats/grading-progress.js ***!
  \***************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GradingProgress: () => (/* binding */ GradingProgress)
/* harmony export */ });
/* harmony import */ var _stats__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stats */ "./lib/components/coursemanage/stats/stats.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! recharts */ "webpack/sharing/consume/default/recharts/recharts");
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(recharts__WEBPACK_IMPORTED_MODULE_2__);




const GradingProgressTooltip = ({ active, payload, label }) => {
    if (active && payload && payload.length) {
        const action = payload[0].payload.name === 'Feedback' ? 'Generated' : 'Graded';
        return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { className: "custom-tooltip" },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", { className: "recharts-tooltip-label", style: { color: payload[0].payload.fill } }, payload[0].payload.name),
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", { className: "recharts-tooltip-label" }, `${(+payload[0].value * 100).toFixed(0)}% ${action}`)));
    }
    return null;
};
const getData = (submissions, users) => {
    if (users === null) {
        return { auto: 0, manual: 0, feedback: 0 };
    }
    const subs = (0,_stats__WEBPACK_IMPORTED_MODULE_3__.filterUserSubmissions)(submissions, users.instructors.concat(users.tutors));
    const totalCounts = subs.reduce((acc, v) => {
        if (v.auto_status === 'automatically_graded') {
            acc.a++;
        }
        if (v.manual_status === 'manually_graded') {
            acc.m++;
        }
        if (v.feedback_available) {
            acc.f++;
        }
        return acc;
    }, { a: 0, m: 0, f: 0 });
    // return {auto: 0.7, manual: 0.5, feedback: 0.2}
    if (subs.length === 0) {
        return { auto: 0, manual: 0, feedback: 0 };
    }
    // we assume latest submissions only so subs only contains unique users
    return {
        auto: totalCounts.a / subs.length,
        manual: totalCounts.m / subs.length,
        feedback: totalCounts.f / subs.length
    };
};
const GradingProgress = (props) => {
    const [data, setData] = react__WEBPACK_IMPORTED_MODULE_0___default().useState([]);
    react__WEBPACK_IMPORTED_MODULE_0___default().useEffect(() => {
        const d = getData(props.latestSubmissions, props.users);
        const a = [
            { name: 'Feedback', value: d.feedback, fill: '#00C49F' },
            { name: 'Manual', value: d.manual, fill: '#0088FE' },
            { name: 'Auto', value: d.auto, fill: '#FFBB28' }
        ];
        setData(a);
    }, [props.latestSubmissions, props.users]);
    return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Card, { sx: { height: 300, width: '100%' } },
        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardHeader, { sx: { pb: 0 }, title: 'Grading Status', subheader: 'as % of latest student submissions', subheaderTypographyProps: { variant: 'caption' } }),
        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardContent, { sx: {
                height: '70%'
            } },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { height: '100%' } },
                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.ResponsiveContainer, { width: "100%", height: "100%" },
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.RadialBarChart, { cx: "50%", cy: "50%", innerRadius: "30%", outerRadius: "90%", barSize: 15, data: data },
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.PolarAngleAxis, { type: "number", domain: [0, 1], angleAxisId: 0, tick: false }),
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.RadialBar, { background: true, dataKey: "value", angleAxisId: 0 }),
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.Tooltip, { content: react__WEBPACK_IMPORTED_MODULE_0___default().createElement(GradingProgressTooltip, null) }),
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.Legend, { layout: "horizontal", verticalAlign: "bottom", align: "center" })))))));
};


/***/ }),

/***/ "./lib/components/coursemanage/stats/score-distribution.js":
/*!*****************************************************************!*\
  !*** ./lib/components/coursemanage/stats/score-distribution.js ***!
  \*****************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ScoreDistribution: () => (/* binding */ ScoreDistribution)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! recharts */ "webpack/sharing/consume/default/recharts/recharts");
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(recharts__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _services_storage_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../services/storage.service */ "./lib/services/storage.service.js");




const binData = (data, min, max, numBuckets) => {
    if (max <= 0.0) {
        return [];
    }
    const bucketSize = (max - min) / numBuckets;
    let currBucket = min;
    const buckets = new Array(numBuckets).fill(0).map(v => {
        return {
            start: currBucket,
            end: (currBucket += bucketSize),
            count: v
        };
    });
    for (const v of data) {
        let bucketIndex = Math.floor((v - min) / bucketSize);
        bucketIndex = Math.min(bucketIndex, numBuckets - 1);
        buckets[bucketIndex].count++;
    }
    return buckets;
};
const getData = (submissions, assignment, numBuckets) => {
    const getBaseLog = (x, y) => Math.log(y) / Math.log(x);
    let decimalPlaces = -Math.floor(getBaseLog(10, assignment.points / numBuckets)) + 1;
    decimalPlaces = Math.max(decimalPlaces, 0);
    decimalPlaces = Math.min(decimalPlaces, 3);
    const data = submissions.map(s => s.score || 0);
    const buckets = binData(data, 0, assignment.points, numBuckets);
    return buckets.map(v => {
        return {
            name: `${v.start.toFixed(decimalPlaces)}-${v.end.toFixed(decimalPlaces)}`,
            count: v.count
        };
    });
};
const ScoreDistributionTooltip = ({ active, payload, label }) => {
    if (active && payload && payload.length) {
        return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { className: "custom-tooltip" },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", { className: "recharts-tooltip-label", style: { color: '#0088FE' } }, payload[0].payload.name + ' Points'),
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", { className: "recharts-tooltip-label" }, `${payload[0].value} Submission${payload[0].value === 1 ? '' : 's'}`)));
    }
    return null;
};
const ScoreDistribution = (props) => {
    const [data, setData] = react__WEBPACK_IMPORTED_MODULE_0___default().useState([]);
    const startBuckets = (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_3__.loadNumber)('score-buckets', null, props.assignment) || 10;
    react__WEBPACK_IMPORTED_MODULE_0___default().useEffect(() => {
        const d = getData(props.latestSubmissions, props.assignment, startBuckets);
        setData(d);
    }, [props.latestSubmissions, props.assignment]);
    return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Card, { sx: { height: 300, width: '100%' } },
        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardHeader, { title: 'Distribution of Scores', action: react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TextField, { id: "outlined-number", size: "small", margin: "dense", InputProps: {
                    inputProps: {
                        min: 1,
                        max: Math.max(Math.floor(props.assignment.points), 20)
                    }
                }, defaultValue: startBuckets, onChange: v => {
                    setData(getData(props.latestSubmissions, props.assignment, +v.target.value));
                    (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_3__.storeNumber)('score-buckets', +v.target.value, null, props.assignment);
                }, label: "Buckets", type: "number", InputLabelProps: {
                    shrink: true
                } }) }),
        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardContent, { sx: {
                height: '70%'
            } }, data.reduce((acc, v) => acc + v.count, 0) === 0 ? (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, { color: 'text.secondary' }, "No Data Available")) : (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { height: '100%' } },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.ResponsiveContainer, { width: "100%", height: "100%" },
                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.BarChart, { height: 150, width: 250, data: data, margin: {
                        top: 5,
                        right: 30,
                        left: 0,
                        bottom: 5
                    }, barGap: 0, barCategoryGap: 0 },
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.XAxis, { dataKey: "name" }),
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.YAxis, { dataKey: "count" }),
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.Tooltip, { content: react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ScoreDistributionTooltip, null) }),
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.Bar, { dataKey: "count", fill: '#0088FE' }))))))));
};


/***/ }),

/***/ "./lib/components/coursemanage/stats/stats.js":
/*!****************************************************!*\
  !*** ./lib/components/coursemanage/stats/stats.js ***!
  \****************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   StatsComponent: () => (/* binding */ StatsComponent),
/* harmony export */   filterUserSubmissions: () => (/* binding */ filterUserSubmissions)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material_Unstable_Grid2__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @mui/material/Unstable_Grid2 */ "./node_modules/@mui/material/Unstable_Grid2/Grid2.js");
/* harmony import */ var _util_section_title__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../util/section-title */ "./lib/components/util/section-title.js");
/* harmony import */ var _mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @mui/icons-material/Replay */ "./node_modules/@mui/icons-material/Replay.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var _submission_timeseries__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./submission-timeseries */ "./lib/components/coursemanage/stats/submission-timeseries.js");
/* harmony import */ var _grading_progress__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./grading-progress */ "./lib/components/coursemanage/stats/grading-progress.js");
/* harmony import */ var _student_submissions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./student-submissions */ "./lib/components/coursemanage/stats/student-submissions.js");
/* harmony import */ var _score_distribution__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./score-distribution */ "./lib/components/coursemanage/stats/score-distribution.js");
/* harmony import */ var _services_lectures_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../services/lectures.service */ "./lib/services/lectures.service.js");
/* harmony import */ var _services_gradebook__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../services/gradebook */ "./lib/services/gradebook.js");
/* harmony import */ var _assignment_score__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./assignment-score */ "./lib/components/coursemanage/stats/assignment-score.js");
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);















const filterUserSubmissions = (submissions, users) => {
    return submissions.filter((v, i, a) => !users.includes(v.username));
};
const StatsComponent = () => {
    const { lecture, assignments, users } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('lecture');
    const { assignment, allSubmissions, latestSubmissions } = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useRouteLoaderData)('assignment');
    const [allSubmissionsState, setAllSubmissionsState] = react__WEBPACK_IMPORTED_MODULE_1__.useState(allSubmissions);
    const [latestSubmissionsState, setLatestSubmissionsState] = react__WEBPACK_IMPORTED_MODULE_1__.useState(latestSubmissions);
    const [gb, setGb] = react__WEBPACK_IMPORTED_MODULE_1__.useState(null);
    const [usersState, setUsersState] = react__WEBPACK_IMPORTED_MODULE_1__.useState(users);
    const updateSubmissions = async () => {
        setAllSubmissionsState(await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.getAllSubmissions)(lecture.id, assignment.id, 'none', true));
        setLatestSubmissionsState(await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.getAllSubmissions)(lecture.id, assignment.id, 'latest', true));
        setUsersState(await (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_4__.getUsers)(lecture.id));
        setGb(new _services_gradebook__WEBPACK_IMPORTED_MODULE_5__.GradeBook(await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_6__.getAssignmentProperties)(lecture.id, assignment.id)));
    };
    react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => {
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.getAllSubmissions)(lecture.id, assignment.id, 'none', true).then(response => {
            setAllSubmissionsState(response);
        });
        (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.getAllSubmissions)(lecture.id, assignment.id, 'latest', true).then(response => {
            setLatestSubmissionsState(response);
        });
    }, [allSubmissions, latestSubmissions]);
    react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => {
        (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_4__.getUsers)(lecture.id).then(response => {
            setUsersState(response);
        });
    }, [users]);
    react__WEBPACK_IMPORTED_MODULE_1__.useEffect(() => {
        (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_6__.getAssignmentProperties)(lecture.id, assignment.id).then(properties => {
            setGb(new _services_gradebook__WEBPACK_IMPORTED_MODULE_5__.GradeBook(properties));
        });
    }, []);
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, null,
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_util_section_title__WEBPACK_IMPORTED_MODULE_7__.SectionTitle, { title: `${assignment.name} Stats` },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { ml: 2 }, display: 'inline-block' },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Tooltip, { title: 'Reload' },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.IconButton, { "aria-label": 'reload', onClick: updateSubmissions },
                        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_icons_material_Replay__WEBPACK_IMPORTED_MODULE_8__["default"], null))))),
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { ml: 3, mr: 3, mb: 3, mt: 3 } },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Unstable_Grid2__WEBPACK_IMPORTED_MODULE_9__["default"], { container: true, spacing: 2, alignItems: 'stretch' },
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Unstable_Grid2__WEBPACK_IMPORTED_MODULE_9__["default"], { xs: 12 },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_submission_timeseries__WEBPACK_IMPORTED_MODULE_10__.SubmissionTimeSeries, { lecture: lecture, assignment: assignment, allSubmissions: allSubmissionsState, latestSubmissions: latestSubmissionsState, users: usersState })),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Unstable_Grid2__WEBPACK_IMPORTED_MODULE_9__["default"], { md: 12, lg: 4 },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_grading_progress__WEBPACK_IMPORTED_MODULE_11__.GradingProgress, { lecture: lecture, assignment: assignment, allSubmissions: allSubmissionsState, latestSubmissions: latestSubmissionsState, users: usersState })),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Unstable_Grid2__WEBPACK_IMPORTED_MODULE_9__["default"], { md: 12, lg: 4 },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_student_submissions__WEBPACK_IMPORTED_MODULE_12__.StudentSubmissions, { lecture: lecture, assignment: assignment, allSubmissions: allSubmissionsState, latestSubmissions: latestSubmissionsState, users: usersState })),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Unstable_Grid2__WEBPACK_IMPORTED_MODULE_9__["default"], { md: 12, lg: 4 },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_assignment_score__WEBPACK_IMPORTED_MODULE_13__.AssignmentScore, { gb: gb })),
                react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material_Unstable_Grid2__WEBPACK_IMPORTED_MODULE_9__["default"], { xs: 12 },
                    react__WEBPACK_IMPORTED_MODULE_1__.createElement(_score_distribution__WEBPACK_IMPORTED_MODULE_14__.ScoreDistribution, { lecture: lecture, assignment: assignment, allSubmissions: allSubmissionsState, latestSubmissions: latestSubmissionsState, users: usersState }))))));
};


/***/ }),

/***/ "./lib/components/coursemanage/stats/student-submissions.js":
/*!******************************************************************!*\
  !*** ./lib/components/coursemanage/stats/student-submissions.js ***!
  \******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   StudentSubmissions: () => (/* binding */ StudentSubmissions)
/* harmony export */ });
/* harmony import */ var _stats__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stats */ "./lib/components/coursemanage/stats/stats.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! recharts */ "webpack/sharing/consume/default/recharts/recharts");
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(recharts__WEBPACK_IMPORTED_MODULE_2__);




const getData = (submissions, users) => {
    if (users.students.length === 0) {
        return 0;
    }
    const subs = (0,_stats__WEBPACK_IMPORTED_MODULE_3__.filterUserSubmissions)(submissions, users.instructors.concat(users.tutors));
    return subs.length / users.students.length;
};
const StudentSubmissions = (props) => {
    const [data, setData] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(0);
    react__WEBPACK_IMPORTED_MODULE_0___default().useEffect(() => {
        const d = getData(props.latestSubmissions, props.users);
        setData(d);
    }, [props.latestSubmissions, props.users]);
    return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Card, { sx: { height: 300, width: '100%' } },
        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardHeader, { sx: { pb: 0 }, title: 'Student Submissions', subheader: 'as % of total students', subheaderTypographyProps: { variant: 'caption' } }),
        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.CardContent, { sx: {
                height: '70%'
            } },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { height: '100%' } },
                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.ResponsiveContainer, { width: "100%", height: "100%" },
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.RadialBarChart, { cx: "50%", cy: "50%", innerRadius: "70%", outerRadius: "90%", barSize: 15, data: [{ name: 'Submissions', value: data, fill: '#0088FE' }] },
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement("text", { fontSize: 40, x: '50%', y: '50%', dy: 12, textAnchor: "middle" }, `${Math.floor(data * 100)}%`),
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.PolarAngleAxis, { type: "number", domain: [0, 1], angleAxisId: 0, tick: false }),
                        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(recharts__WEBPACK_IMPORTED_MODULE_2__.RadialBar, { background: true, dataKey: "value", angleAxisId: 0 })))))));
};


/***/ }),

/***/ "./lib/components/coursemanage/stats/submission-timeseries.js":
/*!********************************************************************!*\
  !*** ./lib/components/coursemanage/stats/submission-timeseries.js ***!
  \********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   SubmissionTimeSeries: () => (/* binding */ SubmissionTimeSeries)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! recharts */ "webpack/sharing/consume/default/recharts/recharts");
/* harmony import */ var recharts__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(recharts__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! moment */ "webpack/sharing/consume/default/moment/moment");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _services_storage_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../services/storage.service */ "./lib/services/storage.service.js");





const SubmissionTimeSeriesTooltip = ({ active, payload, label }) => {
    if (active && payload && payload.length) {
        return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: "custom-tooltip" },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { className: "recharts-tooltip-label" }, moment__WEBPACK_IMPORTED_MODULE_3___default()(payload[0].payload.time).format('DD. MMM')),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { className: "recharts-tooltip-label" }, `${payload[0].value} Submission${payload[0].value === 1 ? '' : 's'}`)));
    }
    return null;
};
const getData = (submissions) => {
    if (submissions.length === 0) {
        return [];
    }
    const map = submissions
        .map(s => moment__WEBPACK_IMPORTED_MODULE_3___default()(s.submitted_at).startOf('day').valueOf())
        .reduce((acc, v) => {
        const c = acc.has(v) ? acc.get(v) : 0;
        acc.set(v, c + 1);
        return acc;
    }, new Map());
    const dates = [];
    const currDate = moment__WEBPACK_IMPORTED_MODULE_3___default()(Math.min(...map.keys())).subtract(2, 'days');
    const lastDate = moment__WEBPACK_IMPORTED_MODULE_3___default()();
    while (currDate.add(1, 'days').diff(lastDate) < 0) {
        dates.push(currDate.valueOf());
    }
    return dates.map(d => {
        if (map.has(d)) {
            return { time: d, n: map.get(d) };
        }
        else {
            return { time: d, n: 0 };
        }
    });
};
const SubmissionTimeSeries = (props) => {
    const [data, setData] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]);
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        const d = getData(props.allSubmissions);
        setData(d);
    }, [props.allSubmissions]);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Card, { sx: { height: 300, width: '100%' } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.CardHeader, { title: 'Submissions' }),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.CardContent, { sx: { height: '70%' } }, data.length === 0 ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { color: 'text.secondary' }, "No Data Available")) : (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Box, { sx: { height: '100%' } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(recharts__WEBPACK_IMPORTED_MODULE_1__.ResponsiveContainer, { width: "100%", height: "100%" },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(recharts__WEBPACK_IMPORTED_MODULE_1__.AreaChart, { height: 150, width: 250, data: data, margin: {
                        top: 5,
                        right: 30,
                        left: 0,
                        bottom: 5
                    } },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement("defs", null,
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement("linearGradient", { id: "gradient", x1: "0", y1: "0", x2: "0", y2: "1" },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement("stop", { offset: "5%", stopColor: '#0088FE', stopOpacity: 0.8 }),
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement("stop", { offset: "95%", stopColor: '#0088FE', stopOpacity: 0.2 }))),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(recharts__WEBPACK_IMPORTED_MODULE_1__.XAxis, { dataKey: "time", tickFormatter: unixTime => moment__WEBPACK_IMPORTED_MODULE_3___default()(unixTime).format('DD. MMM') }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(recharts__WEBPACK_IMPORTED_MODULE_1__.YAxis, { dataKey: "n" }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(recharts__WEBPACK_IMPORTED_MODULE_1__.Tooltip, { label: 'Number of Submissions', content: react__WEBPACK_IMPORTED_MODULE_0__.createElement(SubmissionTimeSeriesTooltip, null) }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(recharts__WEBPACK_IMPORTED_MODULE_1__.Area, { type: "monotone", dataKey: "n", stroke: '#0088FE', strokeWidth: 2, fillOpacity: 1, fill: "url(#gradient)" }),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(recharts__WEBPACK_IMPORTED_MODULE_1__.Brush, { height: 15, startIndex: (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_4__.loadNumber)('stats-sub-brush-start', null, props.assignment) ||
                            0, onChange: e => {
                            (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_4__.storeNumber)('stats-sub-brush-start', e.startIndex, null, props.assignment);
                        } }))))))));
};


/***/ }),

/***/ "./lib/components/notebook/create-assignment/creation-component.js":
/*!*************************************************************************!*\
  !*** ./lib/components/notebook/create-assignment/creation-component.js ***!
  \*************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AntSwitch: () => (/* binding */ AntSwitch),
/* harmony export */   CreationComponent: () => (/* binding */ CreationComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../model */ "./lib/components/notebook/model.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.



const AntSwitch = (0,_mui_material__WEBPACK_IMPORTED_MODULE_1__.styled)(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Switch)(({ theme }) => ({
    width: 28,
    height: 16,
    padding: 0,
    display: 'flex',
    '&:active': {
        '& .MuiSwitch-thumb': {
            width: 15
        },
        '& .MuiSwitch-switchBase.Mui-checked': {
            transform: 'translateX(9px)'
        }
    },
    '& .MuiSwitch-switchBase': {
        padding: 2,
        '&.Mui-checked': {
            transform: 'translateX(12px)',
            color: '#fff',
            '& + .MuiSwitch-track': {
                opacity: 1,
                backgroundColor: theme.palette.mode === 'dark' ? '#177ddc' : '#1890ff'
            }
        }
    },
    '& .MuiSwitch-thumb': {
        boxShadow: '0 2px 4px 0 rgb(0 35 11 / 20%)',
        width: 12,
        height: 12,
        borderRadius: 6,
        transition: theme.transitions.create(['width'], {
            duration: 200
        })
    },
    '& .MuiSwitch-track': {
        borderRadius: 16 / 2,
        opacity: 1,
        backgroundColor: theme.palette.mode === 'dark'
            ? 'rgba(255,255,255,.35)'
            : 'rgba(0,0,0,.25)',
        boxSizing: 'border-box'
    }
}));
const randomString = (length) => {
    let result = '';
    const chars = 'abcdef0123456789';
    let i;
    for (i = 0; i < length; i++) {
        result += chars[Math.floor(Math.random() * chars.length)];
    }
    return result;
};
const CreationComponent = (props) => {
    const nbgraderData = _model__WEBPACK_IMPORTED_MODULE_2__.CellModel.getNbgraderData(props.cell.model.metadata);
    const toolData = _model__WEBPACK_IMPORTED_MODULE_2__.CellModel.newToolData(nbgraderData, props.cell.model.type);
    const [type, setType] = react__WEBPACK_IMPORTED_MODULE_0__.useState(toolData.type);
    const [id, setId] = react__WEBPACK_IMPORTED_MODULE_0__.useState(toolData.id);
    const [points, setPoints] = react__WEBPACK_IMPORTED_MODULE_0__.useState(toolData.points);
    const [hintChecked, setChecked] = react__WEBPACK_IMPORTED_MODULE_0__.useState(props.cell.model.getMetadata('hint') != null);
    const [hint, setHint] = react__WEBPACK_IMPORTED_MODULE_0__.useState(hintChecked ? props.cell.model.getMetadata('hint') : '');
    const handleHintChange = (event) => {
        setChecked(event.target.checked);
    };
    const updateMetadata = () => {
        toolData.type = type;
        if (id === undefined) {
            setId('cell-' + randomString(16));
        }
        else {
            toolData.id = id;
        }
        toolData.points = points;
        const data = _model__WEBPACK_IMPORTED_MODULE_2__.CellModel.newNbgraderData(toolData);
        _model__WEBPACK_IMPORTED_MODULE_2__.CellModel.setNbgraderData(data, props.cell.model);
        //TODO: Currently we set the optional hint differently than the grader data, but maybe we should do it like this
        if (hintChecked) {
            props.cell.model.setMetadata('hint', hint);
        }
        else {
            props.cell.model.deleteMetadata('hint');
        }
    };
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        updateMetadata();
    });
    const alertStyle = { width: 250 };
    const gradableCell = type !== 'readonly' &&
        type !== 'solution' &&
        type !== '';
    const solutionCell = type === 'solution' || type === 'manual';
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Divider, null),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { mt: 2, mb: 1, ml: 3 } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { container: true, spacing: 1 },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TextField, { label: "Type", select: true, size: "small", sx: { minWidth: 150 }, value: type, onChange: e => {
                            setType(e.target.value);
                        } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.MenuItem, { value: "" }, "-"),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.MenuItem, { value: "readonly" }, "Readonly"),
                        props.cell.model.type === 'code' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.MenuItem, { value: "solution" }, "Autograded answer")),
                        props.cell.model.type === 'code' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.MenuItem, { value: "tests" }, "Autograded tests")),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.MenuItem, { value: "manual" }, "Manual graded answer"),
                        props.cell.model.type === 'markdown' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.MenuItem, { value: "task" }, "Manual graded task")))),
                type !== '' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TextField, { size: "small", label: "ID", value: id, onChange: e => setId(e.target.value), error: id === '', helperText: id === '' ? 'ID not set' : ' ' }))),
                gradableCell && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TextField, { size: "small", label: "Points", value: points, type: "number", onChange: e => setPoints(parseFloat(e.target.value)), InputProps: {
                            inputProps: {
                                max: 10000,
                                min: 0,
                                step: 0.25
                            }
                        }, error: points === undefined, helperText: points === undefined ? 'Points not set' : ' ' }))),
                solutionCell && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(AntSwitch, { sx: { mt: 2, ml: 1 }, checked: hintChecked, onChange: handleHintChange, inputProps: { 'aria-label': 'controlled' } }))),
                solutionCell && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TextField, { size: "small", label: "Optional hint", value: hint, disabled: !hintChecked, onChange: e => setHint(e.target.value) }))),
                type === '' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Alert, { variant: "outlined", sx: alertStyle, severity: "warning" }, "Type not set"))),
                points === 0 && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Alert, { variant: "outlined", sx: alertStyle, severity: "warning" }, "Gradable cell with zero points")))))));
};


/***/ }),

/***/ "./lib/components/notebook/create-assignment/creation-switch.js":
/*!**********************************************************************!*\
  !*** ./lib/components/notebook/create-assignment/creation-switch.js ***!
  \**********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AntSwitch: () => (/* binding */ AntSwitch),
/* harmony export */   CreationModeSwitch: () => (/* binding */ CreationModeSwitch)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _creation_widget__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./creation-widget */ "./lib/components/notebook/create-assignment/creation-widget.js");
/* harmony import */ var _error_widget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./error-widget */ "./lib/components/notebook/create-assignment/error-widget.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _validator__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./validator */ "./lib/components/notebook/create-assignment/validator.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.





const AntSwitch = (0,_mui_material__WEBPACK_IMPORTED_MODULE_1__.styled)(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Switch)(({ theme }) => ({
    width: 28,
    height: 16,
    padding: 0,
    display: 'flex',
    '&:active': {
        '& .MuiSwitch-thumb': {
            width: 15,
        },
        '& .MuiSwitch-switchBase.Mui-checked': {
            transform: 'translateX(9px)',
        },
    },
    '& .MuiSwitch-switchBase': {
        padding: 2,
        '&.Mui-checked': {
            transform: 'translateX(12px)',
            color: '#fff',
            '& + .MuiSwitch-track': {
                opacity: 1,
                backgroundColor: theme.palette.mode === 'dark' ? '#177ddc' : '#1890ff',
            },
        },
    },
    '& .MuiSwitch-thumb': {
        boxShadow: '0 2px 4px 0 rgb(0 35 11 / 20%)',
        width: 12,
        height: 12,
        borderRadius: 6,
        transition: theme.transitions.create(['width'], {
            duration: 200,
        }),
    },
    '& .MuiSwitch-track': {
        borderRadius: 16 / 2,
        opacity: 1,
        backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255,255,255,.35)' : 'rgba(0,0,0,.25)',
        boxSizing: 'border-box',
    },
}));
class CreationModeSwitch extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
    constructor(props) {
        super(props);
        this.state = {
            mode: false
        };
        this.handleChange = async () => {
            this.setState({ mode: !this.state.mode }, () => {
                const ids = new Set();
                this.onChange(this.state.mode);
                this.notebook.widgets.map((c) => {
                    const currentLayout = c.layout;
                    if (this.state.mode) {
                        currentLayout.insertWidget(0, new _creation_widget__WEBPACK_IMPORTED_MODULE_2__.CreationWidget(c));
                    }
                    else {
                        currentLayout.widgets.map(w => {
                            if (w instanceof _creation_widget__WEBPACK_IMPORTED_MODULE_2__.CreationWidget || w instanceof _error_widget__WEBPACK_IMPORTED_MODULE_3__.ErrorWidget) {
                                currentLayout.removeWidget(w);
                            }
                        });
                    }
                });
            });
        };
        this.state.mode = props.mode || false;
        this.notebook = props.notebook;
        this.notebookpanel = props.notebookpanel;
        this.onChange = this.props.onChange;
    }
    render() {
        return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Stack, { direction: "row", spacing: 1, alignItems: "center" },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(AntSwitch, { checked: this.state.mode, onChange: this.handleChange }),
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, { variant: "caption" }, "Creation Mode"),
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_validator__WEBPACK_IMPORTED_MODULE_4__.Validator, { notebook: this.notebook })));
    }
}


/***/ }),

/***/ "./lib/components/notebook/create-assignment/creation-widget.js":
/*!**********************************************************************!*\
  !*** ./lib/components/notebook/create-assignment/creation-widget.js ***!
  \**********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   CreationWidget: () => (/* binding */ CreationWidget)
/* harmony export */ });
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _creation_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./creation-component */ "./lib/components/notebook/create-assignment/creation-component.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.



class CreationWidget extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__.ReactWidget {
    constructor(cell) {
        super();
        this.cell = cell;
    }
    render() {
        return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_creation_component__WEBPACK_IMPORTED_MODULE_2__.CreationComponent, { cell: this.cell }));
    }
}


/***/ }),

/***/ "./lib/components/notebook/create-assignment/error-component.js":
/*!**********************************************************************!*\
  !*** ./lib/components/notebook/create-assignment/error-component.js ***!
  \**********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ErrorComponent: () => (/* binding */ ErrorComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.


const ErrorComponent = (props) => {
    //const alertStyle = { width: 250 };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Alert, { sx: { mt: 1 }, variant: "filled", severity: "error" }, props.err));
};


/***/ }),

/***/ "./lib/components/notebook/create-assignment/error-widget.js":
/*!*******************************************************************!*\
  !*** ./lib/components/notebook/create-assignment/error-widget.js ***!
  \*******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ErrorWidget: () => (/* binding */ ErrorWidget)
/* harmony export */ });
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _error_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./error-component */ "./lib/components/notebook/create-assignment/error-component.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.



class ErrorWidget extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__.ReactWidget {
    constructor(cell, err) {
        super();
        this.cell = cell;
        this.err = err;
    }
    render() {
        return react__WEBPACK_IMPORTED_MODULE_1__.createElement(_error_component__WEBPACK_IMPORTED_MODULE_2__.ErrorComponent, { err: this.err });
    }
}


/***/ }),

/***/ "./lib/components/notebook/create-assignment/validator.js":
/*!****************************************************************!*\
  !*** ./lib/components/notebook/create-assignment/validator.js ***!
  \****************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   Validator: () => (/* binding */ Validator)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../model */ "./lib/components/notebook/model.js");
/* harmony import */ var _error_widget__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./error-widget */ "./lib/components/notebook/create-assignment/error-widget.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.




const Validator = (props) => {
    const [dialogOpen, setDialog] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [results, setResult] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]);
    const validateNotebook = () => {
        //check duplicate ids
        const ids = new Set();
        const result = [];
        props.notebook.widgets.map((c) => {
            c.layout.widgets.map((w) => {
                if (w instanceof _error_widget__WEBPACK_IMPORTED_MODULE_2__.ErrorWidget) {
                    c.layout.removeWidget(w);
                }
            });
        });
        let duplicate = 0;
        let noType = 0;
        let wrongTypeSolution = 0;
        let wrongTypeTest = 0;
        let noEndSolution = 0;
        let noEndTest = 0;
        props.notebook.widgets.map((c) => {
            const metadata = _model__WEBPACK_IMPORTED_MODULE_3__.CellModel.getNbgraderData(c.model.metadata);
            const cellText = c.inputArea.model.sharedModel.source;
            const layout = c.layout;
            const toolData = _model__WEBPACK_IMPORTED_MODULE_3__.CellModel.newToolData(metadata, c.model.type);
            if (metadata !== null) {
                if (metadata.grade_id !== null) {
                    //check if the cell id was already found
                    if (ids.has(metadata.grade_id)) {
                        layout.addWidget(new _error_widget__WEBPACK_IMPORTED_MODULE_2__.ErrorWidget(c, 'Duplicate ID found'));
                        duplicate += 1;
                    }
                    else {
                        ids.add(metadata.grade_id);
                    }
                }
            }
            else {
                noType += 1;
            }
            if (/#+\s?BEGIN\sSOLUTION/gim.test(cellText) &&
                /#+\s?END\sSOLUTION/gim.test(cellText) === false) {
                noEndSolution += 1;
                layout.addWidget(new _error_widget__WEBPACK_IMPORTED_MODULE_2__.ErrorWidget(c, 'No end solution found'));
            }
            if (/#+\s?BEGIN\sHIDDEN\sTESTS/gim.test(cellText) &&
                /#+\s?END\sHIDDEN\sTESTS/gim.test(cellText) === false) {
                noEndTest += 1;
                layout.addWidget(new _error_widget__WEBPACK_IMPORTED_MODULE_2__.ErrorWidget(c, 'No end hidden tests found'));
            }
            //check if ### BEGIN/END SOLUTION is placed in a cell with the wrong cell type
            if (toolData.type !== 'solution' && toolData.type !== 'manual') {
                if (/#+\s?[BEGIN|END]{1,}\sSOLUTION/gim.test(cellText)) {
                    wrongTypeSolution += 1;
                    layout.addWidget(new _error_widget__WEBPACK_IMPORTED_MODULE_2__.ErrorWidget(c, 'Solution region must be in solution cell'));
                }
            }
            //check if ### BEGIN/END HIDDEN TESTS is placed wrong
            if (toolData.type !== 'tests') {
                if (/#+\s?[BEGIN|END]{1,}\sHIDDEN\stest/gim.test(cellText)) {
                    wrongTypeTest += 1;
                    layout.addWidget(new _error_widget__WEBPACK_IMPORTED_MODULE_2__.ErrorWidget(c, 'Hidden test region must be in autograded test cell'));
                }
            }
        });
        if (duplicate > 0) {
            result.push({
                id: 'Duplicated ID',
                type: 'error',
                msg: duplicate + 'x Duplicate ID found'
            });
        }
        if (noEndSolution > 0) {
            result.push({
                id: 'No End Solution',
                type: 'error',
                msg: noEndSolution + 'x No end solution found'
            });
        }
        if (noEndTest > 0) {
            result.push({
                id: 'No End Tests',
                type: 'error',
                msg: noEndTest + 'x No end hidden tests found'
            });
        }
        if (wrongTypeSolution > 0) {
            result.push({
                id: 'Wrong Solution Region Placement',
                type: 'error',
                msg: wrongTypeSolution +
                    'x Solution regions can only be placed in solution cells'
            });
        }
        if (wrongTypeTest > 0) {
            result.push({
                id: 'Wrong Test Region Placement',
                type: 'error',
                msg: wrongTypeTest +
                    'x Hidden test regions can only be placed in autograded test cells'
            });
        }
        if (noType > 0) {
            result.push({
                id: 'No Type Cell',
                type: 'warning',
                msg: noType + 'x Cell with no type found'
            });
        }
        setResult(result);
        setDialog(true);
    };
    const handleClose = () => {
        setDialog(false);
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { className: "grader-toolbar-button", onClick: validateNotebook, variant: "outlined", color: "success", size: "small", sx: { fontSize: '0.1rem' } }, "Validate"),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Dialog, { open: dialogOpen, onClose: handleClose, "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description" },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.DialogTitle, { id: "alert-dialog-title" }, 'Validation Report'),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.DialogContent, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Stack, { spacing: 2 },
                    results.length === 0 && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { width: '450px' } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Alert, { severity: "success" },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.AlertTitle, null, "No errors found")))),
                    results.map((e) => (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { width: '450px' } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Alert, { severity: e.type },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.AlertTitle, null, e.id),
                            e.msg)))))),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.DialogActions, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { onClick: handleClose, autoFocus: true }, "Ok")))));
};


/***/ }),

/***/ "./lib/components/notebook/manual-grading/data-widget/data-component.js":
/*!******************************************************************************!*\
  !*** ./lib/components/notebook/manual-grading/data-widget/data-component.js ***!
  \******************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   DataComponent: () => (/* binding */ DataComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../model */ "./lib/components/notebook/model.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.



const DataComponent = (props) => {
    const nbgraderData = _model__WEBPACK_IMPORTED_MODULE_2__.CellModel.getNbgraderData(props.cell.model.metadata);
    const toolData = _model__WEBPACK_IMPORTED_MODULE_2__.CellModel.newToolData(nbgraderData, props.cell.model.type);
    const gradableCell = toolData.type !== 'readonly' &&
        toolData.type !== 'solution' &&
        toolData.type !== '';
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Divider, null),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { mt: 2, mb: 1, ml: 3 } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { container: true, spacing: 2 },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, null,
                        "Type: ",
                        toolData.type)),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, null,
                        "ID: ",
                        toolData.id)),
                toolData.type === 'tests' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, null,
                        "Autograded Points:",
                        ' ',
                        props.gradebook.getAutoGradeScore(props.nbname, toolData.id)))),
                gradableCell && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, null,
                        "Max Points: ",
                        toolData.points)))))));
};


/***/ }),

/***/ "./lib/components/notebook/manual-grading/data-widget/data-widget.js":
/*!***************************************************************************!*\
  !*** ./lib/components/notebook/manual-grading/data-widget/data-widget.js ***!
  \***************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   DataWidget: () => (/* binding */ DataWidget)
/* harmony export */ });
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _data_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./data-component */ "./lib/components/notebook/manual-grading/data-widget/data-component.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.



class DataWidget extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__.ReactWidget {
    constructor(cell, gradebook, nbname) {
        super();
        this.cell = cell;
        this.gradebook = gradebook;
        this.nbname = nbname;
    }
    render() {
        return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_data_component__WEBPACK_IMPORTED_MODULE_2__.DataComponent, { cell: this.cell, gradebook: this.gradebook, nbname: this.nbname }));
    }
}


/***/ }),

/***/ "./lib/components/notebook/manual-grading/grade-widget/comment-component.js":
/*!**********************************************************************************!*\
  !*** ./lib/components/notebook/manual-grading/grade-widget/comment-component.js ***!
  \**********************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   CommentComponent: () => (/* binding */ CommentComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.


const CommentComponent = (props) => {
    const [comment, setComment] = react__WEBPACK_IMPORTED_MODULE_0__.useState(props.gradebook.getComment(props.nbname, props.toolData.id));
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TextField, { label: "Comment", size: "small", multiline: true, value: comment, onChange: e => {
                setComment(e.target.value);
                props.model.setMetadata('updated', true);
                props.gradebook.setComment(props.nbname, props.toolData.id, e.target.value);
            } })));
};


/***/ }),

/***/ "./lib/components/notebook/manual-grading/grade-widget/grade-component.js":
/*!********************************************************************************!*\
  !*** ./lib/components/notebook/manual-grading/grade-widget/grade-component.js ***!
  \********************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GradeComponent: () => (/* binding */ GradeComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _points_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./points-component */ "./lib/components/notebook/manual-grading/grade-widget/points-component.js");
/* harmony import */ var _comment_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./comment-component */ "./lib/components/notebook/manual-grading/grade-widget/comment-component.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.




const GradeComponent = (props) => {
    const model = props.notebook.model;
    if (model.getMetadata('updated') != undefined) {
        model.setMetadata('updated', false);
    }
    const metadata = model.metadata;
    const gradableCell = props.toolData.type !== 'readonly' &&
        props.toolData.type !== 'solution' &&
        props.toolData.type !== '';
    const showCommment = props.toolData.type === 'task' ||
        props.toolData.type === 'manual' ||
        props.toolData.type === 'solution';
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, null, props.toolData.type !== 'readonly' && props.toolData.type !== '' && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, { sx: { mt: 2, mb: 1, ml: 5 } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { container: true, spacing: 2 },
            showCommment && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_comment_component__WEBPACK_IMPORTED_MODULE_2__.CommentComponent, { model: model, nbgraderData: props.nbgraderData, toolData: props.toolData, gradebook: props.gradebook, nbname: props.nbname })),
            gradableCell && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_points_component__WEBPACK_IMPORTED_MODULE_3__.PointsComponent, { model: model, nbgraderData: props.nbgraderData, toolData: props.toolData, gradebook: props.gradebook, nbname: props.nbname })),
            gradableCell && (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_points_component__WEBPACK_IMPORTED_MODULE_3__.ExtraCreditComponent, { model: model, nbgraderData: props.nbgraderData, toolData: props.toolData, gradebook: props.gradebook, nbname: props.nbname })))))));
};


/***/ }),

/***/ "./lib/components/notebook/manual-grading/grade-widget/grade-widget.js":
/*!*****************************************************************************!*\
  !*** ./lib/components/notebook/manual-grading/grade-widget/grade-widget.js ***!
  \*****************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GradeWidget: () => (/* binding */ GradeWidget)
/* harmony export */ });
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _grade_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./grade-component */ "./lib/components/notebook/manual-grading/grade-widget/grade-component.js");
/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../model */ "./lib/components/notebook/model.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.




class GradeWidget extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__.ReactWidget {
    constructor(cell, notebook, gradebook, nbname) {
        super();
        this.cell = cell;
        this.notebook = notebook;
        this.gradebook = gradebook;
        this.nbname = nbname;
        this.nbgraderData = _model__WEBPACK_IMPORTED_MODULE_2__.CellModel.getNbgraderData(this.cell.model.metadata);
        this.toolData = _model__WEBPACK_IMPORTED_MODULE_2__.CellModel.newToolData(this.nbgraderData, this.cell.model.type);
    }
    render() {
        if (this.toolData.type !== '' && this.toolData.type !== 'readonly') {
            return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_grade_component__WEBPACK_IMPORTED_MODULE_3__.GradeComponent, { notebook: this.notebook, nbgraderData: this.nbgraderData, toolData: this.toolData, gradebook: this.gradebook, nbname: this.nbname }));
        }
        else {
            return null;
        }
    }
}


/***/ }),

/***/ "./lib/components/notebook/manual-grading/grade-widget/points-component.js":
/*!*********************************************************************************!*\
  !*** ./lib/components/notebook/manual-grading/grade-widget/points-component.js ***!
  \*********************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ExtraCreditComponent: () => (/* binding */ ExtraCreditComponent),
/* harmony export */   PointsComponent: () => (/* binding */ PointsComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.


const PointsComponent = (props) => {
    const [points, setPoints] = react__WEBPACK_IMPORTED_MODULE_0__.useState(props.gradebook.getGradeScore(props.nbname, props.toolData.id));
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TextField, { size: "small", label: "Points", type: "number", value: points, onChange: e => {
                setPoints(parseFloat(e.target.value));
                props.model.setMetadata('updated', true);
                props.gradebook.setManualScore(props.nbname, props.toolData.id, parseFloat(e.target.value));
            }, InputProps: {
                inputProps: {
                    max: props.toolData.points,
                    min: 0,
                    step: 0.25
                }
            } })));
};
const ExtraCreditComponent = (props) => {
    const [extraCredit, setExtraCredit] = react__WEBPACK_IMPORTED_MODULE_0__.useState(props.gradebook.getExtraCredit(props.nbname, props.toolData.id));
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Grid, { item: true },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TextField, { size: "small", label: "Extra Credit", type: "number", value: extraCredit, onChange: e => {
                setExtraCredit(parseFloat(e.target.value));
                props.model.setMetadata('updated', true);
                props.gradebook.setExtraCredit(props.nbname, props.toolData.id, parseFloat(e.target.value));
            }, InputProps: {
                inputProps: {
                    max: 10000,
                    min: 0,
                    step: 0.25
                }
            } })));
};


/***/ }),

/***/ "./lib/components/notebook/manual-grading/grading-switch.js":
/*!******************************************************************!*\
  !*** ./lib/components/notebook/manual-grading/grading-switch.js ***!
  \******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GradingModeSwitch: () => (/* binding */ GradingModeSwitch)
/* harmony export */ });
/* harmony import */ var _services_gradebook__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../services/gradebook */ "./lib/services/gradebook.js");
/* harmony import */ var _services_submissions_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../services/submissions.service */ "./lib/services/submissions.service.js");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _services_lectures_service__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../services/lectures.service */ "./lib/services/lectures.service.js");
/* harmony import */ var _data_widget_data_widget__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./data-widget/data-widget */ "./lib/components/notebook/manual-grading/data-widget/data-widget.js");
/* harmony import */ var _grade_widget_grade_widget__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./grade-widget/grade-widget */ "./lib/components/notebook/manual-grading/grade-widget/grade-widget.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _create_assignment_creation_switch__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../create-assignment/creation-switch */ "./lib/components/notebook/create-assignment/creation-switch.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../services/file.service */ "./lib/services/file.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.











class GradingModeSwitch extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
    constructor(props) {
        super(props);
        this.state = {
            mode: false,
            saveButtonText: 'Save',
        };
        this.handleChange = async () => {
            const properties = await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.getProperties)(this.lecture.id, this.assignment.id, this.subID);
            this.gradeBook = new _services_gradebook__WEBPACK_IMPORTED_MODULE_4__.GradeBook(properties);
            // TODO This is a dirty bugfix which generates grade dict entries for task cells which should exist
            this.gradeBook.getMaxPoints();
            this.setState({ mode: !this.state.mode }, () => {
                this.onChange(this.state.mode);
                this.notebook.widgets.map((c) => {
                    const currentLayout = c.layout;
                    if (this.state.mode) {
                        currentLayout.insertWidget(0, new _data_widget_data_widget__WEBPACK_IMPORTED_MODULE_5__.DataWidget(c, this.gradeBook, this.notebookPaths[_services_file_service__WEBPACK_IMPORTED_MODULE_6__.lectureSubPaths + 4].split('.').slice(0, -1).join('.')));
                        currentLayout.addWidget(new _grade_widget_grade_widget__WEBPACK_IMPORTED_MODULE_7__.GradeWidget(c, this.notebook, this.gradeBook, this.notebookPaths[_services_file_service__WEBPACK_IMPORTED_MODULE_6__.lectureSubPaths + 4].split('.').slice(0, -1).join('.')));
                    }
                    else {
                        currentLayout.widgets.map(w => {
                            if (w instanceof _data_widget_data_widget__WEBPACK_IMPORTED_MODULE_5__.DataWidget || w instanceof _grade_widget_grade_widget__WEBPACK_IMPORTED_MODULE_7__.GradeWidget) {
                                currentLayout.removeWidget(w);
                            }
                        });
                    }
                });
            });
        };
        this.state.mode = props.mode || false;
        this.notebook = props.notebook;
        this.notebookpanel = props.notebookpanel;
        this.notebookPaths =
            this.notebookpanel.context.contentsModel.path.split('/');
        this.subID = +this.notebookPaths[_services_file_service__WEBPACK_IMPORTED_MODULE_6__.lectureSubPaths + 3];
        this.onChange = this.props.onChange;
    }
    async componentDidMount() {
        const lectures = await (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_8__.getAllLectures)();
        this.lecture = lectures.find(l => l.code === this.notebookPaths[_services_file_service__WEBPACK_IMPORTED_MODULE_6__.lectureSubPaths]);
        this.assignment = await (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_9__.getAssignment)(this.lecture.id, +this.notebookPaths[_services_file_service__WEBPACK_IMPORTED_MODULE_6__.lectureSubPaths + 2]);
        const properties = await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.getProperties)(this.lecture.id, this.assignment.id, this.subID);
        this.gradeBook = new _services_gradebook__WEBPACK_IMPORTED_MODULE_4__.GradeBook(properties);
        this.notebookpanel.context.saveState.connect((sender, saveState) => {
            if (saveState === 'started') {
                this.saveProperties();
            }
        });
    }
    async saveProperties() {
        const model = this.notebook.model;
        //if there were no updates return
        if (!model.getMetadata('updated')) {
            return;
        }
        model.setMetadata('updated', false);
        this.setState({ saveButtonText: 'Saving' });
        try {
            await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.updateProperties)(this.lecture.id, this.assignment.id, this.subID, this.gradeBook.properties);
            this.setState({ saveButtonText: 'Saved' });
            setTimeout(() => this.setState({ saveButtonText: 'Save' }), 2000);
            const submission = await (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.getSubmission)(this.lecture.id, this.assignment.id, this.subID);
            submission.manual_status = 'being_edited';
            (0,_services_submissions_service__WEBPACK_IMPORTED_MODULE_3__.updateSubmission)(this.lecture.id, this.assignment.id, this.subID, submission);
        }
        catch (err) {
            this.setState({ saveButtonText: 'Save' });
            if (err instanceof Error) {
                (0,_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__.showErrorMessage)('Error saving properties', err);
            }
            else {
                console.error('Error while trying to interpret type unknown as error', err);
            }
        }
    }
    render() {
        return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Stack, { direction: "row", spacing: 1, alignItems: "center" },
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_create_assignment_creation_switch__WEBPACK_IMPORTED_MODULE_10__.AntSwitch, { checked: this.state.mode, onChange: this.handleChange }),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { variant: "caption" }, "Grading Mode"),
            react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Button, { className: "grader-toolbar-button", onClick: () => this.saveProperties(), variant: "outlined", color: "success", size: "small" }, this.state.saveButtonText)));
    }
}


/***/ }),

/***/ "./lib/components/notebook/model.js":
/*!******************************************!*\
  !*** ./lib/components/notebook/model.js ***!
  \******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   CellModel: () => (/* binding */ CellModel),
/* harmony export */   NBGRADER_SCHEMA_VERSION: () => (/* binding */ NBGRADER_SCHEMA_VERSION),
/* harmony export */   NbgraderData: () => (/* binding */ NbgraderData),
/* harmony export */   ToolData: () => (/* binding */ ToolData)
/* harmony export */ });
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
const NBGRADER_KEY = 'nbgrader';
const NBGRADER_SCHEMA_VERSION = 3;
/**
 * A namespace for conversions between {@link NbgraderData} and
 * {@link ToolData} and for reading and writing to notebook cells' metadata.
 */
var CellModel;
(function (CellModel) {
    /**
     * Cleans invalid nbgrader data if necessary.
     *
     * @returns Whether cleaning occurred.
     */
    function cleanNbgraderData(cellModel, cellType) {
        const data = CellModel.getNbgraderData(cellModel.metadata);
        if (data == null || !PrivateNbgraderData.isInvalid(data, cellType)) {
            return false;
        }
        data.schema_version = NBGRADER_SCHEMA_VERSION;
        data.solution = false;
        data.grade = false;
        data.locked = false;
        data.task = false;
        CellModel.setNbgraderData(data, cellModel);
        return true;
    }
    CellModel.cleanNbgraderData = cleanNbgraderData;
    /**
     * Removes the "cell_type" property from the nbgrader data.
     */
    function clearCellType(cellMetadata) {
        const data = cellMetadata[NBGRADER_KEY];
        if (data == null) {
            return;
        }
        data['cell_type'] = undefined;
        cellMetadata[NBGRADER_KEY] = data;
    }
    CellModel.clearCellType = clearCellType;
    /**
     * Read the nbgrader data from a cell's metadata.
     *
     * @returns The nbgrader data, or null if it doesn't exist.
     */
    function getNbgraderData(cellMetadata) {
        if (cellMetadata == null) {
            return null;
        }
        const nbgraderValue = cellMetadata[NBGRADER_KEY];
        if (nbgraderValue == null) {
            return null;
        }
        return nbgraderValue.valueOf();
    }
    CellModel.getNbgraderData = getNbgraderData;
    /**
     * @returns True if the cell is gradable.
     */
    function isGraded(data) {
        return PrivateNbgraderData.isGraded(data);
    }
    CellModel.isGraded = isGraded;
    /**
     * @returns True if the cell relevant to nbgrader. A cell is relevant if it is
     * gradable or contains autograder tests.
     */
    function isRelevantToNbgrader(data) {
        return (PrivateNbgraderData.isGraded(data) || PrivateNbgraderData.isSolution(data));
    }
    CellModel.isRelevantToNbgrader = isRelevantToNbgrader;
    /**
     * Converts {@link ToolData} to {@link NbgraderData}.
     *
     * @returns The converted data, or null if the nbgrader cell type is not set.
     */
    function newNbgraderData(data) {
        if (data.type === '') {
            return null;
        }
        const nbgraderData = new NbgraderData();
        nbgraderData.grade = PrivateToolData.getGrade(data);
        nbgraderData.grade_id = PrivateToolData.getGradeId(data);
        nbgraderData.locked = PrivateToolData.getLocked(data);
        nbgraderData.points = PrivateToolData.getPoints(data);
        nbgraderData.schema_version = PrivateToolData.getSchemeaVersion();
        nbgraderData.solution = PrivateToolData.getSolution(data);
        nbgraderData.task = PrivateToolData.getTask(data);
        return nbgraderData;
    }
    CellModel.newNbgraderData = newNbgraderData;
    /**
     * Converts {@link NbgraderData} to {@link ToolData}.
     *
     * @param data The data to convert. Can be null.
     * @param cellType The notebook cell widget type.
     */
    function newToolData(data, cellType) {
        const toolData = new ToolData();
        if (PrivateNbgraderData.isInvalid(data, cellType)) {
            toolData.type = '';
            return toolData;
        }
        toolData.type = PrivateNbgraderData.getType(data, cellType);
        if (toolData.type === '') {
            return toolData;
        }
        if (PrivateNbgraderData.isGrade(data) ||
            PrivateNbgraderData.isSolution(data) ||
            PrivateNbgraderData.isLocked(data)) {
            toolData.id = PrivateNbgraderData.getGradeId(data);
        }
        if (PrivateNbgraderData.isGraded(data)) {
            toolData.points = PrivateNbgraderData.getPoints(data);
        }
        toolData.locked = PrivateNbgraderData.isLocked(data);
        return toolData;
    }
    CellModel.newToolData = newToolData;
    /**
     * Writes the nbgrader data to a cell's metadata.
     *
     * @param data The nbgrader data. If null, the nbgrader entry, if it exists,
     * will be removed from the metadata.
     */
    function setNbgraderData(data, cellModel) {
        const readOnlyMetadata = cellModel.metadata;
        if (data == null) {
            if (readOnlyMetadata[NBGRADER_KEY] != undefined) {
                readOnlyMetadata[NBGRADER_KEY] = undefined;
            }
            return;
        }
        const currentDataJson = readOnlyMetadata[NBGRADER_KEY];
        const currentData = currentDataJson == null
            ? null
            : currentDataJson.valueOf();
        if (currentData != data) {
            cellModel.setMetadata(NBGRADER_KEY, data.toJson());
        }
    }
    CellModel.setNbgraderData = setNbgraderData;
})(CellModel || (CellModel = {}));
var PrivateNbgraderData;
(function (PrivateNbgraderData) {
    function getGradeId(nbgraderData) {
        if (nbgraderData == null || nbgraderData.grade_id == null) {
            return '';
        }
        return nbgraderData.grade_id;
    }
    PrivateNbgraderData.getGradeId = getGradeId;
    function getPoints(nbgraderData) {
        if (nbgraderData == null) {
            return 0;
        }
        return PrivateNbgraderData._to_float(nbgraderData.points);
    }
    PrivateNbgraderData.getPoints = getPoints;
    function getSchemeaVersion(nbgraderData) {
        if (nbgraderData === null) {
            return 0;
        }
        return nbgraderData.schema_version;
    }
    PrivateNbgraderData.getSchemeaVersion = getSchemeaVersion;
    function getType(nbgraderData, cellType) {
        if (PrivateNbgraderData.isTask(nbgraderData)) {
            return 'task';
        }
        else if (PrivateNbgraderData.isSolution(nbgraderData) &&
            isGrade(nbgraderData)) {
            return 'manual';
        }
        else if (PrivateNbgraderData.isSolution(nbgraderData) &&
            cellType === 'code') {
            return 'solution';
        }
        else if (PrivateNbgraderData.isGrade(nbgraderData) &&
            cellType === 'code') {
            return 'tests';
        }
        else if (PrivateNbgraderData.isLocked(nbgraderData)) {
            return 'readonly';
        }
        else {
            return '';
        }
    }
    PrivateNbgraderData.getType = getType;
    function isGrade(nbgraderData) {
        return nbgraderData != null && nbgraderData.grade === true;
    }
    PrivateNbgraderData.isGrade = isGrade;
    function isGraded(nbgraderData) {
        return (PrivateNbgraderData.isGrade(nbgraderData) ||
            PrivateNbgraderData.isTask(nbgraderData));
    }
    PrivateNbgraderData.isGraded = isGraded;
    function isInvalid(nbgraderData, cellType) {
        return (!PrivateNbgraderData.isTask(nbgraderData) &&
            cellType !== 'code' &&
            PrivateNbgraderData.isSolution(nbgraderData) !=
                PrivateNbgraderData.isGrade(nbgraderData));
    }
    PrivateNbgraderData.isInvalid = isInvalid;
    function isLocked(nbgraderData) {
        return (!PrivateNbgraderData.isSolution(nbgraderData) &&
            (PrivateNbgraderData.isGraded(nbgraderData) ||
                (nbgraderData != null && nbgraderData.locked === true)));
    }
    PrivateNbgraderData.isLocked = isLocked;
    function isSolution(nbgraderData) {
        return nbgraderData != null && nbgraderData.solution === true;
    }
    PrivateNbgraderData.isSolution = isSolution;
    function isTask(nbgraderData) {
        return nbgraderData != null && nbgraderData.task === true;
    }
    PrivateNbgraderData.isTask = isTask;
    function _to_float(val) {
        if (val == null || val === '') {
            return 0;
        }
        const valType = typeof val;
        if (valType === 'string') {
            return parseFloat(val);
        }
        else if (valType === 'number') {
            return val;
        }
        return 0;
    }
    PrivateNbgraderData._to_float = _to_float;
})(PrivateNbgraderData || (PrivateNbgraderData = {}));
var PrivateToolData;
(function (PrivateToolData) {
    function getGrade(data) {
        return data.type === 'manual' || data.type === 'tests';
    }
    PrivateToolData.getGrade = getGrade;
    function getGradeId(data) {
        return data.id == null ? '' : data.id;
    }
    PrivateToolData.getGradeId = getGradeId;
    function getLocked(data) {
        if (PrivateToolData.getSolution(data)) {
            return false;
        }
        if (PrivateToolData.getGrade(data)) {
            return true;
        }
        return (data.type === 'task' || data.type === 'tests' || data.type === 'readonly');
    }
    PrivateToolData.getLocked = getLocked;
    function getPoints(data) {
        if (!PrivateToolData.getGrade(data) && !PrivateToolData.getTask(data)) {
            return undefined;
        }
        return data.points >= 0 ? data.points : 0;
    }
    PrivateToolData.getPoints = getPoints;
    function getSchemeaVersion() {
        return NBGRADER_SCHEMA_VERSION;
    }
    PrivateToolData.getSchemeaVersion = getSchemeaVersion;
    function getSolution(data) {
        return data.type === 'manual' || data.type === 'solution';
    }
    PrivateToolData.getSolution = getSolution;
    function getTask(data) {
        return data.type === 'task';
    }
    PrivateToolData.getTask = getTask;
})(PrivateToolData || (PrivateToolData = {}));
/**
 * Dummy class for representing the nbgrader cell metadata.
 */
class NbgraderData {
    toJson() {
        const json = {};
        if (this.grade != null) {
            json['grade'] = this.grade;
        }
        if (this.grade_id != null) {
            json['grade_id'] = this.grade_id;
        }
        if (this.locked != null) {
            json['locked'] = this.locked;
        }
        if (this.points != null) {
            json['points'] = this.points;
        }
        if (this.schema_version != null) {
            json['schema_version'] = this.schema_version;
        }
        if (this.solution != null) {
            json['solution'] = this.solution;
        }
        if (this.task != null) {
            json['task'] = this.task;
        }
        return json;
    }
}
/**
 * Dummy class for representing the UI input/output values.
 */
class ToolData {
}


/***/ }),

/***/ "./lib/components/notebook/slider.js":
/*!*******************************************!*\
  !*** ./lib/components/notebook/slider.js ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   NotebookModeSwitch: () => (/* binding */ NotebookModeSwitch)
/* harmony export */ });
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _switch_factory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./switch-factory */ "./lib/components/notebook/switch-factory.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.


class NotebookModeSwitch extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__.ReactWidget {
    constructor(mode, notebookpanel, notebook) {
        super();
        this.mode = mode;
        const onChange = (m) => {
            this.mode = m;
        };
        const props = {
            notebook: notebook,
            notebookpanel: notebookpanel,
            mode: mode,
            onChange: onChange
        };
        this.component = _switch_factory__WEBPACK_IMPORTED_MODULE_1__.SwitchModeFactory.getSwitch(props);
    }
    render() {
        return this.component;
    }
}


/***/ }),

/***/ "./lib/components/notebook/student-plugin/deadline-widget.js":
/*!*******************************************************************!*\
  !*** ./lib/components/notebook/student-plugin/deadline-widget.js ***!
  \*******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   DeadlineWidget: () => (/* binding */ DeadlineWidget)
/* harmony export */ });
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _deadline_wrapper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./deadline-wrapper */ "./lib/components/notebook/student-plugin/deadline-wrapper.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.



class DeadlineWidget extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__.ReactWidget {
    constructor(path) {
        super();
        this.notebookPaths = path.split('/');
    }
    render() {
        return react__WEBPACK_IMPORTED_MODULE_1__.createElement(_deadline_wrapper__WEBPACK_IMPORTED_MODULE_2__.DeadlineWrapper, { notebookPaths: this.notebookPaths });
    }
}


/***/ }),

/***/ "./lib/components/notebook/student-plugin/deadline-wrapper.js":
/*!********************************************************************!*\
  !*** ./lib/components/notebook/student-plugin/deadline-wrapper.js ***!
  \********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   DeadlineWrapper: () => (/* binding */ DeadlineWrapper)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _util_deadline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../util/deadline */ "./lib/components/util/deadline.js");
/* harmony import */ var _services_lectures_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../services/lectures.service */ "./lib/services/lectures.service.js");
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../services/file.service */ "./lib/services/file.service.js");






/**
 * React Component which handles all request which are needed to get the assignment deadline
 * Why is this needed => we can not to the requests in the widget because the constructor can not handle async requests
 * There is probably a better way to do this
 * @param props props of the component
 */
const DeadlineWrapper = (props) => {
    const [lecture, setLecture] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);
    const [assignment, setAssignment] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        if (lecture === null) {
            (0,_services_lectures_service__WEBPACK_IMPORTED_MODULE_2__.getAllLectures)().then(response => {
                const l = response.find(l => l.code === props.notebookPaths[_services_file_service__WEBPACK_IMPORTED_MODULE_3__.lectureSubPaths]);
                if (l === undefined) {
                    return;
                }
                setLecture(l);
                if (l === null) {
                    return;
                }
                const assignmentIdIndex = _services_file_service__WEBPACK_IMPORTED_MODULE_3__.lectureSubPaths + 2;
                (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_4__.getAssignment)(l.id, +props.notebookPaths[assignmentIdIndex]).then(response => {
                    setAssignment(response);
                });
            });
        }
    }, [props]);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, null, assignment !== null ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_util_deadline__WEBPACK_IMPORTED_MODULE_5__.DeadlineComponent, { due_date: assignment.due_date, compact: false, component: 'chip' })) : null));
};


/***/ }),

/***/ "./lib/components/notebook/student-plugin/hint-component.js":
/*!******************************************************************!*\
  !*** ./lib/components/notebook/student-plugin/hint-component.js ***!
  \******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   HintComponent: () => (/* binding */ HintComponent)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);


const HintComponent = (props) => {
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Collapse, { in: props.show },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Alert, { sx: { mt: 1, mb: 1 }, severity: "info" }, props.hint)));
};


/***/ }),

/***/ "./lib/components/notebook/student-plugin/hint-widget.js":
/*!***************************************************************!*\
  !*** ./lib/components/notebook/student-plugin/hint-widget.js ***!
  \***************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   HintWidget: () => (/* binding */ HintWidget)
/* harmony export */ });
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _hint_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hint-component */ "./lib/components/notebook/student-plugin/hint-component.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.



class HintWidget extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_0__.ReactWidget {
    constructor(hint) {
        super();
        this.showAlert = true;
        this.hint = hint;
    }
    toggleShowAlert() {
        this.showAlert = !this.showAlert;
    }
    setHint(hint) {
        this.hint = hint;
    }
    render() {
        return react__WEBPACK_IMPORTED_MODULE_1__.createElement(_hint_component__WEBPACK_IMPORTED_MODULE_2__.HintComponent, { hint: this.hint, show: this.showAlert });
    }
}


/***/ }),

/***/ "./lib/components/notebook/switch-factory.js":
/*!***************************************************!*\
  !*** ./lib/components/notebook/switch-factory.js ***!
  \***************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   SwitchModeFactory: () => (/* binding */ SwitchModeFactory)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _services_permission_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../services/permission.service */ "./lib/services/permission.service.js");
/* harmony import */ var _create_assignment_creation_switch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./create-assignment/creation-switch */ "./lib/components/notebook/create-assignment/creation-switch.js");
/* harmony import */ var _manual_grading_grading_switch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./manual-grading/grading-switch */ "./lib/components/notebook/manual-grading/grading-switch.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../services/file.service */ "./lib/services/file.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.





class SwitchModeFactory {
    static getSwitch(props) {
        const paths = props.notebookpanel.context.contentsModel.path.split('/');
        const path = paths[_services_file_service__WEBPACK_IMPORTED_MODULE_1__.lectureSubPaths + 1];
        const permissions = _services_permission_service__WEBPACK_IMPORTED_MODULE_2__.UserPermissions.getPermissions();
        const lecturecode = paths[_services_file_service__WEBPACK_IMPORTED_MODULE_1__.lectureSubPaths];
        let hasPermission = false;
        if (permissions.hasOwnProperty(lecturecode)) {
            hasPermission = permissions[lecturecode] !== _services_permission_service__WEBPACK_IMPORTED_MODULE_2__.Scope.student;
        }
        if (!hasPermission) {
            return null;
        }
        switch (path) {
            case 'manualgrade':
                return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_manual_grading_grading_switch__WEBPACK_IMPORTED_MODULE_3__.GradingModeSwitch, { notebook: props.notebook, notebookpanel: props.notebookpanel, mode: props.mode, onChange: props.onChange }));
            case 'source':
                return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_create_assignment_creation_switch__WEBPACK_IMPORTED_MODULE_4__.CreationModeSwitch, { notebook: props.notebook, notebookpanel: props.notebookpanel, mode: props.mode, onChange: props.onChange }));
            default:
                return null;
        }
    }
}


/***/ }),

/***/ "./lib/components/util/breadcrumbs.js":
/*!********************************************!*\
  !*** ./lib/components/util/breadcrumbs.js ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   LinkRouter: () => (/* binding */ LinkRouter),
/* harmony export */   Page: () => (/* binding */ Page),
/* harmony export */   RouterBreadcrumbs: () => (/* binding */ RouterBreadcrumbs)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material_Link__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/material/Link */ "./node_modules/@mui/material/Link/Link.js");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_icons_material_NavigateNext__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @mui/icons-material/NavigateNext */ "./node_modules/@mui/icons-material/NavigateNext.js");
/* harmony import */ var _services_storage_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../services/storage.service */ "./lib/services/storage.service.js");






const Page = ({ id }) => {
    const pathname = "/" + (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useLocation)().pathname.split("/").filter(v => v.length > 0).slice(0, 2).join("/");
    (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_3__.storeString)(`${id}-react-router-path`, pathname);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(RouterBreadcrumbs, null),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Outlet, null)));
};
function LinkRouter(props) {
    return react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Link__WEBPACK_IMPORTED_MODULE_4__["default"], { ...props, component: react_router_dom__WEBPACK_IMPORTED_MODULE_1__.Link });
}
const RouterBreadcrumbs = () => {
    const pathname = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useLocation)().pathname.replace(/\/$/, "");
    let matches = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useMatches)();
    console.log(`Navigating to: ${pathname}`);
    let crumbs = matches
        // first get rid of any matches that don't have handle and crumb
        .filter((match) => Boolean(match.handle?.crumb))
        // now map them into an array of elements, passing the loader
        // data to each one
        .map((match) => match.handle.crumb(match.data));
    console.log(crumbs);
    let links = matches
        .filter((match) => Boolean(match.handle?.link))
        .map((match) => match.handle.link(match.params));
    console.log(links);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Breadcrumbs, { sx: { m: 1 }, "aria-label": 'breadcrumb', separator: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_NavigateNext__WEBPACK_IMPORTED_MODULE_5__["default"], { fontSize: 'small' }) }, links.map((value, index) => {
        const last = index === links.length - 1;
        const to = links.slice(0, index + 1).join('');
        const samePath = to.replace(/\/$/, "") === pathname; // e.g. happens if last path adds nothing to link (second to last crumb also points to same page)
        return last || samePath ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Typography, { color: 'text.primary', key: to }, crumbs[index])) : (react__WEBPACK_IMPORTED_MODULE_0__.createElement(LinkRouter, { underline: 'hover', color: 'inherit', to: to, key: to }, crumbs[index]));
    })));
};


/***/ }),

/***/ "./lib/components/util/deadline.js":
/*!*****************************************!*\
  !*** ./lib/components/util/deadline.js ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   DeadlineComponent: () => (/* binding */ DeadlineComponent),
/* harmony export */   calculateTimeLeft: () => (/* binding */ calculateTimeLeft),
/* harmony export */   getDisplayDate: () => (/* binding */ getDisplayDate)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! moment */ "webpack/sharing/consume/default/moment/moment");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_icons_material_AccessAlarmRounded__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/icons-material/AccessAlarmRounded */ "./node_modules/@mui/icons-material/AccessAlarmRounded.js");
/* harmony import */ var _mui_system__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/system */ "webpack/sharing/consume/default/@mui/system/@mui/system?d248");
/* harmony import */ var _mui_system__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_system__WEBPACK_IMPORTED_MODULE_3__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.





const compactTimeUnits = {
    w: 'W',
    d: 'd',
    h: 'h',
    m: 'm',
    s: 's'
};
const fullTimeUnits = {
    w: 'Week',
    d: 'Day',
    h: 'Hour',
    m: 'Minute',
    s: 'Second'
};
const theme = (0,_mui_material__WEBPACK_IMPORTED_MODULE_2__.createTheme)({
    palette: {
        warning: {
            main: '#ffa726',
            contrastText: '#fff',
        },
        error: {
            main: '#ef5350',
            contrastText: '#fff',
        },
    },
});
const getTimeUnit = (timeUnit, value, compact) => {
    if (compact) {
        return `${value}${compactTimeUnits[timeUnit]}`;
    }
    if (value === 1) {
        return `${value} ${fullTimeUnits[timeUnit]}`;
    }
    else {
        return `${value} ${fullTimeUnits[timeUnit]}s`;
    }
};
const calculateTimeLeft = (date) => {
    const difference = +date - +new Date();
    const timeLeft = {
        weeks: Math.floor(difference / (1000 * 60 * 60 * 24 * 7)),
        days: Math.floor((difference / (1000 * 60 * 60 * 24)) % 7),
        hours: Math.floor((difference / (1000 * 60 * 60)) % 24),
        minutes: Math.floor((difference / 1000 / 60) % 60),
        seconds: Math.floor((difference / 1000) % 60)
    };
    return timeLeft;
};
function getDisplayDate(date, compact) {
    if (date === undefined) {
        return 'No Deadline 😁';
    }
    const time = calculateTimeLeft(date);
    if (time.weeks === 0) {
        if (time.days === 0) {
            return `${getTimeUnit('h', time.hours, compact)} ${getTimeUnit('m', time.minutes, compact)} ${getTimeUnit('s', time.seconds, compact)}`;
        }
        else {
            return `${getTimeUnit('d', time.days, compact)} ${getTimeUnit('h', time.hours, compact)} ${getTimeUnit('m', time.minutes, compact)}`;
        }
    }
    else if (time.weeks > 0) {
        return `${getTimeUnit('w', time.weeks, compact)} ${getTimeUnit('d', time.days, compact)} ${getTimeUnit('h', time.hours, compact)}`;
    }
    else {
        return 'Deadline over!';
    }
}
const DeadlineComponent = (props) => {
    const [date, setDate] = react__WEBPACK_IMPORTED_MODULE_0__.useState(props.due_date !== null
        ? moment__WEBPACK_IMPORTED_MODULE_1___default().utc(props.due_date).local().toDate()
        : undefined);
    const [displayDate, setDisplayDate] = react__WEBPACK_IMPORTED_MODULE_0__.useState(getDisplayDate(date, props.compact));
    const [interval, setNewInterval] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);
    const [color, setColor] = react__WEBPACK_IMPORTED_MODULE_0__.useState('default');
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        const d = props.due_date !== null
            ? moment__WEBPACK_IMPORTED_MODULE_1___default().utc(props.due_date).local().toDate()
            : undefined;
        setDate(d);
        setDisplayDate(getDisplayDate(d, props.compact));
        updateTimeoutInterval(d);
        let c = 'default';
        const time = calculateTimeLeft(d);
        if (d !== undefined) {
            if (time.weeks === 0 && time.days === 0) {
                c = 'warning';
                if (time.hours === 0) {
                    c = 'error';
                }
            }
            if (+d - +new Date() < 0) {
                c = 'error';
            }
        }
        setColor(c);
    }, [props]);
    const updateTimeoutInterval = (date) => {
        if (interval) {
            clearInterval(interval);
        }
        const time = calculateTimeLeft(date);
        const timeout = time.weeks === 0 && time.days === 0 ? 1000 : 10000;
        const newInterval = setInterval(() => {
            setDisplayDate(getDisplayDate(date, props.compact));
        }, timeout);
        setNewInterval(newInterval);
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_system__WEBPACK_IMPORTED_MODULE_3__.ThemeProvider, { theme: theme },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Chip, { sx: props.sx, size: "small", icon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_AccessAlarmRounded__WEBPACK_IMPORTED_MODULE_4__["default"], null), label: displayDate, color: color })));
};


/***/ }),

/***/ "./lib/components/util/dialog-provider.js":
/*!************************************************!*\
  !*** ./lib/components/util/dialog-provider.js ***!
  \************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   DialogProvider: () => (/* binding */ DialogProvider),
/* harmony export */   showDialog: () => (/* binding */ showDialog)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_lab__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/lab */ "webpack/sharing/consume/default/@mui/lab/@mui/lab");
/* harmony import */ var _mui_lab__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_lab__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_3__);




const DialogContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext({
    showDialog: (title, message, onAgree) => {
        return;
    }
});
let showDialog;
const DialogProvider = (props) => {
    const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [open, setOpen] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [title, setTitle] = react__WEBPACK_IMPORTED_MODULE_0__.useState('');
    const [message, setMessage] = react__WEBPACK_IMPORTED_MODULE_0__.useState('');
    const [onAgree, setOnAgree] = react__WEBPACK_IMPORTED_MODULE_0__.useState(undefined);
    showDialog = (title, message, onAgree) => {
        setTitle(title);
        setMessage(message);
        setOnAgree(() => onAgree);
        setOpen(true);
    };
    const closeDialog = () => setOpen(false);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(DialogContext.Provider, { value: { showDialog } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Dialog, { open: open, onClose: closeDialog, onBackdropClick: closeDialog, "aria-labelledby": 'alert-dialog-title', "aria-describedby": 'alert-dialog-description' },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.DialogTitle, { id: 'alert-dialog-title' }, title),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.DialogContent, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.DialogContentText, { id: 'alert-dialog-description' }, message)),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.DialogActions, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { onClick: closeDialog }, "Disagree"),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_lab__WEBPACK_IMPORTED_MODULE_2__.LoadingButton, { loading: loading, onClick: async () => {
                        setLoading(true);
                        try {
                            await onAgree();
                        }
                        catch (e) {
                            const m = (e?.message) ? e?.message : "An Error occurred!";
                            (0,notistack__WEBPACK_IMPORTED_MODULE_3__.enqueueSnackbar)("error", m);
                        }
                        setLoading(false);
                        setOpen(false);
                    }, autoFocus: true },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, "Agree")))),
        props.children));
};


/***/ }),

/***/ "./lib/components/util/dialog.js":
/*!***************************************!*\
  !*** ./lib/components/util/dialog.js ***!
  \***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   CommitDialog: () => (/* binding */ CommitDialog),
/* harmony export */   CreateDialog: () => (/* binding */ CreateDialog),
/* harmony export */   EditLectureDialog: () => (/* binding */ EditLectureDialog),
/* harmony export */   ReleaseDialog: () => (/* binding */ ReleaseDialog),
/* harmony export */   "default": () => (/* binding */ NewAssignmentCard)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var formik__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! formik */ "webpack/sharing/consume/default/formik/formik");
/* harmony import */ var formik__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(formik__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var yup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! yup */ "webpack/sharing/consume/default/yup/yup");
/* harmony import */ var yup__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(yup__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _mui_x_date_pickers_LocalizationProvider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @mui/x-date-pickers/LocalizationProvider */ "./node_modules/@mui/x-date-pickers/LocalizationProvider/LocalizationProvider.js");
/* harmony import */ var _mui_x_date_pickers_AdapterDateFns__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @mui/x-date-pickers/AdapterDateFns */ "./node_modules/@mui/x-date-pickers/AdapterDateFns/AdapterDateFns.js");
/* harmony import */ var _mui_x_date_pickers_DateTimePicker__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @mui/x-date-pickers/DateTimePicker */ "./node_modules/@mui/x-date-pickers/DateTimePicker/DateTimePicker.js");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _mui_lab__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/lab */ "webpack/sharing/consume/default/@mui/lab/@mui/lab");
/* harmony import */ var _mui_lab__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_mui_lab__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _mui_icons_material_Settings__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @mui/icons-material/Settings */ "./node_modules/@mui/icons-material/Settings.js");
/* harmony import */ var _services_assignments_service__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../services/assignments.service */ "./lib/services/assignments.service.js");
/* harmony import */ var _mui_icons_material_HelpOutlineOutlined__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @mui/icons-material/HelpOutlineOutlined */ "./node_modules/@mui/icons-material/HelpOutlineOutlined.js");
/* harmony import */ var _mui_icons_material_Add__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @mui/icons-material/Add */ "./node_modules/@mui/icons-material/Add.js");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _dialog_provider__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./dialog-provider */ "./lib/components/util/dialog-provider.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.














const gradingBehaviourHelp = `Specifies the behaviour when a students submits an assignment.\n
No Automatic Grading: No action is taken on submit.\n
Automatic Grading: The assignment is being autograded as soon as the students makes a submission.\n
Fully Automatic Grading: The assignment is autograded and feedback is generated as soon as the student makes a submission. 
(requires all scores to be based on autograde results)`;
const validationSchema = yup__WEBPACK_IMPORTED_MODULE_2__.object({
    name: yup__WEBPACK_IMPORTED_MODULE_2__.string()
        .min(4, 'Name should be 4-50 character length')
        .max(50, 'Name should be 4-50 character length')
        .required('Name is required'),
    due_date: yup__WEBPACK_IMPORTED_MODULE_2__.date()
        .min(new Date(), 'Deadline must be set in the future')
        .nullable(),
    type: yup__WEBPACK_IMPORTED_MODULE_2__.mixed().oneOf(['user', 'group']),
    automatic_grading: yup__WEBPACK_IMPORTED_MODULE_2__.mixed().oneOf(['unassisted', 'auto', 'full_auto']),
    max_submissions: yup__WEBPACK_IMPORTED_MODULE_2__.number()
        .nullable()
        .min(1, 'Students must be able to at least submit once')
});
const validationSchemaLecture = yup__WEBPACK_IMPORTED_MODULE_2__.object({
    name: yup__WEBPACK_IMPORTED_MODULE_2__.string()
        .min(4, 'Name should be 4-50 characters long')
        .max(50, 'Name should be 4-50 characters long')
        .required('Name is required'),
    complete: yup__WEBPACK_IMPORTED_MODULE_2__.boolean()
});
const EditLectureDialog = (props) => {
    const formik = (0,formik__WEBPACK_IMPORTED_MODULE_1__.useFormik)({
        initialValues: {
            name: props.lecture.name,
            complete: props.lecture.complete
        },
        validationSchema: validationSchemaLecture,
        onSubmit: values => {
            const updatedLecture = Object.assign(props.lecture, values);
            props.handleSubmit(updatedLecture);
            setOpen(false);
        }
    });
    const [openDialog, setOpen] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Tooltip, { title: 'Edit Lecture' },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.IconButton, { onClick: e => {
                    e.stopPropagation();
                    setOpen(true);
                }, onMouseDown: event => event.stopPropagation(), "aria-label": 'edit' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Settings__WEBPACK_IMPORTED_MODULE_6__["default"], null))),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Dialog, { open: openDialog, onBackdropClick: () => setOpen(false) },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogTitle, null, "Edit Lecture"),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement("form", { onSubmit: formik.handleSubmit },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogContent, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Stack, { spacing: 2 },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.TextField, { variant: 'outlined', fullWidth: true, id: 'name', name: 'name', label: 'Lecture Name', value: formik.values.name, onChange: formik.handleChange, error: formik.touched.name && Boolean(formik.errors.name), helperText: formik.touched.name && formik.errors.name }),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Checkbox, { value: formik.values.complete, checked: formik.values.complete, onChange: e => {
                                    formik.setFieldValue('complete', e.target.checked);
                                } }), label: 'Complete' }))),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogActions, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Button, { color: 'primary', variant: 'outlined', onClick: () => {
                            setOpen(false);
                        } }, "Cancel"),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Button, { color: 'primary', variant: 'contained', type: 'submit' }, "Submit"))))));
};
function NewAssignmentCard(props) {
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Card, { sx: { width: 225, height: '100%', m: 1.5, backgroundColor: '#fcfcfc' } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Tooltip, { title: 'New Assignment' },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.CardActionArea, { onClick: props.onClick, sx: {
                    width: '100%',
                    height: '100%',
                    display: 'flex',
                    justifyContent: 'center',
                    alignItems: 'center'
                } },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Add__WEBPACK_IMPORTED_MODULE_7__["default"], { sx: { fontSize: 50 }, color: 'disabled' })))));
}
const CreateDialog = (props) => {
    const formik = (0,formik__WEBPACK_IMPORTED_MODULE_1__.useFormik)({
        initialValues: {
            name: 'Assignment',
            due_date: null,
            type: 'user',
            automatic_grading: 'auto',
            max_submissions: undefined,
            allow_files: false
        },
        validationSchema: validationSchema,
        onSubmit: values => {
            if (values.max_submissions !== null) {
                values.max_submissions = +values.max_submissions;
            }
            const newAssignment = {
                name: values.name,
                due_date: values.due_date,
                type: values.type,
                automatic_grading: values.automatic_grading,
                max_submissions: values.max_submissions,
                allow_files: values.allow_files
            };
            (0,_services_assignments_service__WEBPACK_IMPORTED_MODULE_8__.createAssignment)(props.lecture.id, newAssignment).then(a => props.handleSubmit(a), error => {
                (0,notistack__WEBPACK_IMPORTED_MODULE_5__.enqueueSnackbar)(error.message, {
                    variant: 'error'
                });
            });
            setOpen(false);
        }
    });
    const [openDialog, setOpen] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Tooltip, { title: 'Create New Assignment' },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Button, { variant: 'contained', startIcon: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Add__WEBPACK_IMPORTED_MODULE_7__["default"], null), onClick: e => {
                    e.stopPropagation();
                    setOpen(true);
                } }, "New")),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Dialog, { open: openDialog, onBackdropClick: () => setOpen(false), onClose: () => setOpen(false) },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogTitle, null, "Create Assignment"),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement("form", { onSubmit: formik.handleSubmit },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogContent, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Stack, { spacing: 2 },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.TextField, { variant: 'outlined', fullWidth: true, id: 'name', name: 'name', label: 'Assignment Name', value: formik.values.name, onChange: formik.handleChange, error: formik.touched.name && Boolean(formik.errors.name), helperText: formik.touched.name && formik.errors.name }),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_x_date_pickers_LocalizationProvider__WEBPACK_IMPORTED_MODULE_9__.LocalizationProvider, { dateAdapter: _mui_x_date_pickers_AdapterDateFns__WEBPACK_IMPORTED_MODULE_10__.AdapterDateFns },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Checkbox, { value: false, onChange: async (e) => {
                                        if (e.target.checked) {
                                            await formik.setFieldValue('due_date', new Date());
                                        }
                                        else {
                                            await formik.setFieldValue('due_date', null);
                                        }
                                    } }), label: 'Set Deadline' }),
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_x_date_pickers_DateTimePicker__WEBPACK_IMPORTED_MODULE_11__.DateTimePicker, { disablePast: true, ampm: false, disabled: formik.values.due_date === null, label: 'DateTimePicker', value: formik.values.due_date, onChange: (date) => {
                                    formik.setFieldValue('due_date', date);
                                } })),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Checkbox, { value: Boolean(formik.values.max_submissions), onChange: async (e) => {
                                    if (e.target.checked) {
                                        await formik.setFieldValue('max_submissions', 1);
                                    }
                                    else {
                                        await formik.setFieldValue('max_submissions', undefined);
                                    }
                                } }), label: 'Limit Number of Submissions' }),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.TextField, { variant: 'outlined', fullWidth: true, disabled: !formik.values.max_submissions, type: 'number', id: 'max-submissions', name: 'max_submissions', placeholder: 'Submissions', value: formik.values.max_submissions, onChange: e => {
                                formik.setFieldValue('max_submissions', e.target.value);
                            }, error: formik.values.max_submissions < 1 }),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.InputLabel, { id: 'demo-simple-select-label-auto' },
                            "Auto-Grading Behaviour",
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Tooltip, { title: gradingBehaviourHelp },
                                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_HelpOutlineOutlined__WEBPACK_IMPORTED_MODULE_12__["default"], { fontSize: 'small', sx: { ml: 1.5, mt: 1.0 } }))),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.TextField, { select: true, id: 'assignment-type-select', value: formik.values.automatic_grading, label: 'Auto-Grading Behaviour', placeholder: 'Grading', onChange: e => {
                                formik.setFieldValue('automatic_grading', e.target.value);
                            } },
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.MenuItem, { value: 'unassisted' }, "No Automatic Grading"),
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.MenuItem, { value: 'auto' }, "Automatic Grading"),
                            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.MenuItem, { value: 'full_auto' }, "Fully Automatic Grading")),
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.FormControlLabel, { control: react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Checkbox, { checked: formik.values.allow_files, onChange: async (e) => {
                                    console.log(e.target.checked);
                                    await formik.setFieldValue('allow_files', e.target.checked);
                                } }), label: 'Allow file upload by students' }))),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogActions, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Button, { color: 'primary', variant: 'outlined', onClick: () => {
                            setOpen(false);
                        } }, "Cancel"),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Button, { color: 'primary', variant: 'contained', type: 'submit' }, "Create"))))));
};
const CommitDialog = (props) => {
    const [open, setOpen] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [message, setMessage] = react__WEBPACK_IMPORTED_MODULE_0__.useState('');
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Box, { onClick: () => setOpen(true) }, props.children),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Dialog, { open: open, onBackdropClick: () => setOpen(false), onClose: () => setOpen(false), fullWidth: true, maxWidth: 'sm' },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogTitle, null, "Commit Files"),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogContent, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.TextField, { sx: { mt: 2, width: '100%' }, id: 'outlined-textarea', label: 'Commit Message', placeholder: 'Commit Message', value: message, onChange: event => setMessage(event.target.value), multiline: true })),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogActions, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Button, { color: 'primary', variant: 'outlined', onClick: () => {
                        setOpen(false);
                    } }, "Cancel"),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Button, { color: 'primary', variant: 'contained', type: 'submit', disabled: message === '', onClick: () => {
                        props.handleCommit(message);
                        setOpen(false);
                    } }, "Commit")))));
};
const ReleaseDialog = (props) => {
    const [commitOpen, setCommitOpen] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const [message, setMessage] = react__WEBPACK_IMPORTED_MODULE_0__.useState('');
    const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_0__.useState(false);
    const agreeMessage = `Do you want to release "${props.assignment.name}" for all students? Before releasing, all changes are pushed again as the release version.`;
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null,
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Box, { onClick: () => {
                (0,_dialog_provider__WEBPACK_IMPORTED_MODULE_13__.showDialog)('Release Assignment', agreeMessage, () => {
                    setCommitOpen(true);
                });
            } }, props.children),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Dialog, { open: commitOpen, onClose: () => setCommitOpen(false), fullWidth: true, maxWidth: 'sm' },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogTitle, null, "Commit Files"),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogContent, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.TextField, { sx: { mt: 2, width: '100%' }, id: 'outlined-textarea', label: 'Commit Message', placeholder: 'Commit Message', value: message, onChange: event => setMessage(event.target.value), multiline: true })),
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.DialogActions, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Button, { color: 'primary', variant: 'outlined', onClick: () => {
                        setCommitOpen(false);
                    } }, "Cancel"),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_lab__WEBPACK_IMPORTED_MODULE_4__.LoadingButton, { loading: loading, color: 'primary', variant: 'contained', type: 'submit', disabled: message === '', onClick: async () => {
                        setLoading(true);
                        await props.handleCommit(message);
                        await props.handleRelease();
                        setLoading(false);
                        setCommitOpen(false);
                    } },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, "Commit and Release"))))));
};


/***/ }),

/***/ "./lib/components/util/error.js":
/*!**************************************!*\
  !*** ./lib/components/util/error.js ***!
  \**************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ ErrorPage)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _services_storage_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../services/storage.service */ "./lib/services/storage.service.js");



function ErrorPage({ id }) {
    const error = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_1__.useRouteError)();
    console.error(error);
    (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_2__.storeString)(`${id}-react-router-path`, "/");
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { id: "error-page" },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement("h1", null, "Oops!"),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", null, "Sorry, an unexpected error has occurred."),
        react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", null,
            react__WEBPACK_IMPORTED_MODULE_0__.createElement("i", null, error.statusText || error.message))));
}


/***/ }),

/***/ "./lib/components/util/file-list.js":
/*!******************************************!*\
  !*** ./lib/components/util/file-list.js ***!
  \******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   FilesList: () => (/* binding */ FilesList)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_icons_material_InsertDriveFileRounded__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/icons-material/InsertDriveFileRounded */ "./node_modules/@mui/icons-material/InsertDriveFileRounded.js");
/* harmony import */ var _services_file_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../services/file.service */ "./lib/services/file.service.js");
/* harmony import */ var _mui_material_colors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/material/colors */ "./node_modules/@mui/material/colors/grey.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.





const FilesList = (props) => {
    const [files, setFiles] = react__WEBPACK_IMPORTED_MODULE_0__.useState([]);
    react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {
        (0,_services_file_service__WEBPACK_IMPORTED_MODULE_2__.getFiles)(props.path).then(files => setFiles(files));
    }, [props]);
    // generateItems will be fed using the IIterator from the FilterFileBrowserModel
    const generateItems = (files) => {
        return files.map(file => (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.ListItem, { disablePadding: true },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.ListItemButton, { onClick: () => (0,_services_file_service__WEBPACK_IMPORTED_MODULE_2__.openFile)(file.value.path), dense: true },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.ListItemIcon, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_InsertDriveFileRounded__WEBPACK_IMPORTED_MODULE_3__["default"], null)),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.ListItemText, { primary: file.value.name })))));
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Paper, { elevation: 0, sx: props.sx },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Card, { sx: { mt: 1, maxHeight: 200, overflow: 'auto' }, variant: "outlined" }, files.length === 0 ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, { variant: 'body1', color: _mui_material_colors__WEBPACK_IMPORTED_MODULE_4__["default"][500], sx: { ml: 1 } }, "No Files Found")) : (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.List, { dense: false }, generateItems(files))))));
};


/***/ }),

/***/ "./lib/components/util/overlay.js":
/*!****************************************!*\
  !*** ./lib/components/util/overlay.js ***!
  \****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ LoadingOverlay)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material_Modal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @mui/material/Modal */ "./node_modules/@mui/material/Modal/Modal.js");
/* harmony import */ var _mui_material_Fade__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material/Fade */ "./node_modules/@mui/material/Fade/Fade.js");
/* harmony import */ var _mui_material_Box__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @mui/material/Box */ "./node_modules/@mui/material/Box/Box.js");
/* harmony import */ var _mui_icons_material_Close__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @mui/icons-material/Close */ "./node_modules/@mui/icons-material/Close.js");
/* harmony import */ var _mui_material_IconButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @mui/material/IconButton */ "./node_modules/@mui/material/IconButton/IconButton.js");
/* harmony import */ var _mui_material_Zoom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @mui/material/Zoom */ "./node_modules/@mui/material/Zoom/Zoom.js");
/* harmony import */ var _mui_material_CircularProgress__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @mui/material/CircularProgress */ "./node_modules/@mui/material/CircularProgress/CircularProgress.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.








function LoadingOverlay(props) {
    const baseStyle = {
        position: 'absolute',
        top: 0,
        bottom: 0,
        width: '100%',
        height: '100%',
        bgcolor: 'background.paper'
    };
    const style = { ...baseStyle, ...props.sx };
    const Transitions = {
        fade: _mui_material_Fade__WEBPACK_IMPORTED_MODULE_1__["default"],
        zoom: _mui_material_Zoom__WEBPACK_IMPORTED_MODULE_2__["default"]
    };
    const Transition = Transitions[props.transition];
    let content;
    if (props.loading) {
        if (props.skeleton === null) {
            content = (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_CircularProgress__WEBPACK_IMPORTED_MODULE_3__["default"], { sx: {
                    position: 'absolute',
                    top: '50%',
                    left: '50%'
                } }));
        }
        else {
            content = props.skeleton;
        }
    }
    else {
        content = props.children;
    }
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Modal__WEBPACK_IMPORTED_MODULE_4__["default"], { open: props.open, onClose: props.onClose, hideBackdrop: true, "aria-labelledby": "modal-modal-title", "aria-describedby": "modal-modal-description", container: props.container, keepMounted: props.keepMounted, disableEnforceFocus: true, disableEscapeKeyDown: props.disableEscapeKeyDown, sx: { position: 'absolute', width: '100%', height: '100%' } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(Transition, { in: props.open, timeout: props.timeout },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_Box__WEBPACK_IMPORTED_MODULE_5__["default"], { sx: style, className: '.mui-fixed' },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material_IconButton__WEBPACK_IMPORTED_MODULE_6__["default"], { className: '.mui-fixed', size: "small", sx: {
                        position: 'absolute',
                        right: '20px',
                        top: '20px',
                        zIndex: 1000000
                    }, onClick: props.onClose },
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_icons_material_Close__WEBPACK_IMPORTED_MODULE_7__["default"], null)),
                content))));
}
LoadingOverlay.defaultProps = {
    loading: false,
    skeleton: null,
    timeout: 200,
    transition: 'fade',
    sx: {}
};


/***/ }),

/***/ "./lib/components/util/repo-type.js":
/*!******************************************!*\
  !*** ./lib/components/util/repo-type.js ***!
  \******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   RepoType: () => (/* binding */ RepoType)
/* harmony export */ });
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
var RepoType;
(function (RepoType) {
    RepoType["SOURCE"] = "source";
    RepoType["RELEASE"] = "release";
    RepoType["ASSIGNMENT"] = "assignment";
})(RepoType || (RepoType = {}));


/***/ }),

/***/ "./lib/components/util/section-title.js":
/*!**********************************************!*\
  !*** ./lib/components/util/section-title.js ***!
  \**********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   SectionTitle: () => (/* binding */ SectionTitle)
/* harmony export */ });
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.


const SectionTitle = (props) => {
    return (react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Box, { sx: { m: 3, top: 3 } },
        react__WEBPACK_IMPORTED_MODULE_1__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_0__.Typography, { display: "inline-block", variant: "h4" }, props.title),
        props.children));
};


/***/ }),

/***/ "./lib/components/util/table.js":
/*!**************************************!*\
  !*** ./lib/components/util/table.js ***!
  \**************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ButtonTr: () => (/* binding */ ButtonTr),
/* harmony export */   GraderTable: () => (/* binding */ GraderTable)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @mui/material */ "webpack/sharing/consume/default/@mui/material/@mui/material");
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);


function ButtonTr({ children, ...rest }) {
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Button, { style: { textTransform: 'none' }, component: _mui_material__WEBPACK_IMPORTED_MODULE_1__.TableRow, ...rest }, children));
}
function GraderTable(props) {
    const [page, setPage] = react__WEBPACK_IMPORTED_MODULE_0__.useState(0);
    const [rowsPerPage, setRowsPerPage] = react__WEBPACK_IMPORTED_MODULE_0__.useState(5);
    // Avoid a layout jump when reaching the last page with empty rows.
    const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - props.rows.length) : 0;
    const handleChangePage = (event, newPage) => {
        setPage(newPage);
    };
    const handleChangeRowsPerPage = (event) => {
        setRowsPerPage(parseInt(event.target.value, 10));
        setPage(0);
    };
    return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Paper, { sx: { overflow: 'hidden' } },
        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TableContainer, { sx: { maxHeight: '500px' } },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Table, { "aria-label": 'simple table', stickyHeader: true },
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TableHead, null,
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TableRow, null, props.headers.map(header => react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TableCell, { style: { width: header.width } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Typography, { color: 'primary' }, header.name))))),
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TableBody, null,
                    props.rows.map((row) => props.rowFunc(row)),
                    react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TableRow, { style: { height: 53 * emptyRows } },
                        react__WEBPACK_IMPORTED_MODULE_0__.createElement(_mui_material__WEBPACK_IMPORTED_MODULE_1__.TableCell, { colSpan: 6 })))))));
}
;


/***/ }),

/***/ "./lib/index.js":
/*!**********************!*\
  !*** ./lib/index.js ***!
  \**********************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GlobalObjects: () => (/* binding */ GlobalObjects),
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _jupyterlab_application__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/application */ "webpack/sharing/consume/default/@jupyterlab/application");
/* harmony import */ var _jupyterlab_application__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_application__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _jupyterlab_launcher__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @jupyterlab/launcher */ "webpack/sharing/consume/default/@jupyterlab/launcher");
/* harmony import */ var _jupyterlab_launcher__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_launcher__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _jupyterlab_notebook__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @jupyterlab/notebook */ "webpack/sharing/consume/default/@jupyterlab/notebook");
/* harmony import */ var _jupyterlab_notebook__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_notebook__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _widgets_coursemanage__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./widgets/coursemanage */ "./lib/widgets/coursemanage.js");
/* harmony import */ var _components_notebook_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/notebook/slider */ "./lib/components/notebook/slider.js");
/* harmony import */ var _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @jupyterlab/ui-components */ "webpack/sharing/consume/default/@jupyterlab/ui-components");
/* harmony import */ var _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _jupyterlab_docmanager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @jupyterlab/docmanager */ "webpack/sharing/consume/default/@jupyterlab/docmanager");
/* harmony import */ var _jupyterlab_docmanager__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_docmanager__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _jupyterlab_filebrowser__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @jupyterlab/filebrowser */ "webpack/sharing/consume/default/@jupyterlab/filebrowser");
/* harmony import */ var _jupyterlab_filebrowser__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_filebrowser__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _services_permission_service__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./services/permission.service */ "./lib/services/permission.service.js");
/* harmony import */ var _widgets_assignmentmanage__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./widgets/assignmentmanage */ "./lib/widgets/assignmentmanage.js");
/* harmony import */ var _components_notebook_create_assignment_creation_widget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./components/notebook/create-assignment/creation-widget */ "./lib/components/notebook/create-assignment/creation-widget.js");
/* harmony import */ var _jupyterlab_ui_components_lib_icon_iconimports__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @jupyterlab/ui-components/lib/icon/iconimports */ "./node_modules/@jupyterlab/ui-components/lib/icon/iconimports.js");
/* harmony import */ var _components_notebook_student_plugin_hint_widget__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./components/notebook/student-plugin/hint-widget */ "./lib/components/notebook/student-plugin/hint-widget.js");
/* harmony import */ var _components_notebook_student_plugin_deadline_widget__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./components/notebook/student-plugin/deadline-widget */ "./lib/components/notebook/student-plugin/deadline-widget.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
// noinspection TypeScriptValidateTypes
/* eslint-disable no-constant-condition */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-prototype-builtins */
















var AssignmentsCommandIDs;
(function (AssignmentsCommandIDs) {
    AssignmentsCommandIDs.create = 'assignments:create';
    AssignmentsCommandIDs.open = 'assignments:open';
})(AssignmentsCommandIDs || (AssignmentsCommandIDs = {}));
var CourseManageCommandIDs;
(function (CourseManageCommandIDs) {
    CourseManageCommandIDs.create = 'coursemanage:create';
    CourseManageCommandIDs.open = 'coursemanage:open';
})(CourseManageCommandIDs || (CourseManageCommandIDs = {}));
var NotebookExecuteIDs;
(function (NotebookExecuteIDs) {
    NotebookExecuteIDs.run = 'notebookplugin:run-cell';
})(NotebookExecuteIDs || (NotebookExecuteIDs = {}));
var RevertCellIDs;
(function (RevertCellIDs) {
    RevertCellIDs.revert = 'notebookplugin:revert-cell';
})(RevertCellIDs || (RevertCellIDs = {}));
var ShowHintIDs;
(function (ShowHintIDs) {
    ShowHintIDs.show = 'notebookplugin:show-hint';
})(ShowHintIDs || (ShowHintIDs = {}));
var GradingCommandIDs;
(function (GradingCommandIDs) {
    GradingCommandIDs.create = 'grading:create';
    GradingCommandIDs.open = 'grading:open';
})(GradingCommandIDs || (GradingCommandIDs = {}));
var ManualGradeCommandIDs;
(function (ManualGradeCommandIDs) {
    ManualGradeCommandIDs.create = 'manualgrade:create';
    ManualGradeCommandIDs.open = 'manualgrade:open';
})(ManualGradeCommandIDs || (ManualGradeCommandIDs = {}));
var FeedbackCommandIDs;
(function (FeedbackCommandIDs) {
    FeedbackCommandIDs.create = 'feedback:create';
    FeedbackCommandIDs.open = 'feedback:open';
})(FeedbackCommandIDs || (FeedbackCommandIDs = {}));
var DeadlineCommandIDs;
(function (DeadlineCommandIDs) {
    DeadlineCommandIDs.open = 'deadline:open';
})(DeadlineCommandIDs || (DeadlineCommandIDs = {}));
class GlobalObjects {
}
/**
 * Initialization data for the grading extension.
 */
const extension = {
    id: 'coursemanage:plugin',
    autoStart: true,
    requires: [
        _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.ICommandPalette,
        _jupyterlab_launcher__WEBPACK_IMPORTED_MODULE_2__.ILauncher,
        _jupyterlab_notebook__WEBPACK_IMPORTED_MODULE_3__.INotebookTools,
        _jupyterlab_docmanager__WEBPACK_IMPORTED_MODULE_5__.IDocumentManager,
        _jupyterlab_filebrowser__WEBPACK_IMPORTED_MODULE_6__.IFileBrowserFactory,
        _jupyterlab_notebook__WEBPACK_IMPORTED_MODULE_3__.INotebookTracker,
        _jupyterlab_application__WEBPACK_IMPORTED_MODULE_0__.ILayoutRestorer
    ],
    activate: (app, palette, launcher, nbtools, docManager, browserFactory, tracker, restorer) => {
        console.log('JupyterLab extension grader_labextension is activated!');
        console.log('JupyterFrontEnd:', app);
        console.log('ICommandPalette:', palette);
        console.log('Tracker', tracker);
        GlobalObjects.commands = app.commands;
        GlobalObjects.docRegistry = app.docRegistry;
        GlobalObjects.serviceManager = app.serviceManager;
        GlobalObjects.docManager = docManager;
        GlobalObjects.browserFactory = browserFactory;
        GlobalObjects.tracker = tracker;
        const assignmentTracker = new _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.WidgetTracker({
            namespace: 'grader-assignments'
        });
        restorer.restore(assignmentTracker, {
            command: AssignmentsCommandIDs.open,
            name: () => 'grader-assignments'
        });
        const courseManageTracker = new _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.WidgetTracker({
            namespace: 'grader-coursemanage'
        });
        restorer.restore(courseManageTracker, {
            command: CourseManageCommandIDs.open,
            name: () => 'grader-coursemanage'
        });
        //Creation of in-cell widget for create assignment
        const connectTrackerSignals = (tracker) => {
            tracker.currentChanged.connect(async () => {
                const notebookPanel = tracker.currentWidget;
                //Notebook not yet loaded
                if (notebookPanel === null) {
                    return;
                }
                const notebook = tracker.currentWidget.content;
                const mode = false;
                notebookPanel.context.ready.then(() => {
                    //Creation of widget switch
                    const switcher = new _components_notebook_slider__WEBPACK_IMPORTED_MODULE_7__.NotebookModeSwitch(mode, notebookPanel, notebook);
                    tracker.currentWidget.toolbar.insertItem(10, 'Mode', switcher);
                    //Creation of deadline widget
                    const deadlineWidget = new _components_notebook_student_plugin_deadline_widget__WEBPACK_IMPORTED_MODULE_8__.DeadlineWidget(tracker.currentWidget.context.path);
                    tracker.currentWidget.toolbar.insertItem(11, 'Deadline', deadlineWidget);
                });
            }, undefined);
            tracker.activeCellChanged.connect(() => {
                const notebookPanel = tracker.currentWidget;
                //Notebook not yet loaded
                if (notebookPanel === null) {
                    return;
                }
                const notebook = tracker.currentWidget.content;
                const contentsModel = notebookPanel.context.contentsModel;
                if (contentsModel === null) {
                    return;
                }
                const notebookPaths = contentsModel.path.split('/');
                if (notebookPaths[0] === 'manualgrade') {
                    return;
                }
                let switcher = null;
                notebookPanel.toolbar.layout.widgets.map(w => {
                    if (w instanceof _components_notebook_slider__WEBPACK_IMPORTED_MODULE_7__.NotebookModeSwitch) {
                        switcher = w;
                    }
                });
                const cell = notebook.activeCell;
                //check if in creationmode and new cell was inserted
                if (switcher.mode &&
                    cell.layout.widgets.every(w => {
                        return !(w instanceof _components_notebook_create_assignment_creation_widget__WEBPACK_IMPORTED_MODULE_9__.CreationWidget);
                    })) {
                    cell.layout.insertWidget(0, new _components_notebook_create_assignment_creation_widget__WEBPACK_IMPORTED_MODULE_9__.CreationWidget(cell));
                }
            }, undefined);
        };
        /* ##### Course Manage View Widget ##### */
        let command = CourseManageCommandIDs.create;
        app.commands.addCommand(command, {
            execute: () => {
                // Create a blank content widget inside of a MainAreaWidget
                const gradingView = new _widgets_coursemanage__WEBPACK_IMPORTED_MODULE_10__.CourseManageView();
                const gradingWidget = new _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.MainAreaWidget({
                    content: gradingView
                });
                gradingWidget.id = 'coursemanage-jupyterlab';
                gradingWidget.title.label = 'Course Management';
                gradingWidget.title.closable = true;
                courseManageTracker.add(gradingWidget);
                return gradingWidget;
            }
        });
        command = AssignmentsCommandIDs.create;
        app.commands.addCommand(command, {
            execute: () => {
                // Create a blank content widget inside a MainAreaWidget
                const assignmentView = new _widgets_assignmentmanage__WEBPACK_IMPORTED_MODULE_11__.AssignmentManageView();
                const assignmentWidget = new _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.MainAreaWidget({
                    content: assignmentView
                });
                assignmentWidget.id = 'assignments-jupyterlab';
                assignmentWidget.title.label = 'Assignments';
                assignmentWidget.title.closable = true;
                assignmentTracker.add(assignmentWidget);
                return assignmentWidget;
            }
        });
        // If the user has no instructor roles in any lecture we do not display the course management
        _services_permission_service__WEBPACK_IMPORTED_MODULE_12__.UserPermissions.loadPermissions()
            .then(() => {
            const permissions = _services_permission_service__WEBPACK_IMPORTED_MODULE_12__.UserPermissions.getPermissions();
            let sum = 0;
            for (const el in permissions) {
                if (permissions.hasOwnProperty(el)) {
                    sum += permissions[el];
                }
            }
            if (sum !== 0) {
                console.log('Non-student permissions found! Adding coursemanage launcher and connecting creation mode');
                connectTrackerSignals(tracker);
                command = CourseManageCommandIDs.open;
                app.commands.addCommand(command, {
                    label: 'Course Management',
                    execute: async () => {
                        const gradingWidget = await app.commands.execute(CourseManageCommandIDs.create);
                        if (!gradingWidget.isAttached) {
                            // Attach the widget to the main work area if it's not there
                            app.shell.add(gradingWidget, 'main');
                        }
                        // Activate the widget
                        app.shell.activateById(gradingWidget.id);
                    },
                    icon: _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_4__.checkIcon
                });
                // Add the command to the launcher
                console.log('Add course management launcher');
                launcher.add({
                    command: command,
                    category: 'Assignments',
                    rank: 0
                });
            }
            // only add assignment list if user permissions can be loaded
            command = AssignmentsCommandIDs.open;
            app.commands.addCommand(command, {
                label: 'Assignments',
                execute: async () => {
                    const assignmentWidget = await app.commands.execute(AssignmentsCommandIDs.create);
                    if (!assignmentWidget.isAttached) {
                        // Attach the widget to the main work area if it's not there
                        app.shell.add(assignmentWidget, 'main');
                    }
                    // Activate the widget
                    app.shell.activateById(assignmentWidget.id);
                },
                icon: _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_4__.editIcon
            });
            // Add the command to the launcher
            console.log('Add assignment launcher');
            launcher.add({
                command: command,
                category: 'Assignments',
                rank: 0
            });
        })
            .catch(_ => (0,_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.showErrorMessage)('Grader Service Unavailable', 'Could not connect to the grader service! Please contact your system administrator!'));
        command = NotebookExecuteIDs.run;
        app.commands.addCommand(command, {
            label: 'Run cell',
            execute: async () => {
                await app.commands.execute('notebook:run-cell');
            },
            icon: _jupyterlab_ui_components__WEBPACK_IMPORTED_MODULE_4__.runIcon
        });
        command = RevertCellIDs.revert;
        app.commands.addCommand(command, {
            label: 'Revert cell',
            isVisible: () => {
                if (tracker.activeCell === null) {
                    return false;
                }
                return tracker.activeCell.model.getMetadata('revert') != null;
            },
            isEnabled: () => {
                if (tracker.activeCell === null) {
                    return false;
                }
                return tracker.activeCell.model.getMetadata('revert') != null;
            },
            execute: () => {
                (0,_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.showDialog)({
                    title: "Do you want to revert the cell to it's original state?",
                    body: 'This will overwrite your current changes!',
                    buttons: [_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.Dialog.cancelButton(), _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.Dialog.okButton({ label: 'Revert' })]
                }).then(result => {
                    if (!result.button.accept) {
                        return;
                    }
                    tracker.activeCell.inputArea.model.sharedModel.setSource("");
                    tracker.activeCell.inputArea.model.sharedModel.setSource(tracker.activeCell.model.getMetadata("revert").toString());
                });
            },
            icon: _jupyterlab_ui_components_lib_icon_iconimports__WEBPACK_IMPORTED_MODULE_13__.undoIcon
        });
        command = ShowHintIDs.show;
        app.commands.addCommand(command, {
            label: 'Show hint',
            isVisible: () => {
                if (tracker.activeCell === null) {
                    return false;
                }
                return tracker.activeCell.model.getMetadata('hint') != null;
            },
            isEnabled: () => {
                if (tracker.activeCell === null) {
                    return false;
                }
                return tracker.activeCell.model.getMetadata('hint') != null;
            },
            execute: () => {
                let hintWidget = null;
                tracker.activeCell.layout.widgets.map(widget => {
                    if (widget instanceof _components_notebook_student_plugin_hint_widget__WEBPACK_IMPORTED_MODULE_14__.HintWidget) {
                        hintWidget = widget;
                    }
                });
                if (hintWidget === null) {
                    tracker.activeCell.layout.addWidget(new _components_notebook_student_plugin_hint_widget__WEBPACK_IMPORTED_MODULE_14__.HintWidget(tracker.activeCell.model.getMetadata('hint').toString()));
                }
                else {
                    hintWidget.toggleShowAlert();
                    hintWidget.setHint(tracker.activeCell.model.getMetadata('hint').toString());
                    hintWidget.update();
                }
            },
            icon: _jupyterlab_ui_components_lib_icon_iconimports__WEBPACK_IMPORTED_MODULE_13__.listIcon
        });
    }
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (extension);


/***/ }),

/***/ "./lib/model/assignment.js":
/*!*********************************!*\
  !*** ./lib/model/assignment.js ***!
  \*********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   Assignment: () => (/* binding */ Assignment)
/* harmony export */ });
/**
 * Grader Extension API Schemas
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 0.1
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
var Assignment;
(function (Assignment) {
    Assignment.TypeEnum = {
        User: 'user',
        Group: 'group'
    };
    Assignment.StatusEnum = {
        Created: 'created',
        Pushed: 'pushed',
        Released: 'released',
        Complete: 'complete'
    };
    Assignment.AutomaticGradingEnum = {
        Unassisted: 'unassisted',
        Auto: 'auto',
        FullAuto: 'full_auto'
    };
})(Assignment || (Assignment = {}));


/***/ }),

/***/ "./lib/services/assignments.service.js":
/*!*********************************************!*\
  !*** ./lib/services/assignments.service.js ***!
  \*********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createAssignment: () => (/* binding */ createAssignment),
/* harmony export */   deleteAssignment: () => (/* binding */ deleteAssignment),
/* harmony export */   fetchAssignment: () => (/* binding */ fetchAssignment),
/* harmony export */   generateAssignment: () => (/* binding */ generateAssignment),
/* harmony export */   getAllAssignments: () => (/* binding */ getAllAssignments),
/* harmony export */   getAssignment: () => (/* binding */ getAssignment),
/* harmony export */   getAssignmentProperties: () => (/* binding */ getAssignmentProperties),
/* harmony export */   pullAssignment: () => (/* binding */ pullAssignment),
/* harmony export */   pushAssignment: () => (/* binding */ pushAssignment),
/* harmony export */   resetAssignment: () => (/* binding */ resetAssignment),
/* harmony export */   updateAssignment: () => (/* binding */ updateAssignment)
/* harmony export */ });
/* harmony import */ var _request_service__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./request.service */ "./lib/services/request.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

function createAssignment(lectureId, assignment) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.POST, `/lectures/${lectureId}/assignments`, assignment);
}
function getAllAssignments(lectureId, reload = false, includeSubmissions = false) {
    let url = `/lectures/${lectureId}/assignments`;
    if (includeSubmissions) {
        let searchParams = new URLSearchParams({
            "include-submissions": String(includeSubmissions)
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url, reload);
}
function getAssignment(lectureId, assignmentId, reload = false) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lectureId}/assignments/${assignmentId}`, reload);
}
function getAssignmentProperties(lectureId, assignmentId) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lectureId}/assignments/${assignmentId}/properties`);
}
function updateAssignment(lectureId, assignment) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, `/lectures/${lectureId}/assignments/${assignment.id}`, assignment);
}
function generateAssignment(lectureId, assignment) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, `/lectures/${lectureId}/assignments/${assignment.id}/generate`);
}
function fetchAssignment(lectureId, assignmentId, instructor = false, metadataOnly = false) {
    let url = `/lectures/${lectureId}/assignments/${assignmentId}`;
    if (instructor || metadataOnly) {
        let searchParams = new URLSearchParams({
            "instructor-version": String(instructor),
            "metadata-only": String(metadataOnly)
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url);
}
function deleteAssignment(lectureId, assignmentId) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.DELETE, `/lectures/${lectureId}/assignments/${assignmentId}`);
}
function pushAssignment(lectureId, assignmentId, repoType, commitMessage) {
    let url = `/lectures/${lectureId}/assignments/${assignmentId}/push/${repoType}`;
    if (commitMessage) {
        let searchParams = new URLSearchParams({
            'commit-message': commitMessage
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, url);
}
function pullAssignment(lectureId, assignmentId, repoType) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lectureId}/assignments/${assignmentId}/pull/${repoType}`);
}
function resetAssignment(lecture, assignment) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lecture.id}/assignments/${assignment.id}/reset`);
}


/***/ }),

/***/ "./lib/services/datetime.service.js":
/*!******************************************!*\
  !*** ./lib/services/datetime.service.js ***!
  \******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   localToUTC: () => (/* binding */ localToUTC),
/* harmony export */   utcToLocal: () => (/* binding */ utcToLocal),
/* harmony export */   utcToLocalFormat: () => (/* binding */ utcToLocalFormat),
/* harmony export */   utcToTimestamp: () => (/* binding */ utcToTimestamp)
/* harmony export */ });
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! moment */ "webpack/sharing/consume/default/moment/moment");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_0__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

// 2021-09-03T11:57
function localToUTC(time) {
    return moment__WEBPACK_IMPORTED_MODULE_0___default()(time).utc().format('YYYY-MM-DDTHH:mm:ss.sss') + 'Z';
}
function utcToLocal(time) {
    return moment__WEBPACK_IMPORTED_MODULE_0___default().utc(time).local().format('YYYY-MM-DDTHH:mm:ss.sss');
}
function utcToLocalFormat(time) {
    const locale = window.navigator.language;
    const localeData = moment__WEBPACK_IMPORTED_MODULE_0___default().localeData(locale);
    const format = localeData.longDateFormat('L') + ' HH:mm:ss';
    return moment__WEBPACK_IMPORTED_MODULE_0___default().utc(time).local().format(format);
}
function utcToTimestamp(time) {
    return moment__WEBPACK_IMPORTED_MODULE_0___default()(time, 'YYYY-MM-DDTHH:mm:ss.sss').valueOf();
}


/***/ }),

/***/ "./lib/services/file.service.js":
/*!**************************************!*\
  !*** ./lib/services/file.service.js ***!
  \**************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   getFiles: () => (/* binding */ getFiles),
/* harmony export */   getGitLog: () => (/* binding */ getGitLog),
/* harmony export */   getRemoteStatus: () => (/* binding */ getRemoteStatus),
/* harmony export */   lectureBasePath: () => (/* binding */ lectureBasePath),
/* harmony export */   lectureSubPaths: () => (/* binding */ lectureSubPaths),
/* harmony export */   openFile: () => (/* binding */ openFile)
/* harmony export */ });
/* harmony import */ var _jupyterlab_filebrowser_lib_model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @jupyterlab/filebrowser/lib/model */ "./node_modules/@jupyterlab/filebrowser/lib/model.js");
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../index */ "./lib/index.js");
/* harmony import */ var _request_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./request.service */ "./lib/services/request.service.js");
/* harmony import */ var _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/coreutils */ "webpack/sharing/consume/default/@jupyterlab/coreutils");
/* harmony import */ var _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_1__);
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.





// remove slashes at beginning and end of base path if they exist
let lectureBasePath = _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_0__.PageConfig.getOption('lectures_base_path').replace(/^\/|\/$/g, '');
// append / so that lectureBasePath can be prepended to any string and becomes a valid path
if (lectureBasePath !== '') {
    lectureBasePath += '/';
}
// the number of sub paths in lecture base path e.g. grader/Lectures -> 2
const lectureSubPaths = lectureBasePath.split('/').reduce((acc, v) => (v.length > 0) ? acc + 1 : acc, 0);
const getFiles = async (path) => {
    if (path === null) {
        return [];
    }
    const model = new _jupyterlab_filebrowser_lib_model__WEBPACK_IMPORTED_MODULE_2__.FilterFileBrowserModel({
        auto: true,
        manager: _index__WEBPACK_IMPORTED_MODULE_3__.GlobalObjects.docManager
    });
    try {
        await model.cd(path);
    }
    catch (_) {
        return [];
    }
    if (model.path !== path) {
        return [];
    }
    const items = model.items();
    const files = [];
    let f = items.next();
    while (f.value !== undefined) {
        files.push(f);
        f = items.next();
    }
    console.log('getting files from path ' + path);
    return files;
};
const openFile = async (path) => {
    _index__WEBPACK_IMPORTED_MODULE_3__.GlobalObjects.commands
        .execute('docmanager:open', {
        path: path,
        options: {
            mode: 'tab-after' // tab-after tab-before split-bottom split-right split-left split-top
        }
    })
        .catch(error => {
        (0,notistack__WEBPACK_IMPORTED_MODULE_1__.enqueueSnackbar)(error.message, {
            variant: 'error'
        });
    });
};
function getGitLog(lecture, assignment, repo, nCommits) {
    let url = `/lectures/${lecture.id}/assignments/${assignment.id}/log/${repo}/`;
    let searchParams = new URLSearchParams({
        'n': String(nCommits)
    });
    url += '?' + searchParams;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_4__.request)(_request_service__WEBPACK_IMPORTED_MODULE_4__.HTTPMethod.GET, url, null, true);
}
function getRemoteStatus(lecture, assignment, repo, reload = false) {
    let url = `/lectures/${lecture.id}/assignments/${assignment.id}/remote-status/${repo}/`;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_4__.request)(_request_service__WEBPACK_IMPORTED_MODULE_4__.HTTPMethod.GET, url, null, reload);
}


/***/ }),

/***/ "./lib/services/gradebook.js":
/*!***********************************!*\
  !*** ./lib/services/gradebook.js ***!
  \***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   GradeBook: () => (/* binding */ GradeBook)
/* harmony export */ });
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
class GradeBook {
    constructor(properties) {
        this.properties = properties;
    }
    getNotebooks() {
        return Object.keys(this.properties['notebooks']);
    }
    setComment(notebook, cellId, comment) {
        this.properties['notebooks'][notebook]['comments_dict'][cellId]['manual_comment'] = comment;
    }
    getComment(notebook, cellId) {
        return this.properties['notebooks'][notebook]['comments_dict'][cellId]['manual_comment'];
    }
    setManualScore(notebook, cellId, score) {
        try {
            this.properties['notebooks'][notebook]['grades_dict'][cellId]['manual_score'] = score;
        }
        catch (error) {
            this.createTaskGrade(notebook, cellId, score);
        }
    }
    createTaskGrade(notebook, cellId, score) {
        const maxScore = this.properties['notebooks'][notebook]['task_cells_dict'][cellId]['max_score'];
        const grade = {
            cell_id: cellId,
            notebook_id: notebook,
            id: cellId,
            auto_score: null,
            manual_score: score,
            extra_credit: null,
            needs_manual_grade: false,
            max_score_gradecell: null,
            max_score_taskcell: maxScore,
            failed_tests: null
        };
        this.properties['notebooks'][notebook]['grades_dict'][cellId] = grade;
    }
    getManualScore(notebook, cellId) {
        return this.properties['notebooks'][notebook]['grades_dict'][cellId]['manual_score'];
    }
    setExtraCredit(notebook, cellId, credit) {
        this.properties['notebooks'][notebook]['grades_dict'][cellId]['extra_credit'] = credit;
    }
    getExtraCredit(notebook, cellId) {
        const extraCredit = this.properties['notebooks'][notebook]['grades_dict'][cellId]['extra_credit'];
        if (extraCredit) {
            return extraCredit;
        }
        else {
            return 0.0;
        }
    }
    setNeedsManualGrading(notebook, cellId, needsGrading) {
        this.properties['notebooks'][notebook]['grades_dict'][cellId]['needs_manual_grade'] = needsGrading;
    }
    getNeedsManualGrading(notebook, cellId) {
        return this.properties['notebooks'][notebook]['grades_dict'][cellId]['needs_manual_grade'];
    }
    getNotebookGradingInfo(notebook) {
        const grades_dict = this.properties['notebooks'][notebook]['grades_dict'];
        return Object.keys(grades_dict)
            .map(v => this.getNeedsManualGrading(notebook, v))
            .reduce((r, v) => r || v, false);
    }
    getGradingInfo() {
        const map = new Map();
        for (const notebook of Object.keys(this.properties['notebooks'])) {
            map.set(notebook, this.getNotebookGradingInfo(notebook));
        }
        return map;
    }
    getGradeScore(notebook, cellId) {
        const grade = this.properties['notebooks'][notebook]['grades_dict'][cellId];
        if (grade['manual_score'] === null && grade['auto_score'] === null) {
            return 0.0;
        }
        else if (grade['manual_score'] === null) {
            return grade['auto_score'];
        }
        else if (grade['auto_score'] === null) {
            return grade['manual_score'];
        }
        else {
            return grade['manual_score'];
        }
    }
    getAutoGradeScore(notebook, cellId) {
        return this.properties['notebooks'][notebook]['grades_dict'][cellId]['auto_score'];
    }
    getGradeMaxScore(notebook, cellId) {
        const grade = this.properties['notebooks'][notebook]['grades_dict'][cellId];
        if (grade['max_score_taskcell'] !== null) {
            return grade['max_score_taskcell'];
        }
        else if (grade['max_score_gradecell'] !== null) {
            return grade['max_score_gradecell'];
        }
        else {
            return 0.0;
        }
    }
    getGradeCellMaxScore(notebook, cellId) {
        return this.properties['notebooks'][notebook]['grade_cells_dict'][cellId]['max_score'];
    }
    getNotebookPoints(notebook) {
        let sum = 0;
        const grades_dict = this.properties['notebooks'][notebook]['grades_dict'];
        for (const cellId of Object.keys(grades_dict)) {
            sum += this.getGradeScore(notebook, cellId);
        }
        return sum;
    }
    getPoints() {
        let sum = 0;
        for (const notebook of Object.keys(this.properties['notebooks'])) {
            sum += this.getNotebookPoints(notebook);
        }
        return sum;
    }
    getNotebookMaxPoints(notebook) {
        let sum = 0;
        // add task cells to grades dict if they are not there
        const task_cells_dict = this.properties['notebooks'][notebook]['task_cells_dict'];
        for (const cellId of Object.keys(task_cells_dict)) {
            if (this.properties['notebooks'][notebook]['grades_dict'][cellId] ===
                undefined) {
                console.log('Adding grade for task cell: ' + cellId);
                this.createTaskGrade(notebook, cellId, null);
            }
        }
        const grades_dict = this.properties['notebooks'][notebook]['grades_dict'];
        for (const cellId of Object.keys(grades_dict)) {
            sum += this.getGradeMaxScore(notebook, cellId);
        }
        return sum;
    }
    getNotebookMaxPointsCells(notebook) {
        let sum = 0;
        const grades_dict = this.properties['notebooks'][notebook]['grade_cells_dict'];
        for (const cellId of Object.keys(grades_dict)) {
            sum += this.getGradeCellMaxScore(notebook, cellId);
        }
        return sum;
    }
    getMaxPoints() {
        let sum = 0;
        for (const notebook of Object.keys(this.properties['notebooks'])) {
            sum += this.getNotebookMaxPoints(notebook);
        }
        return sum;
    }
    getNotebookExtraCredit(notebook) {
        let sum = 0;
        const grades_dict = this.properties['notebooks'][notebook]['grades_dict'];
        for (const cellId of Object.keys(grades_dict)) {
            sum += this.getExtraCredit(notebook, cellId);
        }
        return sum;
    }
    getExtraCredits() {
        let sum = 0;
        for (const notebook of Object.keys(this.properties['notebooks'])) {
            sum += this.getNotebookExtraCredit(notebook);
        }
        return sum;
    }
}


/***/ }),

/***/ "./lib/services/grading.service.js":
/*!*****************************************!*\
  !*** ./lib/services/grading.service.js ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   autogradeSubmission: () => (/* binding */ autogradeSubmission),
/* harmony export */   createManualFeedback: () => (/* binding */ createManualFeedback),
/* harmony export */   deleteManualFeedback: () => (/* binding */ deleteManualFeedback),
/* harmony export */   generateFeedback: () => (/* binding */ generateFeedback),
/* harmony export */   getGrade: () => (/* binding */ getGrade),
/* harmony export */   getManualFeedback: () => (/* binding */ getManualFeedback),
/* harmony export */   getStudentSubmissions: () => (/* binding */ getStudentSubmissions),
/* harmony export */   saveSubmissions: () => (/* binding */ saveSubmissions),
/* harmony export */   updateManualFeedback: () => (/* binding */ updateManualFeedback)
/* harmony export */ });
/* harmony import */ var _request_service__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./request.service */ "./lib/services/request.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

function createManualFeedback(lectid, assignid, subid) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lectid}/assignments/${assignid}/grading/${subid}/manual`);
}
function saveSubmissions(lecture, assignment, filter = "none") {
    let url = `/lectures/${lecture.id}/assignments/${assignment.id}/submissions/save`;
    if (filter) {
        const searchParams = new URLSearchParams({
            filter: filter
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, url);
}
function autogradeSubmission(lecture, assignment, submission) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lecture.id}/assignments/${assignment.id}/grading/${submission.id}/auto`);
}
function generateFeedback(lecture_id, assignment_id, submission_id) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lecture_id}/assignments/${assignment_id}/grading/${submission_id}/feedback`);
}
//response is not a schema => any
//TODO: should prob be changed
function getStudentSubmissions(lecture, assignment, reload = false) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lecture.id}/assignements/${assignment.id}/grading`, reload);
}
function getManualFeedback(lecture, assignment, student) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lecture.id}/assignments/${assignment.id}/grading/${student.name}/manual`);
}
function updateManualFeedback(lecture, assignment, student, manual) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, `/lectures/${lecture.id}/assignements/${assignment.id}/grading/${student.name}/manual`, manual);
}
function deleteManualFeedback(lecture, assignment, student, manual) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.DELETE, `/lectures/${lecture.id}/assignments/${assignment.id}/grading/${student.name}/manual`, manual);
}
function getGrade(lecture, assignment, student) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lecture.id}/assignments/${assignment.id}/grading/${student.name}/score`);
}


/***/ }),

/***/ "./lib/services/lectures.service.js":
/*!******************************************!*\
  !*** ./lib/services/lectures.service.js ***!
  \******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createLecture: () => (/* binding */ createLecture),
/* harmony export */   deleteLecture: () => (/* binding */ deleteLecture),
/* harmony export */   getAllLectures: () => (/* binding */ getAllLectures),
/* harmony export */   getLecture: () => (/* binding */ getLecture),
/* harmony export */   getUsers: () => (/* binding */ getUsers),
/* harmony export */   updateLecture: () => (/* binding */ updateLecture)
/* harmony export */ });
/* harmony import */ var _request_service__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./request.service */ "./lib/services/request.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

function createLecture(lecture) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.POST, '/lectures', lecture);
}
function getAllLectures(complete = false, reload = false) {
    let url = '/lectures';
    if (complete) {
        let searchParams = new URLSearchParams({
            'complete': String(complete)
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url, reload);
}
function updateLecture(lecture) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, `/lectures/${lecture.id}`, lecture);
}
function getLecture(lectureId, reload = false) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lectureId}`, reload);
}
function deleteLecture(lectureId) {
    (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.DELETE, `/lectures/${lectureId}`);
}
function getUsers(lectureId) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lectureId}/users`);
}


/***/ }),

/***/ "./lib/services/permission.service.js":
/*!********************************************!*\
  !*** ./lib/services/permission.service.js ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   Scope: () => (/* binding */ Scope),
/* harmony export */   UserPermissions: () => (/* binding */ UserPermissions)
/* harmony export */ });
/* harmony import */ var _request_service__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./request.service */ "./lib/services/request.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

var Scope;
(function (Scope) {
    Scope[Scope["student"] = 0] = "student";
    Scope[Scope["tutor"] = 1] = "tutor";
    Scope[Scope["instructor"] = 2] = "instructor";
    Scope[Scope["admin"] = 3] = "admin";
})(Scope || (Scope = {}));
var UserPermissions;
(function (UserPermissions) {
    let permissions = null;
    async function loadPermissions() {
        permissions = {};
        let response = await (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, '/permissions');
        response.forEach(role => {
            permissions[role.lecture_code] = role.scope;
        });
    }
    UserPermissions.loadPermissions = loadPermissions;
    function getPermissions() {
        return permissions;
    }
    UserPermissions.getPermissions = getPermissions;
    function getScope(lecture) {
        if (permissions === null) {
            return null;
        }
        return permissions[lecture.code];
    }
    UserPermissions.getScope = getScope;
})(UserPermissions || (UserPermissions = {}));


/***/ }),

/***/ "./lib/services/request.service.js":
/*!*****************************************!*\
  !*** ./lib/services/request.service.js ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   HTTPMethod: () => (/* binding */ HTTPMethod),
/* harmony export */   request: () => (/* binding */ request)
/* harmony export */ });
/* harmony import */ var _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @jupyterlab/coreutils */ "webpack/sharing/consume/default/@jupyterlab/coreutils");
/* harmony import */ var _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _jupyterlab_services__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @jupyterlab/services */ "webpack/sharing/consume/default/@jupyterlab/services");
/* harmony import */ var _jupyterlab_services__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_services__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! rxjs */ "webpack/sharing/consume/default/rxjs/rxjs");
/* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(rxjs__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! rxjs/operators */ "./node_modules/rxjs/dist/esm5/internal/operators/switchMap.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.




var HTTPMethod;
(function (HTTPMethod) {
    HTTPMethod["GET"] = "GET";
    HTTPMethod["POST"] = "POST";
    HTTPMethod["PUT"] = "PUT";
    HTTPMethod["DELETE"] = "DELETE";
})(HTTPMethod || (HTTPMethod = {}));
function request(method, endPoint, body = null, reload = false) {
    const options = {};
    options.method = method;
    if (body) {
        options.body = JSON.stringify(body);
    }
    const settings = _jupyterlab_services__WEBPACK_IMPORTED_MODULE_1__.ServerConnection.makeSettings();
    let requestUrl = '';
    // ServerConnection only allows requests to notebook baseUrl
    requestUrl = _jupyterlab_coreutils__WEBPACK_IMPORTED_MODULE_0__.URLExt.join(settings.baseUrl, '/grader_labextension', // API Namespace
    endPoint);
    // set cache always to default,
    // otherwise ServerConnection.makeRequest puts the timestamp as a query parameter resulting in no cache hits
    options.cache = "default";
    if (reload) {
        options.cache = "reload";
    }
    return _jupyterlab_services__WEBPACK_IMPORTED_MODULE_1__.ServerConnection.makeRequest(requestUrl, options, settings).then(async (response) => {
        if (!response.ok) {
            return response.text().then(text => {
                throw new Error(JSON.parse(text)['message']);
            });
        }
        let data = await response.text();
        if (data.length > 0) {
            try {
                data = JSON.parse(data);
            }
            catch (error) {
                console.log('Not a JSON response body.', response);
            }
        }
        console.log('Request ' + method.toString() + ' URL: ' + requestUrl);
        console.log(data);
        return data;
    });
    return (0,rxjs__WEBPACK_IMPORTED_MODULE_2__.lastValueFrom)((0,rxjs__WEBPACK_IMPORTED_MODULE_2__.from)(_jupyterlab_services__WEBPACK_IMPORTED_MODULE_1__.ServerConnection.makeRequest(requestUrl, options, settings)).pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_3__.switchMap)(async (response) => {
        if (!response.ok) {
            throw new _jupyterlab_services__WEBPACK_IMPORTED_MODULE_1__.ServerConnection.ResponseError(response, await response.text());
        }
        let data = await response.text();
        if (data.length > 0) {
            try {
                data = JSON.parse(data);
            }
            catch (error) {
                console.log('Not a JSON response body.', response);
            }
        }
        console.log('Request ' + method.toString() + ' URL: ' + requestUrl);
        console.log(data);
        return data;
    })));
}


/***/ }),

/***/ "./lib/services/storage.service.js":
/*!*****************************************!*\
  !*** ./lib/services/storage.service.js ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   deleteKey: () => (/* binding */ deleteKey),
/* harmony export */   loadBoolean: () => (/* binding */ loadBoolean),
/* harmony export */   loadNumber: () => (/* binding */ loadNumber),
/* harmony export */   loadObject: () => (/* binding */ loadObject),
/* harmony export */   loadString: () => (/* binding */ loadString),
/* harmony export */   storeBoolean: () => (/* binding */ storeBoolean),
/* harmony export */   storeNumber: () => (/* binding */ storeNumber),
/* harmony export */   storeObject: () => (/* binding */ storeObject),
/* harmony export */   storeString: () => (/* binding */ storeString)
/* harmony export */ });
function getKey(key, lecture, assignment) {
    if (lecture) {
        key = key + `-l${lecture.id}`;
    }
    if (assignment) {
        key = key + `-a${assignment.id}`;
    }
    return "grader:" + key;
}
function deleteKey(key) {
    key = getKey(key);
    localStorage.removeItem(key);
}
function storeString(key, value, lecture, assignment) {
    key = getKey(key, lecture, assignment);
    localStorage.setItem(key, value);
}
function loadString(key, lecture, assignment) {
    key = getKey(key, lecture, assignment);
    return localStorage.getItem(key);
}
function storeBoolean(key, value, lecture, assignment) {
    storeString(key, String(value), lecture, assignment);
}
function loadBoolean(key, lecture, assignment) {
    const v = loadString(key, lecture, assignment);
    if (v === null) {
        return null;
    }
    else {
        return v === "true";
    }
}
function storeNumber(key, value, lecture, assignment) {
    storeString(key, String(value), lecture, assignment);
}
function loadNumber(key, lecture, assignment) {
    const v = loadString(key, lecture, assignment);
    if (v === null) {
        return null;
    }
    else {
        return +v;
    }
}
function storeObject(key, value, lecture, assignment) {
    storeString(key, JSON.stringify(value), lecture, assignment);
}
function loadObject(key, lecture, assignment) {
    return JSON.parse(loadString(key, lecture, assignment));
}


/***/ }),

/***/ "./lib/services/submissions.service.js":
/*!*********************************************!*\
  !*** ./lib/services/submissions.service.js ***!
  \*********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   createOrOverrideEditRepository: () => (/* binding */ createOrOverrideEditRepository),
/* harmony export */   getAllSubmissions: () => (/* binding */ getAllSubmissions),
/* harmony export */   getFeedback: () => (/* binding */ getFeedback),
/* harmony export */   getLogs: () => (/* binding */ getLogs),
/* harmony export */   getProperties: () => (/* binding */ getProperties),
/* harmony export */   getSubmission: () => (/* binding */ getSubmission),
/* harmony export */   getSubmissions: () => (/* binding */ getSubmissions),
/* harmony export */   ltiSyncSubmissions: () => (/* binding */ ltiSyncSubmissions),
/* harmony export */   pullFeedback: () => (/* binding */ pullFeedback),
/* harmony export */   pullSubmissionFiles: () => (/* binding */ pullSubmissionFiles),
/* harmony export */   pushSubmissionFiles: () => (/* binding */ pushSubmissionFiles),
/* harmony export */   submitAssignment: () => (/* binding */ submitAssignment),
/* harmony export */   updateProperties: () => (/* binding */ updateProperties),
/* harmony export */   updateSubmission: () => (/* binding */ updateSubmission)
/* harmony export */ });
/* harmony import */ var _request_service__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./request.service */ "./lib/services/request.service.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

function submitAssignment(lecture, assignment, submit = false) {
    let url = `/lectures/${lecture.id}/assignments/${assignment.id}/push/assignment`;
    if (submit) {
        const searchParams = new URLSearchParams({
            submit: String(submit)
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, url);
}
async function pullFeedback(lecture, assignment, submission) {
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, `/lectures/${lecture.id}/assignments/${assignment.id}/grading/${submission.id}/pull/feedback`);
}
async function pullSubmissionFiles(lecture, assignment, submission) {
    let url = `/lectures/${lecture.id}/assignments/${assignment.id}/pull/edit`;
    const searchParams = new URLSearchParams({
        subid: String(submission.id)
    });
    url += '?' + searchParams;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url);
}
async function pushSubmissionFiles(lecture, assignment, submission) {
    let url = `/lectures/${lecture.id}/assignments/${assignment.id}/push/edit`;
    const searchParams = new URLSearchParams({
        subid: String(submission.id)
    });
    url += '?' + searchParams;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, url);
}
function getSubmissions(lecture, assignment, filter = 'none', reload = false) {
    let url = `/lectures/${lecture.id}/assignments/${assignment.id}/submissions`;
    if (filter) {
        const searchParams = new URLSearchParams({
            filter: filter
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url, reload);
}
function getAllSubmissions(lectureId, assignmentId, filter = 'none', instructor = true, reload = false) {
    let url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions`;
    if (filter || instructor) {
        const searchParams = new URLSearchParams({
            'instructor-version': String(instructor),
            filter: filter
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url, null, reload);
}
function getFeedback(lecture, assignment, latest = false, instructor = false) {
    let url = `/lectures/${lecture.id}/assignments/${assignment.id}/feedback`;
    if (latest || instructor) {
        const searchParams = new URLSearchParams({
            'instructor-version': String(instructor),
            latest: String(latest)
        });
        url += '?' + searchParams;
    }
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url);
}
function getProperties(lectureId, assignmentId, submissionId, reload = false) {
    const url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions/${submissionId}/properties`;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url, reload);
}
function getLogs(lectureId, assignmentId, submissionId, reload = false) {
    const url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions/${submissionId}/logs`;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url, reload);
}
function createOrOverrideEditRepository(lectureId, assignmentId, submissionId) {
    const url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions/${submissionId}/edit`;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, url, {});
}
function updateProperties(lectureId, assignmentId, submissionId, properties) {
    const url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions/${submissionId}/properties`;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, url, properties);
}
function getSubmission(lectureId, assignmentId, submissionId) {
    const url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions/${submissionId}`;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.GET, url);
}
function updateSubmission(lectureId, assignmentId, submissionId, sub) {
    const url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions/${submissionId}`;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, url, sub);
}
function ltiSyncSubmissions(lectureId, assignmentId) {
    const url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions/lti`;
    return (0,_request_service__WEBPACK_IMPORTED_MODULE_0__.request)(_request_service__WEBPACK_IMPORTED_MODULE_0__.HTTPMethod.PUT, url);
}


/***/ }),

/***/ "./lib/widgets/assignmentmanage.js":
/*!*****************************************!*\
  !*** ./lib/widgets/assignmentmanage.js ***!
  \*****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   AssignmentManageView: () => (/* binding */ AssignmentManageView)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _components_assignment_routes__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../components/assignment/routes */ "./lib/components/assignment/routes.js");
/* harmony import */ var _services_storage_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../services/storage.service */ "./lib/services/storage.service.js");
/* harmony import */ var _components_util_dialog_provider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../components/util/dialog-provider */ "./lib/components/util/dialog-provider.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.







class AssignmentManageView extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.ReactWidget {
    constructor(options = {}) {
        super();
        this.id = options.id;
        this.addClass('GradingWidget');
        this.root = this.node;
        const savedPath = (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_4__.loadString)('assignment-manage-react-router-path');
        let path = '/';
        if (savedPath !== null && savedPath !== '') {
            console.log(`Restoring path: ${savedPath}`);
            path = savedPath;
        }
        this.router = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_3__.createMemoryRouter)((0,_components_assignment_routes__WEBPACK_IMPORTED_MODULE_5__.getRoutes)(this.root), { initialEntries: [path] });
    }
    render() {
        return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(notistack__WEBPACK_IMPORTED_MODULE_2__.SnackbarProvider, { maxSnack: 3 },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_util_dialog_provider__WEBPACK_IMPORTED_MODULE_6__.DialogProvider, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_3__.RouterProvider, { router: this.router }))));
    }
}


/***/ }),

/***/ "./lib/widgets/coursemanage.js":
/*!*************************************!*\
  !*** ./lib/widgets/coursemanage.js ***!
  \*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   CourseManageView: () => (/* binding */ CourseManageView)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @jupyterlab/apputils */ "webpack/sharing/consume/default/@jupyterlab/apputils");
/* harmony import */ var _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! notistack */ "webpack/sharing/consume/default/notistack/notistack");
/* harmony import */ var notistack__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(notistack__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-router-dom */ "webpack/sharing/consume/default/react-router-dom/react-router-dom");
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _components_coursemanage_routes__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../components/coursemanage/routes */ "./lib/components/coursemanage/routes.js");
/* harmony import */ var _services_storage_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../services/storage.service */ "./lib/services/storage.service.js");
/* harmony import */ var _components_util_dialog_provider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../components/util/dialog-provider */ "./lib/components/util/dialog-provider.js");
// Copyright (c) 2022, TU Wien
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.







class CourseManageView extends _jupyterlab_apputils__WEBPACK_IMPORTED_MODULE_1__.ReactWidget {
    constructor(options = {}) {
        super();
        this.id = options.id;
        this.addClass('GradingWidget');
        this.root = this.node;
        const savedPath = (0,_services_storage_service__WEBPACK_IMPORTED_MODULE_4__.loadString)('course-manage-react-router-path');
        let path = '/';
        if (savedPath !== null && savedPath !== '') {
            console.log(`Restoring path: ${savedPath}`);
            path = savedPath;
        }
        this.router = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_3__.createMemoryRouter)((0,_components_coursemanage_routes__WEBPACK_IMPORTED_MODULE_5__.getRoutes)(), { initialEntries: [path] });
    }
    render() {
        return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(notistack__WEBPACK_IMPORTED_MODULE_2__.SnackbarProvider, { maxSnack: 3 },
            react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_util_dialog_provider__WEBPACK_IMPORTED_MODULE_6__.DialogProvider, null,
                react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_3__.RouterProvider, { router: this.router }))));
    }
}


/***/ })

}]);
//# sourceMappingURL=lib_index_js-webpack_sharing_consume_default_jupyterlab_translation-webpack_sharing_consume_d-c41005.431e736cb6e3bdfd3852.js.map