You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func (ks*KolibriService) ImportCourses(db*gorm.DB) error { //add more to this:::
101
101
log.Println("Importing channel and classroom courses from Kolibri")
102
-
varcourses []map[string]interface{}
102
+
varcourses []map[string]interface{}//modified to left join as quizzes only activate when teachers click 'START QUIZ'
103
103
sql:=`SELECT id, name, description, thumbnail, total_resource_count, root_id, 'channel' as course_type FROM content_channelmetadata
104
104
UNION
105
-
SELECT col.id, name, '' as description, '' as thumbnail, lesson.resource_count+exam.resource_count as total_resource_count, col.id as root_id, 'class' as course_type
105
+
SELECT col.id, name, '' as description, '' as thumbnail, lesson.resource_count+COALESCE(exam.resource_count,0) as total_resource_count, col.id as root_id, 'class' as course_type
106
106
FROM kolibriauth_collection col
107
107
inner join (SELECT col.id, count(col.id) as resource_count
108
108
FROM kolibriauth_collection col
109
109
inner join lessons_lesson lesson on col.id = lesson.collection_id
110
110
where kind = 'classroom'
111
111
group by col.id
112
112
) lesson on col.id = lesson.id
113
-
inner join (SELECT exam.collection_id, count(exam.collection_id) as resource_count
113
+
left join (SELECT exam.collection_id, count(exam.collection_id) as resource_count
114
114
FROM kolibriauth_collection col
115
115
inner join exams_exam exam on col.id = exam.collection_id
116
116
where kind = 'classroom'
@@ -124,6 +124,9 @@ func (ks *KolibriService) ImportCourses(db *gorm.DB) error { //add more to this:
124
124
for_, course:=rangecourses {
125
125
id:=course["id"].(string)
126
126
ifdb.Where("provider_platform_id = ? AND external_id = ?", ks.ProviderPlatformID, id).First(&models.Course{}).Error==nil {
0 commit comments