Skip to content

Commit

Permalink
[Bugfix:Submission] Notebook Generated Files Filter Fix (#9613)
Browse files Browse the repository at this point in the history
### Please check if the PR fulfills these requirements:

* [ ] 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 -->
If a student submits a file with the same name as a notebook generated
file, it won't be shown in downloads

### What is the new behavior?
Now it will be shown

### Other information?
Make sure this is the case for all user levels, and that it doesn't
accidentally show anything it shouldn't (ie, notebook generated files)

---------

Co-authored-by: Barb Cutler <bmcutler@users.noreply.github.com>
Co-authored-by: Musaab Imran <96174078+musaabimran@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 8, 2023
1 parent 0d7e3bc commit 8e6731f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<div class="row">
<div class="box col-md-6" id="submitted-files">
{% for file in files %}
{% if not (file.name in notebook) %}
{# In a notebook, files in the root directory are server-generated. If not a notebook, all files can be seen #}
{% if (is_notebook and (file.relative_name|split('/'))|length > 1) or (not is_notebook) %}
<div class="flex-row">
<span>
{{ file.relative_name }} ({{ (file.size / 1024) | number_format(2) | default(-1) }}kb)
Expand Down
23 changes: 1 addition & 22 deletions site/app/views/submission/HomeworkView.php
Original file line number Diff line number Diff line change
Expand Up @@ -1034,29 +1034,8 @@ private function renderVersionBox(GradedGradeable $graded_gradeable, $version_in

$files = $version_instance->getFiles();

$notebook_data = null;
$hidefiles = [];
if ($autograding_config->isNotebookGradeable()) {
$notebook_model = $autograding_config->getUserSpecificNotebook($this->core->getUser()->getId());

$notebook = $notebook_model->getNotebook();
if ($graded_gradeable !== null) {
$notebook_data = $notebook_model->getMostRecentNotebookSubmissions(
$graded_gradeable->getAutoGradedGradeable()->getHighestVersion(),
$notebook,
$this->core->getUser()->getId(),
$version_instance->getVersion(),
$graded_gradeable->getGradeableId()
);
}
foreach ($notebook_data as $note) {
if (array_key_exists('filename', $note)) {
array_push($hidefiles, $note['filename']);
}
}
}
$param = array_merge($param, [
'notebook' => $hidefiles,
'is_notebook' => $autograding_config->isNotebookGradeable(),
'submission_time' => DateUtils::dateTimeToString($version_instance->getSubmissionTime()),
'days_late' => $version_instance->getDaysLate(),
'num_autogrades' => $version_instance->getHistoryCount(),
Expand Down

0 comments on commit 8e6731f

Please sign in to comment.