source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/controllers/review_mapping_controller.rb | Ruby | mit | 191 | main | 28,916 | class ReviewMappingController < ApplicationController
include AuthorizationHelper
autocomplete :user, :name
# helper :dynamic_review_assignment
helper :submitted_content
# including the following helper to refactor the code in response_report function
# include ReportFormatterHelper
@@time_create_last_r... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/controllers/teams_controller.rb | Ruby | mit | 191 | main | 8,294 | class TeamsController < ApplicationController
include AuthorizationHelper
autocomplete :user, :name
# Check if the current user has TA privileges
def action_allowed?
current_user_has_ta_privileges?
end
# attempt to initialize team type in session
def init_team_type(type)
return unless type && T... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/controllers/roles_controller.rb | Ruby | mit | 191 | main | 1,340 | class RolesController < ApplicationController
include AuthorizationHelper
def action_allowed?
current_user_has_super_admin_privileges?
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify method: :post, only: %i[destroy create update], redirect_to: Role
def index
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/controllers/assignment_questionnaire_controller.rb | Ruby | mit | 191 | main | 2,332 | # Author: Hao Liu
# Email: hliu11@ncsu.edu
class AssignmentQuestionnaireController < ApplicationController
include AuthorizationHelper
# According to Dr. Gehringer, only the instructor, an ancestor of the instructor,
# or the TA for the course should be allowed to execute a method of this controller
def actio... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/controllers/duties_controller.rb | Ruby | mit | 191 | main | 1,923 | # frozen_string_literal: true
class DutiesController < ApplicationController
include AuthorizationHelper
# duties can be created/modified by Teaching Assistants, Instructor, Admin, Super Admin
def action_allowed?
current_user_has_ta_privileges?
end
before_action :set_duty, only: %i[show edit update des... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/controllers/review_bids_controller.rb | Ruby | mit | 191 | main | 5,178 | class ReviewBidsController < ApplicationController
require 'json'
require 'uri'
require 'net/http'
require 'rest_client'
# action allowed function checks the action allowed based on the user working
def action_allowed?
case params[:action]
when 'show', 'set_priority', 'index'
['Instructor',
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/controllers/tree_display_controller.rb | Ruby | mit | 191 | main | 13,149 | class TreeDisplayController < ApplicationController
helper :application
include SecurityHelper
include AuthorizationHelper
# Checks controller permissions
def action_allowed?
true
end
# refactored method to provide direct access to parameters
# added an argument prevTab for sending the respective ... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/review_bids_helper.rb | Ruby | mit | 191 | main | 1,365 | module ReviewBidsHelper
# renders the topic row for the topics table
# in review_bids/show.html.erb
def get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)
row_html = ''
if selected_topics.present?
selected_topics.each do |selected_topic|
row_html = if (selected_t... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/assignment_helper.rb | Ruby | mit | 191 | main | 4,123 | module AssignmentHelper
def course_options(instructor = nil)
courses = []
if session[:user].role.name == 'Teaching Assistant'
ta = Ta.find(session[:user].id)
ta.ta_mappings.each { |mapping| courses << Course.find(mapping.course_id) }
# If a TA created some courses before, s/he can still add ... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/answer_helper.rb | Ruby | mit | 191 | main | 4,612 | # E1924 Spring 2019 Addition
module AnswerHelper
# Delete responses for given questionnaire
def self.delete_existing_responses(question_ids, questionnaire_id)
# For each of the question's answers, log the response_id if in active period
response_ids = log_answer_responses(question_ids, questionnaire_id)
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/summary_helper.rb | Ruby | mit | 191 | main | 5,090 | # require for webservice calls
require 'json'
require 'rest_client'
require 'logger'
# required by autosummary
module SummaryHelper
class Summary
attr_accessor :summary, :reviewers, :avg_scores_by_reviewee, :avg_scores_by_round, :avg_scores_by_criterion, :summary_ws_url
def summarize_reviews_by_reviewee(que... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/import_topics_helper.rb | Ruby | mit | 191 | main | 1,623 | require 'csv'
module ImportTopicsHelper
def self.define_attributes(row_hash)
attributes = {}
attributes['topic_identifier'] = row_hash[:topic_identifier].strip
attributes['topic_name'] = row_hash[:topic_name].strip
attributes['max_choosers'] = row_hash[:max_choosers].strip
attributes['category'] ... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/manage_team_helper.rb | Ruby | mit | 191 | main | 1,142 | # This helper contains all functions associated with team management.
# These include creating a new team, adding a new member to a team etc
# This helper is used by both sign_up_sheet controller and signup controller
module ManageTeamHelper
# Adds a user specified by 'user' object to a team specified by 'team_id'
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/grades_helper.rb | Ruby | mit | 191 | main | 7,963 | module GradesHelper
include PenaltyHelper
# Render the title
def accordion_title(last_topic, new_topic)
if last_topic.nil?
# this is the first accordion
render partial: 'response/accordion', locals: { title: new_topic, is_first: true }
elsif !new_topic.eql? last_topic
# render new accord... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/sign_up_sheet_helper.rb | Ruby | mit | 191 | main | 4,449 | module SignUpSheetHelper
# if the instructor does not specific the topic due date, it should be the same as assignment due date;
# otherwise, it should display the topic due date.
def check_topic_due_date_value(assignment_due_dates, topic_id, deadline_type_id = 1, review_round = 1)
due_date = get_topic_deadli... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/question_helper.rb | Ruby | mit | 191 | main | 789 | module QuestionHelper
# Maps type to question
QUESTION_MAP = {
'Criterion' => Criterion,
'Scale' => Scale,
'Cake' => Cake,
'Dropdown' => Dropdown,
'Checkbox' => Checkbox,
'TextArea' => TextArea,
'TextField' => TextField,
'UploadFile' => UploadFile,
'SectionHeader' => SectionHead... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/authorization_helper.rb | Ruby | mit | 191 | main | 8,202 | module AuthorizationHelper
# Notes:
# We use session directly instead of current_role_name and the like
# Because helpers do not seem to have access to the methods defined in app/controllers/application_controller.rb
# PUBLIC METHODS
# Determine if the currently logged-in user has the privileges of a Super-... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/conference_helper.rb | Ruby | mit | 191 | main | 5,423 | module ConferenceHelper
def is_valid_conference_assignment?
# if assignment id is present in url the check if it's a valid conference assignment.
unless params[:assignment_id].nil?
@assignment = Assignment.find_by_id(params[:assignment_id])
if !@assignment.nil? && @assignment.is_conference_assignm... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/access_helper.rb | Ruby | mit | 191 | main | 1,672 | module AccessHelper
def authorize
unless all_actions_allowed?
flash_msg
redirect_back fallback_location: root_path
end
end
def flash_msg
flash[:error] = if current_role && current_role.name.try(:downcase).start_with?('a', 'e', 'i', 'o', 'u')
if params[:action] == 'ne... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/application_helper.rb | Ruby | mit | 191 | main | 738 | # Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def available?(user, owner_id)
user.id == owner_id ||
user.admin? ||
user.super_admin?
end
# Make a new user of the same class
def self.get_user_role(l_user)
eval "#{l_user.role.na... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/mailer_helper.rb | Ruby | mit | 191 | main | 1,896 | # frozen_string_literal: true
module MailerHelper
def self.send_mail_to_user(user, subject, partial_name, password)
Mailer.generic_message(
to: user.email,
subject: subject,
body: {
user: user,
password: password,
first_name: ApplicationHelper.get_user_first_name(user),
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/security_helper.rb | Ruby | mit | 191 | main | 671 | module SecurityHelper
def special_chars
special = '/\\?<>|&$#'
special
end
def contains_special_chars?(str)
special = special_chars
regex = /[#{special.gsub(/./) { |char| "\\#{char}" }}]/
!(str =~ regex).nil?
end
def warn_for_special_chars(str, field_name)
if contains_special_chars?... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/penalty_helper.rb | Ruby | mit | 191 | main | 4,562 | module PenaltyHelper
def calculate_penalty(participant_id)
@submission_deadline_type_id = 1
@review_deadline_type_id = 2
@meta_review_deadline_type_id = 5
@participant = AssignmentParticipant.find(participant_id)
@assignment = @participant.assignment
if @assignment.late_policy_id
late_po... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/auth_helper.rb | Ruby | mit | 191 | main | 246 | module AuthHelper
def self.get_home_action(user)
user.role.get_home_action
rescue StandardError
'drill'
end
def self.get_home_controller(user)
user.role.get_home_controller
rescue StandardError
'tree_display'
end
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/join_team_requests_helper.rb | Ruby | mit | 191 | main | 531 | module JoinTeamRequestsHelper
def display_request_status(join_team_request)
status = case join_team_request.status
when 'P'
'Pending: A request has been made to join this team.'
when 'D'
'Denied: The team has denied your request.'
when 'A'
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/survey_deployment_helper.rb | Ruby | mit | 191 | main | 1,156 | module SurveyDeploymentHelper
# Returns an array containing the number of responses for a question in a survey deployment
def get_responses_for_question_in_a_survey_deployment(q_id, sd_id)
question = Question.find(q_id)
responses = []
type_of_response_map = %w[AssignmentSurveyResponseMap CourseSurveyRes... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/charts_helper.rb | Ruby | mit | 191 | main | 2,340 | module ChartsHelper
# labels: array of labels
# values: array of values
def self.get_pie_chart_url(labels, values)
return '' if labels.length != values.length
address = 'http://chart.apis.google.com/chart?cht=p3&chs=300x125'
max = 100.0
values.each do |value|
max = value if value.to_f > ma... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/string_operation_helper.rb | Ruby | mit | 191 | main | 534 | module StringOperationHelper
def string_similarity(str1, str2)
# Perform bigram comparison between two strings and return a percentage match in decimal form
pairs1 = get_ngrams(str1, 3)
pairs2 = get_ngrams(str2, 3)
(2.0 * (pairs1 & pairs2).size / (pairs1.size + pairs2.size))
end
private
def g... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/submitted_content_helper.rb | Ruby | mit | 191 | main | 5,160 | module SubmittedContentHelper
def display_directory_tree(participant, files, display_to_reviewer_flag)
index = 0
participant = @participant if @participant
assignment = participant.assignment # participant is @map.contributor
topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id)... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/participants_helper.rb | Ruby | mit | 191 | main | 3,955 | module ParticipantsHelper
# separates the file into the necessary elements to create a new user
def self.upload_users(filename, session, params, home_page)
users = []
File.open(filename, 'r') do |infile|
while (rline = infile.gets)
config = get_config
attributes = define_attributes(rli... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/student_task_helper.rb | Ruby | mit | 191 | main | 1,620 | module StudentTaskHelper
def get_review_grade_info(participant)
if participant.try(:review_grade).try(:grade_for_reviewer).nil? ||
participant.try(:review_grade).try(:comment_for_reviewer).nil?
result = 'N/A'
else
info = 'Score: ' + participant.try(:review_grade).try(:grade_for_reviewer).to... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/file_helper.rb | Ruby | mit | 191 | main | 1,946 | module FileHelper
def self.sanitize_filename(file_name)
just_filename = File.basename(file_name)
FileHelper.clean_path(just_filename)
end
def self.move_file(oldloc, newloc)
items = newloc.split(%r{/})
filename = items[items.length - 1]
items.delete_at(items.length - 1)
newdir = ''
it... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/response_helper.rb | Ruby | mit | 191 | main | 2,681 | module ResponseHelper
# E2218: this module contains methods that are used in response_controller class
# E-1973 - helper method to check if the current user is the reviewer
# if the reviewer is an assignment team, we have to check if the current user is on the team
def current_user_is_reviewer?(map, _reviewer_... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/deadline_helper.rb | Ruby | mit | 191 | main | 1,443 | # This helper contains methods to manipulate due dates of topics in an assignment. This helper if used by
# sign_up_controller
module DeadlineHelper
DEADLINE_TYPE_SUBMISSION = 1
DEADLINE_TYPE_REVIEW = 2
DEADLINE_TYPE_METAREVIEW = 5
DEADLINE_TYPE_DROP_TOPIC = 6
DEADLINE_TYPE_SIGN_UP = 7
DEADLINE_TYPE_TEAM_FO... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/import_file_helper.rb | Ruby | mit | 191 | main | 1,023 | require 'csv'
module ImportFileHelper
def self.define_attributes(row_hash)
attributes = {}
attributes['role_id'] = Role.student.id
attributes['name'] = row_hash[:username]
attributes['fullname'] = row_hash[:fullname]
attributes['email'] = row_hash[:email]
attributes['email_on_submission'] = 1... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/report_formatter_helper.rb | Ruby | mit | 191 | main | 4,809 | module ReportFormatterHelper
include Scoring
def review_response_map(params, _session = nil)
assign_basics(params)
@review_user = params[:user]
# If review response is required call review_response_report method in review_response_map model
@reviewers = ReviewResponseMap.review_response_report(@id,... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/review_mapping_helper.rb | Ruby | mit | 191 | main | 18,055 | module ReviewMappingHelper
def create_report_table_header(headers = {})
render partial: 'report_table_header', locals: { headers: headers }
end
#
# gets the response map data such as reviewer id, reviewed object id and type for the review report
#
def get_data_for_review_report(reviewed_object_id, revi... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/questionnaire_helper.rb | Ruby | mit | 191 | main | 2,348 | # OSS808 Change 28/10/2013
# FasterCSV replaced now by CSV which is present by default in Ruby
# require 'fastercsv'
# require 'csv'
module QuestionnaireHelper
CSV_QUESTION = 0
CSV_TYPE = 1
CSV_PARAM = 2
CSV_WEIGHT = 3
def self.adjust_advice_size(questionnaire, question)
# now we only support question a... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/helpers/plagiarism_checker_helper.rb | Ruby | mit | 191 | main | 4,858 | module PlagiarismCheckerHelper
require 'simicheck_webservice'
require 'submission_content_fetcher'
# PlagiarismCheckerHelper acts as the integration point between all services and models
# related to PlagiarismChecker
def self.run(assignment_id)
assignment = Assignment.find(assignment_id)
teams = Te... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/invitation.rb | Ruby | mit | 191 | main | 3,996 | class Invitation < ApplicationRecord
# belongs_to :to_user, class_name: "User", foreign_key: "to_id"
belongs_to :to_user, class_name: 'User', foreign_key: 'to_id', inverse_of: false
# belongs_to :from_user, class_name: "User", foreign_key: "from_id"
belongs_to :from_user, class_name: 'User', foreign_key: 'from_... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/scale.rb | Ruby | mit | 191 | main | 4,255 | class Scale < ScoredQuestion
# This method returns what to display if an instructor (etc.) is creating or editing a questionnaire (questionnaires_controller.rb)
def edit(_count)
html = '<tr>'
html += '<td align="center"><a rel="nofollow" data-method="delete" href="/questions/' + id.to_s + '">Remove</a></td>... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/answer_tag.rb | Ruby | mit | 191 | main | 615 | class AnswerTag < ApplicationRecord
belongs_to :answer
belongs_to :tag_prompts_deployment
validates :answer_id, presence: true
validates :tag_prompt_deployment_id, presence: true
validates :value, presence: true
validates :user_id, presence: true
def tag_prompt
tag_dep = TagPromptDeployment.find(tag... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/cake.rb | Ruby | mit | 191 | main | 6,928 | class Cake < ScoredQuestion
include ActionView::Helpers
validates :size, presence: true
# method is called during creation of questionnaire --> when cake type is added to the questionnaire.
def edit(_count)
html = '<td align="center"><a rel="nofollow" data-method="delete" href="/questions/' + id.to_s + '">R... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/question.rb | Ruby | mit | 191 | main | 4,858 | class Question < ApplicationRecord
belongs_to :questionnaire # each question belongs to a specific questionnaire
belongs_to :review_of_review_score # ditto
has_many :question_advices, dependent: :destroy # for each question, there is separate advice about each possible score
has_many :signup_choices # ?? this m... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/assignment_team.rb | Ruby | mit | 191 | main | 9,657 | class AssignmentTeam < Team
require File.dirname(__FILE__) + '/analytic/assignment_team_analytic'
include AssignmentTeamAnalytic
include Scoring
belongs_to :assignment, class_name: 'Assignment', foreign_key: 'parent_id'
has_many :review_mappings, class_name: 'ReviewResponseMap', foreign_key: 'reviewee_id'
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/teams_user.rb | Ruby | mit | 191 | main | 2,438 | class TeamsUser < ApplicationRecord
belongs_to :user
belongs_to :team
has_one :team_user_node, foreign_key: 'node_object_id', dependent: :destroy
has_paper_trail
# attr_accessible :user_id, :team_id # unnecessary protected attributes
def name(ip_address = nil)
name = user.name(ip_address)
# E2115 ... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/bid.rb | Ruby | mit | 191 | main | 2,406 | class Bid < ApplicationRecord
belongs_to :topic, class_name: 'SignUpTopic'
belongs_to :team
# Create new bids for team based on `ranks` variable for each team member
# Structure of users_bidding_info variable:
# [[topic_1_priority, topic_2_priority, ...], [topic_1_priority, topic_2_priority, ...], ...]
# C... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/site_controller.rb | Ruby | mit | 191 | main | 726 | class SiteController < ApplicationRecord
has_many :controller_actions
belongs_to :permission
validates :name, presence: true
validates :name, uniqueness: true
scope :builtin, -> { where(builtin: 1).order(:name) }
scope :application, -> { where('builtin is null or builtin = 0').order(:name) }
def action... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/dropdown.rb | Ruby | mit | 191 | main | 2,576 | class Dropdown < UnscoredQuestion
include ActionView::Helpers
validates :alternatives, presence: true
def edit(_count)
html = '<td align="center"><a rel="nofollow" data-method="delete" href="/questions/' + id.to_s + '">Remove</a></td>'
html += '<td><input size="6" value="' + seq.to_s
html += '" name... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/team_user_node.rb | Ruby | mit | 191 | main | 608 | class TeamUserNode < Node
belongs_to :node_object, class_name: 'TeamsUser'
# attr_accessible :parent_id, :node_object_id # unnecessary protected attributes
def self.table
'teams_users'
end
def get_name(ip_address = nil)
TeamsUser.find(node_object_id).name(ip_address)
end
def self.get(parent_id... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/questionnaire_node.rb | Ruby | mit | 191 | main | 2,229 | class QuestionnaireNode < Node
belongs_to :questionnaire, class_name: 'Questionnaire', foreign_key: 'node_object_id', inverse_of: false
belongs_to :node_object, class_name: 'Questionnaire', foreign_key: 'node_object_id', inverse_of: false
def self.table
'questionnaires'
end
def self.get(sortvar = nil, s... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/institution.rb | Ruby | mit | 191 | main | 220 | class Institution < ApplicationRecord
# attr_accessible :name
has_many :courses, dependent: :destroy, foreign_key: 'institutions_id'
validates :name, length: { minimum: 1 }
validates :name, uniqueness: true
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/assignment_survey_deployment.rb | Ruby | mit | 191 | main | 260 | class AssignmentSurveyDeployment < SurveyDeployment
belongs_to :assignment, class_name: 'Assignment', foreign_key: 'parent_id'
def parent_name
assignment.name
end
def response_maps
AssignmentSurveyResponseMap.where(reviewee_id: id)
end
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/deadline_type.rb | Ruby | mit | 191 | main | 231 | class DeadlineType < ApplicationRecord
has_many :assignment_due_dates, class_name: 'AssignmentDueDate', foreign_key: 'deadline_type_id'
has_many :topic_due_dates, class_name: 'TopicDueDate', foreign_key: 'deadline_type_id'
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/multiple_choice_radio.rb | Ruby | mit | 191 | main | 3,300 | class MultipleChoiceRadio < QuizQuestion
def edit
quiz_question_choices = QuizQuestionChoice.where(question_id: id)
html = '<tr><td>'
html += '<textarea cols="100" name="question[' + id.to_s + '][txt]" '
html += 'id="question_' + id.to_s + '_txt">' + txt + '</textarea>'
html += '</td></tr>'
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/teammate_review_questionnaire.rb | Ruby | mit | 191 | main | 378 | class TeammateReviewQuestionnaire < Questionnaire
after_initialize :post_initialization
@print_name = 'Team Review Rubric'
class << self
attr_reader :print_name
end
def post_initialization
self.display_type = 'Teammate Review'
end
def symbol
'teammate'.to_sym
end
def get_assessments_fo... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/tag_prompt_deployment.rb | Ruby | mit | 191 | main | 3,372 | class TagPromptDeployment < ApplicationRecord
belongs_to :tag_prompt
belongs_to :assignment
belongs_to :questionnaire
has_many :answer_tags, dependent: :destroy
require 'time'
def tag_prompt
TagPrompt.find(tag_prompt_id)
end
def get_number_of_taggable_answers(user_id)
team = Team.joins(:teams... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/survey_response_map.rb | Ruby | mit | 191 | main | 728 | # this class has 2 sub-classes: CourseSurveyResponseMap and AssignmentSurveyResponseMap
# The reviewed_object id is either assignment or course id;
# The reviewer_id is either assignment participant id or course participant id;
# The reviewee_id is survey_deployment id.
# (if global survey is required, the reviewee_id ... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/mentored_team.rb | Ruby | mit | 191 | main | 1,394 | class MentoredTeam < AssignmentTeam
# Class created during refactoring of E2351
# Overridden method to include the MentorManagement workflow
def add_member(user, _assignment_id = nil)
raise "The user #{user.name} is already a member of the team #{name}" if user?(user)
can_add_member = f... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/score_view.rb | Ruby | mit | 191 | main | 570 | class ScoreView < ApplicationRecord
# setting this to false so that factories can be created
# to test the grading of weighted quiz questionnaires
def readonly?
false
end
def self.questionnaire_data(questionnaire_id, response_id)
questionnaire_data = ScoreView.find_by_sql ["SELECT q1_max_question_sco... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/response_map.rb | Ruby | mit | 191 | main | 3,433 | class ResponseMap < ApplicationRecord
extend Scoring
has_many :response, foreign_key: 'map_id', dependent: :destroy, inverse_of: false
belongs_to :reviewer, class_name: 'Participant', foreign_key: 'reviewer_id', inverse_of: false
belongs_to :assignment, class_name: 'Assignment', foreign_key: 'reviewed_object_id... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/track_notification.rb | Ruby | mit | 191 | main | 210 | class TrackNotification < ApplicationRecord
# attr_accessible :notification
validates :notification_id, presence: true
validates :user_id, presence: true
belongs_to :notification
belongs_to :user
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/assignment_due_date.rb | Ruby | mit | 191 | main | 204 | class AssignmentDueDate < DueDate
belongs_to :assignment, class_name: 'Assignment', foreign_key: 'parent_id'
belongs_to :deadline_type, class_name: 'DeadlineType', foreign_key: 'deadline_type_id'
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/text_response.rb | Ruby | mit | 191 | main | 1,588 | class TextResponse < Question
validates :size, presence: true
# This method returns what to display if an instructor (etc.) is creating or editing a questionnaire (questionnaires_controller.rb)
def edit(_count)
html = '<tr>'
html += '<td align="center"><a rel="nofollow" data-method="delete" href="/questi... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/tag_prompt.rb | Ruby | mit | 191 | main | 3,106 | class TagPrompt < ApplicationRecord
validates :prompt, presence: true
validates :desc, presence: true
validates :control_type, presence: true
def html_control(tag_prompt_deployment, answer, user_id)
html = ''
unless answer.nil?
stored_tags = AnswerTag.where(tag_prompt_deployment_id: tag_prompt_de... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/sign_up_topic.rb | Ruby | mit | 191 | main | 10,399 | class SignUpTopic < ApplicationRecord
has_many :signed_up_teams, foreign_key: 'topic_id', dependent: :destroy
has_many :teams, through: :signed_up_teams # list all teams choose this topic, no matter in waitlist or not
has_many :due_dates, class_name: 'TopicDueDate', foreign_key: 'parent_id', dependent: :destroy
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/plagiarism_checker_comparison.rb | Ruby | mit | 191 | main | 555 | class PlagiarismCheckerComparison < ApplicationRecord
# attr_accessible :similarity_link, :similarity_percentage, :file1_name, :file1_team, :file2_name, :file2_team
belongs_to :plagiarism_checker_assignment_submission
# t.string :similarity_link
# t.decimal :similarity_percentage
validates :similarity_perce... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/role.rb | Ruby | mit | 191 | main | 3,376 | require 'credentials'
require 'menu'
class Role < ApplicationRecord
belongs_to :parent, class_name: 'Role', inverse_of: false
has_many :users, inverse_of: false, dependent: :nullify
serialize :cache
validates :name, presence: true
validates :name, uniqueness: true
# rubocop:disable Lint/DuplicateMethods
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/true_false.rb | Ruby | mit | 191 | main | 2,930 | class TrueFalse < QuizQuestion
def edit
quiz_question_choices = QuizQuestionChoice.where(question_id: id)
html = '<tr><td>'
html += '<textarea cols="100" name="question[' + id.to_s + '][txt]" '
html += 'id="question_' + id.to_s + '_txt">' + txt + '</textarea>'
html += '</td></tr>'
html += '<... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/controller_action.rb | Ruby | mit | 191 | main | 2,179 | class ControllerAction < ApplicationRecord
belongs_to :site_controller
belongs_to :permission
validates :name, presence: true
validates :name, uniqueness: { scope: 'site_controller_id' }
# rubocop:disable Lint/DuplicateMethods
attr_accessor :controller, :permission, :url, :allowed, :specific_name
scope... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/permission.rb | Ruby | mit | 191 | main | 238 | class Permission < ApplicationRecord
# attr_accessible :name
validates :name, presence: true
validates :name, uniqueness: true
has_many :content_pages, dependent: :nullify
has_many :controller_actions, dependent: :nullify
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/http_request.rb | Ruby | mit | 191 | main | 968 | class HttpRequest
require 'net/http'
class << self
# IP addresses and local URLs will not match, must include http(s)
def valid_url?(url)
/^#{URI::DEFAULT_PARSER.make_regexp}$/.match(url)
end
def get(url, limit = 5)
return '' if limit <= 0
uri = URI.parse(url)
req = Net::H... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/quiz_questionnaire.rb | Ruby | mit | 191 | main | 915 | class QuizQuestionnaire < Questionnaire
attr_accessor :questionnaire
after_initialize :post_initialization
def post_initialization
self.display_type = 'Quiz'
end
def symbol
'quiz'.to_sym
end
def get_assessments_for(participant)
participant.quizzes_taken
end
def get_weighted_score(scores... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/logger_message.rb | Ruby | mit | 191 | main | 286 | class LoggerMessage
attr_reader :generator, :unity_id, :message, :oip, :req_id
def initialize(generator, unity_id, message, req = nil)
@generator = generator
@unity_id = unity_id
@message = message
@oip = req.remote_ip if req
@req_id = req.uuid if req
end
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/menu_item.rb | Ruby | mit | 191 | main | 2,462 | class MenuItem < ApplicationRecord
attr_accessor :controller_action, :content_page
validates :name, presence: true
validates :name, uniqueness: true
def self.find_or_create_by_name(params)
MenuItem.find_or_create_by(name: params)
end
def delete
children = MenuItem.where('parent_id = ?', id)
c... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/instructor.rb | Ruby | mit | 191 | main | 1,836 | class Instructor < User
# has_many :questionnaires
has_many :questionnaires, dependent: :nullify
QUESTIONNAIRE = [['My questionnaires', 'list_mine'],
['All public questionnaires', 'list_all']].freeze
SIGNUPSHEET = [['My signups', 'list_mine'],
['All public signups', 'list_a... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/submission_record.rb | Ruby | mit | 191 | main | 237 | class SubmissionRecord < ApplicationRecord
validates :content, presence: true
validates :operation, presence: true
validates :team_id, presence: true
validates :user, presence: true
validates :assignment_id, presence: true
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/course_node.rb | Ruby | mit | 191 | main | 3,675 | class CourseNode < Node
belongs_to :course, class_name: 'Course', foreign_key: 'node_object_id'
belongs_to :node_object, class_name: 'Course', foreign_key: 'node_object_id'
# Creates a new courese node from the given course
def self.create_course_node(course)
parent_id = CourseNode.get_parent_id
@cours... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/google_doc_fetcher.rb | Ruby | mit | 191 | main | 1,221 | class GoogleDocFetcher
require 'http_request'
class << self
def supports_url?(url)
lower_case_url = url.downcase
allowed_hosts = ["drive.google.com", "docs.google.com"]
allowed_hosts.each do |allowed_host|
if (HttpRequest.valid_url?(url) && lower_case_url.include?(allowed_host))
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/text_area.rb | Ruby | mit | 191 | main | 925 | class TextArea < TextResponse
def complete(count, answer = nil)
if size.nil?
cols = '70'
rows = '1'
else
cols = size.split(',')[0]
rows = size.split(',')[1]
end
html = '<p><label for="responses_' + count.to_s + '">' + txt + '</label></p>'
html += '<input id="responses_' + c... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/response.rb | Ruby | mit | 191 | main | 15,493 | require 'analytic/response_analytic'
require 'lingua/en/readability'
class Response < ApplicationRecord
# Added for E1973. A team review will have a lock on it so only one user at a time may edit it.
include Lockable
include ResponseAnalytic
include Scoring
belongs_to :response_map, class_name: 'ResponseMap'... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/lock.rb | Ruby | mit | 191 | main | 4,278 | # This class was added to facilitate functionality in E1973:
# http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_Project_E1973._Team_Based_Reviewing
# But was generalized at the behest of Dr. Gehringer.
# The purpose of this model is to help facilitate the locking of edits of models, or more specifically... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/author_feedback_questionnaire.rb | Ruby | mit | 191 | main | 374 | class AuthorFeedbackQuestionnaire < Questionnaire
after_initialize :post_initialization
@print_name = 'Author Feedback Rubric'
class << self
attr_reader :print_name
end
def post_initialization
self.display_type = 'Author Feedback'
end
def symbol
'feedback'.to_sym
end
def get_assessment... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/assignment_questionnaire.rb | Ruby | mit | 191 | main | 1,179 | class AssignmentQuestionnaire < ApplicationRecord
belongs_to :assignment
belongs_to :questionnaire
belongs_to :sign_up_topic
has_paper_trail
scope :retrieve_questionnaire_for_assignment, lambda { |assignment_id|
joins(:questionnaire).where('assignment_questionnaires.assignment_id = ?', assignment_id)
}... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/team.rb | Ruby | mit | 191 | main | 11,855 | class Team < ApplicationRecord
has_many :teams_users, dependent: :destroy
has_many :users, through: :teams_users
has_many :join_team_requests, dependent: :destroy
has_one :team_node, foreign_key: :node_object_id, dependent: :destroy
has_many :signed_up_teams, dependent: :destroy
has_many :bids, dependent: :... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/team_node.rb | Ruby | mit | 191 | main | 714 | class TeamNode < Node
belongs_to :node_object, class_name: 'Team'
# attr_accessible :parent_id, :node_object_id # unnecessary protected attributes
def self.table
'teams'
end
def self.get(parent_id)
nodes = Node.joins('INNER JOIN teams ON nodes.node_object_id = teams.id')
.select('nod... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/course_participant.rb | Ruby | mit | 191 | main | 1,375 | class CourseParticipant < Participant
belongs_to :course, class_name: 'Course', foreign_key: 'parent_id'
# Copy this participant to an assignment
def copy(assignment_id)
part = AssignmentParticipant.where(user_id: user_id, parent_id: assignment_id).first
if part.nil?
part = AssignmentParticipant.cre... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/assignment_form.rb | Ruby | mit | 191 | main | 19,497 | require 'active_support/time_with_zone'
class AssignmentForm
attr_accessor :assignment,
:assignment_questionnaires,
:due_dates,
:tag_prompt_deployments,
:is_conference_assignment,
:auto_assign_mentor
attr_accessor :errors
DEFAULT_M... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/vm_question_response_row.rb | Ruby | mit | 191 | main | 1,286 | # represents each row of a heatgrid-table, which is represented by the vm_question_response class.
class VmQuestionResponseRow
attr_reader :question_seq, :question_text, :question_id, :score_row, :weight
attr_accessor :metric_hash
def initialize(question_text, question_id, weight, question_max_score, seq)
@q... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/questionnaire.rb | Ruby | mit | 191 | main | 5,239 | class Questionnaire < ApplicationRecord
# for doc on why we do it this way,
# see http://blog.hasmanythrough.com/2007/1/15/basic-rails-association-cardinality
has_many :questions, dependent: :destroy # the collection of questions associated with this Questionnaire
belongs_to :instructor # the creator of this qu... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/locale.rb | Ruby | mit | 191 | main | 2,515 | class Locale
attr_reader :code_name, :display_name, :database_encoding
# Initializes a new locale
# == Example
# Locale.new(:en_US, 'English', 1)
#
def initialize(code_name, display_name, database_encoding)
@code_name = code_name
@display_name = display_name
@database_encoding = database_encod... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/website_fetcher.rb | Ruby | mit | 191 | main | 525 | class WebsiteFetcher
require 'http_request'
class << self
def supports_url?(url)
HttpRequest.valid_url?(url)
end
end
def initialize(params)
@url = params['url']
end
def fetch_content
res = HttpRequest.get(@url)
if res.is_a? Net::HTTPSuccess
sanitize(res.body)
else
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/ta_mapping.rb | Ruby | mit | 191 | main | 295 | class TaMapping < ApplicationRecord
belongs_to :course
belongs_to :ta
has_paper_trail
def self.get_course_id(user_id)
TaMapping.find_by(ta_id: user_id).course_id
end
def self.get_courses(user_id)
Course.where('id = ?', TaMapping.find_by(ta_id: user_id).course_id)
end
end |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/review_bid.rb | Ruby | mit | 191 | main | 2,740 | class ReviewBid < ApplicationRecord
belongs_to :topic, class_name: 'SignUpTopic'
belongs_to :participant, class_name: 'Participant'
belongs_to :assignment, class_name: 'Assignment'
# method to get bidding data
# returns the bidding data needed for the assigning algorithm
# student_ids, topic_ids, student_p... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/awarded_badge.rb | Ruby | mit | 191 | main | 488 | class AwardedBadge < ApplicationRecord
belongs_to :badge
belongs_to :participant
def approved?
approval_status == 1
end
# E2218: This method is called when a badge is awarded to a participant
# This method is called from response controller
def award_badge(participant_id, badge_name)
badge_id = ... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/course_team.rb | Ruby | mit | 191 | main | 2,396 | class CourseTeam < Team
belongs_to :course, class_name: 'Course', foreign_key: 'parent_id'
# NOTE: inconsistency in naming of users that's in the team
# currently they are being called: member, participant, user, etc...
# suggestion: refactor all to participant
# Get parent course
def parent_model
... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/expertiza_logger.rb | Ruby | mit | 191 | main | 1,478 | # expertiza_logger.rb
class ExpertizaLogFormatter < Logger::Formatter
# This method is invoked when a log event occurs
def call(s, ts, pg, msg)
if msg.is_a?(LoggerMessage)
"TST=[#{ts}] SVT=[#{s}] PNM=[#{pg}] OIP=[#{msg.oip}] RID=[#{msg.req_id}] CTR=[#{msg.generator}] UID=[#{msg.unity_id}] MSG=[#{filter(ms... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/duty.rb | Ruby | mit | 191 | main | 1,254 | class Duty < ApplicationRecord
belongs_to :assignment
# validates name with format matching regex, length to be at least 3 and
# same name cannot be assigned to multiple duties in particular assignment.
validates :name,
format: { with: /\A[^`!@#\$%\^&*+_=]+\z/,
message: 'Please... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/review_assignment.rb | Ruby | mit | 191 | main | 9,300 | module ReviewAssignment
def contributors
# ACS Contributors are just teams, so removed check to see if it is a team assignment
@contributors ||= teams # ACS
end
# Returns a set of topics that can be reviewed.
# We choose the topics if one of its submissions has received the fewest reviews so far
# re... |
github | expertiza/expertiza | https://github.com/expertiza/expertiza | app/models/mentor_management.rb | Ruby | mit | 191 | main | 5,616 | class MentorManagement
# Select a mentor using the following algorithm
#
# 1) Find all assignment participants for the
# assignment with id [assignment_id] whose
# duty is the same as [Participant#DUTY_MENTOR].
# 2) Count the number of teams those participants
# are a part of, acting as a proxy f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.