Skip to content

Commit

Permalink
Fixed already submitted disclaimer
Browse files Browse the repository at this point in the history
- Fixed already submitted disclaimers
- Changed already submitted disclaimer color to make it move obvious
- Fixed checked todos "Mark as incomplete" button style
- Removed old commented code
  • Loading branch information
da-stoi committed Nov 13, 2023
1 parent 1eb72b5 commit 2e7180a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Canvas Strikethrough",
"description": "Mark assignments without deliverables as complete.",
"author": "Daniel Stoiber",
"version": "1.1",
"version": "1.2",
"manifest_version": 3,
"permissions": [
"storage"
Expand Down
31 changes: 16 additions & 15 deletions src/displayCheckButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ function checkButtonHtml(courseId: number, todo: Todo, isChecked: boolean, isSub
checkButton.id = 'canvas-strikethrough-check-button';
checkButton.classList.add('Button', 'Button--primary');

// Grey out button if assignment is already submitted
// if (isSubmitted) {
// checkButton.classList.add('Button--disabled');
// checkButton.disabled = true;
// }

if (isChecked) {
checkButton.onclick = () => {
markIncompleteOnclick(courseId, todo, checkButton, true);
Expand All @@ -37,11 +31,11 @@ function assignmentDisclaimer(): HTMLSpanElement {

function gradedDisclaimer(): HTMLSpanElement {
const disclaimer: HTMLSpanElement = document.createElement('span');
disclaimer.innerHTML = 'Note: This assignment has already been graded.';
disclaimer.innerHTML = 'Note: This assignment has already been submitted.';
disclaimer.style.fontStyle = 'italic';
disclaimer.style.color = 'var(--ic-link-color)';

return disclaimer;

}

async function handleAssignment(courseId: number, assignmentId: number) {
Expand All @@ -58,7 +52,7 @@ async function handleAssignment(courseId: number, assignmentId: number) {
const assignmentData = await assignmentReq.json();

const assignmentName = assignmentData.name;
const isSubmitted = assignmentData.graded_submissions_exist;
const isSubmitted = assignmentData.has_submitted_submissions;

// Create todo object
const todo: Todo = {
Expand All @@ -77,17 +71,20 @@ async function handleAssignment(courseId: number, assignmentId: number) {

// Create check button
const checkButton = checkButtonHtml(courseId, todo, isChecked, isSubmitted);

buttonDiv.appendChild(header);
buttonDiv.appendChild(checkButton);
buttonDiv.appendChild(document.createElement('br'));
buttonDiv.appendChild(assignmentDisclaimer());

// Add disclaimer if assignment is already submitted
if (isSubmitted) {
buttonDiv.appendChild(document.createElement('br'));
buttonDiv.appendChild(gradedDisclaimer());
buttonDiv.appendChild(document.createElement('br'));
}

// Add disclaimer
buttonDiv.appendChild(assignmentDisclaimer());

rightSide?.prepend(buttonDiv);
}

Expand Down Expand Up @@ -154,7 +151,7 @@ async function handleEvent(courseId: number, todoId: number | string, eventType:
const assignmentData = await assignmentReq.json();

const assignmentName = assignmentData.name;
isSubmitted = assignmentData.graded_submissions_exist;
isSubmitted = assignmentData.has_submitted_submissions;

// Create todo object
todo = {
Expand All @@ -181,11 +178,15 @@ async function handleEvent(courseId: number, todoId: number | string, eventType:
// Add disclaimer if assignment
if (eventType === 'assignment') {
header.appendChild(document.createElement('br'));
header.appendChild(assignmentDisclaimer());

// Add disclaimer if assignment is already submitted
if (isSubmitted) {
header.appendChild(document.createElement('br'));
header.appendChild(gradedDisclaimer());
header.appendChild(document.createElement('br'));
}

// Add disclaimer
header.appendChild(assignmentDisclaimer());
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/displayCheckedTodos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export async function displayCheckedTodos() {
div.id = 'checked-todos';
div.style.display = 'block';
div.style.opacity = '1';
div.classList.add('ui-droppable');

const ul = document.createElement('ul');
ul.style.listStyleType = 'none';
Expand Down Expand Up @@ -83,7 +82,13 @@ export async function displayCheckedTodos() {
markAsIncompleteButton.classList.add('Button');
markAsIncompleteButton.classList.add('Button--link');
markAsIncompleteButton.innerText = 'Mark as incomplete';
markAsIncompleteButton.style.padding = '5px';
markAsIncompleteButton.style.padding = '3px';
markAsIncompleteButton.style.margin = '3px';
markAsIncompleteButton.style.backgroundColor = 'white';
markAsIncompleteButton.style.color = 'black';
markAsIncompleteButton.style.borderRadius = '3px';
markAsIncompleteButton.style.cursor = 'pointer';
markAsIncompleteButton.style.border = '1px solid black';

markAsIncompleteButton.onclick = () => {
markIncompleteOnclick(todo.courseId, todo, markAsIncompleteButton, true);
Expand Down

0 comments on commit 2e7180a

Please sign in to comment.