app/controllers/review_mapping_controller.rb
# 7/12/2015 -zhewei
# This method is used for assign submissions to students for peer review.
# This method is different from 'assignment_reviewer_automatically', which is in 'review_mapping_controller'
# and is used for instructor assigning reviewers in instructor-selected assignment.
7/12/2015 -zhewei
This method is used for assign submissions to students for peer review.
This method is different from 'assignment_reviewer_automatically', which is in 'review_mapping_controller'
and is used for instructor assigning reviewers in instructor-selected assignment.
7 / 12 / 2015 - zhewei This method is used for assign submissions to students for peer review . This method is different from ' assignment_reviewer_automatically ' which is in ' review_mapping_controller ' and is used for instructor assigning reviewers in instructor - selected assignment .
def assign_reviewer_dynamically
    assignment = Assignment.find(params[:assignment_id])
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first
    if params[:i_dont_care].nil? && params[:topic_id].nil? && assignment.topics? && assignment.can_choose_topic_to_review?
      flash[:error] = "No topic is selected.  Please go back and select a topic."
    else
      if assignment.topics? 
        topic = if params[:topic_id]
                  SignUpTopic.find(params[:topic_id])
                else
                  assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil
                end
        if topic.nil?
          flash[:error] = "No topics are available to review at this time. Please try later."
        else
          assignment.assign_reviewer_dynamically(reviewer, topic)
        end
      else 
        assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)
        assignment_team = assignment_teams.to_a.sample rescue nil
        if assignment_team.nil?
          flash[:error] = "No artifacts are available to review at this time. Please try later."
        else
          assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)
        end
      end
      end
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id
  end
def assign_reviewer_dynamically assignment = Assignment . find ( params [ :assignment_id ] ) reviewer = AssignmentParticipant . where ( user_id : params [ :reviewer_id ] , parent_id : assignment . id ) . first if params [ :i_dont_care ] . nil? && params [ :topic_id ] . nil? && assignment . topics? && assignment . can_choose_topic_to_review? flash [ :error ] = "No topic is selected.  Please go back and select a topic." else if assignment . topics? topic = if params [ :topic_id ] SignUpTopic . find ( params [ :topic_id ] ) else assignment . candidate_topics_to_review ( reviewer ) . to_a . sample rescue nil end if topic . nil? flash [ :error ] = "No topics are available to review at this time. Please try later." else assignment . assign_reviewer_dynamically ( reviewer , topic ) end else assignment_teams = assignment . candidate_assignment_teams_to_review ( reviewer ) assignment_team = assignment_teams . to_a . sample rescue nil if assignment_team . nil? flash [ :error ] = "No artifacts are available to review at this time. Please try later." else assignment . assign_reviewer_dynamically_no_topic ( reviewer , assignment_team ) end end end redirect_to controller : 'student_review' , action : 'list' , id : reviewer . id end
7/12/2015 -zhewei
This method is used for assign submissions to students for peer review.
7 / 12 / 2015 - zhewei This method is used for assign submissions to students for peer review .
# begin # assignment with topics # assignment without topic -Yang # rescue Exception => e #   flash[:error] = (e.nil?) ? $! : e # end