From 2824474bd115264bc9359f0275b5b85f7c42ffa5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 01:52:27 +0000 Subject: [PATCH 1/5] build(deps): bump webrick from 1.8.1 to 1.8.2 (#7228) Bumps [webrick](https://github.com/ruby/webrick) from 1.8.1 to 1.8.2. - [Release notes](https://github.com/ruby/webrick/releases) - [Commits](https://github.com/ruby/webrick/compare/v1.8.1...v1.8.2) --- updated-dependencies: - dependency-name: webrick dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index a7792e86de..a4ba3e3ea1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -472,7 +472,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.8.1) + webrick (1.8.2) websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) From 81f057db9458e735fc5e21cb9921107ad1a7e16c Mon Sep 17 00:00:00 2001 From: donny-wong <141858744+donny-wong@users.noreply.github.com> Date: Sun, 6 Oct 2024 11:15:34 -0400 Subject: [PATCH 2/5] Fix grader csv download for marks spreadsheets (#7257) --- Changelog.md | 6 ++++ app/models/grade_entry_form.rb | 9 +++--- spec/models/grade_entry_form_spec.rb | 43 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 299246473d..2927a29186 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,11 @@ # Changelog +## [v2.5.3] + +### 🐛 Bug fixes + +- Fix Marks Spreadsheet csv bug of showing incorrect marks (#7257) + ## [v2.5.2] ### ✨ New features and improvements diff --git a/app/models/grade_entry_form.rb b/app/models/grade_entry_form.rb index 4a8bbad4dd..6c54c82187 100644 --- a/app/models/grade_entry_form.rb +++ b/app/models/grade_entry_form.rb @@ -122,11 +122,10 @@ def export_as_csv(role) .group_by { |x| x[0] } num_items = self.grade_entry_items.count elsif role.ta? - grade_data = role.grade_entry_students - .joins(:user) - .joins(:grades) - .joins(:grade_entry_items) - .where(grade_entry_form: self) + grade_data = self.grades + .joins(:grade_entry_item, grade_entry_student: :user) + .joins(grade_entry_student: :grade_entry_student_tas) + .where('grade_entry_student_tas.ta_id': role.id) .pluck('users.user_name', 'grade_entry_items.position', 'grades.grade') .group_by { |x| x[0] } num_items = self.grade_entry_items.count diff --git a/spec/models/grade_entry_form_spec.rb b/spec/models/grade_entry_form_spec.rb index 3dac204889..92978ed736 100644 --- a/spec/models/grade_entry_form_spec.rb +++ b/spec/models/grade_entry_form_spec.rb @@ -385,4 +385,47 @@ end end end + + describe 'when TA downloads a csv file of the grades' do + let(:ta) { create(:ta) } + let!(:student1) { create(:student) } + let!(:student2) { create(:student) } + let!(:grade_entry_form_with_data) { create(:grade_entry_form_with_data) } + + before do + grade_entry_student1 = GradeEntryStudent.find_by(role: student1) + grade_entry_student2 = GradeEntryStudent.find_by(role: student2) + + GradeEntryStudentTa.create(grade_entry_student: grade_entry_student1, ta: ta) + GradeEntryStudentTa.create(grade_entry_student: grade_entry_student2, ta: ta) + + item2 = create(:grade_entry_item, name: 'Test2', position: 2, grade_entry_form: grade_entry_form_with_data) + + grade_entry_student1.grades.create(grade: Random.rand(item2.out_of), grade_entry_item: item2) + grade_entry_student1.save + + grade_entry_student2.grades.create(grade: Random.rand(item2.out_of), grade_entry_item: item2) + grade_entry_student2.save + + grade_spreadsheet = grade_entry_form_with_data.export_as_csv(ta) + results = CSV.parse(grade_spreadsheet, headers: false).drop(2) + + @res_marks = {} + results.each do |x| + mark1 = x[6] == '' ? nil : x[6].to_f + mark2 = x[7] == '' ? nil : x[7].to_f + @res_marks[x[0]] = [mark1, mark2] + end + + @student_marks = {} + @student_marks[student1.user.user_name] = + [grade_entry_student1.grades.first.grade, grade_entry_student1.grades.second.grade] + @student_marks[student2.user.user_name] = + [grade_entry_student2.grades.first.grade, grade_entry_student2.grades.second.grade] + end + + it 'correctly displays the marks' do + expect(@res_marks).to eq(@student_marks) + end + end end From 2495bcc4dc7faa97582ee05ee0cb8fa08cc531e5 Mon Sep 17 00:00:00 2001 From: Samuel Maldonado Date: Wed, 16 Oct 2024 18:30:49 -0400 Subject: [PATCH 3/5] Remove course parameter from LtiSyncJob (#7258) --- Changelog.md | 1 + app/controllers/assignments_controller.rb | 2 +- app/jobs/lti_sync_job.rb | 4 ++-- spec/jobs/lti_sync_job_spec.rb | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 2927a29186..48b4d10695 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ ### 🐛 Bug fixes - Fix Marks Spreadsheet csv bug of showing incorrect marks (#7257) +- Fix incorrect inclusion of course parameter in LtiSyncJob (#7258) ## [v2.5.2] diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index dbbcb21777..4c853b438b 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -628,7 +628,7 @@ def upload_config_files def create_lti_grades assessment = record lti_deployments = LtiDeployment.where(course: assessment.course, id: params[:lti_deployments]) - @current_job = LtiSyncJob.perform_later(lti_deployments.to_a, assessment, current_course, + @current_job = LtiSyncJob.perform_later(lti_deployments.to_a, assessment, can_create_users: allowed_to?(:lti_manage?, with: UserPolicy), can_create_roles: allowed_to?(:manage?, with: RolePolicy)) session[:job_id] = @current_job.job_id diff --git a/app/jobs/lti_sync_job.rb b/app/jobs/lti_sync_job.rb index 6cd156f085..f768a9bbfc 100644 --- a/app/jobs/lti_sync_job.rb +++ b/app/jobs/lti_sync_job.rb @@ -9,12 +9,12 @@ def self.completed_message(_status) I18n.t('lti.grade_sync_complete') end - def perform(lti_deployments, assessment, course, can_create_users: false, can_create_roles: false) + def perform(lti_deployments, assessment, can_create_users: false, can_create_roles: false) if lti_deployments.empty? raise I18n.t('lti.no_platform') end lti_deployments.each do |deployment| - roster_error = roster_sync(deployment, course, + roster_error = roster_sync(deployment, [LtiDeployment::LTI_ROLES[:learner], LtiDeployment::LTI_ROLES[:ta]], can_create_users: can_create_users, can_create_roles: can_create_roles) if roster_error diff --git a/spec/jobs/lti_sync_job_spec.rb b/spec/jobs/lti_sync_job_spec.rb index 0f7e1ba543..247206e64a 100644 --- a/spec/jobs/lti_sync_job_spec.rb +++ b/spec/jobs/lti_sync_job_spec.rb @@ -29,7 +29,7 @@ end context 'when running as a background job' do - let(:job_args) { [[lti_deployment.id], assessment, course] } + let(:job_args) { [[lti_deployment.id], assessment] } include_examples 'background job' end @@ -43,7 +43,7 @@ end context 'with no lti deployments' do - let(:job_args) { [[], assessment, course] } + let(:job_args) { [[], assessment] } it 'should raise an error' do expect { LtiSyncJob.perform_now(*job_args) }.to raise_error(RuntimeError) From ee2631a09679c95c5c45095f08a7355201c19168 Mon Sep 17 00:00:00 2001 From: donny-wong <141858744+donny-wong@users.noreply.github.com> Date: Sun, 27 Oct 2024 20:27:36 -0400 Subject: [PATCH 4/5] Fix Google Colab Jupyter Notebooks rendering by excluding widgets (#7271) Co-authored-by: Donny Wong --- Changelog.md | 1 + app/controllers/submissions_controller.rb | 7 +++ .../submissions_controller_spec.rb | 13 +++++ spec/fixtures/files/example_widgets.ipynb | 52 +++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 spec/fixtures/files/example_widgets.ipynb diff --git a/Changelog.md b/Changelog.md index 48b4d10695..c897bec2cd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ - Fix Marks Spreadsheet csv bug of showing incorrect marks (#7257) - Fix incorrect inclusion of course parameter in LtiSyncJob (#7258) +- Fix Google Colab Jupyter Notebooks rendering by excluding widgets (#7271) ## [v2.5.2] diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 59f15dfbe9..6f0d628da5 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -1,3 +1,5 @@ +require 'json' + class SubmissionsController < ApplicationController include SubmissionsHelper include RepositoryHelper @@ -937,6 +939,11 @@ def notebook_to_html(file_contents, unique_path, type) '--template', 'markus-html-template' ] end + file_contents = JSON.parse(file_contents) + if file_contents['metadata'].key?('widgets') + file_contents['metadata'].delete('widgets') + end + file_contents = JSON.generate(file_contents) _stdout, stderr, status = Open3.capture3(*args, stdin_data: file_contents) return "#{I18n.t('submissions.cannot_display')}

#{stderr.lines.last}" unless status.exitstatus.zero? diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 609cf36550..c457c43fc6 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -1665,6 +1665,19 @@ it_behaves_like 'notebook content' end + context 'a jupyter-notebook file with widgets', + skip: Rails.application.config.nbconvert_enabled ? false : 'nbconvert dependencies not installed' do + render_views + let(:filename) { 'example_widgets.ipynb' } + + it 'renders without widgets' do + subject + expect(response.body).not_to include("KeyError: 'state'") + end + + it_behaves_like 'notebook content' + end + context 'an rmarkdown file' do let(:filename) { 'example.Rmd' } diff --git a/spec/fixtures/files/example_widgets.ipynb b/spec/fixtures/files/example_widgets.ipynb new file mode 100644 index 0000000000..20d2a1c94b --- /dev/null +++ b/spec/fixtures/files/example_widgets.ipynb @@ -0,0 +1,52 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + } + } + }, + "cells": [ + { + "cell_type": "code", + "source": [ + ], + "metadata": { + "id": "wekaZO6DYWz6", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "outputId": "990f2494-5ca0-442f-ba8d-f7a31bd463e4" + }, + "execution_count": 17, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Training: 0%| | 0/1000 [00:00 Date: Thu, 31 Oct 2024 15:38:46 -0400 Subject: [PATCH 5/5] update changelog --- app/MARKUS_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/MARKUS_VERSION b/app/MARKUS_VERSION index a10b9631ab..834f068caf 100644 --- a/app/MARKUS_VERSION +++ b/app/MARKUS_VERSION @@ -1 +1 @@ -VERSION=v2.5.2,PATCH_LEVEL=DEV +VERSION=v2.5.3,PATCH_LEVEL=DEV