Commit bb99390c authored by Taico Aerts's avatar Taico Aerts
Browse files

Merge branch 'development' into 'master'

Project Forum Hotfix Release v2.8.11

See merge request !872
parents 37cab03d 15470cd0
......@@ -345,10 +345,20 @@ class CourseEdition < ApplicationRecord
).uniq
end
# This method returns
# * Users who have specified experiments
# * For one or more experiments of the current round
# * Who have a course participation
# * Which is not rejected
# @return [Array]
def participants_with_current_round_experiment_preference
User.joins(:experiment_preferences).where(
experiment_preferences: {
experiment_project: current_round_experiments
experiment_project: ce.current_round_experiments
}
).joins(:course_participations).where.not(
course_participations: {
status: :rejected
}
).uniq
end
......
......@@ -32,6 +32,10 @@ class ExperimentProject < ApplicationRecord
# Scopes
# ===========================================================================
scope :sort_by_round_and_name, (lambda {
order(arel_table[:round], arel_table[:name].lower)
})
scope :sort_by_priority, (lambda { |user, course_edition|
subquery = ExperimentPreference.where(user: user)
# TODO: The ExperimentPreference should be linked to the course edition, and this query should be updated accordingly as well
......
......@@ -21,7 +21,7 @@ module ExperimentProjectMatcher
experiments = course_edition.current_round_experiments
number_of_experiments_this_round = experiments.size
objective_weights = []
weights = Array.new(number_of_experiments_this_round) { Array.new(number_of_couples) }
weights = Array.new(number_of_couples) { Array.new(number_of_experiments_this_round) }
assignments = []
Rglpk::Problem.create do |p|
......
......@@ -17,7 +17,7 @@
<div class="col-md-12">
<%= render 'admin/course_editions/project_preferences/experiment_results/grouping_details',
couples: couples %>
assignments: assignments %>
</div>
......
......@@ -13,7 +13,7 @@
</td>
</tr>
<tr>
<td><strong><%= couples&.size || 0 %></strong></td>
<td><strong><%= assignments&.size || 0 %></strong></td>
<td>
couples created (including odd ones)
</td>
......
......@@ -13,7 +13,7 @@
<th>Experiment</th>
<th>Priority</th>
</tr>
</th>
</thead>
<tbody>
<% @user.round_course_edition_experiment_preferences(round, edition).order(:priority).each do |preference| %>
......
......@@ -12,7 +12,7 @@
<tr>
<th>Name</th>
</tr>
</th>
</thead>
<tbody>
<% @user.course_edition_student_preferences(edition).each do |preference| %>
......
......@@ -7,8 +7,10 @@
User.unscoped.role_student.sort_by_name, :id, :name,
{ prompt: true, selected: false },
{ class: 'selectize', placeholder: 'All students' } %>
<%= f.collection_select :experiment_project_id,
ExperimentProject.sort_by_name, :id, :name_with_round,
<%= f.grouped_collection_select :experiment_project_id,
CourseEdition.supporting_experiment_projects.relevance_ordered,
->(ce) { ce.experiment_projects.sort_by_round_and_name }, :display_name,
:id, :name_with_round,
{ prompt: true, selected: false },
{ class: 'selectize', placeholder: 'All experiments' } %>
<%= f.submit class: 'btn btn-primary' %>
......
......@@ -70,7 +70,7 @@
controllers: [:experiment_profiles, :experiment_projects, :experiment_preference_dashboard],
items: [
{
name: :experiment,
name: :experiment_project,
url: admin_experiment_projects_path,
fa_icon: :flask,
controllers: [:experiment_projects],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment