Skip to content

Commit

Permalink
Merge branch '8.0.x' into new/scorm
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Sep 10, 2024
2 parents 8b205ed + 9b009a5 commit a0c0581
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 108 deletions.
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,58 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [8.0.32](https://github.com/macite/doubtfire-deploy/compare/v8.0.31...v8.0.32) (2024-09-05)


### Features

* add support for upload of vue components ([7c85aaf](https://github.com/macite/doubtfire-deploy/commit/7c85aaf1e1080554f4132bd7da18c1e67e2d2aea))

### [8.0.31](https://github.com/doubtfire-lms/doubtfire-deploy/compare/v8.0.30...v8.0.31) (2024-08-29)


### Bug Fixes

* ensure sidekiq logs latex errors to stdout ([78151b3](https://github.com/doubtfire-lms/doubtfire-deploy/commit/78151b3c00f768ee83dd6838628eee2163bd6cde))
* limit sidekiq concurrency to 1 ([0046562](https://github.com/doubtfire-lms/doubtfire-deploy/commit/004656216508f5469b234f3024c0d95a19d3b014))
* revert delay in sidekiq pdf generation ([904ca34](https://github.com/doubtfire-lms/doubtfire-deploy/commit/904ca3432cf777f88121e1cd1cf59284c628e1cf))

### [8.0.30](https://github.com/doubtfire-lms/doubtfire-deploy/compare/v8.0.29...v8.0.30) (2024-08-29)


### Bug Fixes

* add short delay for accept submission job ([b3861ff](https://github.com/doubtfire-lms/doubtfire-deploy/commit/b3861ff2f44467e135a92427141844f9d33d6164))

### [8.0.29](https://github.com/macite/doubtfire-deploy/compare/v8.0.28...v8.0.29) (2024-08-28)


### Bug Fixes

* correct email reporting of pdf errors in sidekiq ([ff2686a](https://github.com/macite/doubtfire-deploy/commit/ff2686ab0074c5f9442debdaddc9fce02dcdae54))

### [8.0.28](https://github.com/macite/doubtfire-deploy/compare/v8.0.27...v8.0.28) (2024-08-28)


### Bug Fixes

* ensure that TII can log multiple similarity issues for each task ([55aa194](https://github.com/macite/doubtfire-deploy/commit/55aa1940b418d5bcb7d43663d5453e7cc6f8610a))

### [8.0.27](https://github.com/macite/doubtfire-deploy/compare/v8.0.26...v8.0.27) (2024-08-28)


### Bug Fixes

* correct link to error log mailer and add test ([312f22e](https://github.com/macite/doubtfire-deploy/commit/312f22eacead8b8d666116df52a7c11e49ce1794))

### [8.0.26](https://github.com/macite/doubtfire-deploy/compare/v8.0.23...v8.0.26) (2024-08-26)


### Bug Fixes

* logging of fail to send message in accept submission ([38abe9e](https://github.com/macite/doubtfire-deploy/commit/38abe9eeb7dedf8f7d26b7b1c659be94d9c42d4a))
* use system timeout command with timeout helper ([b77147c](https://github.com/macite/doubtfire-deploy/commit/b77147c791396e202bbf2e01eb60385a1ae6cd7b))

### [8.0.25](https://github.com/macite/doubtfire-deploy/compare/v8.0.24...v8.0.25) (2024-08-09)


Expand Down
2 changes: 1 addition & 1 deletion app/helpers/file_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module FileHelper
extend MimeCheckHelpers

def known_extension?(extn)
allow_extensions = %w(pdf ps csv xls xlsx pas cpp c cs csv h hpp java py js html coffee scss yaml yml xml json ts r rb rmd rnw rhtml rpres tex vb sql txt md jack hack asm hdl tst out cmp vm sh bat dat ipynb css png bmp tiff tif jpeg jpg gif zip gz tar wav ogg mp3 mp4 webm aac pcm aiff flac wma alac pml)
allow_extensions = %w(pdf ps csv xls xlsx pas cpp c cs csv h hpp java py js html coffee scss yaml yml xml json ts r rb rmd rnw rhtml rpres tex vb sql txt md jack hack asm hdl tst out cmp vm sh bat dat ipynb css png bmp tiff tif jpeg jpg gif zip gz tar wav ogg mp3 mp4 webm aac pcm aiff flac wma alac pml vue)

# Allow empty or nil extensions for blobs otherwise check that it matches the allowed list
extn.blank? || allow_extensions.include?(extn)
Expand Down
10 changes: 4 additions & 6 deletions app/helpers/timeout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ def try_within(sec, timeout_message = 'operation')
#
def system_try_within(sec, timeout_message, command)
# shell script to kill command after timeout
timeout_exec = Rails.root.join('lib/shell/timeout.sh')
result = false
try_within sec, timeout_message do
result = system "#{timeout_exec} -t #{sec} nice -n 10 #{command}"
end
result
system "timeout -k 2 #{sec} nice -n 10 #{command}"
rescue
logger.error "Timeout when #{timeout_message} after #{sec}s"
false
end

# Export functions as module functions
Expand Down
2 changes: 1 addition & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ def self.pygments_lang(extn)
elsif ['cpp', 'hpp', 'c++', 'h++', 'cc', 'cxx', 'cp'].include?(extn) then 'cpp'
elsif ['java'].include?(extn) then 'java'
elsif %w(js json ts).include?(extn) then 'js'
elsif ['html', 'rhtml'].include?(extn) then 'html'
elsif ['html', 'rhtml', 'vue'].include?(extn) then 'html'
elsif %w(css scss).include?(extn) then 'css'
elsif ['rb'].include?(extn) then 'ruby'
elsif ['coffee'].include?(extn) then 'coffeescript'
Expand Down
22 changes: 10 additions & 12 deletions app/models/turn_it_in/tii_action_upload_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def update_from_pdf_report_status(response)
case response
when 'FAILED' # The report failed to be generated
error_message = 'similarity PDF failed to be created'
when 'SUCCESS' # Similarity report is complete
entity.status = :similarity_pdf_requested
when 'SUCCESS' # Similarity report is complete - pdf is available
entity.status = :similarity_pdf_available
entity.save
save_progress
download_similarity_report_pdf(skip_check: true)
Expand Down Expand Up @@ -64,17 +64,15 @@ def update_from_similarity_status(response)
# when 'PROCESSING' # Similarity report is being generated
# return
when 'COMPLETE' # Similarity report is complete
entity.overall_match_percentage = response.overall_match_percentage

flag = response.overall_match_percentage.present? && response.overall_match_percentage.to_i > task.tii_match_pct(idx)

# Update the status of the entity
entity.update(status: flag ? :similarity_report_complete : :complete_low_similarity)
entity.overall_match_percentage = response.overall_match_percentage.present? ? response.overall_match_percentage.to_i : -1
flag = entity.should_flag?
entity.status = flag ? :similarity_report_complete : :complete_low_similarity
entity.save

# Create the similarity record
TiiTaskSimilarity.find_or_initialize_by task: entity.task do |similarity|
similarity.pct = response.overall_match_percentage
similarity.tii_submission = entity
# Create the similarity record - for task and this turn it in submission
TiiTaskSimilarity.find_or_initialize_by task: entity.task, tii_submission: entity do |similarity|
similarity.pct = entity.overall_match_percentage # record percentage
similarity.flagged = flag
similarity.save
end
Expand Down Expand Up @@ -108,7 +106,7 @@ def next_step
"awaiting similarity report"
when :similarity_pdf_available
"downloading similarity report"
when "similarity_pdf_downloaded"
when :similarity_pdf_downloaded
"complete - report available"
when :to_delete
"awaiting deletion"
Expand Down
7 changes: 7 additions & 0 deletions app/models/turn_it_in/tii_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ def create_viewer_url(user)
).perform
end

# Should we flag this task for high similarity?
#
# @return [Boolean] true if the task should be flagged, false otherwise
def should_flag?
overall_match_percentage > task.tii_match_pct(idx)
end

private

# Delete the turn it in submission for a task
Expand Down
4 changes: 2 additions & 2 deletions app/sidekiq/accept_submission_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def perform(task_id, user_id, accepted_tii_eula)
begin
logger.info "Accepting submission for task #{task.id} by user #{user.id}"
# Convert submission to PDF
task.convert_submission_to_pdf(log_to_stdout: false)
task.convert_submission_to_pdf(log_to_stdout: true)
rescue StandardError => e
# Send email to student if task pdf failed
if task.project.student.receive_task_notifications
begin
PortfolioEvidenceMailer.task_pdf_failed(project, [task]).deliver
PortfolioEvidenceMailer.task_pdf_failed(task.project, [task]).deliver
rescue StandardError => e
logger.error "Failed to send task pdf failed email for project #{task.project.id}!\n#{e.message}"
end
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:concurrency: 1
86 changes: 0 additions & 86 deletions lib/shell/timeout.sh

This file was deleted.

19 changes: 19 additions & 0 deletions test/mailers/error_log_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'test_helper'
require 'grade_helper'

class ErrorLogMailerTest < ActionMailer::TestCase

def test_can_send_error_log_mail
Doubtfire::Application.config.email_errors_to = 'test <[email protected]>'
begin
raise 'test'
rescue StandardError => e
mail = ErrorLogMailer.error_message('test', 'test message', e)
end

assert mail.present?
assert mail.to.include? '[email protected]'
assert mail.body.include? e.message
assert mail.body.include? e.backtrace.join("\n")
end
end
23 changes: 23 additions & 0 deletions test_files/submissions/test.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div class="example">{{ msg }}</div>
</template>

<script>
export default {
data() {
return {
msg: 'Hello world!'
}
}
}
</script>

<style>
.example {
color: red;
}
</style>

<custom1>
This could be e.g. documentation for the component.
</custom1>

0 comments on commit a0c0581

Please sign in to comment.