Class: Studium::CurriculumModuleDisplayer

Inherits:
Base
  • Object
show all
Defined in:
lib/studium/curricula/curriculum_module_displayer/menu.rb,
lib/studium/curricula/curriculum_module_displayer/run.rb,
lib/studium/curricula/curriculum_module_displayer/reset.rb,
lib/studium/curricula/curriculum_module_displayer/constants.rb,
lib/studium/curricula/curriculum_module_displayer/initialize.rb,
lib/studium/curricula/curriculum_module_displayer/show_and_report.rb,
lib/studium/curricula/curriculum_module_displayer/set_use_this_curriculum.rb,
lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb

Overview

Studium::CurriculumModuleDisplayer

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
DEFAULT_CURRICULUM_TO_USE =
#

DEFAULT_CURRICULUM_TO_USE

#
:bachelor_vektor_curriculum
ENSURE_MINIMUM_SIZE_OF_A_MODULE =
#

ENSURE_MINIMUM_SIZE_OF_A_MODULE

If the following constant is set to true then this class will warn if a module is too small - e. g. having less than the minimum amount of ECTS as specified below.

#
true
MINIMAL_AMOUNT_OF_ECTS_POINTS_PER_MODULE =
#

MINIMAL_AMOUNT_OF_ECTS_POINTS_PER_MODULE

Define, in n ECTS, the minimum amount of ECTS points per module. A value of 5.0 or 6.0 seems a good number.

#
5.0

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

Studium::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, #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_arguments, #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 = nil, run_already = true) ⇒ CurriculumModuleDisplayer

#

initialize

#


14
15
16
17
18
19
20
21
22
23
# File 'lib/studium/curricula/curriculum_module_displayer/initialize.rb', line 14

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.[](i = '') ⇒ Object

#

Studium::CurriculumModuleDisplayer[]

#


407
408
409
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 407

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

Instance Method Details

#already_solved?(i) ⇒ Boolean

#

already_solved?

#

Returns:

  • (Boolean)


133
134
135
136
137
138
139
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 133

def already_solved?(i)
  already_solved_or_not = false
  if @dataset_from_the_file_lecture_information[i].has_key? :already_solved
    already_solved_or_not = @dataset_from_the_file_lecture_information[i][:already_solved]
  end
  already_solved_or_not
end

#colour_for_ects_points(i) ⇒ Object

#

colour_for_ects_points

#


374
375
376
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 374

def colour_for_ects_points(i)
  skyblue(i)
end

#colour_for_percentage_values(i) ⇒ Object

#

colour_for_percentage_values

#


381
382
383
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 381

def colour_for_percentage_values(i)
  mediumseagreen(i)
end

#colour_for_university(i) ⇒ Object

#

colour_for_university

#


100
101
102
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 100

def colour_for_university(i)
  olive(i)
end

#commandline_arguments?Boolean

#

commandline_arguments?

#

Returns:

  • (Boolean)


49
50
51
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 49

def commandline_arguments?
  @commandline_arguments
end

#dataset_from_the_file_lecture_information?Boolean Also known as: main_dataset?

#

dataset_from_the_file_lecture_information?

#

Returns:

  • (Boolean)


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

def dataset_from_the_file_lecture_information?
  @dataset_from_the_file_lecture_information
end

#determine_which_curriculum_to_use(i = commandline_arguments?.first) ⇒ Object

#

determine_which_curriculum_to_use

#


362
363
364
365
366
367
368
369
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 362

def determine_which_curriculum_to_use(
    i = commandline_arguments?.first
  )
  if i.nil? or i.empty?
    i = :default
  end
  set_use_this_curriculum(i)
end

#do_prefer_englishObject Also known as: prefer_english

#

do_prefer_english

#


35
36
37
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 35

def do_prefer_english
  @prefer_this_language_for_the_curriculum = :english
end

#do_show_only_the_modulesObject

#

do_show_only_the_modules

Invoke this method like so:

CurriculumModuleDisplayer --show-modules
#


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/studium/curricula/curriculum_module_displayer/show_and_report.rb', line 19

def do_show_only_the_modules
  e
  @hash_keeping_the_modules.each {|this_name, array_these_lectures_are_part_of_that_module|
    n_ects_points_in_this_module = 0
    first_lecture = array_these_lectures_are_part_of_that_module.first
    pointer = main_dataset?[first_lecture]
    result  = slateblue(this_name.rjust(3)).dup
    if pointer.has_key? :name_of_the_curriculum_module
      array_these_lectures_are_part_of_that_module.each {|this_lecture|
        n_ects_points = main_dataset?[this_lecture][:ects]
        n_ects_points_in_this_module += n_ects_points
      }
      title = pointer[:name_of_the_curriculum_module].strip
      result << ' '+royalblue(title)+' '+
                colour_for_ects_points(
                  n_ects_points_in_this_module.to_s+' ECTS'
                )
    end
    e result
  }
  e
end

#has_a_dependency_on_a_prior_module?(this_lecture_dataset) ⇒ Boolean

#

has_a_dependency_on_a_prior_module?

This method will return true if the passed dataset has a dependency listed on a prior module.

We will also check for an individual curriculum here. If this exists then we will try to prefer the entry for this individual curriculum.

#

Returns:

  • (Boolean)


69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 69

def has_a_dependency_on_a_prior_module?(this_lecture_dataset)
  has_a_dependency = false # By default there is no dependency known.
  if this_lecture_dataset
    if is_an_individual_curriculum? and
      this_lecture_dataset.has_key?(:individual_curriculum_depends_on_these_modules)
      has_a_dependency = true
    elsif this_lecture_dataset.has_key? :depends_on_these_modules
      has_a_dependency = true
    end
  end
  has_a_dependency
end

#has_description?(i) ⇒ Boolean

#

has_description?

#

Returns:

  • (Boolean)


279
280
281
282
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 279

def has_description?(i)
  @dataset_from_the_file_lecture_information[i].has_key?(:description_in_english) or
  @dataset_from_the_file_lecture_information[i].has_key?(:description_in_german)
end

#is_an_individual_curriculum?Boolean

#

is_an_individual_curriculum?

#

Returns:

  • (Boolean)


42
43
44
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 42

def is_an_individual_curriculum?
  @is_an_individual_curriculum
end

#is_more_than_one_university_involved_in_this_curriculum?Boolean

#

is_more_than_one_university_involved_in_this_curriculum?

This method will return true e. g. if it is an individual curriculum.

#

Returns:

  • (Boolean)


153
154
155
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 153

def is_more_than_one_university_involved_in_this_curriculum?
  @hash_universities.keys.size > 1
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
# File 'lib/studium/curricula/curriculum_module_displayer/menu.rb', line 14

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === CurriculumModuleDisplayer --overview
    # ===================================================================== #
    when /^-?-?overview$/i
      run_post_menu_actions(:default)
      do_show_only_the_modules
      exit
    # ===================================================================== #
    # === CurriculumModuleDisplayer --bvektor --show-modules
    # ===================================================================== #
    when /^-?-?show(_|-)?modules$/i
      run_post_menu_actions
      do_show_only_the_modules
      exit
    # ===================================================================== #
    # === help
    # ===================================================================== #
    when /help$/i
      show_help
      exit
    end
  end
end

#notify_the_user_that_this_module_has_too_few_ects_points(name_of_the_module, n_ects) ⇒ Object

#

notify_the_user_that_this_module_has_too_few_ects_points

#


262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 262

def notify_the_user_that_this_module_has_too_few_ects_points(
    name_of_the_module,
    n_ects
  )
  e
  e 'Module '+sfancy(name_of_the_module)+' has too '\
    'few ECTS points ('+
    colourize_ects(n_ects.to_s+' ECTS points')+').'
  e 'This is not allowed, as defined per the '\
    'constant '+slateblue('ENSURE_MINIMUM_SIZE_OF_A_MODULE')+'.'
  e 'Consider changing the composition of the module.'
  e
end

#report(hash = @hash_keeping_the_modules) ⇒ Object

#

report (report tag)

This is the main report-method of this class. It will report the findings on the commandline to the end-user.

#


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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/studium/curricula/curriculum_module_displayer/show_and_report.rb', line 66

def report(
    hash = @hash_keeping_the_modules
  )
  hash.each_pair {|name_of_the_module, array_these_lectures_are_part_of_that_module|
    total_ects = return_n_ects_of_this_lecture(
      array_these_lectures_are_part_of_that_module
    )
    # ===================================================================== #
    # First, display the title of the module.
    # ===================================================================== #
    e
    e gold('Modul: '+name_of_the_module.ljust(12))+
      colour_for_ects_points('[zu '+total_ects.to_s+' ECTS Punkten]')+
      steelblue(
        ' ['+array_these_lectures_are_part_of_that_module.size.to_s+
        ' Lehrveranstaltungen in diesem Modul]'
      )
    # ===================================================================== #
    # Notify the user if we have too few entries in the module.
    # ===================================================================== #
    if @ensure_minimum_size_of_a_module
      if total_ects.to_f < MINIMAL_AMOUNT_OF_ECTS_POINTS_PER_MODULE
        notify_the_user_that_this_module_has_too_few_ects_points(
          name_of_the_module,
          total_ects
        )
        exit
      end
    end
    # ===================================================================== #
    # Also peek at the first lecture's dataset, in order to determine
    # whether it has a key called :name_of_the_curriculum_module. 
    # ===================================================================== #
    first_lecture = array_these_lectures_are_part_of_that_module.first
    pointer = main_dataset?[first_lecture]
    if pointer.has_key? :name_of_the_curriculum_module
      # =================================================================== #
      # === Show the title of that particular module
      #
      # In this case a key was found, so we can display that title of
      # the module at hand, such as "Advanced techniques in molecular
      # biology".
      # =================================================================== #
      title = pointer[:name_of_the_curriculum_module]
      e "       #{lightgreen('Name: ')}"\
               "#{lightgreen(title.chomp)}" # <- Show the name of the module here.
    end
    # ===================================================================== #
    # Next, we will also show dependencies that this module has on other,
    # prior modules. We do so only after checking for a certain instance
    # variable - and only IF this module has at the least one dependency.
    # ===================================================================== #
    if @show_dependency_on_other_modules
      if has_a_dependency_on_a_prior_module?(pointer)
        # ================================================================= #
        # Ok, this lecture has a dependency. We will show it at once,
        # but only once.
        # ================================================================= #
        if pointer[return_the_proper_module_dependency_entry]
          e mediumturquoise(
              '       This module depends on these prior modules: '
            )+
            mediumseagreen(
              pointer[return_the_proper_module_dependency_entry].join(', ').strip
            )
        end
      end
    end
    e
    array_these_lectures_are_part_of_that_module.each {|this_lecture|
      n_ects = return_n_ects_of_this_lecture(this_lecture)
      belongs_to_this_university = which_university?(this_lecture)
      lecture_belongs_to_these_curricula = which_curricula?(this_lecture)
      has_the_lecture_been_completed_already = already_solved?(this_lecture)
      has_description = has_description?(this_lecture)
      unless has_description
        e crimson('No :description entry was found for ')+
          sfancy(this_lecture)+crimson('.')
      end
      # =================================================================== #
      # Ok, we will next add the amount of ECTS to the different
      # curricula there.
      # =================================================================== #
      lecture_belongs_to_these_curricula.each {|this_curriculum_number|
        @hash_ects_per_curriculum[this_curriculum_number] += n_ects
      }
      @n_ects_in_total += n_ects
      @hash_universities[belongs_to_this_university] += n_ects
      result = '  '+
               royalblue(
                 this_lecture.ljust(90)
               )+
               colour_for_ects_points(
                 n_ects.to_s.rjust(4)+' ECTS'
               ) # <- Add the ECTS here
      # =================================================================== #
      # Next, add the university to this.
      # =================================================================== #
      result << ' '+colour_for_university(
        belongs_to_this_university.ljust(12)
      )
      # =================================================================== #
      # == Colourize success or failure text
      #
      # We will also show a small text in red or green colour. Green will
      # indicate that this exam has already been passed; and the red text
      # will indicate that we have not yet passed that exam.
      # =================================================================== #
      if has_the_lecture_been_completed_already
        result << lightgreen('[completed already]')
      else
        result << crimson('[not yet completed]')
      end
      e result
    }
  }
  e
  e "This curriculum has a total of "\
    "#{colour_for_ects_points(@n_ects_in_total.to_s+' ECTS points')}."
  e
  report_average_module_size
  report_university_attribution if @shall_we_report_university_attribution
end

#report_average_module_sizeObject

#

report_average_module_size

#


85
86
87
88
89
90
91
92
93
94
95
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 85

def report_average_module_size
  average_ects_points = 0
  values = @hash_keeping_the_modules.values
  values = values.map {|entry| return_n_ects_of_this_lecture(entry) }
  average_ects_points = (
    values.sum.to_f / values.size
  ).round(2).to_s
  e "The average module size is: "\
    "#{colourize_ects(average_ects_points.to_s+' ECTS points')}"
  e
end

#report_university_attributionObject

#

report_university_attribution

This method will report to which specific university the lectures belong to.

#


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 163

def report_university_attribution
  e 'Of these lectures, the following university/universities '\
    'are attributed:'
  e
  total_ects_points = total_ects_points?
  sorted_hash = @hash_universities.sort_by {|key, n_ects_points|
    n_ects_points
  }.reverse
  sorted_hash = Hash[*sorted_hash.flatten]
  index = 0
  sorted_hash.each_pair {|name_of_the_university, n_ects_points| index += 1
    # ===================================================================== #
    # Set up the percentage value properly, as a String:
    # ===================================================================== #
    percent_value = (
      (n_ects_points * 100 ) / total_ects_points
    ).round(2)
    percent_value = '%.2f' % percent_value.to_f 
    percentage_value_as_string = (
      percent_value.to_s+'%'
    ).rjust(6)
    padded_index = '('+index.to_s+') '
    colourized_and_padded_index = mediumspringgreen(padded_index) 
    e '  '+
      colourized_and_padded_index+
      colour_for_university(name_of_the_university.ljust(14))+' '+
      colourize_ects(n_ects_points.to_s.rjust(5)+' ECTS points')+' '+
      colour_for_percentage_values(
        '('+percentage_value_as_string+')'
      )
  }
  e
  if is_more_than_one_university_involved_in_this_curriculum?
    # ===================================================================== #
    # In this case we will report how many ECTS points are attributed
    # to each curriculum. We still have to sort it. The entries there
    # may look like this: "033305"=>2.0
    # ===================================================================== #
    sorted = @hash_ects_per_curriculum.sort_by {|curriculum_id, n_ects_points|
      n_ects_points
    }.reverse
    sorted = Hash[*sorted.flatten]
    # ===================================================================== #
    # We will reject curricula IDs that start with '1' - this indicates
    # a "Lehramt" curriculum. We will also reject things such as
    # '860'.
    # ===================================================================== #
    sorted.reject! {|a,b|
      a.start_with?('1') or (a.size < 4)
    }
    e 'More than one university is involved with this curriculum. '\
      'Thus, we will show the'
    e 'ECTS attribution to each respective curriculum AND the '\
      'associated university next:'
    e
    sorted.each_pair {|curriculum_id, n_ects_points|
      n_percentage = (
        (n_ects_points * 100) / total_ects_points?
      ).round(2).to_s
      n_percentage = '%.2f' % n_percentage
      belongs_to_this_curriculum = Studium.curriculum_id_to_curriculum_name(curriculum_id)
      at_this_university = Studium.curriculum_id_to_university(curriculum_id)
      e '    '+lightgreen(curriculum_id)+
        ': '+colour_ects(n_ects_points.to_s.rjust(5))+' '+
        colour_for_percentage_values(
          n_percentage.to_s.rjust(5)+'%'
        )+
        slateblue(
          ' ['+at_this_university.to_s.center(12)+']'
        )+# <- Show the university here.
        ' (from curriculum '+sfancy(belongs_to_this_curriculum)+')' # <- Show the name of the curriculum here.
    }
    e
  end
end

#resetObject

#

reset (reset 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
# File 'lib/studium/curricula/curriculum_module_displayer/reset.rb', line 14

def reset
  super()
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @ensure_minimum_size_of_a_module
  # ======================================================================= #
  @ensure_minimum_size_of_a_module = ENSURE_MINIMUM_SIZE_OF_A_MODULE
  # ======================================================================= #
  # === @dataset_from_the_file_lecture_information
  # ======================================================================= #
  @dataset_from_the_file_lecture_information = return_dataset_from_the_file_lecture_information
  # ======================================================================= #
  # === @hash_ects_per_curriculum
  # ======================================================================= #
  @hash_ects_per_curriculum = {} # <- Keep track of how many ECTS are in any given curriculum at hand.
  @hash_ects_per_curriculum.default = 0
  # ======================================================================= #
  # === @hash_keeping_the_modules
  #
  # The following Hash will keep all modules of the curriculum at hand.
  # ======================================================================= #
  @hash_keeping_the_modules = {}
  # ======================================================================= #
  # === @n_ects_in_total
  # ======================================================================= #
  @n_ects_in_total = 0
  @hash_universities = {}
  @hash_universities.default = 0
  @is_an_individual_curriculum = false
  # ======================================================================= #
  # The variable @use_this_module_entry can be either :module or
  # :individual_curriculum_module.
  #
  # By default it will be set to :module.
  # ======================================================================= #
  @use_this_module_entry = :module
  # ======================================================================= #
  # === @show_dependency_on_other_modules
  #
  # If the next variable is true then we will also show the dependencies
  # on other modules. This will then be displayed on a per-module level,
  # after we showed the name of the module on the commandline.
  # ======================================================================= #
  @show_dependency_on_other_modules = true
  # ======================================================================= #
  # === @prefer_this_language_for_the_curriculum
  #
  # The next variable determines which entry to prioritize if we have
  # multiple descriptions for a given lecture (e. g. in german and in
  # english). By default we will use german, but some lectures, in
  # particular the individual vektor-curricula will use the english
  # language.
  # ======================================================================= #
  @prefer_this_language_for_the_curriculum = :german
  # ======================================================================= #
  # === @shall_we_report_university_attribution
  # ======================================================================= #
  @shall_we_report_university_attribution = true
end

#return_n_ects_of_this_lecture(i) ⇒ Object

#

return_n_ects_of_this_lecture

This method will always return a number (a Float).

#


109
110
111
112
113
114
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 109

def return_n_ects_of_this_lecture(i)
  i = [i].flatten.compact
  i.map {|entry|
    @dataset_from_the_file_lecture_information[entry][:ects].to_f
  }.sum
end

#return_the_proper_module_dependency_entryObject

#

return_the_proper_module_dependency_entry

This method must return the proper module-dependency entry.

#


251
252
253
254
255
256
257
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 251

def return_the_proper_module_dependency_entry
  if is_an_individual_curriculum?
    :individual_curriculum_depends_on_these_modules
  else
    :depends_on_these_modules
  end
end

#runObject

#

run (run tag)

#


14
15
16
17
18
# File 'lib/studium/curricula/curriculum_module_displayer/run.rb', line 14

def run
  menu
  run_post_menu_actions
  report
end

#run_post_menu_actions(i = commandline_arguments?.first) ⇒ Object

#

run_post_menu_actions

#


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
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 287

def run_post_menu_actions(
    i = commandline_arguments?.first
  )
  determine_which_curriculum_to_use(i)
  # ======================================================================= #
  # Obtain all lectures that are part of the curriculum. This
  # depends on @use_this_curriculum having been set properly.
  # ======================================================================= #
  array_all_lectures = return_lectures_from_this_curriculum(
    @use_this_curriculum
  )
  # ======================================================================= #
  # Must replace them with the proper dataset from the file lecture
  # information.
  # ======================================================================= #
  array_all_lectures.map! {|entry|
    [
      entry,
      @dataset_from_the_file_lecture_information[entry]
    ]
  }
  # ======================================================================= #
  # Next we must find common modules. We will iterate over the entries
  # in a linear manner, starting from top-to-bottom.
  # ======================================================================= #
  array_all_lectures.each {|name_of_the_lecture, inner_dataset|
    if name_of_the_lecture
      name_of_the_lecture.squeeze!(' ')
    end
    if inner_dataset.nil?
      opnn; e "#{steelblue(nil)} value for the lecture "\
              "#{sfancy(name_of_the_lecture)}"\
              ", at the variable inner_dataset."
      next
    end
    # ===================================================================== #
    # We need to use use_this_module_entry to distinguish between an
    # individual curriculum and a regular, registered one.
    # ===================================================================== #
    use_this_module_entry = use_which_module_entry?
    # ===================================================================== #
    # Sanitize this a bit next:
    # ===================================================================== #
    case use_this_module_entry
    when :bachelor_vektor_curriculum,
         :master_vektor_curriculum
      use_this_module_entry = :individual_curricula
    end
    if inner_dataset.has_key? use_this_module_entry
      _ = inner_dataset[use_this_module_entry]
      # =================================================================== #
      # This here is not quite correct, since we changed the format in
      # the yaml file.
      # =================================================================== #
      first_entry = _.first
      name_of_the_module = first_entry
      if @hash_keeping_the_modules.has_key? name_of_the_module
        @hash_keeping_the_modules[name_of_the_module] << name_of_the_lecture
      else
        # else it is a new entry.
        @hash_keeping_the_modules[name_of_the_module] = [name_of_the_lecture]
      end
    else
      opnn; e 'No module entry for `'+sfancy(name_of_the_lecture)+'`.'
      e 'Also showing the data associated with this lecture:'
      pp inner_dataset
      e "The name of the module would have been: "\
        "#{orange(use_this_module_entry.to_s)}"
    end
  }
end

#set_use_this_curriculum(i = :default) ⇒ Object

#

set_use_this_curriculum

#


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
# File 'lib/studium/curricula/curriculum_module_displayer/set_use_this_curriculum.rb', line 14

def set_use_this_curriculum(
    i = :default
  )
  # ======================================================================= #
  # The first case menu has to convert into the vektor-curriculum,
  # if we did not input anything.
  # ======================================================================= #
  case i
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default, nil
    i = DEFAULT_CURRICULUM_TO_USE
  end
  case i.to_sym # case tag
  when :genetik,
       :genetic,
       :genetics
    i = :genetik_curriculum
  else
    # ===================================================================== #
    # In the following case/when menu we will intercept e. g. bvek
    # and mvek. Since as of March 2020 we will use the leading
    # part ":individuelles_curriculum" for an individual curriculum.
    # ===================================================================== #
    case i # case tag
    # ===================================================================== #
    # === curdisplayer --boku_bachelor_individuelles_curriculum
    # ===================================================================== #
    when /^-?-?boku(_|-)?bachelor(_|-)?individuelles(_|-)?curriculum$/i
      i = :individuelles_curriculum_bachelor_boku
      set_use_this_module_entry(i)
    # ===================================================================== #
    # === curdisplayer --bvek
    # ===================================================================== #
    when /^-?-?bvek$/i,
         /^-?-?bvektor$/i
      i = :individuelles_curriculum_bachelor_vektor
      set_use_this_module_entry(i)
    # ===================================================================== #
    # === curdisplayer --master
    # ===================================================================== #
    when /^-?-?master$/i,
         /^-?-?mvek$/i,    # === curdisplayer --mvek
         /^-?-?mvec$/i     # === curdisplayer --mvec
      i = :individuelles_curriculum_master_vektor
      set_use_this_module_entry(i)
    else
      # =================================================================== #
      # === Handle input that includes 'vektor' or 'vekcor' next
      # =================================================================== #
      if i.to_s.include?('vektor') or
         i.to_s.include?('vekcor')
        # ================================================================= #
        # In this case it must be the individual curriculum, either
        # bachelor or master.
        # ================================================================= #
        name_of_the_curriculum = i.to_s.delete('-')
        do_prefer_english # These curricula require the english language.
        if name_of_the_curriculum.start_with? 'm' # <- Trigger via: cmodules --mvektor
          # =============================================================== #
          # === cmodules mvektor
          # =============================================================== #
          i = :master_vektor_curriculum
        elsif name_of_the_curriculum.start_with? 'bm'
          # =============================================================== #
          # === cmodules bmvektor
          # =============================================================== #
          i = :bachelor_master_vektor_curriculum
        else
          i = :bachelor_vektor_curriculum
        end
        set_use_this_module_entry(i)
      end
    end
  end
  @use_this_curriculum = i
end

#set_use_this_module_entry(i = :individual_curriculum_module) ⇒ Object

#

set_use_this_module_entry

#


388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 388

def set_use_this_module_entry(
    i = :individual_curriculum_module
  )
  case i
  # ======================================================================= #
  # === :individual_curriculum_module
  # ======================================================================= #
  when :individual_curriculum_module,
       :master_vektor_curriculum,
       :bachelor_vektor_curriculum,
       :individuelles_curriculum_bachelor_boku
    @is_an_individual_curriculum = true
  end
  @use_this_module_entry = i
end

#show_helpObject

#

show_help (help tag)

#


45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/studium/curricula/curriculum_module_displayer/show_and_report.rb', line 45

def show_help
  e
  e 'These curricula are especially important:'
  e
  e '  --genetik'
  e '  --bvektor'
  e '  --mvektor'
  e '  --bmvektor'
  e
  e 'Furthermore, you can show a short summary over the modules, via:'
  e
  e '  --overview'
  e
end

#total_ects_points?Boolean

#

total_ects_points?

#

Returns:

  • (Boolean)


242
243
244
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 242

def total_ects_points?
  @n_ects_in_total
end

#use_which_module_entry?Boolean

#

use_which_module_entry?

#

Returns:

  • (Boolean)


56
57
58
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 56

def use_which_module_entry?
  @use_this_module_entry
end

#which_curricula?(i) ⇒ Boolean

#

which_curricula?

#

Returns:

  • (Boolean)


126
127
128
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 126

def which_curricula?(i)
  @dataset_from_the_file_lecture_information[i]['curricula']
end

#which_university?(i) ⇒ Boolean

#

which_university?

#

Returns:

  • (Boolean)


119
120
121
# File 'lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb', line 119

def which_university?(i)
  @dataset_from_the_file_lecture_information[i][:university].to_s
end