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

Papyros integration #3453

Merged
merged 110 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
b03d050
Add papyros dependency
winniederidder Feb 8, 2022
ef445d3
Add offcanvas bootstrap
winniederidder Feb 8, 2022
f27a0a4
Add policy and route for service worker
winniederidder Feb 13, 2022
543a612
Add route in controller for service worker
winniederidder Feb 13, 2022
ccebf09
Remove service worker and instead use headers
winniederidder Feb 16, 2022
e4fc939
Use working headers for exercises
winniederidder Feb 16, 2022
1df426e
Rubocop
winniederidder Feb 16, 2022
162e49b
Add decent looking Papyros integration
winniederidder Feb 16, 2022
a34037a
Remove useless things and use correct locale
winniederidder Feb 16, 2022
889c207
Use new flexible rendering options
winniederidder Feb 20, 2022
e6f7370
Proper merge
winniederidder Feb 20, 2022
b046700
Lint
winniederidder Feb 21, 2022
54ee124
Minimal service worker config
winniederidder Feb 21, 2022
2d297ed
Start with initial code if it exists
winniederidder Feb 21, 2022
e66303a
Rename and refactor into partial
winniederidder Feb 24, 2022
3179139
Improve show button
winniederidder Feb 25, 2022
bb9eb2f
Use bootstrap variable
winniederidder Feb 25, 2022
6c673f0
Update button
winniederidder Feb 25, 2022
c597854
Improve text and add link
winniederidder Feb 25, 2022
94592a8
Add beta label
winniederidder Feb 25, 2022
168d576
Increase info text size
winniederidder Feb 25, 2022
11b6061
Cleanup service worker handling
winniederidder Feb 27, 2022
6413c46
Update service worker
winniederidder Feb 28, 2022
4bfa03b
Ignore service worker during linting
winniederidder Feb 28, 2022
9ec5388
Rubocop fix
winniederidder Feb 28, 2022
94c46e9
Use -A instead of --fix
winniederidder Feb 28, 2022
f7b7632
Correct dependencies
winniederidder Mar 1, 2022
96930de
Merge branch 'jsbundling-rails' into papyros-integration-v2
winniederidder Mar 1, 2022
306822f
Merge branch 'develop' into papyros-integration-v2
winniederidder Mar 2, 2022
238ee0b
Change to TypeScript
winniederidder Mar 4, 2022
8280e86
Apply suggestions
winniederidder Mar 4, 2022
0e5e937
Lint
winniederidder Mar 4, 2022
2c05f62
Rename and update styling
winniederidder Mar 4, 2022
6190c87
Better margins and padding
winniederidder Mar 4, 2022
a276ce3
Update service worker, reference from builds folder
winniederidder Mar 4, 2022
f2837fe
Add button to status panel to copy code
winniederidder Mar 4, 2022
b6a8a2f
Merge branch 'develop' into papyros-integration-v2
winniederidder Mar 9, 2022
01ccc08
Fix copy button and overwriting of code
winniederidder Mar 14, 2022
cfad836
Allow ts packs
winniederidder Mar 14, 2022
5fc0b5a
Add proper service worker for input
winniederidder Mar 14, 2022
02c6bc0
Allow serving serviceworker from assets while maintaining functionality
winniederidder Mar 14, 2022
35a7497
Update dependencies
winniederidder Mar 14, 2022
89b6468
Translation merge fix
winniederidder Mar 14, 2022
19384c6
Yarn lint
winniederidder Mar 14, 2022
3078122
Rubocop and fix pre-commit hook
winniederidder Mar 14, 2022
8ebfd9d
Add test for isw route
winniederidder Mar 14, 2022
59265b1
Also actually add the lint fix
winniederidder Mar 14, 2022
b3f676c
Update styling according to suggestions
winniederidder Mar 15, 2022
cd19533
Merge branch 'develop' into papyros-integration-v2
winniederidder Mar 21, 2022
3032dcf
Update import comment
winniederidder Mar 25, 2022
635ab16
Rename method, localize csp
winniederidder Mar 25, 2022
06ac4d7
Update translations
winniederidder Mar 25, 2022
c51d1e2
Fix style and policies
winniederidder Mar 25, 2022
34575c0
Merge branch 'papyros-integration-v2' of github.com:dodona-edu/dodona…
winniederidder Mar 25, 2022
75ec84a
Merge with develop
winniederidder Mar 25, 2022
7a7b1c9
Allow using a bundled Python tar
winniederidder Apr 1, 2022
b9cbc83
Update version and fix input mode switch
winniederidder Apr 3, 2022
9a1ad7d
Update version
winniederidder Apr 12, 2022
2afd96d
Merge branch 'develop' into papyros-integration-v2
winniederidder Apr 12, 2022
3f44a11
Apply translation suggestions
winniederidder Apr 15, 2022
a8a42f6
Prompt user after offcanvas is shwon
winniederidder Apr 15, 2022
a013089
Close scratchpad after copying
winniederidder Apr 15, 2022
13bf357
Fix header height and css suggestions
winniederidder Apr 15, 2022
67ef0e0
Merge branch 'papyros-integration-v2' of github.com:dodona-edu/dodona…
winniederidder Apr 15, 2022
47dbb79
Update version
winniederidder Apr 15, 2022
63179c0
Add explicit request filter
winniederidder Apr 18, 2022
dc6c294
Missing semicolon
winniederidder Apr 18, 2022
08bf41d
More explicit filter
winniederidder Apr 18, 2022
d24e602
Missing return type
winniederidder Apr 18, 2022
7ac6005
Add suggestions
winniederidder Apr 18, 2022
d3ff2f3
New version for dark mode support and fix gutter issue
winniederidder Apr 21, 2022
c4b649f
Merge branch 'develop' into papyros-integration-v2
winniederidder Apr 21, 2022
a9f82f8
Try to fix scrollbar issue
winniederidder Apr 22, 2022
dbfbf79
Merge branch 'papyros-integration-v2' of github.com:dodona-edu/dodona…
winniederidder Apr 22, 2022
7095e78
Fix gutter issue again
winniederidder Apr 22, 2022
8b1de40
Fix gutters again and better style for copy button
winniederidder Apr 22, 2022
b40ef30
Use latest version to prevent css class name clashes
winniederidder Apr 22, 2022
cfb9d73
Document showButton rendering
winniederidder Apr 22, 2022
f96babd
Add Hello World! integration test
winniederidder Apr 23, 2022
ffde5be
Update screenshot path
winniederidder Apr 23, 2022
4fbe51c
Ensure programming language is python
winniederidder Apr 23, 2022
5229f8e
Try creating exercise with python as language
winniederidder Apr 23, 2022
ba38157
Create python to ensure it is useable
winniederidder Apr 23, 2022
4e9e9b6
Add missing html id signs
winniederidder Apr 23, 2022
72cfa54
Try using editor directly
winniederidder Apr 23, 2022
4a6dd61
Try sending to .cm-content
winniederidder Apr 23, 2022
2a524c1
Remove the capybara timeout part
winniederidder Apr 24, 2022
67dfbe4
Use a bare find
winniederidder Apr 24, 2022
b40901f
Use correct argument name
winniederidder Apr 24, 2022
387714b
Add input test
winniederidder Apr 24, 2022
85ebc63
Missing ID signs
winniederidder Apr 24, 2022
71175a8
Remove method and filter on enabled
winniederidder Apr 24, 2022
80c63d3
Use better selectors
winniederidder Apr 24, 2022
782ecdb
Try to get tests to work again
winniederidder Apr 24, 2022
db70a7d
Retry old version
winniederidder Apr 24, 2022
38484d4
Increase default wait time to account for Papyros
winniederidder Apr 24, 2022
9d33396
Run both tests with new timeout
winniederidder Apr 24, 2022
28e02a1
Refactor tests for less duplication
winniederidder Apr 24, 2022
9093561
Add batch and sleep test
winniederidder Apr 24, 2022
a0820b3
Don't add the code a second time
winniederidder Apr 24, 2022
23527e0
Check whether textarea contains the input
winniederidder Apr 24, 2022
b9f53b4
Some docs and spacing to improve legibility
winniederidder Apr 24, 2022
b9bf1a2
Apply suggestions to show-button
winniederidder Apr 24, 2022
3c5e120
Integrate latest version
winniederidder Apr 24, 2022
c900fb0
Use latest version for tooltips
winniederidder Apr 24, 2022
6aca167
Try using nested tests
winniederidder Apr 24, 2022
48b4822
Combine tests into one
winniederidder Apr 24, 2022
465a561
Add newlines to code
winniederidder Apr 24, 2022
60557c3
Use double quotes for newlines
winniederidder Apr 24, 2022
484224d
Wait at the right time
winniederidder Apr 24, 2022
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ app/assets/config/manifest.js
app/assets/javascripts/application_old.js
app/assets/javascripts/i18n/translations.js
app/assets/javascripts/types/index.d.ts
app/assets/javascripts/inputServiceWorker.js
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: screenshots-failure
path: tmp/screenshots
path: tmp/capybara
97 changes: 97 additions & 0 deletions app/assets/javascripts/coding_scratchpad.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { Papyros } from "@dodona/papyros";
import { InputMode } from "@dodona/papyros";
import { ProgrammingLanguage } from "@dodona/papyros";

/**
* Custom interface to not have to add the ace package as dependency
*/
interface Editor {
setValue(v: string): void;
getValue(): string;
}

/** Identifiers used in HTML for relevant elements */
const CODE_EDITOR_PARENT_ID = "scratchpad-editor-wrapper";
const PANEL_PARENT_ID = "scratchpad-panel-wrapper";
const CODE_OUTPUT_PARENT_ID = "scratchpad-output-wrapper";
const CODE_INPUT_PARENT_ID = "scratchpad-input-wrapper";
const OFFCANVAS_ID = "scratchpad-offcanvas";
const SHOW_OFFCANVAS_BUTTON_ID = "scratchpad-offcanvas-show-btn";
const CODE_COPY_BUTTON_ID = "scratchpad-code-copy-btn";
const CLOSE_BUTTON_ID = "scratchpad-offcanvas-close-btn";
const SUBMIT_TAB_ID = "activity-handin-link";

function initCodingScratchpad(programmingLanguage: ProgrammingLanguage): void {
if (Papyros.supportsProgrammingLanguage(programmingLanguage)) {
let papyros: Papyros | undefined = undefined;
let editor: Editor | undefined = undefined;
// To prevent horizontal scrollbar issues, we delay rendering the button
// until after the page is loaded
const showButton = document.getElementById(SHOW_OFFCANVAS_BUTTON_ID);
showButton.classList.add("offcanvas-show-btn");
showButton.classList.remove("hidden");
showButton.addEventListener("click", async function () {
if (!papyros) { // Only create Papyros once per session, but only when required
papyros = new Papyros(
{
programmingLanguage: Papyros.toProgrammingLanguage(programmingLanguage),
standAlone: false,
locale: I18n.locale,
inputMode: InputMode.Interactive,
});
editor ||= window.dodona.editor;
if (editor) {
// Shortcut to copy code to ACE editor
papyros.addButton(
{
id: CODE_COPY_BUTTON_ID,
buttonText: I18n.t("js.coding_scratchpad.copy_code")
},
() => {
editor.setValue(papyros.getCode());
document.getElementById(CLOSE_BUTTON_ID).click();
// Open submit panel if possible
document.getElementById(SUBMIT_TAB_ID)?.click();
}
);
}

// Render once new button is added
papyros.render({
codeEditorOptions: {
parentElementId: CODE_EDITOR_PARENT_ID
},
statusPanelOptions: {
parentElementId: PANEL_PARENT_ID
},
outputOptions: {
parentElementId: CODE_OUTPUT_PARENT_ID
},
inputOptions: {
parentElementId: CODE_INPUT_PARENT_ID
},
darkMode: window.dodona.darkMode
});
await papyros.configureInput(location.href, "inputServiceWorker.js");
await papyros.launch();
}
});
// Ask user to choose after offcanvas is shown
document.getElementById(OFFCANVAS_ID).addEventListener("shown.bs.offcanvas", () => {
editor ||= window.dodona.editor;
if (editor) { // Start with code from the editor, if there is any
const editorCode = editor.getValue();
const currentCode = papyros.getCode();
if (!currentCode || // Papyros empty
// Neither code areas are empty, but they differ
(editorCode && currentCode !== editorCode &&
// and user chooses to overwrite current code with editor value
confirm(I18n.t("js.coding_scratchpad.overwrite_code")))) {
papyros.setCode(editorCode);
}
}
});
}
}

export { initCodingScratchpad };
3 changes: 2 additions & 1 deletion app/assets/javascripts/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ function initExerciseShow(exerciseId, programmingLanguage, loggedIn, editorShown
$(".activity-description a[target='_blank']").each(function () {
$(this).attr("rel", "noopener");
});

// export function
window.dodona.feedbackTableLoaded = feedbackTableLoaded;
}
Expand All @@ -202,6 +201,8 @@ function initExerciseShow(exerciseId, programmingLanguage, loggedIn, editorShown
editor.$blockScrolling = Infinity; // disable warning
editor.focus();
editor.on("focus", enableSubmitButton);
// Make editor available globally
window.dodona.editor = editor;
}

function swapActionButtons() {
Expand Down
Loading