Skip to content

Commit

Permalink
Merge pull request #5228 from mishaschwartz/v1.12.1
Browse files Browse the repository at this point in the history
v1.12.1
  • Loading branch information
mishaschwartz authored Apr 27, 2021
2 parents 9dad1fb + 2fdda57 commit 7810ea9
Show file tree
Hide file tree
Showing 32 changed files with 209 additions and 49 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Changelog

## [v1.12.1]
- Remove counter caches (#5222)
- Delay grouping creation for working-alone timed assessments to when the student starts the assessment (#5224)
- Add option to hide starter files after collection date (#5226)

## [v1.12.0]
- Remove annotations context menu from peer assignments view (#5116)
- Change 'Next' and 'Previous' submission button to use partial reloads (#5082)
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mimemagic (0.3.5)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.14.4)
Expand Down
2 changes: 1 addition & 1 deletion app/MARKUS_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=1.12.0,PATCH_LEVEL=DEV
VERSION=1.12.1,PATCH_LEVEL=DEV
35 changes: 30 additions & 5 deletions app/assets/javascripts/Components/starter_file_manager.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {Fragment} from 'react';
import {render} from "react-dom";
import FileManager from "./markus_file_manager";
import FileUploadModal from "./Modals/file_upload_modal";
Expand All @@ -22,6 +22,7 @@ class StarterFileManager extends React.Component {
files: {},
sections: {},
form_changed: false,
available_after_due: true
}
}

Expand Down Expand Up @@ -121,7 +122,8 @@ class StarterFileManager extends React.Component {
const data = {
assignment: {
starter_file_type: this.state.starterfileType,
default_starter_file_group_id: this.state.defaultStarterFileGroup
default_starter_file_group_id: this.state.defaultStarterFileGroup,
starter_files_after_due: this.state.available_after_due
},
sections: this.state.sections,
starter_file_groups: this.state.files.map((data) => {
Expand Down Expand Up @@ -369,6 +371,27 @@ class StarterFileManager extends React.Component {
return '';
};

renderVisibilityOptions = () => {
return (
<Fragment>
<label>
<input
type={'checkbox'}
checked={this.state.available_after_due}
onChange={() => {
this.setState((prev) => ({available_after_due: !prev.available_after_due}),
() => this.toggleFormChanged(true))
}}
/>
{I18n.t('assignments.starter_file.available_after_due')}
</label>
<div className="inline-help">
<p>{I18n.t('assignments.starter_file.available_after_due_help')}</p>
</div>
</Fragment>
)
};

render() {
return (
<div>
Expand Down Expand Up @@ -405,13 +428,15 @@ class StarterFileManager extends React.Component {
{this.renderStarterFileTypes()}
{this.renderStarterFileAssigner()}
{this.renderStarterFileRenamer()}
{this.renderVisibilityOptions()}
<p>
<button
<input
type={'submit'}
value={I18n.t('save')}
onClick={this.saveStateChanges}
disabled={!this.state.form_changed}
>
{I18n.t('save')}
</button>
</input>
</p>
</fieldset>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class UsersController < MainApiController

# Define default fields to display for index and show methods
DEFAULT_FIELDS = [:id, :user_name, :email, :id_number, :type, :first_name,
:last_name, :grace_credits, :notes_count, :hidden].freeze
:last_name, :grace_credits, :hidden].freeze

# Returns users and their attributes
# Optional: filter, fields
Expand Down
18 changes: 15 additions & 3 deletions app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def show
if @grouping.nil?
if @assignment.scanned_exam
flash_now(:notice, t('assignments.scanned_exam.under_review'))
elsif @assignment.group_max == 1
elsif @assignment.group_max == 1 && (!@assignment.is_timed ||
Time.current > assignment.section_due_date(@current_user&.section))
begin
current_user.create_group_for_working_alone_student(@assignment.id)
rescue StandardError => e
Expand Down Expand Up @@ -403,6 +404,7 @@ def populate_starter_file_manager
'starter_file_groups.name as group_name')
data = { files: file_data,
sections: section_data,
available_after_due: assignment.starter_files_after_due,
starterfileType: assignment.starter_file_type,
defaultStarterFileGroup: assignment.default_starter_file_group&.id || '' }
render json: data
Expand Down Expand Up @@ -478,7 +480,17 @@ def set_boolean_graders_options

# Start timed assignment for the current user's grouping for this assignment
def start_timed_assignment
grouping = current_user.try(:accepted_grouping_for, params[:id])
assignment = Assignment.find(params[:id])
grouping = current_user.accepted_grouping_for(assignment.id)
if grouping.nil? && assignment.group_max == 1
begin
current_user.create_group_for_working_alone_student(assignment.id)
grouping = current_user.accepted_grouping_for(assignment.id)
set_repo_vars(assignment, grouping)
rescue StandardError => e
flash_message(:error, e.message)
end
end
return head 400 if grouping.nil?
authorize! grouping
unless grouping.update(start_time: Time.current)
Expand Down Expand Up @@ -669,7 +681,7 @@ def submission_rule_params
end

def starter_file_assignment_params
params.require(:assignment).permit(:starter_file_type, :default_starter_file_group_id)
params.require(:assignment).permit(:starter_file_type, :default_starter_file_group_id, :starter_files_after_due)
end

def starter_file_group_params
Expand Down
4 changes: 2 additions & 2 deletions app/lib/memory_revision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def path_exists?(path)
# Return all of the files in this repository at the root directory
def files_at_path(path="/", with_attrs: true)
return Hash.new if @files.empty?
return files_at_path_helper(path)
files_at_path_helper(path, false)
end

# Return true if there was files submitted at the desired path for the revision
Expand Down Expand Up @@ -111,7 +111,7 @@ def files_at_path_helper(path = '/', only_changed = false, type = Repository::Re
end
git_path = object.path + '/'
if object.instance_of?(type) && (object.path == path ||
alt_path == path || git_path == path)
alt_path == path || git_path == path)
if !only_changed
object.from_revision = @revision_identifier # set revision number
result[object.name] = object
Expand Down
2 changes: 1 addition & 1 deletion app/models/annotation_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AnnotationText < ApplicationRecord
# AnnotationText is destroyed.
has_many :annotations, dependent: :destroy

belongs_to :annotation_category, optional: true, counter_cache: true
belongs_to :annotation_category, optional: true
validates_associated :annotation_category, on: :create

validates_numericality_of :deduction,
Expand Down
1 change: 0 additions & 1 deletion app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Assessment < ApplicationRecord
validate :short_identifier_unchanged, on: :update
validates_presence_of :description
validates_inclusion_of :is_hidden, in: [true, false]
validates_presence_of :notes_count
validates :short_identifier, format: { with: /\A[a-zA-Z0-9\-_]+\z/,
message: 'short_identifier must only contain alphanumeric, hyphen, or '\
'underscore' }
Expand Down
2 changes: 1 addition & 1 deletion app/models/grouping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Grouping < ApplicationRecord
validates_numericality_of :criteria_coverage_count, greater_than_or_equal_to: 0

# user association/validation
belongs_to :assignment, foreign_key: :assessment_id, counter_cache: true
belongs_to :assignment, foreign_key: :assessment_id
validates_associated :assignment, on: :create

belongs_to :group
Expand Down
4 changes: 2 additions & 2 deletions app/models/note.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Note < ApplicationRecord
belongs_to :noteable, polymorphic: true, counter_cache: true
belongs_to :noteable, polymorphic: true

validates_presence_of :notes_message

belongs_to :user, foreign_key: :creator_id, counter_cache: true
belongs_to :user, foreign_key: :creator_id
validates_associated :user

NOTEABLES = %w(Grouping Student Assignment)
Expand Down
1 change: 1 addition & 0 deletions app/policies/grouping_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def start_timed_assignment?
def download_starter_file?
return false unless user.student?
return false if record.assignment.is_hidden?
return false if !record.assignment.starter_files_after_due && record.past_collection_date?
return true unless record.assignment.is_timed?

!record.start_time.nil? || record.past_collection_date?
Expand Down
2 changes: 1 addition & 1 deletion app/views/assignments/_read.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
</ul>
<% end %>

<% if !peer_review && (!@assignment.is_timed || !@grouping.start_time.nil? || @grouping.past_collection_date?) %>
<% if !peer_review && (!@assignment.is_timed || !@grouping&.start_time.nil? || @grouping&.past_collection_date?) %>
<h3><%= Submission.model_name.human.pluralize %></h3>
<% if @grouping.nil? %>
<p><%= t('submissions.student.no_submission') %></p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/assignments/_timed_due_info.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
duration_string = ["#{parts[:hours]} #{I18n.t('durations.hours', count: parts[:hours])}",
"#{parts[:minutes]} #{I18n.t('durations.minutes', count: parts[:minutes])}"].join(', ') %>
<strong><%= Assignment.human_attribute_name(:duration) %></strong>: <%= duration_string %>
<% unless @grouping.extension.nil? %>
<% unless @grouping&.extension.nil? %>
<% ext_parts = AssignmentProperties.duration_parts(@grouping.extension.time_delta)
extension_string = [
"#{ext_parts[:hours]} #{I18n.t('durations.hours', count: ext_parts[:hours])}",
Expand Down
5 changes: 3 additions & 2 deletions app/views/assignments/_timed_due_message.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
duration_string = ["#{parts[:hours]} #{I18n.t('durations.hours', count: parts[:hours])}",
"#{parts[:minutes]} #{I18n.t('durations.minutes', count: parts[:minutes])}"].join(', ')
%>
<% if grouping.extension.nil? %>
<% if grouping&.extension.nil? %>
<%= I18n.t('assignments.timed.before_start_instructions', duration_string: duration_string) %>
<% else %>
<% ext_parts = AssignmentProperties.duration_parts(grouping.extension.time_delta)
Expand All @@ -31,9 +31,10 @@
duration_string: duration_string, extension_string: extension_string) %>
<% end %>
</p>
<% if !grouping.nil? && allowed_to?(:start_timed_assignment?, grouping) %>
<% if grouping.nil? || allowed_to?(:start_timed_assignment?, grouping) %>
<%= form_with url: start_timed_assignment_assignment_path(assignment.id), method: 'put', local: true do |f| %>
<%= f.submit I18n.t('assignments.timed.start_button'),
disabled: grouping.nil? && assignment.group_max != 1,
data: { confirm: t('assignments.timed.start_confirmation') } %>
<% end %>
<% end %>
Expand Down
5 changes: 3 additions & 2 deletions app/views/assignments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
<% end %>
</p>

<% # Test if the student can form groupings or not
unless @assignment.student_form_groups %>
<% if @assignment.is_timed && @assignment.group_max == 1 %>
<p><%= t('groups.student_interface.create_individual_group_on_start') %></p>
<% elsif !@assignment.student_form_groups %>
<p>
<%= t('groups.student_interface.not_allowed_to_form_group') %>
</p>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/views/assignments/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ en:
scanned_exam:
under_review: This exam is still under review.
starter_file:
available_after_due: Starter files are available to students after the due date has passed
available_after_due_help: For timed assessments, this allows students who do not start the assessment to download starter files after the start window is over.
changed_at: Starter files were last updated on %{changed_date}
changed_warning: The starter files for this assignment have changed. Please download the newest version of the starter files below and update your submission accordingly.
default_starter_file_group: Default Starter File Group
Expand Down
2 changes: 2 additions & 0 deletions config/locales/views/assignments/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ es:
scanned_exam:
under_review: Este examen todavía está en revisión
starter_file:
available_after_due: UPDATE ME
available_after_due_help: UPDATE ME
changed_at: UPDATE ME %{changed_date}
changed_warning: UPDATE ME
default_starter_file_group: UPDATE ME
Expand Down
2 changes: 2 additions & 0 deletions config/locales/views/assignments/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ fr:
scanned_exam:
under_review: Cet examen est marqué
starter_file:
available_after_due: UPDATE ME
available_after_due_help: UPDATE ME
changed_at: UPDATE ME %{changed_date}
changed_warning: UPDATE ME
default_starter_file_group: UPDATE ME
Expand Down
2 changes: 2 additions & 0 deletions config/locales/views/assignments/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pt:
scanned_exam:
under_review: Este exame está sendo marcado
starter_file:
available_after_due: UPDATE ME
available_after_due_help: UPDATE ME
changed_at: UPDATE ME %{changed_date}
changed_warning: UPDATE ME
default_starter_file_group: UPDATE ME
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/groups/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ en:
student_interface:
confirm_create_group: This action will decline your pending invitations. Are you sure?
confirm_delete_group: 'WARNING: You will lose access to your submitted files after deleting your group. Make sure you have a local copy of your files before clicking OK.'
create_individual_group_on_start: Your individual group will be created when you start this assessment.
form_group: Create a group
group_information: Group information
group_options: Group options
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/groups/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ es:
student_interface:
confirm_create_group: Esto rechazará la invitación que se le ha realizado. ¿Está seguro/a de querer rechazar esta invitación?
confirm_delete_group: 'PRECAUCIÓN: Usted perderá acceso a los archivos enviados en su entrega después de eliminar su grupo. Asegúrese de tener una copia local de sus archivos antes de dar click en OK.'
create_individual_group_on_start: UPDATE ME
form_group: Formar su propio grupo
group_information: Información del Grupo
group_options: Opciones del grupo
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/groups/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fr:
student_interface:
confirm_create_group: Êtes-vous sûr de vouloir décliner l'invitation ?
confirm_delete_group: 'AVERTISSEMENT : Vous perdrez l''accès à vos dossiers présentés après la suppression de votre groupe . Assurez-vous que vous avez une copie locale de vos fichiers avant de cliquer sur OK .'
create_individual_group_on_start: UPDATE ME
form_group: Former votre propre groupe
group_information: Informations sur le groupe
group_options: Options du groupe
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/groups/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pt:
student_interface:
confirm_create_group: Isso irá recusar outro convite que você tem. Você tem certeza disso?
confirm_delete_group: 'AVISO: Você vai perder o acesso a seus arquivos submetidos após a exclusão de seu grupo. Verifique se você tem uma cópia local de seus arquivos antes de clicar em OK.'
create_individual_group_on_start: UPDATE ME
form_group: Forme o seu próprio grupo
group_information: Informação do grupo
group_options: Opções de grupo
Expand Down
17 changes: 17 additions & 0 deletions db/migrate/20210422193041_remove_counter_caches.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class RemoveCounterCaches < ActiveRecord::Migration[6.0]
def self.up
remove_column :users, :notes_count
remove_column :groupings, :notes_count
remove_column :assessments, :notes_count
remove_column :assessments, :groupings_count
remove_column :annotation_categories, :annotation_texts_count
end

def self.down
add_column :users, :notes_count, :integer, default: 0
add_column :groupings, :notes_count, :integer, default: 0
add_column :assessments, :notes_count, :integer, default: 0
add_column :assessments, :groupings_count, :integer, default: 0
add_column :annotation_categories, :annotation_texts_count, :integer, default: 0
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class StarterFileAvailableAfterDueToAssignmentProperties < ActiveRecord::Migration[6.0]
def change
add_column :assignment_properties, :starter_files_after_due, :boolean, null: false, default: true
end
end
Loading

0 comments on commit 7810ea9

Please sign in to comment.