Created
March 23, 2009 14:18
-
-
Save wallace/83562 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 diff --git a/app/models/enrollment.rb b/app/models/enrollment.rb | |
2 index 15b88ac..db503c5 100644 | |
3 --- a/app/models/enrollment.rb | |
4 +++ b/app/models/enrollment.rb | |
5 @@ -369,9 +369,14 @@ class Enrollment < ActiveRecord::Base | |
6 unless match_a.nil? | |
7 # we can take the first match, because we ordered by compelted date and then enrolled date | |
8 match = Hash[*course_enrollments_resp.fields.zip(match_a).flatten] | |
9 + | |
10 + | |
11 + completed_on = match["completed_on"].blank? ? "NULL" : "'#{match["completed_on"]}'" | |
12 + started_on = match["started_on"].blank? ? "NULL" : "'#{match["started_on"]}'" | |
13 + score = match["score"].blank? ? "NULL" : match["score"] 14 eca_id = ActiveRecord::Base.connection.insert("insert into enrollment_curriculum_activities | |
15 (account_id, enrollment_id, user_id, curriculum_activity_id, curriculum_id, course_id, course_enrollment_id, started_on, completed_on, status, score, attempts) values 16 - (#{self.account_id}, #{self.id}, #{self.user_id}, #{activity["curriculum_activity_id"]}, #{self.course_id}, #{match["course_enrollment_id"]}, '#{match["started_ on"]}', '#{match["completed_on"]}', '#{match["status"]}', '#{match["score"]}', 1)") 17 + (#{self.account_id}, #{self.id}, #{self.user_id}, #{activity["curriculum_activity_id"]}, #{self.curriculum_id}, #{self.course_id}, #{match["course_enrollment_id "]}, #{started_on}, #{completed_on}, '#{match["status"]}', #{score}, 1)") | |
18 | |
19 # update the activity element | |
20 activity["enrollment_id"] = self.id | |
21 @@ -390,18 +395,22 @@ class Enrollment < ActiveRecord::Base | |
22 unless match_a.nil? | |
23 # we can take the first match, because we ordered by compelted date and then enrolled date | |
24 match = Hash[*course_enrollments_resp.fields.zip(match_a).flatten] 25 + | |
26 + completed_on = match["completed_on"].blank? ? "NULL" : "'#{match["completed_on"]}'" | |
27 + started_on = match["started_on"].blank? ? "NULL" : "'#{match["started_on"]}'" | |
28 + score = match["score"].blank? ? "NULL" : match["score"] | |
29 ActiveRecord::Base.connection.execute("update enrollment_curriculum_activities | |
30 set course_enrollment_id = #{match["course_enrollment_id"]}, | |
31 - started_on = '#{match["started_on"]}', | |
32 - completed_on = '#{match["completed_on"]}', | |
33 + completed_on = #{completed_on}, | |
34 + started_on = #{started_on}, | |
35 status = '#{match["status"]}', | |
36 - score = #{match["score"]}, 37 + score = #{score}, | |
38 attempts = attempts + 1 39 where id = #{activity["enrollment_curriculum_activity_id"]}") | |
40 41 # update the activity element 42 activity.merge!(match.slice("course_enrollment_id", "started_on", "completed_on", "status", "score")) 43 - activity["attempts"] += 1 44 + activity["attempts"] = activity["attempts"].to_i + 1 | |
45 end 46 end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment