mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
adding default lock offset
This commit is contained in:
@@ -13,6 +13,7 @@ import { LocalAssignmentGroup } from "@/models/local/assignment/localAssignmentG
|
|||||||
import {
|
import {
|
||||||
dateToMarkdownString,
|
dateToMarkdownString,
|
||||||
getDateFromString,
|
getDateFromString,
|
||||||
|
getDateFromStringOrThrow,
|
||||||
} from "@/models/local/timeUtils";
|
} from "@/models/local/timeUtils";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
@@ -66,6 +67,18 @@ export default function NewItemForm({
|
|||||||
dueDate === ""
|
dueDate === ""
|
||||||
? dueDate
|
? dueDate
|
||||||
: dateToMarkdownString(defaultDate ?? new Date());
|
: dateToMarkdownString(defaultDate ?? new Date());
|
||||||
|
const lockAt =
|
||||||
|
settings.defaultLockHoursOffset === undefined
|
||||||
|
? undefined
|
||||||
|
: dateToMarkdownString(
|
||||||
|
addHoursToDate(
|
||||||
|
getDateFromStringOrThrow(
|
||||||
|
dueDate,
|
||||||
|
"getting default lock time"
|
||||||
|
),
|
||||||
|
settings.defaultLockHoursOffset
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
console.log("submitting");
|
console.log("submitting");
|
||||||
if (!moduleName) {
|
if (!moduleName) {
|
||||||
@@ -77,6 +90,7 @@ export default function NewItemForm({
|
|||||||
name,
|
name,
|
||||||
description: "",
|
description: "",
|
||||||
dueAt,
|
dueAt,
|
||||||
|
lockAt,
|
||||||
submissionTypes: settings.defaultAssignmentSubmissionTypes,
|
submissionTypes: settings.defaultAssignmentSubmissionTypes,
|
||||||
allowedFileUploadExtensions: settings.defaultFileUploadTypes,
|
allowedFileUploadExtensions: settings.defaultFileUploadTypes,
|
||||||
rubric: [],
|
rubric: [],
|
||||||
@@ -90,6 +104,7 @@ export default function NewItemForm({
|
|||||||
name,
|
name,
|
||||||
description: "",
|
description: "",
|
||||||
dueAt,
|
dueAt,
|
||||||
|
lockAt,
|
||||||
shuffleAnswers: true,
|
shuffleAnswers: true,
|
||||||
showCorrectAnswers: true,
|
showCorrectAnswers: true,
|
||||||
oneQuestionAtATime: true,
|
oneQuestionAtATime: true,
|
||||||
@@ -160,3 +175,9 @@ export default function NewItemForm({
|
|||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addHoursToDate(date: Date, hours: number): Date {
|
||||||
|
const newDate = new Date(date.getTime());
|
||||||
|
newDate.setHours(newDate.getHours() + hours);
|
||||||
|
return newDate;
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ export default function DefaultLockOffset() {
|
|||||||
const id = setTimeout(() => {
|
const id = setTimeout(() => {
|
||||||
try {
|
try {
|
||||||
const hoursNumber = parseInt(hoursOffset);
|
const hoursNumber = parseInt(hoursOffset);
|
||||||
if (hoursNumber && hoursNumber !== settings.defaultLockHoursOffset) {
|
if (
|
||||||
|
!Number.isNaN(hoursNumber) &&
|
||||||
|
hoursNumber !== settings.defaultLockHoursOffset
|
||||||
|
) {
|
||||||
updateSettings.mutate({
|
updateSettings.mutate({
|
||||||
...settings,
|
...settings,
|
||||||
defaultLockHoursOffset: hoursNumber,
|
defaultLockHoursOffset: hoursNumber,
|
||||||
|
|||||||
Reference in New Issue
Block a user