-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #830 from rage/relay-data-to-plagiarism-backend
Relay data to plagiarism backend
- Loading branch information
Showing
9 changed files
with
175 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/backendv2/database/migrations/20210930184939_add_column_check_plagiarism_to_quiz.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as Knex from "knex" | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
await knex.raw( | ||
`alter table quiz add column check_plagiarism boolean default false;`, | ||
) | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.raw(`alter table quiz drop column check_plagiarism;`) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import axios from "axios" | ||
import jwt from "jsonwebtoken" | ||
import { GlobalLogger } from "../middleware/logger" | ||
|
||
const CancelToken = axios.CancelToken | ||
const source = CancelToken.source() | ||
|
||
export const relayNewAnswer = async (data: any) => { | ||
try { | ||
const csd_url = process.env.CSD_URL || "http://localhost/5150" | ||
await axios.post(csd_url + "/new", data, { | ||
headers: { | ||
authorization: jwt.sign( | ||
{ source: "quizzes" }, | ||
process.env.JWT_SECRET || "", | ||
), | ||
}, | ||
cancelToken: source.token, | ||
}) | ||
setTimeout(() => { | ||
GlobalLogger.warn("plagiarism detection: request timed out") | ||
source.cancel() | ||
}, 10000) | ||
} catch (error) { | ||
GlobalLogger.error("plagiarism detection: backend responded with error") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters