Class: Studium::Exams::ShowThemes

Inherits:
Base
  • Object
show all
Defined in:
lib/studium/exams/show_themes/menu.rb,
lib/studium/exams/show_themes/misc.rb,
lib/studium/exams/show_themes/reset.rb,
lib/studium/exams/show_themes/constants.rb

Overview

Studium::Exams::ShowThemes

Constant Summary collapse

COMPLETED_COURSE =
#

COMPLETED_COURSE

#
''
NAMESPACE =
#

NAMESPACE

#
inspect
SHOW_NAMESPACE_IN_HELP_SECTION =
#

SHOW_NAMESPACE_IN_HELP_SECTION

If this constant is true, then we will show the namespace in the help section of this class.

#
false
PAD_TO_THE_RIGHT_FOR_INDIVIDUAL_ECTS_POINTS =
#

PAD_TO_THE_RIGHT_FOR_INDIVIDUAL_ECTS_POINTS

How much to pad, via ' ', to the right side.

#
72

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?, #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) ⇒ ShowThemes

#

initialize

#


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/studium/exams/show_themes/misc.rb', line 41

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

Class Method Details

.[](i = '') ⇒ Object

#

Studium::Exams::ShowThemes[]

Simpler initializer for the class.

#


518
519
520
# File 'lib/studium/exams/show_themes/misc.rb', line 518

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

Instance Method Details

#check_whether_the_passed_theme_is_an_allowed_theme(_ = search_which_theme? ) ⇒ Object

#

check_whether_the_passed_theme_is_an_allowed_theme

This method will check whether the given input at hand is a valid exam-theme.

Invalid entries will be reported at once, so that the user has to correct them.

We wish for our dataset to be correct at all times.

#


439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/studium/exams/show_themes/misc.rb', line 439

def check_whether_the_passed_theme_is_an_allowed_theme(
    _ = search_which_theme?
  )
  if _
    dataset = @allowed_themes_for_exams
    if dataset.include? _
      # In this case all is fine.
    elsif _.start_with?('--') # These are exempt.
    else
      opnn; e "No theme was found matching to `#{steelblue(_)}`."
      report_no_result_was_found
      exit
    end
  end
end

#colourize_ects(i) ⇒ Object

#

colourize_ects

#


292
293
294
# File 'lib/studium/exams/show_themes/misc.rb', line 292

def colourize_ects(i)
  palevioletred(i)
end

#consider_sorting_the_datasetObject

#

consider_sorting_the_dataset (sort tag)

#


458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/studium/exams/show_themes/misc.rb', line 458

def consider_sorting_the_dataset
  if @sort_how
    case @sort_how
    # ===================================================================== #
    # === :default
    #
    # This defaults to alphabetical sorting.
    # ===================================================================== #
    when :default,
         :alphabetically
      # =================================================================== #
      # Each key may look like this:
      #
      #   840.007 Einführung in die Biostatistik
      #
      # =================================================================== #
      sorted = @dataset.sort_by {|name, inner_hash|
        if name.include? ' '
          name = name.split(' ')[1]
        end
        name
      }
      @dataset = Hash[sorted] # Turn it into a Hash again.
    # ===================================================================== #
    # === :highest_ects_first
    # ===================================================================== #
    when :highest_ects_first
      sorted = @dataset.sort_by {|name, inner_hash|
        inner_hash[:ects]
      }.reverse
      @dataset = Hash[sorted]
    end
  end
end

#dataset?Boolean Also known as: dataset

#

dataset?

#

Returns:

  • (Boolean)


67
68
69
# File 'lib/studium/exams/show_themes/misc.rb', line 67

def dataset?
  @dataset
end

#ensure_that_the_themes_of_this_course_are_all_valid_or_exit(i) ⇒ Object

#

ensure_that_the_themes_of_this_course_are_all_valid_or_exit

#


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
# File 'lib/studium/exams/show_themes/misc.rb', line 104

def ensure_that_the_themes_of_this_course_are_all_valid_or_exit(i)
  if i.nil?
    return
  end
  if i.all? {|line|
      @allowed_themes_for_exams.include? line.tr(' ','_')
    }
  else
    # =================================================================== #
    # Ok we found at the least one faulty or missing entry. We must
    # determine this entry and then notify the user about it. However
    # had, we will only notify the user, but otherwise continue to
    # work.
    # =================================================================== #
    not_included_entries = i.select {|inner_entry|
      inner_entry.tr!(' ','_')
      !@allowed_themes_for_exams.include? inner_entry
    }
    not_included_entries.each {|this_entry_is_not_included|
      opnn; e "Note that the entry #{swarn(this_entry_is_not_included)}"\
              " is not included in the"
      opnn; e "file `#{sfile(Studium.file_allowed_themes_for_exams)}`."
      opnn; e 'This should be remedied - please ensure that it is a'
      opnn; e 'valid entry before adding it to that file.'
    }
    # exit unless not_included_entries.empty?
    # ^^^ The above can be re-enabled.
  end
end
#

menu (menu tag)

#


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
# File 'lib/studium/exams/show_themes/menu.rb', line 16

def menu(
    i = commandline_arguments_with_hyphens?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # =================================================================== #
    # === showthemes --highest
    #
    # Invoke this entry pointlike so:
    #
    #   themes cellbiology --highest
    #
    # =================================================================== #
    when /^-?-?biggest/,
         /^-?-?highest/,
         /^-?-?sort(-|_)?by(-|_)?ects/
      @sort_how = :highest_ects_first
    # =================================================================== #
    # === showthemes --help
    # =================================================================== #
    when /^-?-?help$/i,
         /^-?-?show(-|_)?help$/i
      show_help(:then_exit)
    # =================================================================== #
    # === showthemes --open
    # =================================================================== #
    when /^-?-?open$/i
      open_csv_file
      exit
    # =================================================================== #
    # === showthemes --available_themes?
    # =================================================================== #
    when /^-?-?available(_|-)?themes\??/,
         /^-?-?athemes?/,
         /^-?-?available/,
         /^-?-?overview/,
         /^-?-?topics/
      show_available_themes
      exit
    end
  end    
end

#obtain_the_dataset_holding_matching_lectures_to_the_given_theme(_ = search_for_which_theme? ) ⇒ Object

#

obtain_the_dataset_holding_matching_lectures_to_the_given_theme

This method will obtain the dataset that holds all matching lectures to the given theme at hand.

#


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/exams/show_themes/misc.rb', line 77

def obtain_the_dataset_holding_matching_lectures_to_the_given_theme(
    _ = search_for_which_theme?
  )
  @dataset = @dataset_from_file_lecture_information.select {|name, inner_hash|
    themes = inner_hash['themes']
    # =================================================================== #
    # Note that "themes" will be an Array.
    # =================================================================== #
    if themes.nil? or themes.compact.empty?
      e "Empty entry for #{steelblue(name)} - please fix this."
      exit
    end
    ensure_that_the_themes_of_this_course_are_all_valid_or_exit(themes)
    if themes and themes.include?(_)
      true
    else
      false
    end
  }
  if @dataset.empty?
    report_no_result_was_found
  end
end

#open_csv_file(i = csv_file? ) ⇒ Object

#

open_csv_file

The first argument should be the path to the .csv file in question.

#


319
320
321
322
323
# File 'lib/studium/exams/show_themes/misc.rb', line 319

def open_csv_file(
    i = csv_file?
  )
  open_in_editor(i)
end

#opnn_in_helpsectionObject

#

opnn_in_helpsection

#


424
425
426
# File 'lib/studium/exams/show_themes/misc.rb', line 424

def opnn_in_helpsection
  opnn if SHOW_NAMESPACE_IN_HELP_SECTION
end

#report(this_dataset = @dataset) ⇒ Object

#

report (report tag)

#


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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/studium/exams/show_themes/misc.rb', line 173

def report(
    this_dataset = @dataset
  )
  @n_ects_completed = 0
  index = 0
  string = "#{N}#{ropnn}#{rev}Showing all matches fitting to ".dup
  string << rev+'the theme '+steelblue(which_theme?)+':'+N+N
  e string
  e
  if File.exist? FILE_PASSED_EXAMS_PER_MONTH
    passed_exams_dataset = File.readlines(
      FILE_PASSED_EXAMS_PER_MONTH
    ).reject {|line|
      line.strip.empty? or
      line.strip.start_with?('#')
    }
  else
    passed_exams_dataset = nil
  end
  this_dataset.each {|name, inner_hash| index += 1
    padded_index   = ("#{index}) ").rjust(5)
    lecture_type   = inner_hash[:type].to_s
    n_ects         = inner_hash[:ects].to_s
    already_solved = inner_hash[:already_solved]
    if already_solved
      grade = inner_hash[:grade]
      unless (grade == '+') or (grade == 'E')
        @average_grade << grade
        @n_ects_completed += n_ects.to_f
      end
    end
    # ===================================================================== #
    # Determine next whether it is a Bachelor, Master or
    # Diploma lecture.
    # ===================================================================== #
    bachelor_or_master_or_diploma = bachelor_master_or_diploma(
      name, passed_exams_dataset
    )
    # ===================================================================== #
    # Cap too-long names next:
    # ===================================================================== #
    if name.size > 68
      name = name[0..68]
    end
    # ===================================================================== #
    # Expand the type next:
    # ===================================================================== #
    case bachelor_or_master_or_diploma # case tag
    when 'B/D'
      bachelor_or_master_or_diploma = 'Bachelor/Diplom'
    when 'B/M'
      bachelor_or_master_or_diploma = 'Bachelor/Master'
    when 'B'
      bachelor_or_master_or_diploma = 'Bachelor'
    when 'M'
      bachelor_or_master_or_diploma = 'Master'
    when 'D'
      bachelor_or_master_or_diploma = 'Diplomstudium'
    when '(unknown)'
      bachelor_or_master_or_diploma = ''
    end
    bachelor_or_master_or_diploma = (
      "[#{bachelor_or_master_or_diploma.center(17)}]"
    )
    # ===================================================================== #
    # Re-format the ECTS points.
    # ===================================================================== #
    n_ects_points = " [#{n_ects.to_s.rjust(4)} ECTS]"
    # ===================================================================== #
    # Finally display it here.
    # ===================================================================== #
    result = @left_padding_to_use+
             darkseagreen(padded_index)+
             steelblue(
               name.strip.ljust(
                 PAD_TO_THE_RIGHT_FOR_INDIVIDUAL_ECTS_POINTS
               )
             )+
             chocolate(
               "[#{lecture_type.center(5)}] "
             )+
             colourize_ects(
               n_ects_points
             )+' '+
             slateblue(bachelor_or_master_or_diploma) # ← Bachelor or Master or Diploma
    if already_solved
      result << " #{yellow(COMPLETED_COURSE)}"
    end
    result << N
    e result
  }
  report_how_many_ECTS_points_were_completed
  # ======================================================================= #
  # Report the average grade next: 
  # ======================================================================= #
  report_the_average_grade
end

#report_how_many_ECTS_points_were_completedObject

#

report_how_many_ECTS_points_were_completed

#


274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/studium/exams/show_themes/misc.rb', line 274

def report_how_many_ECTS_points_were_completed
  n_ects_completed = "Total ECTS points: #{@n_ects_completed}".ljust(25)
  n_ects_completed = n_ects_completed.rjust(
    PAD_TO_THE_RIGHT_FOR_INDIVIDUAL_ECTS_POINTS + 18
  )+N
  n_ects_completed.rstrip!
  formatted_n_ects_completed = n_ects_completed
  e formatted_n_ects_completed.sub(
    /(Total ECTS points: )/,
    orange('ECTS points completed: ')
  ).sub(
    /(\d{0,3}\.\d{0,1})/, colourize_ects('\1')
  )
end

#report_no_result_was_foundObject

#

report_no_result_was_found

The opn() that is normally used, becomes a String in this method, returned by a call to the method called return_opnn().

#


411
412
413
414
415
416
417
418
419
# File 'lib/studium/exams/show_themes/misc.rb', line 411

def report_no_result_was_found
  e "#{return_opnn}#{rev}Not found any result for "\
    "#{steelblue(search_term?)}. Pass in "\
    "#{sfancy('--help')} or #{sfancy('--available?')} for#{N}"
  e "#{return_opnn}#{rev}how to use this class.#{N}"
  e "#{return_opnn}#{rev}If you wish to add an alias, modify "\
    "the method#{N}"
  e "#{return_opnn}#{rev}#{yellow('sanitize_this_topic()')}."
end

#report_that_the_dataset_is_emptyObject

#

report_that_the_dataset_is_empty

#


508
509
510
511
# File 'lib/studium/exams/show_themes/misc.rb', line 508

def report_that_the_dataset_is_empty
  e "#{ropnn(@namespace)}#{rev}The dataset is empty. Please supply "\
    "at the least one topic."
end

#report_the_average_gradeObject

#

report_the_average_grade

This method will report the average grade of all exams.

#


301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/studium/exams/show_themes/misc.rb', line 301

def report_the_average_grade
  formatted_average_grade = (
    @average_grade.sum / @average_grade.size.to_f
  ).round(2).to_s
  e
  e 'The average grade among the '+
    royalblue(@average_grade.size.to_s)+
    ' passed exams for the topic '+
    tomato(which_topic?)+' is: '+
    steelblue(formatted_average_grade)
  e
end

#resetObject

#

reset (reset tag)

#


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
# File 'lib/studium/exams/show_themes/reset.rb', line 16

def reset
  super()
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @left_padding_to_use
  # ======================================================================= #
  @left_padding_to_use = ' '
  # ======================================================================= #
  # === @allowed_themes_for_exams
  # ======================================================================= #
  _ = Studium.file_allowed_themes_for_exams
  # ======================================================================= #
  # We need to sanitize this a little bit.
  # ======================================================================= #
  @allowed_themes_for_exams = YAML.load_file(_).map {|line|
    line.tr(' ','_')
  }
  # ======================================================================= #
  # === @dataset_from_file_lecture_information
  # ======================================================================= #
  @dataset_from_file_lecture_information = return_dataset_from_file_lecture_information
  # ======================================================================= #
  # === @dataset
  #
  # This variable will contain our actual dataset that is ready for
  # display.
  # ======================================================================= #
  @dataset = nil
  # ======================================================================= #
  # === @sort_how
  #
  # How to sort the dataset by default.
  #
  # A value of nil means that this class will not do any special
  # sorting whatsoever.
  # ======================================================================= #
  @sort_how = :alphabetically
  # ======================================================================= #
  # === @average_grade
  #
  # This variable will keep track of the average grade.
  # ======================================================================= #
  @average_grade = []
end

#return_available_topicsObject

#

return_available_topics

This method will return all the available topics, in Array format.

#


330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/studium/exams/show_themes/misc.rb', line 330

def return_available_topics
  hash = @dataset_from_file_lecture_information.values # .flatten.sort.uniq
  result = hash.select {|key, value|
    themes = key['themes']
    if themes
      true
    else
      false
    end
  }.map {|entry|
    entry['themes'].compact
  }.flatten.sort.uniq
  return result
end

#runObject

#

run (run tag)

#


496
497
498
499
500
501
502
503
# File 'lib/studium/exams/show_themes/misc.rb', line 496

def run
  set_search_for_this_theme(first_argument?)
  check_whether_the_passed_theme_is_an_allowed_theme
  menu
  obtain_the_dataset_holding_matching_lectures_to_the_given_theme
  consider_sorting_the_dataset
  report
end

#search_for_this_theme?Boolean Also known as: search_which_theme?, search_term?, search_for_which_theme?, which_theme?, which_topic?

#

search_for_this_theme?

#

Returns:

  • (Boolean)


56
57
58
# File 'lib/studium/exams/show_themes/misc.rb', line 56

def search_for_this_theme?
  @search_for_this_theme
end

#set_search_for_this_theme(i) ⇒ Object

#

set_search_for_this_theme

#


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
# File 'lib/studium/exams/show_themes/misc.rb', line 137

def set_search_for_this_theme(i)
  if i.nil? or i.empty?
    report_that_the_dataset_is_empty
    exit
  end
  if i.is_a? Array
    if i.empty?
      i = :display_all_themes
    else
      i = i.join(' ').strip
    end
  end
  # ======================================================================= #
  # Replace all ' ' with '_' characters next.
  # ======================================================================= #
  if i.is_a? String
    i = i.dup if i.frozen?
    i.tr!(' ','_')
  end
  case i
  when :display_all_themes
    i = return_available_topics
  end
  unless i.start_with? '--'
    if i.is_a? Array
      i = i.map {|entry| sanitize_this_topic(entry) }
    else
      i = sanitize_this_topic(i)
    end
  end
  @search_for_this_theme = i
end

#show_available_themesObject

#

show_available_themes

This method will show which themes are available, e. g. “cellbiology” and “genetics” and so on. The resulting Array will be sorted and output alphabetically.

Invocation example:

showthemes --available?
#


357
358
359
360
361
362
363
364
# File 'lib/studium/exams/show_themes/misc.rb', line 357

def show_available_themes
  _ = return_available_topics # Obtain the available topics.
  e "#{ropnn(@namespace)}#{rev}These #{sfancy(_.size.to_s)} themes "\
    "are available:#{N}"
  _.each {|topic|
    e "  #{simp(topic)}#{N}"
  }
end

#show_help(optional_shall_we_also_exit = false) ⇒ Object

#

show_help (help tag)

To invoke this method from the commandline, do:

themes --show-help

For some more specific examples:

showexamthemes --available_themes?
#


378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/studium/exams/show_themes/misc.rb', line 378

def show_help(
    optional_shall_we_also_exit = false
  )
  case optional_shall_we_also_exit
  when true
    optional_shall_we_also_exit = true
  end
  e
  opnn
  e
  e
  opnn_in_helpsection; e '  --available_themes? # Show an overview over all '\
                         'available/registered themes'
  opnn_in_helpsection; e '  --open              # Open the .csv file '\
                         'in your editor'
  opnn_in_helpsection; e '  --bioinformatics    # Show all '\
                         'bioinformatics-related lectures.'
  opnn_in_helpsection; e '  --cellbiology       # Show all '\
                         'cellbiology-related lectures.'
  opnn_in_helpsection; e '  --genetics          # Show all '\
                         'genetics-related lectures.'
  opnn_in_helpsection; e '  --highest           # Show '\
                         'highest entry (= most ECTS) first'
  e
  exit if optional_shall_we_also_exit
end