Skip to content

Commit

Permalink
[Testing:TAGrading] Download Zip File (Submitty#10694)
Browse files Browse the repository at this point in the history
### Please check if the PR fulfills these requirements:
Closes Submitty#10601

* [x] Tests for the changes have been added/updated (if possible)
* [ ] Documentation has been updated/added if relevant
* [ ] Screenshots are attached to Github PR if visual/UI changes were
made

### What is the current behavior?
<!-- List issue if it fixes/closes/implements one using the "Fixes
#<number>" or "Closes #<number>" syntax -->
When we download the zip file , 
the file name will be like this `assignementName_RCSID_version `and we
do not want to exposed any kind of student details

### What is the new behavior?
new file name - `grading_homework_hG1b13ljpDjKu32_v1.zip`
(**assignementName_anonId_version**)
And no test existed so added test for  download zip file button 

**Concerned about should we need to test the content of zip file ??
Difficult to do that**

### Other information?
<!-- Is this a breaking change? -->
<!-- How did you test -->

---------

Co-authored-by: Cameron Peterson <[email protected]>
Co-authored-by: Barb Cutler <[email protected]>
  • Loading branch information
3 people authored Jul 30, 2024
1 parent 9533d69 commit 2c18347
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions site/.performance_warning_ignore.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"/courses/<term>/<course>/gradeable/<gradeable>/grading/graded_gradeable",
"/courses/<term>/<course>/gradeable/<gradeable>/grading/status",
"/courses/<term>/<course>/gradeable/<gradeable>/update",
"/courses/<term>/<course>/gradeable/<gradeable>/download_zip",
"/courses/<term>/<course>/forum",
"/courses/<term>/<course>/forum/threads/new",
"/courses/<term>/<course>/forum/threads/[0-9]+",
Expand Down
8 changes: 1 addition & 7 deletions site/app/controllers/MiscController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use app\libraries\response\JsonResponse;
use app\views\MiscView;
use Symfony\Component\Routing\Annotation\Route;
use app\models\User;

class MiscController extends AbstractController {
const GENERIC_NO_ACCESS_MSG = 'You do not have access to this file';
Expand Down Expand Up @@ -413,12 +412,7 @@ public function downloadSubmissionZip($gradeable_id, $submitter_id, $version, $i

// TODO: Zip file anonymization is currently done based on access level (students==peers)
// When single/double blind grading is merged, this will need to be updated.
if ($this->core->getUser()->getGroup() === User::GROUP_STUDENT) {
$zip_file_name = $gradeable_id . "_" . $anon_id . "_v" . $version . ".zip";
}
else {
$zip_file_name = $gradeable_id . "_" . $submitter_id . "_v" . $version . ".zip";
}
$zip_file_name = $gradeable_id . "_" . $anon_id . "_v" . $version . ".zip";

// create a new zipstream object
$zip_stream = new \ZipStream\ZipStream(
Expand Down
3 changes: 2 additions & 1 deletion site/app/templates/grading/electronic/SubmissionPanel.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
$('#' + currentCodeStyleRadio).prop('checked', true);
});
</script>
<button class="btn btn-default" tabindex="0" onclick="downloadSubmissionZip('{{ gradeable_id }}','{{ anon_submitter_id }}', {{ active_version }}, null, true)">Download Zip File</button>

<button class="btn btn-default" tabindex="0" onclick="downloadSubmissionZip('{{ gradeable_id }}','{{ anon_submitter_id }}', {{ active_version }}, null, true)" data-testid="download-zip-file">Download Zip File</button>

<span style="padding-right: 10px; white-space: nowrap;"> <input aria-label="Auto open" type="checkbox" id="autoscroll_id" onclick="updateCookies();" class="key_to_click" tabindex="0"> <label for="autoscroll_id">Auto open</label> </span>
</span>
Expand Down
14 changes: 14 additions & 0 deletions site/cypress/e2e/Cypress-TAGrading/zip_file_download.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import path from 'path';
describe('download zip file', () => {
const downloadsFolder = Cypress.config('downloadsFolder');
it('downloading and verifying the file', () => {
cy.login();
cy.visit(['sample', 'gradeable', 'grading_homework', 'grading', 'grade?who_id=hG1b13ljpDjKu32&sort=id&direction=ASC']);
cy.get('body').type('{A}');
cy.get('body').type('{O}'); // Solution/Notes
cy.get('[data-testid="download-zip-file"]').should('contain', 'Download Zip File');
cy.get('[data-testid="download-zip-file"]').click();
const filename = path.join(downloadsFolder, 'grading_homework_hG1b13ljpDjKu32_v1.zip');
cy.readFile(filename);
});
});

0 comments on commit 2c18347

Please sign in to comment.