Skip to content

Commit

Permalink
Merge pull request #180 from TU-Wien-dataLAB/release-lab-0.2.13
Browse files Browse the repository at this point in the history
Release lab 0.2.13
  • Loading branch information
meffmadd committed Jan 9, 2024
2 parents 80ec36c + 2da7689 commit 9282245
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,8 @@ async def put(self, lecture_id: int, assignment_id: int, repo: str):
self.log.error(e.response)
raise HTTPError(e.code, reason=e.response.reason)

# TODO: similar logic for push instruction submission
# however we cannot push to edit repository when no submission exists
# reverse order:
# first create submission (with fake commit hash since autograder does not need any commit hash if submission is set to edited),
# then set submission to edited and update username to student username -> need to be able to set this later (in PUT?) -> also refactor SubmissionEditHandler? -> create new endpoint?
# then push to edit repository directly (not using SubmissionEditHandler),

# differentiate between "normal" edit and "create" edit by sub_id -> if it is None we know we are in submission creation mode instead of edit mode
# differentiate between "normal" edit and "create" edit by sub_id -> if it is None we know we are in
# submission creation mode instead of edit mode
if repo == "edit" and sub_id is None:
submission = Submission(commit_hash="0" * 40)
response: dict = await self.request_service.request(
Expand Down Expand Up @@ -443,6 +437,7 @@ async def put(self, lecture_id: int, assignment_id: int, repo: str):
git_service.push(f"grader_{repo}", force=True)
except GitError as e:
self.log.error("GitError:\n" + e.error)
git_service.undo_commit()
raise HTTPError(HTTPStatus.INTERNAL_SERVER_ERROR, reason=str(e.error))

if submit and repo == "assignment":
Expand Down
6 changes: 6 additions & 0 deletions grader_labextension/grader_labextension/services/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ def go_to_commit(self, commit_hash):
self.log.info(f"Show commit with hash {commit_hash}")
self._run_command(f"git checkout {commit_hash}", cwd=self.path)

def undo_commit(self, n: int = 1) -> None:
self.log.info(f"Undoing {n} commit(s)")
self._run_command(f"git reset --hard HEAD~{n}", cwd=self.path)
self._run_command(f"git gc", cwd=self.path)


def pull(self, origin: str, branch="main", force=False):
"""Pulls a repository
Expand Down
189 changes: 0 additions & 189 deletions grader_labextension/src/components/coursemanage/assignment.tsx

This file was deleted.

69 changes: 38 additions & 31 deletions grader_labextension/src/components/coursemanage/lecture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Grid,
LinearProgress, Stack, TableCell, TableRow,
Typography,
Box
Box, Tooltip
} from '@mui/material';
import * as React from 'react';
import { Assignment } from '../../model/assignment';
Expand All @@ -22,14 +22,13 @@ import {
createAssignment, deleteAssignment,
getAllAssignments
} from '../../services/assignments.service';
import { AssignmentComponent } from './assignment';
import { CreateDialog, EditLectureDialog } from '../util/dialog';
import {
getLecture,
getUsers,
updateLecture
} from '../../services/lectures.service';
import { red } from '@mui/material/colors';
import { red, grey } from '@mui/material/colors';
import { enqueueSnackbar } from 'notistack';
import {
deleteKey,
Expand Down Expand Up @@ -88,41 +87,49 @@ const AssignmentTable = (props: IAssignmentTableProps) => {
</IconButton>
</TableCell>
<TableCell>
<IconButton
aria-label='delete assignment'
size={'small'}
onClick={(e) => {
showDialog(
'Delete Assignment',
'Do you wish to delete this assignment?',
async () => {
try {
await deleteAssignment(
props.lecture.id,
row.id
);
enqueueSnackbar('Successfully Deleted Assignment', {
variant: 'success'
<Tooltip title={row.status === 'released' || row.status === 'complete'
? 'Released or Completed Assignments cannot be deleted'
: `Delete Assignment ${row.name}`
}>
<span> {/* span because of https://mui.com/material-ui/react-tooltip/#disabled-elements */}
<IconButton
aria-label='delete assignment'
size={'small'}
disabled={row.status === 'released' || row.status === 'complete'}
onClick={(e) => {
showDialog(
'Delete Assignment',
'Do you wish to delete this assignment?',
async () => {
try {
await deleteAssignment(
props.lecture.id,
row.id
);
enqueueSnackbar('Successfully Deleted Assignment', {
variant: 'success'
});
props.setAssignments(props.rows.filter(a => a.id !== row.id));
} catch (error: any) {
enqueueSnackbar(error.message, {
variant: 'error'
});
}
});
props.setAssignments(props.rows.filter(a => a.id !== row.id));
} catch (error: any) {
enqueueSnackbar(error.message, {
variant: 'error'
});
}
});
e.stopPropagation();
}}
>
<CloseIcon sx={{ color: red[500] }} />
</IconButton>
e.stopPropagation();
}}
>
<CloseIcon
sx={{ color: (row.status === 'released' || row.status === 'complete') ? grey[500] : red[500] }} />
</IconButton>
</span>
</Tooltip>
</TableCell>
</TableRow>
);
}}
/>
</>

);
};

Expand Down

0 comments on commit 9282245

Please sign in to comment.