SHARE
TWEET

Untitled

a guest Feb 27th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  def perform
  2.     assign_id=390
  3.     @participants=[]
  4.     Participant.find_each(:conditions => ["parent_id=?", assign_id] ) do |participant|
  5.         @participants.push(participant.id)
  6.     end
  7.     for participant in @participants
  8.         #find the latest submission
  9.         latest_sub_time=ResubmissionTime.find(:first,:limit =>1, :conditions => ["participant_id =? ",participant] ,:order => "resubmitted_at DESC")
  10.         if(latest_sub_time!=nil)
  11.             latest_sub_time=latest_sub_time.resubmitted_at
  12.         end
  13.         #find all ReviewResponsemaps for this participant
  14.         @response_maps=[]
  15.         #if !team assignment
  16.         ParticipantReviewResponseMap.find_each(:conditions => ["reviewee_id = ? ", participant]) do |response_map|
  17.             if(response_map!=nil)
  18.                 @response_maps.push(response_map.id);
  19.             end
  20.         end
  21.         #find all responses for this responsemap
  22.         puts @response_maps
  23.         for response_map in @response_maps
  24.             #need to find the latest review..
  25.             @reviews=Response.find(:all, :limit =>1, :conditions => ["map_id = ?", response_map], :order => ["created_at DESC"])
  26.             latest_review_time=@reviews[0].created_at
  27.             #so we need to check if latest response is valid or not..;
  28.             #check if review date > last submission date? if no then invalid;
  29.             #else this one is valid and all others are invalid..;
  30.             if(latest_review_time < latest_sub_time)
  31.                 #invalidate this review.
  32.                 #reviews[0].update_attribute(:valid, false);
  33.                 puts reviews[0].id 
  34.             else
  35.                 #this review is valid and all other reviews before this are invalid;
  36.                 #reviews[0].update_attribute(:valid, true)
  37.                 # for all other reviews mark as false or invalid;#TODO
  38.                 puts reviews[0].id                 
  39.             end                            
  40.         end
  41.        
  42.     end
  43.    end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top