Skip to content

Commit

Permalink
Merge bdddd9f into af5f58e
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfranks committed Apr 27, 2024
2 parents af5f58e + bdddd9f commit bfd95f7
Show file tree
Hide file tree
Showing 52 changed files with 1,818 additions and 923 deletions.
68 changes: 12 additions & 56 deletions app/assets/javascripts/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,77 +9,33 @@ function checkForFile() {
});
}

function checkIfUserColumnDuplicate() {

var sel1 = document.getElementById("select1");
var sel2 = document.getElementById("select2");
var sel3 = document.getElementById("select3");

var val1 = sel1.options[sel1.selectedIndex].value;
var val2 = sel2.options[sel2.selectedIndex].value;
var val3 = sel3.options[sel3.selectedIndex].value;

if(val1 == val2 || val2 == val3 || val1 == val3) {
alert("No two columns can have same value.")
} else {
column_form.submit();
}
}

function checkForParticipantColumnDuplicate() {

var sel1 = document.getElementById("select1");
var sel2 = document.getElementById("select2");
var sel3 = document.getElementById("select3");
var sel4 = document.getElementById("select4");

var val1 = sel1.options[sel1.selectedIndex].value;
var val2 = sel2.options[sel2.selectedIndex].value;
var val3 = sel3.options[sel3.selectedIndex].value;
var val4 = sel4.options[sel4.selectedIndex].value;

if(val1 == val2 || val1 == val3 || val1 == val4 || val2 == val3 || val2 == val4 || val3 == val4) {
alert("No two columns can have same value.")
} else {
column_form.submit();
}
}

function checkTopicForDuplicatesAndRequiredColumns(optional_count) {

var sel1 = document.getElementById("select1");
var sel2 = document.getElementById("select2");
var sel3 = document.getElementById("select3");

var val1 = sel1.options[sel1.selectedIndex].value;
var val2 = sel2.options[sel2.selectedIndex].value;
var val3 = sel3.options[sel3.selectedIndex].value;

var val_array = [val1, val2, val3];

for (var i = 0; i < optional_count; i++) {
var sel = document.getElementById("select" + (i + 4).toString());
val_array[i + 3] = sel.options[sel.selectedIndex].value;
}
function checkForDuplicates(field_count) {
var val_array = [];
var i = getElements(field_count, val_array);

var sorted_val_array = val_array.slice().sort();
var has_duplicates = false;

for (var i = 0; i < sorted_val_array.length - 1; i++) {
if (sorted_val_array[i + 1] == sorted_val_array[i]) {
has_duplicates = true;
}
}

if (!val_array.includes('topic_identifier') || !val_array.includes('topic_name') || !val_array.includes('max_choosers')) {
alert("Topic Identifier, Topic Name, and Max Choosers are required columns.");
} else if (has_duplicates) {
if (has_duplicates) {
alert("No two columns can have the same value.");
} else {
column_form.submit();
}
}

function getElements(field_count, val_array) {
for (var i = 1; i <= field_count; i++) {
var sel = document.getElementById("select" + (i).toString());
val_array[i] = sel.options[sel.selectedIndex].value;
}
return i;
}

function checkIfFileExists(filename, flag)
{
if(filename=='')
Expand Down
16 changes: 10 additions & 6 deletions app/controllers/export_file_controller.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
class ExportFileController < ApplicationController
include AuthorizationHelper

TITLES = { 'Assignment' => 'Grades for submission', 'CourseParticipant' => 'Course Participants', 'AssignmentTeam' => 'Assignment Teams',
'CourseTeam' => 'Course Teams', 'User' => 'Users', 'Question' => 'Questions', 'SignUpTopic' => 'Sign Up Topics',
'TagPromptDeployment' => 'TagPromptDeployment'}.freeze
def action_allowed?
current_user_has_ta_privileges?
end

# Assign titles to model for display
def start
@model = params[:model]
titles = { 'Assignment' => 'Grades', 'CourseParticipant' => 'Course Participants', 'AssignmentTeam' => 'Teams',
'CourseTeam' => 'Teams', 'User' => 'Users', 'Question' => 'Questions' }
@title = titles[@model]

@title = TITLES[@model]
@id = params[:id]
end

Expand Down Expand Up @@ -41,7 +43,7 @@ def exportdetails
# the model in the generated CSV file.
csv_data = CSV.generate(col_sep: delimiter) do |csv|
if allowed_models.include? params[:model]
csv << Object.const_get(params[:model]).export_headers(params[:id])
csv << Object.const_get(params[:model]).export_assignment_title(params[:id])
csv << Object.const_get(params[:model]).export_details_fields(params[:details])
Object.const_get(params[:model]).export_details(csv, params[:id], params[:details])
else
Expand All @@ -59,7 +61,7 @@ def exportdetails
def export
@delim_type = params[:delim_type]
filename, delimiter = find_delim_filename(@delim_type, params[:other_char])

title = TITLES[params[:model]].to_s
allowed_models = %w[Assignment
AssignmentParticipant
AssignmentTeam
Expand All @@ -69,7 +71,9 @@ def export
Question
ReviewResponseMap
User
Team]
Team
SignUpTopic
TagPromptDeployment]
csv_data = CSV.generate(col_sep: delimiter) do |csv|
if allowed_models.include? params[:model]
csv << Object.const_get(params[:model]).export_fields(params[:options])
Expand Down
Loading

0 comments on commit bfd95f7

Please sign in to comment.