class CourseTypes

To change this template, choose Tools | Templates and open the template in the editor.

Public Class Methods

files() click to toggle source
# File Entities/CourseType.rb, line 39
def self.files
  ddir = Courses.dir_diplomas
  Dir.glob(ddir + '/*{odt,odg,ods}').
      collect { |f| f.sub(/^.*\//, '') }
end
listp_name() click to toggle source
# File Entities/CourseType.rb, line 57
def self.listp_name
  self.search_all_.collect { |ct|
    [ct.coursetype_id, ct.name]
  }.sort { |a, b| a[1].downcase <=> b[1].downcase }
end

Public Instance Methods

icc_fetch(arg) click to toggle source
# File Entities/CourseType.rb, line 98
def icc_fetch(arg)
  if ct_names = arg._course_type_names
    ct_names.collect { |ct|
      self.find_by_name(ct) or return "Error: CourseType #{ct} doesn't exist"
    }
  else
    return 'Error: no course_type_name given'
  end
end
icc_file(arg) click to toggle source
# File Entities/CourseType.rb, line 108
def icc_file(arg)
  file = "#{ConfigBase.template_dir}/#{File.basename(arg._name.first)}"
  if File.exists? file
    log_msg :CourseTypes, "Sending file #{file}"
    IO.binread(file)
  else
    log_msg :CourseTypes, "Didn't find #{file.inspect}"
    return "Error: can't find file"
  end
end
icc_list(arg) click to toggle source
# File Entities/CourseType.rb, line 94
def icc_list(arg)
  list_name
end
listp_name() click to toggle source
# File Entities/CourseType.rb, line 53
def listp_name
  CourseTypes.listp_name
end
migration_1(ct) click to toggle source
# File Entities/CourseType.rb, line 63
def migration_1(ct)
  ct.tests = 1
  ct.output = ['certificate']
end
migration_2(ct) click to toggle source
# File Entities/CourseType.rb, line 68
def migration_2(ct)
  ct.diploma_type = ['simple']
end
migration_3(ct) click to toggle source
# File Entities/CourseType.rb, line 72
def migration_3(ct)
  ct.page_format = [0]
end
migration_4(ct) click to toggle source
# File Entities/CourseType.rb, line 76
def migration_4(ct)
  ct.page_format[0] += 1
end
migration_5_raw(ct) click to toggle source

Changed tests to tests_str and files_needed to files_str

# File Entities/CourseType.rb, line 81
def migration_5_raw(ct)
  if (ct._tests_nbr = ct._tests.to_i) > 0
    ct._tests_str = (1..ct._tests_nbr).collect { |t| "Test #{t}" }.join("\n")
  end
  if (ct._files_nbr = ct._files_needed.to_i) > 0
    ct._files_str = (1..ct._files_nbr).collect { |f| "Files #{f}" }.join("\n")
  end
end
migration_6(ct) click to toggle source
# File Entities/CourseType.rb, line 90
def migration_6(ct)
  ct.diploma_lang = ['fr']
end
set_entry(id, field, value) click to toggle source
Calls superclass method
# File Entities/CourseType.rb, line 45
def set_entry(id, field, value)
  case field.to_s
    when 'name'
      value.gsub!(/[^a-zA-Z0-9_-]/, '_')
  end
  super(id, field, value)
end
setup_data() click to toggle source
# File Entities/CourseType.rb, line 5
def setup_data
  value_str :file_diploma
  value_str :file_exam

  value_block :strings
  value_str :name
  value_str :duration

  value_block :long
  value_str :description
  value_text :contents

  value_block :central
  value_list_drop :diploma_type, '%w( simple files accredited report )'
  value_list_drop :output, '%w( certificate label )'
  value_list_drop :diploma_lang, '%w( en fr )'
  value_list_drop :page_format,
                  "[[1,'normal'],[2,'interchanged'],[3,'landscape'],[4,'seascape']]"
  value_list_drop :remark, '%w(false true)'

  value_block :lists
  value_str :tests_str
  value_int :tests_nbr
  value_str :files_str
  value_int :files_nbr

  value_block :accounting
  value_int :salary_teacher
  value_int :cost_student

  value_block :account
  value_entity_account :account_base, :drop, :path
end