Class: StudentProgress::Cohort

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/student_progress/cohort.rb

Instance Method Summary collapse

Instance Method Details

#add_students(usernames) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/student_progress/cohort.rb', line 4

def add_students(usernames)
  usernames.each do |username|
    student = StudentProgress::Student.find_or_create(github_username: username.downcase)
    self.add_student(student)
    student.save
  end
  self.save
end

#delete_and_unassign_studentsObject



28
29
30
31
32
33
34
# File 'lib/student_progress/cohort.rb', line 28

def delete_and_unassign_students
  students.each do |student|
    student.cohort_id = nil
    student.save
  end
  self.delete
end

#remove_students(usernames) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/student_progress/cohort.rb', line 13

def remove_students(usernames)
  removed = 0
  usernames.each do |username|
    student = self.students_dataset.first(github_username: username.downcase)
    if student
      self.remove_student(student)
      removed += 1
    else
      puts "Student with github username: #{username} not found."
    end
  end
  self.save
  removed
end

#run_progress_reportObject



36
37
38
# File 'lib/student_progress/cohort.rb', line 36

def run_progress_report
  StudentProgress::Scraper.scrape_progress(self)
end