Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable plagiarism detection when language is not supported by dolos #5607

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/assets/javascripts/dolos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@

const LOADER_ID = "dolos-loader";
const DOLOS_URL = "/dolos_reports";
// List from https://github.com/dodona-edu/dolos/issues/1029 on 2024-06-13
const SUPPORTED_LANGUAGES = new Set(["sh", "c", "cpp", "csharp", "elm", "java", "javascript", "python", "typescript", "tsx"]);

Check warning on line 10 in app/assets/javascripts/dolos.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/dolos.ts#L10

Added line #L10 was not covered by tests

export function initDolosBtn(btnID: string, url: string): void {
export function initDolosBtn(btnID: string, url: string, lang: string): void {

Check warning on line 12 in app/assets/javascripts/dolos.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/dolos.ts#L12

Added line #L12 was not covered by tests
const btn = document.getElementById(btnID) as HTMLLinkElement;

const langName = lang.toLowerCase();

Check warning on line 15 in app/assets/javascripts/dolos.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/dolos.ts#L15

Added line #L15 was not covered by tests
if (!SUPPORTED_LANGUAGES.has(langName)) {
btn.classList.add("disabled-with-tooltip");
btn.title = i18n.t("js.dolos.unsupported_language", { lang: lang });
return;

Check warning on line 19 in app/assets/javascripts/dolos.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/dolos.ts#L17-L19

Added lines #L17 - L19 were not covered by tests
}

btn.addEventListener("click", () => startDolos(btn, url));
}

Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/i18n/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"date_on": "on",
"description_languages": "Language of the description",
"dolos": {
"unsupported_language": "%{lang} is not supported by the plagiarism checker.",
"view_report": "Open plagiarism report"
},
"draft": "Draft",
Expand Down Expand Up @@ -722,6 +723,7 @@
"date_on": "op",
"description_languages": "Taal van de beschrijving",
"dolos": {
"unsupported_language": "%{lang} wordt niet ondersteund door Dolos",
"view_report": "Rapport bekijken"
},
"draft": "Concept",
Expand Down
14 changes: 13 additions & 1 deletion app/assets/stylesheets/components/btn.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
pointer-events: none;
}

&.disabled-with-tooltip {
opacity: 0.38;
pointer-events: auto;
cursor: default;
}

// define the default button colors
// makes it easier to combine with other classes such as d-btn-danger, d-btn-success, etc.
--d-btn-color: var(--d-primary);
Expand Down Expand Up @@ -95,6 +101,11 @@
&:active {
opacity: 1;
background: rgba(var(--d-btn-color-rgb), 0.1);

&.disabled-with-tooltip {
opacity: 0.38;
background: none;
}
}
}

Expand Down Expand Up @@ -135,7 +146,8 @@
}

&.disabled,
&:disabled {
&:disabled,
&.disabled-with-tooltip {
color: var(--d-on-surface);
border: 1px solid rgba(var(--d-on-surface-rgb), 0.12);
opacity: 0.38;
Expand Down
2 changes: 1 addition & 1 deletion app/views/evaluations/_exercises_progress_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</a>
<script>
dodona.ready.then(() =>{
dodona.initDolosBtn('dolos-btn-<%= meta[:exercise].id %>', "<%= series_exports_path(@evaluation.series, token: (@evaluation.series.access_token if @evaluation.series.hidden?), selected_ids: [meta[:exercise].id], evaluation: true) %>");
dodona.initDolosBtn('dolos-btn-<%= meta[:exercise].id %>', "<%= series_exports_path(@evaluation.series, token: (@evaluation.series.access_token if @evaluation.series.hidden?), selected_ids: [meta[:exercise].id], evaluation: true) %>", "<%= meta[:exercise].programming_language.renderer_name %>");
})
</script>
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/submissions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<% actions << {icon: 'graph-outline', text: t('.detect_plagiarism'), id: "dolos-btn" } if @series && @activity %>
<script>
dodona.ready.then(() => {
dodona.initDolosBtn("dolos-btn", "<%= series_exports_path(@series, token: (@series.access_token if @series.hidden?), selected_ids: [@activity.id]) %>");
dodona.initDolosBtn("dolos-btn", "<%= series_exports_path(@series, token: (@series.access_token if @series.hidden?), selected_ids: [@activity.id]) %>", "<%= @activity.programming_language.renderer_name %>");
});
</script>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/js/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,4 @@ en:
popularity: Popularity
dolos:
view_report: Open plagiarism report
unsupported_language: "%{lang} is not supported by the plagiarism checker."
1 change: 1 addition & 0 deletions config/locales/js/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,5 @@ nl:
popularity: Populariteit
dolos:
view_report: Rapport bekijken
unsupported_language: "%{lang} wordt niet ondersteund door Dolos"

Loading