Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def perform
- assign_id=390
- @participants=[]
- Participant.find_each(:conditions => ["parent_id=?", assign_id] ) do |participant|
- @participants.push(participant.id)
- end
- for participant in @participants
- #find the latest submission
- latest_sub_time=ResubmissionTime.find(:first,:limit =>1, :conditions => ["participant_id =? ",participant] ,:order => "resubmitted_at DESC")
- if(latest_sub_time!=nil)
- latest_sub_time=latest_sub_time.resubmitted_at
- end
- #find all ReviewResponsemaps for this participant
- @response_maps=[]
- #if !team assignment
- ParticipantReviewResponseMap.find_each(:conditions => ["reviewee_id = ? ", participant]) do |response_map|
- if(response_map!=nil)
- @response_maps.push(response_map.id);
- end
- end
- #find all responses for this responsemap
- puts @response_maps
- for response_map in @response_maps
- #need to find the latest review..
- @reviews=Response.find(:all, :limit =>1, :conditions => ["map_id = ?", response_map], :order => ["created_at DESC"])
- latest_review_time=@reviews[0].created_at
- #so we need to check if latest response is valid or not..;
- #check if review date > last submission date? if no then invalid;
- #else this one is valid and all others are invalid..;
- if(latest_review_time < latest_sub_time)
- #invalidate this review.
- #reviews[0].update_attribute(:valid, false);
- puts reviews[0].id
- else
- #this review is valid and all other reviews before this are invalid;
- #reviews[0].update_attribute(:valid, true)
- # for all other reviews mark as false or invalid;#TODO
- puts reviews[0].id
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement