Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Jul 29, 2024
1 parent 20ee525 commit d2566d6
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Installation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Setup
### Notices before installation

We assume you use [RVM](https://rvm.io/). If you don't, then replace `rvmsudo` with `sudo` during the installation process.
We assume you use [RVM](https://rvm.io/). If you don't, then replace `rvmsudo` with `sudo` during the installation process.
> Note: Installation instructions works on WSL, but node needs to be installed according to [these](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2) instructions.
### Installation instructions for Ubuntu
We expect the user to be using account which name is tmc.
Expand All @@ -24,7 +24,7 @@ RVM dependencies
```bash
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
```
ext/sandbox dependencies see [rage/sandbox](https://github.com/rage/sandbox) for latest deps
ext/sandbox dependencies see [rage/sandbox](https://github.com/rage/sandbox) for latest deps
Requires docker to be installed aswell, read instructions [here](https://docs.docker.com/engine/install/ubuntu/).
```
sudo apt-get install tar zstd moreutils nodejs
Expand Down Expand Up @@ -115,8 +115,8 @@ bundle install
git submodule update --init --recursive
```

You can view the site settings from the file `config/site.defaults.yml`. If you want to change the settings for the site, create a new file `config/site.yml` and define the changes there.
> Note: You do not need to copy the entire file. Settings not in `site.yml` will be looked up from `site.defaults.yml`.
You can view the site settings from the file `config/site.defaults.yml`. If you want to change the settings for the site, create a new file `config/site.yml` and define the changes there.
> Note: You do not need to copy the entire file. Settings not in `site.yml` will be looked up from `site.defaults.yml`.
:exclamation: For development environment you can run command `cp config/site.dev.yml config/site.yml`

Initialize the database with `bin/rails db:create db:migrate`
Expand Down
1 change: 1 addition & 0 deletions app/background_tasks/refresh_course_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def wait_delay

private
def broadcast_to_channel(id, msg, percent, time, refresh_id = nil)
Rails.logger.info("Broadcasting message: #{msg} to channel CourseTemplateRefreshChannel-#{id}, Percent done: #{percent}, Time: #{time}, Course Template Refresh ID: #{refresh_id}")
ActionCable.server.broadcast("CourseTemplateRefreshChannel-#{id}", {
message: msg,
percent_done: percent,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/migrate_to_other_course_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def show
@already_migrated = already_migrated
@extra_alert_text = get_extra_text
return respond_with_error('Please login to continue') if current_user.guest?
return respond_with_error('This migration is not allowed') unless StudentSubmissionMigrator.new(@old_course, @to_course, current_user).migration_is_allowed
respond_with_error('This migration is not allowed') unless StudentSubmissionMigrator.new(@old_course, @to_course, current_user).migration_is_allowed
end

def migrate
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def bs_labeled_field(label, field, options = {})
str << " #{field}#{label}"
str << '</label>'
else
label_title = options[:label_title] ? options[:label_title] : nil
label_title = options[:label_title] || nil
label = label_tag label, label_title, class: 'control-label'
str += raw('<div class="form-group">' + raw(label) + raw(field) + '</div>')
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/available_point.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'point_comparison'

# Caches points that can be awarded from an exercise.
# Awarded points don't have a hard reference to these because
# these are recreated every time a course is refreshed.
Expand Down
2 changes: 2 additions & 0 deletions app/models/awarded_point.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'point_comparison'

# Stores when a point (course_id, name) has been awared to a particular user.
#
# There is a reference to the submission that first awarded the point, but this
Expand Down
2 changes: 1 addition & 1 deletion app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def test_case_records
successful: tcr.successful?,
message: tcr.message,
exception: tcr.exception ? ActiveSupport::JSON.decode(tcr.exception) : nil,
detailed_message: tcr.detailed_message ? tcr.detailed_message : nil
detailed_message: tcr.detailed_message || nil
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def self.authenticate(login, submitted_password)
user = find_by(login: login)
user ||= find_by('lower(email) = ?', login.downcase)
return nil if user.nil?
return user if user.has_password?(submitted_password)
user if user.has_password?(submitted_password)
end

def password_reset_key
Expand Down
2 changes: 1 addition & 1 deletion app/views/courses/_refresh_report.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<% report.course_template_refresh_report['refresh_timings'].each do |k,v| %>
<tr>
<td class="py-1"><%= simple_format k.to_s.split("_").join(" ").capitalize(), {}, wrapper_tag: 'span' %></td>
<td class="py-1 align-right"><%= "%.3f" % v.real %></td>
<td class="py-1 align-right"><%= "%.3f" % v["real"] %></td>
<% end %>
</tbody>
</table>
Expand Down
3 changes: 3 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@
else
config.cache_store = :memory_store, { size: 64.megabytes }
end


config.hosts << URI.parse(SiteSetting.value('baseurl_for_remote_sandboxes')).host
end
2 changes: 2 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,6 @@
config.active_record.dump_schema_after_migration = false

config.wkhtmltopdf = 'xvfb-run wkhtmltopdf'

config.hosts << URI.parse(SiteSetting.value('baseurl_for_remote_sandboxes')).host
end
File renamed without changes.
39 changes: 39 additions & 0 deletions lib/twitter_bootstrap_breadcrumbs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

module BreadCrumbs
def self.included(base)
base.extend(ClassMethods)
end

module ClassMethods
def add_breadcrumb(name, url, options = {})
class_name = self.name
before_action options do |controller|
name = controller.send :translate_breadcrumb, name, class_name if name.is_a?(Symbol)
controller.send :add_breadcrumb, name, url
end
end
end

protected
def add_breadcrumb(name, url = '', options = {})
@breadcrumbs ||= []
name = translate_breadcrumb(name, self.class.name) if name.is_a?(Symbol)
url = eval(url.to_s) if url =~ /_path|_url|@/ # rubocop:disable Performance/RegexpMatch
@breadcrumbs << { name: name, url: url, options: options }
end

def translate_breadcrumb(name, class_name)
scope = [:breadcrumbs]
namespace = class_name.underscore.split('/')
namespace.last.sub!('_controller', '')
scope += namespace

I18n.t name, scope: scope
end

def render_breadcrumbs(divider = '/')
s = render partial: 'twitter-bootstrap/breadcrumbs', locals: { divider: divider }
s.first
end
end

0 comments on commit d2566d6

Please sign in to comment.