Class: Studium::DetermineCurricula

Inherits:
Base
  • Object
show all
Defined in:
lib/studium/curricula/determine_curricula/misc.rb,
lib/studium/curricula/determine_curricula/run.rb,
lib/studium/curricula/determine_curricula/help.rb,
lib/studium/curricula/determine_curricula/menu.rb,
lib/studium/curricula/determine_curricula/reset.rb,
lib/studium/curricula/determine_curricula/report.rb,
lib/studium/curricula/determine_curricula/constants.rb,
lib/studium/curricula/determine_curricula/initialize.rb,
lib/studium/curricula/determine_curricula/determine_curricula.rb

Overview

Studium::DetermineCurricula

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect

Constants inherited from Base

Base::ARRAY_HTML_COLOURS_IN_USE, Base::CHECK_FOR_INCORRECT_ENTRIES_IN_THE_QUESTION_ANSWER_FILE_THAT_SHOULD_BE_COMMENTS, Base::COLOURS, Base::COMMON_YEAR_DAYS_IN_MONTH, Base::GRAY, Base::LEFT_PADDING, Base::N_CHARACTERS_PER_LINE, Base::UNICODE_RIGHT_ARROW

Constants included from Colours

Colours::COLOURS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_proper_year_entry_to_this_line, #already_solved_this_lva_number?, #append_what_into, #available_topics_as_short_name, #average_grade, #bachelor_master_or_diploma, #base_dir?, #be_silent, #be_verbose?, #beautiful_url, #change_directory, #cheering_person, #cliner, #colour_for_ects_points, #colourize_percentage, #commandline_arguments_joined, #commandline_arguments_with_hyphens?, #convert_this_array_of_lectures_into_the_full_dataset, #copy, #cpruby, #create_directory, #create_file, #csv_file?, #current_month?, #datum?, #day_month_year, #debug?, #delete_file, #directory_of_the_exam_topics?, #directory_to_my_exam_topics, #directory_to_the_exam_topics?, #disable_colours, #disable_colours_globally, #do_not_be_verbose, #do_not_use_opn, #do_these_curricula_include_both_a_bachelor_and_a_master_curriculum?, #does_this_line_include_a_german_weekday?, #does_this_line_include_a_html_colour?, #e, #ecomment, #editor?, #ee, #enable_colours, #enable_colours_globally, #enable_debug, #encoding?, #english_to_german_weekday, #ensure_main_encoding, #ensure_that_the_log_directory_exists, #eparse, #erev, #esystem, #etomato, #exit_program, #expand_topic, #extract_dd_mm_yyyy, #file_lecture_information?, #file_read_with_proper_encoding, #filter_away_invalid_questions, #find_corresponding_exam_topic, #first_argument?, #first_non_hyphen_argument?, #from_curriculum_id_to_university, #german_date_notation, #german_weekday?, #german_weekdays?, #has_a_bachelor_curriculum?, #has_a_master_curriculum?, #has_this_exam_topic_been_solved?, #has_year_entry?, #hh_mm_ss_dd_mm_yyyy, #horizontal_bar?, #html_log_directory?, #is_a_master_lecture?, #is_a_weekday?, #is_connected_to_the_www?, #is_on_roebe?, #is_prüfungsimmanent?, #is_this_a_valid_html_colour?, #is_this_day_today?, #konsole_support?, #last_file?, #lectures_from_indi1, #lectures_from_indi2, #lectures_from_indi3, #lectures_from_indi4, #lectures_from_the_bachelor_genetik_curriculum, #lectures_from_the_individual_vektor_curricula, #load_yaml_dataset, #move_file, #n_days_difference_from_today_to_this_day, #no_ext_name, #no_file_at, #number_to_month, #obtain, #obtain_lectures_from_this_curriculum, #open_in_editor, #opnn, #path_to_exam_topic?, #read_dataset_from_a_curriculum_file, #read_in_exam_dataset_from_this_file, #read_this_file_with_default_encoding, #readlines_from_this_input_file, #register_sigint, #remove_empty_strings, #remove_escape_sequences, #remove_internal_comments, #remove_leading_comments, #remove_leading_weekday_names_from, #remove_newlines, #remove_tags_from_this_input, #rename_kde_konsole_tab, #rename_konsole_tab?, #replace_all_html_colours_in_this, #replace_bold_token_with_default_colour, #replace_italic_token_with_default_colour, #replace_italic_token_with_this_colour, #replace_regular_numbers_with_unicode_numbers, #replace_underline_token_with_default_colour, #replace_underline_token_with_this_colour, #return_all_bachelor_lectures, #return_all_exams_on_this_day, #return_all_numbers_from, #return_all_registered_curricula, #return_all_steop_lectures, #return_current_year, #return_dataset_for_this_topic, #return_dataset_from_this_curriculum_file, #return_dd_mm_yy_and_time_from, #return_directory_for, #return_ects_points_from_these_lectures, #return_either_grey_or_the_custom_colour_for_answers, #return_either_grey_or_the_custom_colour_for_questions, #return_file_for_this_curriculum, #return_german_name_for_this_english_month, #return_german_weekday_of?, #return_hh_mm_ss_from, #return_hour_from_this, #return_lectures_from_bachelor_vektor_curriculum, #return_lectures_with_at_the_least_one_upcoming_exam, #return_local_path_of_this_pwdstud, #return_lva_number_of_this_lecture, #return_month_fitting_to_this_input, #return_n_days_until_monday, #return_n_days_until_sunday, #return_n_exam_questions_in, #return_n_questions_were_answered_for_this_topic, #return_name_of_the_weekday, #return_name_of_this_curriculum, #return_name_of_this_curriculum_based_on_its_id_number, #return_opnn, #return_passed_courses, #return_pwd, #return_random_curriculum, #return_sanitized_dataset_from_the_file_lecture_information, #return_solved_lectures, #return_steop_lectures, #return_the_remote_homepage_url, #return_this_line_has_n_characters_as_html_colour_tags, #return_title_from_this_curriculum_file, #rev, #right_arrow?, #rinstall2, #roebe_exam_directory?, #ruby_src_dir_at_home?, #runmode?, #sanitize_this_topic, #sanitize_url, #select_lectures_with_this_key, #set_be_quiet, #set_be_verbose, #set_commandline_mode, #set_runmode, #set_this_cd_alias_to, #set_www_mode, #sfancy, #shall_we_make_use_of_unicode_symbols?, #show_todays_date, #simp, #sort_these_lecture_names_by_time, #spacer, #swarn, #this_month_has_n_days?, #total_ects_points_passed, #translate_dd_mm_yyyy_to_weekday, #try_to_require_the_rcfiles, #turn_this_array_into_the_full_dataset, #unicode_blocks_line, #use_colours?, #use_opn?, #vertical_bar?, #web_liner, #weekday?, #weekdays?, #word_wrap, #write_what_into, #www_connection_is_unavailable, #www_mode?, #yaml_dir?

Methods included from Colours

#bold_blue, #bold_red, #bold_yellow, #cadetblue, #chartreuse, crimson, #darkgray, darkgreen, darkseagreen, deepskyblue, #deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #ewarn, #forestgreen, gold, #grey, lightblue, lightgreen, #lightslategray, #lightsteelblue, #mediumorchid, #mediumseagreen, #oldlace, #olivedrab, orange, orangered, #orchid, palevioletred, #papayawhip, rev, royalblue, sdir, #sdir, sfancy, #sfancy, sfile, #sfile, simp, #simp, slateblue, steelblue, #steelblue, #swarn, swarn, #teal, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow

Constructor Details

#initialize(commandline_arguments = ARGV, run_already = true) ⇒ DetermineCurricula

#

initialize

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/studium/curricula/determine_curricula/initialize.rb', line 14

def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  set_commandline_arguments(
    commandline_arguments
  )
  reset
  # ======================================================================= #
  # === Handle blocks
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :do_not_run_yet
    # ===================================================================== #
    when :do_not_run_yet
      run_already = false
    # ===================================================================== #
    # === :do_not_report
    #
    # Use this like so:
    #
    #   x = Studium::DetermineCurricula.new('indi2') { :do_not_report }
    #
    # ===================================================================== #
    when :do_not_report
      @may_we_report = false
    end
  end
  run if run_already
end

Class Method Details

.[](i = '') ⇒ Object

#

Studium::DetermineCurricula[]

#


382
383
384
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 382

def self.[](i = '')
  new(i)
end

Instance Method Details

#add_30_ects_pointsObject

#

add_30_ects_points

This method can be used to add the “Masterarbeit”.

#


246
247
248
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 246

def add_30_ects_points
  @total_ects_points += 30
end

#append_entries_from_this_curriculum(i = :bachelor_vektoren) ⇒ Object

#

append_entries_from_this_curriculum

Input to this method should be a file containing the lectures of the given individual curriculum.

#


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 17

def append_entries_from_this_curriculum(
    i = :bachelor_vektoren
  )
  dataset = ''.dup
  use_these_files = curriculum_location_of(i)
  case i
  # ======================================================================= #
  # === :master_bioinformatics_and_molecular_biotechnology
  # ======================================================================= #
  when :master_bioinformatics_and_molecular_biotechnology,
       :master_informatik_und_molekulare_biologie,
       :indi4
    use_these_files = curriculum_location_of(:master_bioinformatics_and_molecular_biotechnology)
  # ======================================================================= #
  # === :master_dummy
  # ======================================================================= #
  when :master_dummy,
       :mdummy
    use_these_files = curriculum_location_of(:master_dummy_curriculum)
  # ======================================================================= #
  # === :dummy
  # ======================================================================= #
  when :dummy,
       :bachelor_dummy
    use_these_files = curriculum_location_of(:bachelor_dummy_curriculum)
  # ======================================================================= #
  # === :indi3
  # ======================================================================= #
  when :indi3,
       :bachelor_biologische_informatik
    use_these_files = curriculum_location_of(:bachelor_biologische_informatik)
  # ======================================================================= #
  # === :indi2
  # ======================================================================= #
  when :indi2,
       :bachelor_bioinformatik_und_biotechnologie
    use_these_files = curriculum_location_of(:bachelor_bioinformatik_und_biotechnologie)
  # ======================================================================= #
  # === :bachelor_master_vektoren
  # ======================================================================= #
  when :bachelor_master_vektoren
    if @show_only_master_curricula
      use_these_files = curriculum_location_of(:master_vektoren)
    elsif @show_only_bachelor_curricula
      use_these_files = curriculum_location_of(:bachelor_vektoren)
    else
      use_these_files = [
        curriculum_location_of(:bachelor_vektoren),
        curriculum_location_of(:master_vektoren)
      ]
    end
  end
  unless use_these_files.is_a? Array # Ensure that we work on an Array.
    use_these_files = [use_these_files]
  end
  use_these_files.flatten!
  notify_the_user_that_these_files_will_be_used(use_these_files)
  # ======================================================================= #
  # Now that we have notified the user which files will be used,
  # we can read in these files.
  # ======================================================================= #
  use_these_files.each {|this_file|
    content_from_this_file = read_this_file(this_file)
    set_title_from_this_file(content_from_this_file)
    dataset << content_from_this_file
  }
  # ======================================================================= #
  # Next, get rid of all lines that start with '#' or that are completely
  # empty. We will apply .strip prior to checking for '#' because there
  # may also be entries such as '             # === STEOP END'.
  # ======================================================================= #
  dataset = dataset.split(N).reject {|line|
    line.strip.empty? or line.strip.start_with? '#'
  }
  dataset.map! {|line|
    if line.include? '#'
      line = line[0 .. (line.index('#') - 1)]
    end
    line.strip!
    line.squeeze(' ')
  }
  @dataset = dataset
end

#bachelor?Boolean

#

bachelor?

#

Returns:

  • (Boolean)


137
138
139
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 137

def bachelor?
  @show_only_bachelor_curricula
end

#colourize_this_file_with_two_colours(i) ⇒ Object

#

colourize_this_file_with_two_colours

#


104
105
106
107
108
109
110
111
112
113
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 104

def colourize_this_file_with_two_colours(i)
  if i.include? '/'
    i = sfile(i)
    splitted = i.split('/')
    last_part = splitted.last
    splitted[-1] = paleturquoise(last_part)
    i = splitted.join('/')
  end
  i
end

#commandline_arguments?Boolean Also known as: input?

#

commandline_arguments?

#

Returns:

  • (Boolean)


177
178
179
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 177

def commandline_arguments?
  @commandline_arguments
end

#consider_using_a_default_curriculum_if_no_other_instructions_were_issuedObject

#

consider_using_a_default_curriculum_if_no_other_instructions_were_issued

This method ensures that we can work on a default curriculum, if no other dataset has been provided.

#


194
195
196
197
198
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 194

def consider_using_a_default_curriculum_if_no_other_instructions_were_issued
  append_entries_from_this_curriculum(
    :bachelor_master_vektoren
  ) if @dataset.nil?
end

#dataset_from_file_lecture_information?Boolean

#

dataset_from_file_lecture_information?

#

Returns:

  • (Boolean)


158
159
160
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 158

def dataset_from_file_lecture_information?
  @dataset_from_file_lecture_information
end

#do_show_only_bachelor_curriculaObject

#

do_show_only_bachelor_curricula

Use this method if you only want to show bachelor-curricula.

#


237
238
239
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 237

def do_show_only_bachelor_curricula
  @show_only_bachelor_curricula = true
end

#do_show_only_master_curriculaObject

#

do_show_only_master_curricula

#


228
229
230
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 228

def do_show_only_master_curricula
  @show_only_master_curricula = true
end

#do_these_curricula_contain_at_the_least_one_bachelor_course?(i) ⇒ Boolean

#

do_these_curricula_contain_at_the_least_one_bachelor_course?

This method will return true if any of the input-array starts with the string '033'.

#

Returns:

  • (Boolean)


221
222
223
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 221

def do_these_curricula_contain_at_the_least_one_bachelor_course?(i)
  i.any? {|line| line.start_with? '033' }
end

#find_entry_corresponding_to_this_line(line) ⇒ Object

#

find_entry_corresponding_to_this_line

#


151
152
153
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 151

def find_entry_corresponding_to_this_line(line)
  @dataset_from_file_lecture_information[line]
end

#is_it_a_bachelor_curriculum?Boolean

#

is_it_a_bachelor_curriculum?

Here we assume that a bachelor curriculum will have 180.0 ECTS points in total.

#

Returns:

  • (Boolean)


130
131
132
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 130

def is_it_a_bachelor_curriculum?
  @total_ects_points == 180.0
end

#is_this_curriculum_an_individual_curriculum?(i = @title) ⇒ Boolean

#

is_this_curriculum_an_individual_curriculum?

#

Returns:

  • (Boolean)


118
119
120
121
122
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 118

def is_this_curriculum_an_individual_curriculum?(
    i = @title
  )
  ARRAY_TITLE_OF_THE_INDIVIDUAL_CURRICULA.include?(i)
end

#iterate_over_the_main_datasetObject

#

iterate_over_the_main_dataset

This method is the main powerhorse method of this class. In order for it to work, the variable @dataset must exist.

#


274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 274

def iterate_over_the_main_dataset
  if may_we_report?
    e lime("#{@title}:")+N+N # In lime colour.
  end
  @dataset.each_with_index {|line, index| index += 1
    line.squeeze!(' ')
    _ = find_entry_corresponding_to_this_line(line)
    if _
      n_ects_points = _[:ects]
      if n_ects_points.nil?
        opnn; e "#{swarn('DEBUG:')} Something went wrong with the entry `"\
                "#{sfancy(entry)}`: No ects points were found."
      end
      curricula = _['curricula']
      # =================================================================== #
      # === Intercept erroneous curricula-entries (nil or empty)
      #
      # Note that the above variable can still be nil, so we must
      # handle these cases.
      # =================================================================== #
      if curricula.nil? or curricula.empty? 
        opnn; e "No entry appears to be registered for the "\
                "lecture #{simp(line)}"
      end
      unless curricula.is_a? Array
        curricula = [curricula]
      end
      @total_ects_points += n_ects_points
      curriculum_number = turquoise('[Curricula used: ')+
                          springgreen(
                            curricula.join(', ').to_s
                          )+turquoise(']:')
      padded_this_lecture = remove_leading_numbers(
        line
      ).ljust(88)
      # =================================================================== #
      # Report the lecture here.
      # =================================================================== #
      if may_we_report?
        e "#{orange((index.to_s+')').rjust(4))} "\
          "#{sfancy(padded_this_lecture)} #{curriculum_number}"
      end
      curricula.each {|this_curriculum|
        @hash_storing_all_curricula[this_curriculum] += n_ects_points
      }
      # =================================================================== #
      # Next, add a random entry to the university at hand:
      # =================================================================== #
      sample = curricula.sample
      this_university = from_curriculum_id_to_university(sample)
      if this_university.nil?
        # ================================================================= #
        # We have two ways: first we determine the university from
        # the variable @dataset_from_file_lecture_information;
        # and if this still does not work then we will simply
        # report to the user that something is wrong.
        # ================================================================= #
        if @dataset_from_file_lecture_information.has_key?(line)
          this_university = @dataset_from_file_lecture_information[line][:university]
          unless this_university.end_with?(' Wien')
            this_university = this_university.dup if this_university.frozen?
            this_university << ' Wien'
          end
        else
          opnn; e 'Careful - a nil value has been obtained for '+sfancy(sample)+'.'
          opnn; e 'Right now this means that the program will stop here, so'
          opnn; e 'that this error can be corrected.'
          opnn; e 'The curricula used here were:'
          pp curricula
          e steelblue(padded_this_lecture)
          exit
        end
      end
      @hash_n_ects_at_this_university[this_university] += n_ects_points.to_f
    else
      opnn; e "No entry was found for `#{sfancy(line.to_s)}`."
      opnn; e 'This must be corrected before we can continue.'
      opnn; e "Have a look at the file `#{sfile(main_file?)}`."
      if line.to_s.empty?
        opnn; e 'As the line was empty, we will show the whole '\
                '@dataset variable next:'
        e
        pp @dataset
        e
      end
      opnn; e 'Exiting now.'
      exit
    end
  }
end

#lectures?Boolean

#

lectures?

#

Returns:

  • (Boolean)


368
369
370
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 368

def lectures?
  @dataset
end

#main_file?Boolean

#

main_file?

#

Returns:

  • (Boolean)


211
212
213
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 211

def main_file?
  FILE_LECTURE_INFORMATION
end

#master?Boolean

#

master?

#

Returns:

  • (Boolean)


144
145
146
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 144

def master?
  @show_only_master_curricula
end

#may_we_report?Boolean

#

may_we_report?

#

Returns:

  • (Boolean)


375
376
377
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 375

def may_we_report?
  @may_we_report
end
#

menu (menu tag)

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/studium/curricula/determine_curricula/menu.rb', line 14

def menu(
    i = @commandline_arguments
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === detcur --master-vektoren
    # ===================================================================== #
    when /^-?-?master(-|_)?vektoren$/i,
         /^-?-?master(-|_)?vektorx?$/i,
         /^-?-?mvek$/i,
         /^-?-?mvec$/i,
         /^-?-?mvektor$/i,
         '2'
      append_entries_from_this_curriculum(:master_vektoren)
      add_30_ects_points
    # ===================================================================== #
    # === detcur --bvektoren --only-bachelor
    #
    # This is also known as "indi1".
    # ===================================================================== #
    when /^-?-?bachelor(-|_)?vektoren$/i,
         /^-?-?bachelor(-|_)?vektor$/i,
         /^-?-?bvektoren$/i,
         /^-?-?bvektor$/i,
         /^-?-?indi1$/i,
         /^-?-?indi$/i,
         /^-?-?bvek$/i,
         /^-?-?bvec$/i,
         '1'
      append_entries_from_this_curriculum(:bachelor_vektoren)
    # ===================================================================== #
    # === detcur --indi4
    #
    # This is also known as indi4.
    # ===================================================================== #
    when /^-?-?indi4$/i,
         /^-?-?master(-|_)?bioinformatics(-|_)?and(-|_)?molecular(-|_)?biotechnology$/i,
         /^-?-?master(-|_)?informatik(-|_)?und(-|_)?molekulare(-|_)?biologie$/i,
         /^-?-?master(-|_)?biologische(-|_)?informatik$/i
      append_entries_from_this_curriculum(:master_bioinformatics_and_molecular_biotechnology)
    # ===================================================================== #
    # === detcur --indi3
    #
    # This is also known as indi3.
    # ===================================================================== #
    when /^-?-?indi3$/i,
         /^-?-?bachelor(-|_)?informatik(-|_)?und(-|_)?molekulare(-|_)?biologie$/i,
         /^-?-?bachelor(-|_)?biologische(-|_)?informatik$/i
      append_entries_from_this_curriculum(:bachelor_informatik_und_molekulare_biologie)
    # ===================================================================== #
    # === detcur --indi2
    #
    # This is also known as indi2.
    # ===================================================================== #
    when /^-?-?indi2$/i,
         /^-?-?bachelor(-|_)?bioinformatik(-|_)?und(-|_)?biotechnologie$/i
      append_entries_from_this_curriculum(:indi2)
    # ===================================================================== #
    # === detcur --master_dummy
    # ===================================================================== #
    when /^-?-?master(-|_)?dummy?$/i,
         /^-?-?mdummy?$/i
      append_entries_from_this_curriculum(:master_dummy)
    # ===================================================================== #
    # === detcur --only-bachelor-curricula
    # ===================================================================== #
    when /^-?-?only(-|_)?bachelor(-|_)?curricula$/i,
         /^-?-?only(-|_)?bachelor$/i,
         /^-?-?bachelor$/i,
         /^-?-?b$/i
      do_show_only_bachelor_curricula
    # ===================================================================== #
    # === detcur --bachelor-mikrobiologie
    # ===================================================================== #
    when /^-?-?bachelor(-|_)?mikrobiologie$/i
      append_entries_from_this_curriculum(:bachelor_mikrobiologie)
    # ===================================================================== #
    # === detcur --bachelor-master-vektoren
    # ===================================================================== #
    when /^-?-?bachelor(-|_)?master(-|_)?vektoren$/i,
         '3', :default # This is the default entry point.
      append_entries_from_this_curriculum(:bachelor_master_vektoren)
    # ===================================================================== #
    # === detcur --only-master-curricula
    # ===================================================================== #
    when /^-?-?only(-|_)?master(-|_)?curricula$/i,
         /^-?-?only(-|_)?master$/i,
         /^-?-?master$/i
      do_show_only_master_curricula
    # ===================================================================== #
    # === detcur --help
    # ===================================================================== #
    when /help/
      show_help
      exit
    # ===================================================================== #
    # === detcur ----bachelor-molbio
    # ===================================================================== #
    when /^-?-?bachelor(-|_)?mol(-|_)?bio$/i,
         '6'
      append_entries_from_this_curriculum(:bachelor_molbio)
    # ===================================================================== #
    # === detcur --master-boku-individuell
    # ===================================================================== #
    when /^-?-?master(-|_)?boku(-|_)?individuell$/i,
         '5'
      append_entries_from_this_curriculum(:master_boku_individuell)
      add_30_ects_points
    # ===================================================================== #
    # === detcur --bachelor-boku-individuell
    # ===================================================================== #
    when /^-?-?bachelor(-|_)?boku(-|_)?individuell$/i,
         '4'
      append_entries_from_this_curriculum(:bachelor_boku_individuell)
    else
      opnn; e "Input #{sfancy(i)} was not found. Is it registered?"
      exit
    end
  end
end

#notify_the_user_that_these_files_will_be_used(i) ⇒ Object

#

notify_the_user_that_these_files_will_be_used (notify tag)

#


253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 253

def notify_the_user_that_these_files_will_be_used(i)
  if may_we_report?
    opnn; e 'The following file(s) will be used:'
    result = ''.dup
    result << N
    i.each_with_index {|this_file, index| index += 1
      result << "   (#{index}) "\
                "#{colourize_this_file_with_two_colours(this_file)}#{N}#{N}"
    }
    result.chomp!
    result << N
    e result
  end
end

#remove_leading_numbers(i) ⇒ Object

#

remove_leading_numbers

#


184
185
186
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 184

def remove_leading_numbers(i)
  i.sub(/^\d{1,7}\.?[A-Z]{0,1}\d{1,4} /,'') # <- Must also check for "185.A47" entries.
end

#report_curricula_usedObject Also known as: report

#

report_curricula_used (report tag)

#


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/studium/curricula/determine_curricula/report.rb', line 37

def report_curricula_used
  golden_arrow = gold(" #{right_arrow?} ")
  # ======================================================================= #
  # We must first sort the Hash.
  # The entries it uses are: "033630" => 61.5
  # ======================================================================= #
  sorted = @hash_storing_all_curricula.sort_by {|name_of_the_curriculum, n_ects_points|
    n_ects_points
  }.reverse
  e
  e "This curriculum has a total of "\
    "#{orange(@total_ects_points.to_s)} ECTS points. "\
    "The percentage value will be shown as well.#{N}#{N}"
  sorted.each {|id_number_of_the_curriculum, n_ects_points|
    if @show_only_bachelor_curricula and
       id_number_of_the_curriculum.start_with?('066','800','990')
      next # The above entries ^^^ are not really bachelor-courses, so we skip them.
    end
    if @show_only_master_curricula and
       id_number_of_the_curriculum.start_with?('033','193','198')
      next # Here we skip "Lehramt".
    end
    name_of_the_curriculum = return_name_of_this_curriculum_based_on_its_id_number(id_number_of_the_curriculum)
    next if name_of_the_curriculum.nil? or name_of_the_curriculum.include? 'Lehramt'
    if name_of_the_curriculum.nil?
      opnn; e "No name could be found for curriculum number "\
              "#{sfancy(id_number_of_the_curriculum)}"
    end
    if id_number_of_the_curriculum and !id_number_of_the_curriculum.empty?
      this_university = from_curriculum_id_to_university(id_number_of_the_curriculum)
    else
      this_university = "Unregistered curriculum-id "\
                        "(#{id_number_of_the_curriculum})."
    end
    properly_formatted_and_colourized_string_showing_the_respective_university =
      seagreen(
        ' ['+this_university.to_s.center(12)+']'
      )
    # ===================================================================== #
    # The amount of ECTS points will be shown on the right hand side.
    # ===================================================================== #
    colourized_and_padded_n_ects_points = mediumseagreen(
      n_ects_points.to_s.rjust(4)+' ECTS points'
    )
    # ===================================================================== #
    # Next we will colourizing the ID of the curriculum. The last three
    # letters will be in a slightly lighter colour tone.
    # ===================================================================== #
    id_number_of_the_curriculum = id_number_of_the_curriculum.center(6)
    first_part = id_number_of_the_curriculum[0 .. -4]
    last_part  = id_number_of_the_curriculum[-3,3]
    colourized_id_of_the_curriculum = sfancy(' (')+
      mediumslateblue(first_part)+
      mediumpurple(last_part)+ 
      sfancy(')')
    n_percent = (
      ( n_ects_points * 100 ) / @total_ects_points
    ).round(1)
    percentage_string = springgreen(
      ' ['+n_percent.to_s.rjust(4)+'%]'
    )
    if is_this_curriculum_an_individual_curriculum? and
       is_it_a_bachelor_curriculum? and
       !name_of_the_curriculum.include?('Bachelorcurriculum ')
      # ===================================================================== #
      # In this case simply pass-through, but notify the user about this
      # at a later time.
      # ===================================================================== #
    else
      # ===================================================================== #
      # Finally report our findings to the user:
      # ===================================================================== #
      e slateblue(
          name_of_the_curriculum.ljust(82)
        )+
        colourized_id_of_the_curriculum+
        golden_arrow+ # A cute, golden "arrow".
        colourized_and_padded_n_ects_points+
        properly_formatted_and_colourized_string_showing_the_respective_university+
        percentage_string
    end
  }; e
  if is_this_curriculum_an_individual_curriculum? and
     is_it_a_bachelor_curriculum?
    e coral('   This is an individual bachelor-curriculum, so master-lectures')
    e coral('   have not been shown in the above commandline-table.')
    e
  end
  # ======================================================================= #
  # Next show how many ECTS points are allotted to each university.
  # ======================================================================= #
  report_n_ects_per_university
end

#report_n_ects_per_universityObject

#

report_n_ects_per_university

This method will report the ECTS attribution per university, e. g. 20.0 ECTS at the BOKU, 10.0 ECTS at the TU Vienna, and so forth.

The input Hash should look like this:

{"TU Wien"=>115.5, "Uni Wien"=>30.0, "BOKU Wien"=>26.0, "Vetmed Wien"=>8.5}
#


27
28
29
30
31
32
# File 'lib/studium/curricula/determine_curricula/report.rb', line 27

def report_n_ects_per_university
  Studium.report_n_ects_per_university(
    @hash_n_ects_at_this_university,
    @total_ects_points
  )
end

#resetObject

#

reset

#


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/studium/curricula/determine_curricula/reset.rb', line 16

def reset
  super()
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @dataset_from_file_lecture_information
  # ======================================================================= #
  @dataset_from_file_lecture_information = dataset_from_file_lecture_information
  # ======================================================================= #
  # === @may_we_report
  # ======================================================================= #
  @may_we_report = true
  # ======================================================================= #
  # === @total_ects_points
  # ======================================================================= #
  @total_ects_points = 0
  # ======================================================================= #
  # === @title
  # ======================================================================= #
  @title = nil
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = nil
  # ======================================================================= #
  # === @hash_storing_all_curricula
  # ======================================================================= #
  @hash_storing_all_curricula = {}
  @hash_storing_all_curricula.default = 0
  # ======================================================================= #
  # === @hash_n_ects_at_this_university
  # ======================================================================= #
  @hash_n_ects_at_this_university = {}
  @hash_n_ects_at_this_university.default = 0
  # ======================================================================= #
  # === @show_only_bachelor_curricula
  # ======================================================================= #
  @show_only_bachelor_curricula = false
  # ======================================================================= #
  # === @show_only_master_curricula
  # ======================================================================= #
  @show_only_master_curricula = false
end

#runObject

#

run

#


12
13
14
15
16
17
# File 'lib/studium/curricula/determine_curricula/run.rb', line 12

def run
  menu
  consider_using_a_default_curriculum_if_no_other_instructions_were_issued
  iterate_over_the_main_dataset
  report if @may_we_report
end

#set_commandline_arguments(i = :default) ⇒ Object

#

set_commandline_arguments

#


165
166
167
168
169
170
171
172
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 165

def set_commandline_arguments(
    i = :default
  )
  if i.is_a? Array and i.empty?
    i << :default
  end
  @commandline_arguments = i
end

#set_title_from_this_file(i) ⇒ Object

#

set_title_from_this_file

#


203
204
205
206
# File 'lib/studium/curricula/determine_curricula/misc.rb', line 203

def set_title_from_this_file(i)
  i = i.split(N)[1].delete('#=').strip
  @title = i
end

#show_helpObject

#

show_help (help tag)

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/studium/curricula/determine_curricula/help.rb', line 14

def show_help
  result =<<EOF

Several curricula are defined. Only a few will be highlighted here:
 
detcur --bvektoren
detcur --bachelor-vektoren
detcur --bvektor
detcur --master-vektoren
detcur --bachelor-master-vektoren
detcur --bachelor-genetik
detcur --bachelor-mikrobiologie                      # ← individual curriculum
detcur --bachelor-informatik-und-molekulare-biologie # ← individual curriculum
detcur --dummy                                       # ← generic individual curriculum

If you only want to show courses registered in a bachelor-curriculum
then you may want to use the option:
 
detcur --only-bachelor-curricula
detcur --only-master-curricula

EOF
  e result
end