-
-
Notifications
You must be signed in to change notification settings - Fork 24
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 #5420 from dodona-edu/feat/dolos-export
Add dolos plagiarism detection
- Loading branch information
Showing
15 changed files
with
117 additions
and
10 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
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,52 @@ | ||
import { LoadingBar } from "components/search/loading_bar"; | ||
import { exportData, prepareExport } from "export"; | ||
import { fetch } from "utilities"; | ||
import { html, render } from "lit"; | ||
import { i18n } from "i18n/i18n"; | ||
|
||
const LOADER_ID = "dolos-loader"; | ||
const BTN_ID = "dolos-btn"; | ||
const DOLOS_URL = "/dolos_reports"; | ||
|
||
export async function startDolos(url: string): Promise<void> { | ||
const loader = document.getElementById(LOADER_ID) as LoadingBar; | ||
loader.show(); | ||
const btn = document.getElementById(BTN_ID) as HTMLLinkElement; | ||
btn.classList.add("disabled"); | ||
|
||
const settings = new FormData(); | ||
settings.append("with_info", "true"); | ||
settings.append("only_last_submission", "true"); | ||
settings.append("group_by", "user"); | ||
|
||
const exportDataUrl = await prepareExport(url, settings); | ||
const download = await exportData(exportDataUrl); | ||
|
||
const dolosResponse = await fetch(DOLOS_URL, { | ||
method: "POST", | ||
body: JSON.stringify({ export_id: download.id }), | ||
headers: { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json" | ||
} | ||
}); | ||
|
||
if (!dolosResponse.ok) { | ||
alert("An error occurred while creating the plagiarism report."); | ||
loader.hide(); | ||
return; | ||
} | ||
|
||
const json = await dolosResponse.json(); | ||
const dolosUrl = json.html_url; | ||
window.open(dolosUrl, "_blank"); | ||
loader.hide(); | ||
|
||
const newBtn = html` | ||
<a id="${BTN_ID}" class="btn btn-outline with-icon" href="${dolosUrl}" target="_blank"> | ||
<i class="mdi mdi-graph-outline mdi-18"></i> ${i18n.t("js.dolos.view_report")} | ||
</a> | ||
`; | ||
render(newBtn, btn.parentElement, { renderBefore: btn }); | ||
btn.remove(); | ||
} |
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,22 @@ | ||
class DolosReportsController < ApplicationController | ||
def create | ||
export = Export.find(params[:export_id]) | ||
|
||
authorize export, :show? | ||
return head :unprocessable_entity unless export.finished? | ||
|
||
export.archive.open do |file| | ||
response = HTTParty.post( | ||
'https://dolos.ugent.be/api/reports', | ||
body: { | ||
dataset: { | ||
zipfile: file, | ||
name: export.archive.filename | ||
} | ||
} | ||
) | ||
|
||
render json: response | ||
end | ||
end | ||
end |
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,3 @@ | ||
import { startDolos } from "dolos.ts"; | ||
|
||
window.dodona.startDolos = startDolos; |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
json.id @export.id | ||
json.ready @export.finished? | ||
json.url rails_blob_path(@export.archive, disposition: 'attachment') if @export.finished? && @export.archive.attached? |
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
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