Module: Kurki

Defined in:
lib/kurki.rb,
lib/kurki/version.rb

Constant Summary collapse

VERSION =
"0.3.3"

Class Method Summary collapse

Class Method Details

.get_course(id) ⇒ Object



21
22
23
24
# File 'lib/kurki.rb', line 21

def self.get_course(id)
  # First because API returns array with one element
  get(url + "courses/#{id}").first
end

.get_coursesObject



13
14
15
# File 'lib/kurki.rb', line 13

def self.get_courses
  get(url + "courses")
end

.get_students(course_id) ⇒ Object



17
18
19
# File 'lib/kurki.rb', line 17

def self.get_students(course_id)
  get(url + "courses/#{course_id}/students")
end

.set_exam_points(course_id, points) ⇒ Object

Exam points in format: { “123123123” => {

"1" => 1,
"2" => 56
}

}



53
54
55
# File 'lib/kurki.rb', line 53

def self.set_exam_points(course_id, points)
  post(url + "courses/#{course_id}/students", parse_exam_points(points))
end

.set_exercise_points(course_id, points) ⇒ Object

Exercise points in format: { “123123123” => {

  "2" => 1,
  "3" => 4
}

}



65
66
67
# File 'lib/kurki.rb', line 65

def self.set_exercise_points(course_id, points)
  post(url + "courses/#{course_id}/students", parse_exercise_points(points))
end

.set_grades(course_id, grades) ⇒ Object

Grades in form “3”, “01243483”: “4”



32
33
34
# File 'lib/kurki.rb', line 32

def self.set_grades(course_id, grades)
  post(url + "courses/#{course_id}/students", parse_grades(grades))
end

.set_grades_from_csv(course_id, file_path, delimiter = ",") ⇒ Object

.csv in two columns, with one header row



37
38
39
40
41
42
43
# File 'lib/kurki.rb', line 37

def self.set_grades_from_csv(course_id, file_path, delimiter=",")
  grades = {}
  read_csv(file_path, delimiter).each do |result|
    grades[result[0]] = result[1]
  end
  set_grades course_id, grades
end

.set_students(course_id, student_ids) ⇒ Object

Student_ids in form [“12345678”, “12345678”]



27
28
29
# File 'lib/kurki.rb', line 27

def self.set_students(course_id, student_ids)
  post(url + "courses/#{course_id}/students", parse_students(student_ids))
end

.urlObject



8
9
10
11
# File 'lib/kurki.rb', line 8

def self.url
  return ENV["KURKI_URL"] if ENV["KURKI_URL"][-1] == "/"
  ENV["KURKI_URL"]+"/"
end