Class: Studium::Exams::MandatoryContinuousAssessment

Inherits:
Base
  • Object
show all
Defined in:
lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb

Constant Summary collapse

N_TOKENS_FOR_THE_SPRINGREEN_SPACER =
#

N_TOKENS_FOR_THE_SPRINGREEN_SPACER

#
132

Constants inherited from Base

Base::COMMON_YEAR_DAYS_IN_MONTH, Base::LEFT_PADDING, Base::NAMESPACE, Base::N_CHARACTERS_PER_LINE

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, #be_silent, #be_verbose?, #beautiful_url, #change_directory, #cheering_person, #chmod, #cliner, #colour_for_ects_points, #colourize_percentage, #convert_this_array_of_lectures_into_the_full_dataset, #copy, #course_filter, #cpruby, #create_directory, #create_file, #csv_file?, #current_month?, #current_semester?, #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?, #does_this_line_include_an_english_weekday?, #does_this_line_start_with_a_german_weekday?, #e, #ecomment, #editor?, #ee, #egrey, #enable_colours, #enable_colours_globally, #enable_debug, #encoding?, #english_to_german_weekday, #ensure_that_a_base_directory_exists_for_this_file, #ensure_that_the_log_directory_exists, #eparse, #esystem, #etomato, #exit_program, #extract_dd_mm_yyyy, #fetch_this_curriculum, #file_important_exams?, #file_lecture_information?, #file_passed_exams_per_month, #file_read_with_proper_encoding, #filter_away_already_answered_questions, #filter_away_invalid_questions, #filter_for_all_passed_exams, #find_corresponding_exam_topic, #from_curriculum_id_to_university, #german_date_notation, #german_weekday?, #german_weekdays?, #german_weekend_for?, #german_yes_or_no, #has_a_bachelor_and_a_master_curriculum?, #has_a_bachelor_curriculum?, #has_a_master_curriculum?, #has_lva_dates_registered?, #has_this_exam_topic_been_solved?, #has_year_entry?, #hh_mm_ss_dd_mm_yyyy, #horizontal_bar?, #html_log_directory?, #infer_the_namespace, #initialize_the_internal_hash, #internal_hash?, #is_a_master_lecture?, #is_a_registered_curriculum?, #is_a_weekday?, #is_connected_to_the_www?, #is_german_weekday?, #is_on_roebe?, #is_prüfungsimmanent?, #is_this_a_registered_exam_topic?, #is_this_a_valid_html_colour?, #is_this_day_today?, #is_this_lecture_a_practical_course?, #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, #left_arrow?, #load_yaml_dataset, #map_input_to_this_curriculum_filename, #move_file, #n_days_difference_from_today_to_this_day, #n_seconds_to_n_days, #namespace?, #no_ext_name, #no_file_exists_at, #number_to_month, #obtain, #obtain_lectures_from_this_curriculum, #open_in_browser, #open_in_editor, #opne, #opnerev, #opnn, #padded_current_month?, #parse_dd_mm_yyyy, #parse_this_line_for_date_entry, #path_to_exam_topic?, #project_yaml_directory?, #rds, #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, #require_open_uri, #reset_the_internal_state, #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, #right_arrow?, #rinstall2, #roebe_exam_directory?, #roebe_path_to_file_lecture_information?, #ruby_src_dir_at_home?, #sanitize_this_topic, #sanitize_url, #select_for_prüfungsimmanente_LVs, #select_lectures_with_this_key, #set_be_verbose, #set_this_cd_alias_to, #set_xorg_buffer, #sfancy, #shall_we_make_use_of_unicode_symbols?, #show_todays_date, #silently_open_in_browser, #simp, #sort_these_lecture_names_by_time, #spacer, #studium_log_dir?, #this_month_has_n_days?, #total_ects_points_passed, #translate_dd_mm_yyyy_to_weekday, #try_to_require_html_templates, #try_to_require_the_open_gem, #try_to_require_the_rcfiles, #try_to_require_the_verbose_truth_gem, #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, #yaml_dir?, #yellowrev, #yes_or_no

Methods included from RunmodeModule

#commandline?, #runmode?, #set_commandline_mode, #set_runmode, #set_www_mode, #www_mode?

Methods included from CommandlineArgumentsModule

#commandline_arguments?, #commandline_arguments_joined, #commandline_arguments_with_hyphens?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_non_hyphen_argument?, #reset_the_commandline_arguments, #set_commandline_arguments, #set_first_argument

Methods included from HtmlColoursModule

#aquamarine, #blanchedalmond, #brown, #cadetblue, #chocolate, #coral, #cornflowerblue, #crimson, #cyan, #darkblue, #darkcyan, #darkgoldenrod, #darkgreen, #darkkhaki, #darkolivegreen, #darkorange, #darkred, #darkseagreen, #darkslateblue, #darkslategray, #darkturquoise, #deepskyblue, #firebrick, #forestgreen, #gold, #goldenrod, #green, #grey, #indianred, #khaki, #lavender, #lawngreen, #lightblue, #lightcoral, #lightgreen, #lightred, #lightseagreen, #lightskyblue, #lightslategray, #lightslategrey, #lime, #limegreen, #mediumaquamarine, #mediumblue, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mediumvioletred, #mintcream, #moccasin, #oldlace, #olive, #olivedrab, #orange, #orangered, #orchid, #palegoldenrod, #palegreen, #paleturquoise, #palevioletred, #peru, #plum, #powderblue, #red, #rosybrown, #royalblue, #saddlebrown, #salmon, #sandybrown, #seagreen, #sienna, #silver, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #tan, #teal, #thistle, #tomato, #turquoise, #violet, #whitesmoke, #yellow, #yellowgreen

Methods included from Colours

#bold_blue, #bold_red, #bold_yellow, cadetblue, #cadetblue, #chartreuse, #coral, coral, #cornflowerblue, cornflowerblue, crimson, #cyan, cyan, darkgoldenrod, #darkgoldenrod, #darkgray, darkgreen, darkolivegreen, darkseagreen, #darkslateblue, darkslateblue, #darkslategray, darkslategray, #darkturquoise, darkturquoise, #deepskyblue, deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #erev, #ewarn, #forestgreen, forestgreen, gold, #goldenrod, goldenrod, #grey, grey, indianred, #indianred, khaki, #khaki, lawngreen, #lawngreen, lightblue, lightgreen, lightsalmon, #lightseagreen, lightseagreen, lightskyblue, #lightskyblue, #lightslategray, lightslategray, #lightsteelblue, lime, #lime, limegreen, #limegreen, #mediumaquamarine, mediumaquamarine, #mediumorchid, #mediumpurple, mediumpurple, #mediumseagreen, mediumseagreen, #mediumslateblue, mediumslateblue, #mediumspringgreen, mediumspringgreen, #mediumturquoise, mediumturquoise, #oldlace, olive, #olive, olivedrab, #olivedrab, orange, orangered, #orchid, orchid, palegreen, #palegreen, paleturquoise, #paleturquoise, palevioletred, #papayawhip, peru, #peru, plum, #plum, #powderblue, powderblue, rev, #rev?, royalblue, saddlebrown, #saddlebrown, #sandybrown, sandybrown, sdir, #sdir, seagreen, #seagreen, sfancy, #sfancy, sfile, #sfile, #simp, simp, #skyblue, skyblue, slateblue, #slategray, slategray, springgreen, #springgreen, #steelblue, steelblue, #swarn, swarn, #tan, tan, teal, #teal, #tomato, tomato, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow, yellowgreen, #yellowgreen

Constructor Details

#initialize(i = ARGV, run_already = true) ⇒ MandatoryContinuousAssessment

#

initialize

#


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
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 38

def initialize(
    i           = ARGV,
    run_already = true
  )
  reset
  set_commandline_arguments(i)
  case run_already
  # ======================================================================= #
  # === :do_not_run_yet
  # ======================================================================= #
  when :do_not_run_yet,
       :dont_run_yet
    run_already = false
  end
  # ======================================================================= #
  # === Handle blocks given to this class
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :do_not_report_the_title
    # ===================================================================== #
    when :do_not_report_the_title
      do_not_show_the_title_of_the_curriculum
    # ===================================================================== #
    # === :do_not_report_anything
    # ===================================================================== #
    when :do_not_report_anything
      do_not_report_anything
    end
  end
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Studium::Exams::MandatoryContinuousAssessment[]

#


1314
1315
1316
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1314

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

Instance Method Details

#available_curricula?Boolean

#

available_curricula?

#

Returns:

  • (Boolean)


387
388
389
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 387

def available_curricula?
  ARRAY_REGISTERED_CURRICULA
end

#bachelor_or_master(i) ⇒ Object

#

bachelor_or_master

This method will return a String, either “Bachelor” or “Master” or “Bachelor/Master”.

#


511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 511

def bachelor_or_master(i)
  result = ''.dup
  if is_a_bachelor_lecture?(i)
    result << 'Bachelor'
  end
  if has_a_master_curriculum?(i) # is_a_master_lecture?(i) # ← Changed this in January 2023.
    unless result.empty?
      result << '/'
    end
    result << 'Master'
  end
  return result
end

#consider_displaying_the_title_of_the_curriculumObject

#

consider_displaying_the_title_of_the_curriculum

#


256
257
258
259
260
261
262
263
264
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 256

def consider_displaying_the_title_of_the_curriculum
  if show_the_title_of_the_curriculum? and be_verbose?
    _ = title?
    if _
      e sfancy(_)
      e
    end
  end
end

#dataset?Boolean

#

dataset

#

Returns:

  • (Boolean)


394
395
396
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 394

def dataset?
  @internal_hash[:dataset]
end

#display_split_line?Boolean

#

display_split_line?

#

Returns:

  • (Boolean)


150
151
152
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 150

def display_split_line?
  @internal_hash[:display_split_line]
end

#display_these_lectures_sorted_by_priority(i, priority_to_use = [5,4,3,2,1]) ⇒ Object

#

display_these_lectures_sorted_by_priority

Do note that we will actually sort in two ways in this method:

- First, by priority, which can have values from 1 up to 5
- Second, by the amount of ECTS points. Lectures that have
  more ECTS points will be displayed first.
#


429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
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
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 429

def display_these_lectures_sorted_by_priority(
    i, priority_to_use = [5,4,3,2,1]
  )
  if priority_to_use.is_a? Array
    priority_to_use.each {|entry|
      # =================================================================== #
      # Call this method recursively.
      # =================================================================== #
      display_these_lectures_sorted_by_priority(i, entry)
    }
  else
    if be_verbose?
      # =================================================================== #
      # Show a little header, to notify the user which Priority-setting
      # is currently shown.
      # =================================================================== #
      smiley_face = ''
      if use_unicode_symbols? and Object.const_defined?(:Roebe)
        smiley_face = lightseagreen(Roebe.smiley_face)
      end
      e sfancy("Priority #{priority_to_use.to_s}: #{smiley_face}")
      e
    end
    matching_priority = i.select {|a, b| b[:priority] == priority_to_use }
    counter = 0
    sorted_by_n_ECTS_points_of_matching_priority = matching_priority.sort_by {|a, b|
      b[:ects]
    }.reverse
    sorted_by_n_ECTS_points_of_matching_priority.each {|name, inner_hash| counter += 1
      name = name.first if name.is_a? Array
      n_ects_points     = inner_hash[:ects]
      university        = inner_hash[:university]
      lecture_type      = inner_hash[:type]
      summer_or_winter  = inner_hash[:semester]
      outdated_lecture  = inner_hash[:outdated_lecture]
      next if outdated_lecture == true
      curricula_entries = obtain(:curricula_entries, inner_hash)
      currently_participating_in_this_course = inner_hash[:currently_participating_in_this_course]
      if currently_participating_in_this_course
        # ================================================================= #
        # Lectures that we are presently doing in the current semester
        # will be shown in skyblue rather than slateblue.
        # ================================================================= #
        colourized_name_of_the_lecture = skyblue(name)
      else
        colourized_name_of_the_lecture = slateblue(name)
      end
      # =================================================================== #
      # Colourize the ECTS points, in seagreen and lightseeagreen.
      # Also show the lecture type and the university.
      # =================================================================== #
      colourized_n_ects_points = seagreen('(n ECTS: '+n_ects_points.to_s+', ')+
                                 lightseagreen(lecture_type)+ # <- Display the lecture type here.
                                 seagreen(', ')
      unless summer_or_winter.nil?
        colourized_summer_or_winter = mediumseagreen(summer_or_winter.to_s)
        colourized_n_ects_points << colourized_summer_or_winter+
                                    seagreen(', ')
      end
      colourized_n_ects_points << olivedrab(university)
      colourized_n_ects_points << seagreen(', ')
      colourized_n_ects_points << crimson(bachelor_or_master(curricula_entries))
      # =================================================================== #
      # Add the closing ')' next.
      # =================================================================== #
      colourized_n_ects_points << seagreen(')')
      if be_verbose?
        e slategray(counter.to_s.rjust(2))+'  '+
          colourized_name_of_the_lecture+' '+
          colourized_n_ects_points
      end
    }
    e if be_verbose?
  end
end

#display_this_array_including_only_mandatory_continuous_assessment_lectures(array, be_verbose = be_verbose? ) ⇒ Object

#

display_this_array_including_only_mandatory_continuous_assessment_lectures

The input to this method will be an Array of mandatory continuous assessment lectures.

#


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
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
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 160

def display_this_array_including_only_mandatory_continuous_assessment_lectures(
    array,
    be_verbose = be_verbose?
  )
  case be_verbose
  # ======================================================================= #
  # === nil
  # ======================================================================= #
  when nil
    be_verbose = be_verbose?
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  when :be_verbose
    be_verbose = true
  end
  consider_displaying_the_title_of_the_curriculum
  # ======================================================================= #
  # Sometimes the input may be a String. In this case, split it up.
  # ======================================================================= #
  if array.is_a? String
    array = return_entries_that_are_of_mandatory_continuous_assessment_type(
      array.split(N)
    )
  end
  # ======================================================================= #
  # Next we can display the result.
  # ======================================================================= #
  sorted_array = array.map {|line|
    line.delete('"')
  }.sort
  sorted_array.each {|line|
    # ===================================================================== #
    # Up to 05.11.2019 this code used to read in the content of a file,
    # but since that day we will instead obtain the information from
    # the file called "lecture_information.yml" instead. A useful
    # side-effect of this is that this approach should be faster
    # than using regexes.
    # ===================================================================== #
    line.strip!
    if line.include? '#'
      line = line[0 .. (line.index('#')-1)]
      line.strip!
    end
    line.squeeze!(' ')
    if dataset?[line].nil?
      opne 'A nil-value was found, for line '+steelblue(line)+'.'
      opne 'Continuing nonetheless.'
      #exit
    else
      n_ects_points = dataset?[line][:ects]
      type_of_the_lecture = dataset?[line][:type]
      # ===================================================================== #
      # Instantly ensure that we have a valid amount of ECTS points.
      # ===================================================================== #
      if n_ects_points == 0.0
        opne swarn('We encountered a problem, a 0.0 ECTS lecture, at: ')+
             lightgreen(line)
      end
      # ===================================================================== #
      # Left-pad the lecture ID.
      # ===================================================================== #
      if line.include? ' '
        splitted = line.split(' ')
        splitted[0] = splitted[0].ljust(7)
        name = splitted.join(' ')
      end
      @internal_hash[:total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum] += n_ects_points
      if be_verbose
        e '  '+orange(
            name.ljust(93)
          )+' '+mediumpurple(
            n_ects_points.to_s.rjust(4)
          )+' ECTS points '+
          seagreen(type_of_the_lecture.to_s.rjust(4)) # <- Last part is type of the lecture.
      end
    end
  }
  e if be_verbose
  do_calculate_the_percentage
  # ======================================================================= #
  # Next, report the total amount of ECTS and some more information.
  # ======================================================================= #
  if be_verbose
    e 'Total amount of ECTS points: '+
       crimson(total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum?.to_s)+
       lightblue(' (== ')+
       seagreen(n_percent?.round(2).to_s+'%')+
       lightblue(' of '+total_amount_of_ECTS_points_in_the_curriculum?.to_s+
       ' ECTS points in total)')
  end
end

#do_assume_120_ects_pointsObject

#

do_assume_120_ects_points

#


699
700
701
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 699

def do_assume_120_ects_points
  @internal_hash[:total_amount_of_ECTS_points_in_the_curriculum] = 120
end

#do_assume_180_ects_pointsObject

#

do_assume_180_ects_points

#


545
546
547
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 545

def do_assume_180_ects_points
  @internal_hash[:total_amount_of_ECTS_points_in_the_curriculum] = 180
end

#do_assume_300_ects_pointsObject Also known as: do_assume_300_points

#

do_assume_300_ects_points

#


692
693
694
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 692

def do_assume_300_ects_points
  @internal_hash[:total_amount_of_ECTS_points_in_the_curriculum] = 300
end

#do_calculate_the_percentage(n_ects_in_mandatory_courses = total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum?, , n_total_ects_points_in_the_curriculum = total_amount_of_ECTS_points_in_the_curriculum? ) ⇒ Object

#

do_calculate_the_percentage

This method will calculate the percentage of ects points in courses with mandatory-attendance.

#


1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1268

def do_calculate_the_percentage(
    n_ects_in_mandatory_courses           = total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum?,
    n_total_ects_points_in_the_curriculum = total_amount_of_ECTS_points_in_the_curriculum?
  )
  n_percent = (
    n_ects_in_mandatory_courses.to_f * 100
  ) / n_total_ects_points_in_the_curriculum
  # ======================================================================= #
  # Note that this method will also set the percentage.
  # ======================================================================= #
  set_percentage(n_percent) # Set the percentage here as well.
end

#do_compare_the_registered_curricula(show_details = false) ⇒ Object

#

do_compare_the_registered_curricula

This method can be used to compare different curricula for their mandatory ECTS points, in a batch-processive manner.

To invoke this method from the commandline, do:

mandatory --compare
#


573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 573

def do_compare_the_registered_curricula(
    show_details = false
  )
  do_not_report_any_findings
  # ======================================================================= #
  # Do not use the combined bachelor-master vector curriculum though.
  # The following method-call ensures that.
  # ======================================================================= #
  report_these_curricula = ::Studium.return_registered_standalone_curricula
  report_these_curricula << :indi1
  report_these_curricula << :indi2
  report_these_curricula << :indi3
  report_these_curricula << :indi4
  e
  e "#{rev}  Comparing the number of ECTS points assigned to "\
    "mandatory-presence"
  e '  courses in different curricula:'
  e
  # ======================================================================= #
  # Iterate over these curricula next:
  # ======================================================================= #
  report_these_curricula.each_with_index {|this_curriculum, index| index += 1
    # ===================================================================== #
    # We will next delegate towards class MandatoryContinuousAssessment,
    # which will tell us how many ECTS points are mandatory.
    #
    #   bl MandatoryContinuousAssessment
    #
    # ===================================================================== #
    _ = Studium::Exams::MandatoryContinuousAssessment.new(this_curriculum) { :do_not_report_anything }
    n_ects_points_that_are_mandatory = _.n_mandatory_ects_points_in_this_curriculum?.to_s.rjust(5)
    n_ects_points_in_total_in_this_curriculum = _.n_total_ects_points
    title_of_the_curriculum = _.title?(this_curriculum)
    if title_of_the_curriculum.nil?
      # =================================================================== #
      # Report missing title next:
      # =================================================================== #
      e "This curriculum (#{sfancy(this_curriculum)}) has no title."
      e 'This is currently not allowed. Please correct this error in that .yml file.'
      exit
    end
    if title_of_the_curriculum and title_of_the_curriculum.is_a?(String)
      title_of_the_curriculum = title_of_the_curriculum.dup if title_of_the_curriculum.frozen?
      title_of_the_curriculum.strip!
    end
    # ===================================================================== #
    # If the title of the curriculum is too long, chop it down.
    # ===================================================================== #
    threshold_value = 55
    title_of_the_curriculum = ''.dup if title_of_the_curriculum.nil?
    if title_of_the_curriculum.size > threshold_value
      title_of_the_curriculum = "#{title_of_the_curriculum[0 .. threshold_value]} [...]"
    end
    if title_of_the_curriculum.include? 'Master'
      if display_split_line?
        # ================================================================= #
        # Display a horizontal-line next, coloured in springgreen, as
        # visual separator:
        # ================================================================= #
        e springgreen(
            '  '+('-' * N_TOKENS_FOR_THE_SPRINGREEN_SPACER)
          )
        @internal_hash[:display_split_line] = false # We already displayed it once.
      end
    end
    padded_index = " (#{index}".rjust(4)+') '
    colourized_and_padded_index = mediumpurple(padded_index)
    formatted_percentage_value  = _.percentage?.round(2).to_s.ljust(5,'0')
    # ===================================================================== #
    # Pad the title of the curriculum a little next:
    # ===================================================================== #
    padded_title_of_the_curriculum = title_of_the_curriculum.ljust(threshold_value+7)
    n_percent_solved = Studium.n_percent_solved_in_this_curriculum(this_curriculum)
    # ===================================================================== #
    # We will display the two major individual curricula, about "Vektorsysteme",
    # in a slightly brighter colour:
    # ===================================================================== #
    if padded_title_of_the_curriculum.include? 'Vektor'
      colourized_and_padded_title_of_the_curriculum = mediumturquoise(padded_title_of_the_curriculum)
    else
      colourized_and_padded_title_of_the_curriculum = sfancy(padded_title_of_the_curriculum)
    end
    # ===================================================================== #
    # First comes the index, then the title of the curriculum at hand.
    # The index is presently colourized in 'mediumpurple'.
    # ===================================================================== #
    e colourized_and_padded_index+ # <- First show the colourized and padded index.
      colourized_and_padded_title_of_the_curriculum+
      powderblue(n_ects_points_that_are_mandatory)+' ECTS in '+
      seagreen('mandatory-courses')+' (total ECTS: '+
      powderblue(n_ects_points_in_total_in_this_curriculum.to_s)+
      ', '+slateblue(formatted_percentage_value+'%')+' share'+
      ', '+seagreen(n_percent_solved.round(1).to_s.rjust(4)+'%')+' solved'+
      ')'
    # ===================================================================== #
    # Enter this clause if the user wants to show some more details.
    # ===================================================================== #
    case show_details
    # ===================================================================== #
    # === :show_more_details_but_without_the_title
    #
    # This variant will show more details, that is, every course will be 
    # shown on a new line each.
    # ===================================================================== #
    when :show_more_details_but_without_the_title
      Studium::Exams::MandatoryContinuousAssessment.new(this_curriculum) { :do_not_report_the_title } 
    # ===================================================================== #
    # === :show_details
    # ===================================================================== #
    when :show_details,
         :show_more_details
      Studium::Exams::MandatoryContinuousAssessment.new(this_curriculum)
    end 
  }; e
end

#do_compare_the_registered_curricula_quickly(i = :show_more_details_but_without_the_title) ⇒ Object

#

do_compare_the_registered_curricula_quickly

#


552
553
554
555
556
557
558
559
560
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 552

def do_compare_the_registered_curricula_quickly(
    i = :show_more_details_but_without_the_title
  )
  cliner { :mediumaquamarine }
  Studium.return_registered_standalone_curricula.each {|this_curriculum|
    do_determine_the_prüfungsimmanente_ECTS_of_this_curriculum(this_curriculum)
  }
  cliner { :mediumaquamarine }
end

#do_determine_the_prüfungsimmanente_ECTS_of_this_curriculum(i, optional_index = nil, be_verbose = be_verbose? ) ⇒ Object Also known as: try_to_find_this_curriculum

#

do_determine_the_prüfungsimmanente_ECTS_of_this_curriculum

#


1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1185

def do_determine_the_prüfungsimmanente_ECTS_of_this_curriculum(
    i,
    optional_index = nil,
    be_verbose     = be_verbose?
  )
  i = i.to_s # To avoid Symbols.
  dataset = dataset?
  @internal_hash[:total_amount_of_ECTS_points_in_the_curriculum] = 0
  curriculum_dataset = fetch_this_curriculum(i) { :be_quiet }
  @internal_hash[:total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum] = 0
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    when :be_verbose
      be_verbose = true
    end
  end
  if optional_index and be_verbose
    # ===================================================================== #
    # Report the curriculum number in this case as well.
    # ===================================================================== #
    e
    e springgreen('Curriculum number: ')+
      slateblue(optional_index.to_s)+
      limegreen(" (#{name_of_the_curriculum?})")
    e
  end
  if curriculum_dataset
    if be_verbose and show_the_title_of_the_curriculum?
      print steelblue(
              (
                return_title_from_this_curriculum_file(i)+'  '
              ).ljust(58)
            )
    end
    curriculum_dataset.each {|name_of_the_lecture|
      pointer = dataset[name_of_the_lecture]
      if pointer.nil?
        e tomato('Nil value for ')+
          steelblue(name_of_the_lecture)
      else
        n_ECTS = pointer[:ects]
        type   = pointer[:type]
        if is_this_a_prüfungsimmanent_course?(type)
          @internal_hash[:total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum] += n_ECTS
        end
        @internal_hash[:total_amount_of_ECTS_points_in_the_curriculum] += n_ECTS
      end
    }
    do_calculate_the_percentage
    formatted_percentage_value = percentage?.round(2).to_s.ljust(5,'0')
    n_percent_solved = Studium.n_percent_solved_in_this_curriculum(i)
    if be_verbose?
      e "#{lightblue(n_prüfungsimmanente_ECTS?)}"\
        " #{lightblue('ECTS')} "+
        moccasin('out of')+
        " "+
        royalblue(@internal_hash[:total_amount_of_ECTS_points_in_the_curriculum].to_s.rjust(5))+" "+
        moccasin('ECTS - ')+
        (
          slateblue(formatted_percentage_value+'%')+
          moccasin(' mandatory-presence share ')+
          moccasin('and ')+
          seagreen(
            n_percent_solved.round(1).to_s.rjust(4)
          )+
          moccasin('% solved already.')
        )
    end
  else
    opne "Could not find anything for the given input `#{steelblue(i)}`."
  end
end

#do_not_report_any_findingsObject Also known as: do_not_report_anything

#

do_not_report_any_findings

#


352
353
354
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 352

def do_not_report_any_findings
  set_be_quiet
end

#do_not_show_the_title_of_the_curriculumObject

#

do_not_show_the_title_of_the_curriculum

#


380
381
382
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 380

def do_not_show_the_title_of_the_curriculum
  @internal_hash[:show_the_title_of_the_curriculum] = false
end

#do_show_all_passed_mandatory_continuous_assessmentsObject

#

do_show_all_passed_mandatory_continuous_assessments

This method will show all “prüfungsimmanente” Lehrveranstaltungen.

#


1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1010

def do_show_all_passed_mandatory_continuous_assessments
  obtain_default_dataset
  # ======================================================================= #
  # Next, grab all entries that are "prüfungsimmanent". These are those
  # types that are part of the array-constant, so, UE, PS, SE, LU and
  # so forth. These all have mandatory continuous assessment parts.
  # ======================================================================= #
  set_result dataset?.select {|line|
    splitted = line.split('|').map(&:strip)
    lecture_type = splitted[6] # <- This is the right entry.
    is_included = ARRAY_LECTURE_TYPES_THAT_ARE_MANDATORY_CONTINUOUS_ASSESSMENT.include? lecture_type
    is_included
  }
  report_result # Report it as we assigned the result above.
end

#do_show_all_passed_mandatory_continuous_assessments_from_this_year(the_year) ⇒ Object

#

do_show_all_passed_mandatory_continuous_assessments_from_this_year

The input argument denotes the year. If the exam was passed in that year, then it will be shown.

Invocation example:

mandatory --2017
#


818
819
820
821
822
823
824
825
826
827
828
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 818

def do_show_all_passed_mandatory_continuous_assessments_from_this_year(the_year)
  obtain_default_dataset
  set_result dataset?.select {|line|
    splitted = line.split('|').map(&:strip)
    year = splitted.first.strip.split('.').last
    lecture_type = splitted[6] # <- This is the right entry.
    ARRAY_LECTURE_TYPES_THAT_ARE_MANDATORY_CONTINUOUS_ASSESSMENT.include?(lecture_type) &&
    (the_year == year) # Make the year-check here. 
  }
  report_result # Report it as we assigned the result above.
end

#do_show_the_title_of_the_curriculumObject

#

do_show_the_title_of_the_curriculum

#


373
374
375
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 373

def do_show_the_title_of_the_curriculum
  @internal_hash[:show_the_title_of_the_curriculum] = true
end

#epowderblue(i) ⇒ Object

#

epowderblue

#


987
988
989
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 987

def epowderblue(i)
  e powderblue(i) if be_verbose?
end

#filter_for_lectures_at_the_BOKUObject

#

filter_for_lectures_at_the_BOKU

#


785
786
787
788
789
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 785

def filter_for_lectures_at_the_BOKU
  dataset?.select! {|name_of_the_lecture, hash_inner_dataset|
    hash_inner_dataset[:university] == 'BOKU'
  }
end

#filter_for_lectures_at_the_TU_ViennaObject

#

filter_for_lectures_at_the_TU_Vienna

#


794
795
796
797
798
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 794

def filter_for_lectures_at_the_TU_Vienna
  dataset?.select! {|name_of_the_lecture, hash_inner_dataset|
    hash_inner_dataset[:university] == 'TU Vienna'
  }
end

#filter_for_lectures_during_the_summer(this_semester = 'summer') ⇒ Object

#

filter_for_lectures_during_the_summer

This method will filter for lectures during summer - in other words, lectures that are during winter, will specifically be excluded.

#


1287
1288
1289
1290
1291
1292
1293
1294
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1287

def filter_for_lectures_during_the_summer(
    this_semester = 'summer'
  )
  dataset?.select! {|name_of_the_lecture, hash_inner_dataset|
    (hash_inner_dataset[:semester] == this_semester) or
    (hash_inner_dataset[:semester] == 'both') # Allowed since as of February 2023.
  }
end

#filter_for_lectures_during_the_winter(this_semester = 'winter') ⇒ Object

#

filter_for_lectures_during_the_winter

This method will filter for lectures during winter - in other words, lectures that are during summer, will specifically be excluded.

#


1302
1303
1304
1305
1306
1307
1308
1309
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1302

def filter_for_lectures_during_the_winter(
    this_semester = 'winter'
  )
  dataset?.select! {|name_of_the_lecture, hash_inner_dataset|
    (hash_inner_dataset[:semester] == this_semester) or
    (hash_inner_dataset[:semester] == 'both') # Allowed since as of February 2023.
  }
end
#

menu (menu tag)

#


843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 843

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # (case tag)
    # ===================================================================== #
    # === mandatory --summer
    # ===================================================================== #
    when /^-?-?s(u|o)?mmer$/i
      filter_for_lectures_during_the_summer
    # ===================================================================== #
    # === mandatory --winter
    # ===================================================================== #
    when /^-?-?winter$/i
      filter_for_lectures_during_the_winter
    # ===================================================================== #
    # === mandatory --do-compare-the-registered-curricula-quickly
    #
    # This entry point was added in December 2022.
    # ===================================================================== #
    when /^-?-?do(-|_)?compare(-|_)?the(-|_)?registered(-|_)?curricula(-|_)?quickly$/i
      do_compare_the_registered_curricula_quickly
      exit
    # ===================================================================== #
    # === mandatory --upcoming
    # ===================================================================== #  
    when /^-?-?upcoming$/i,
         /^-?-?todo$/i,
         /^-?-?next$/i,
         /^-?-?show(-|_)?all$/i
      show_upcoming_mandatory_continuous_assessments { commandline_arguments? }
      exit
    # ===================================================================== #
    # === mandatory --compare
    # ===================================================================== #
    when /^-?-?compare$/i
      do_compare_the_registered_curricula
      exit
    # ===================================================================== #
    # === mandatory --show-all-passed-mandatory-continuous-assessments
    # ===================================================================== #
    when /^-?-?show(-|_)?all(-|_)?passed(-|_)?mandatory(-|_)?continuous(-|_)?assessments$/i,
         /^-?-?all$/i
      do_show_all_passed_mandatory_continuous_assessments
    # ===================================================================== #
    # === mandatory --boku --summer
    # ===================================================================== #
    when /^-?-?BOKU$/i
      filter_for_lectures_at_the_BOKU
    # ===================================================================== #
    # === mandatory --tuwien --summer
    # ===================================================================== #
    when /^-?-?tuwien$/i,
         /^-?-?tuvienna$/i
      filter_for_lectures_at_the_TU_Vienna
    # ===================================================================== #
    # === mandatory_assessment --all
    #
    # Show all the mandatory continuous assessment lectures that were
    # passed so far.
    # ===================================================================== #
    when /-?-?all$/i,
         /-?-?everything$/i,
         /-?-?default$/i
      @internal_hash[:use_spacer_to_separate_a_new_year] = true
      :show_all_passed_mandatory_continuous_assessments
    # ===================================================================== #
    # === mandatory --only-wintersemester
    # ===================================================================== #
    when /^-?-?only(-|_)?wintersemester$/i,
         /^-?-?wintersemester$/i
      dataset?.select! {|a,b|
        semester = obtain(:semester, b, :be_quiet)
        semester == 'winter'
      }
      show_upcoming_mandatory_continuous_assessments(
        dataset?
      )
    # ===================================================================== #
    # === mandatory_assessment --all_curricula
    #
    # Show all the different curricula - at the least those that were
    # registered in the main Array.
    # ===================================================================== #
    when /-?-?all(_|-)?curricula$/i
      show_all_available_curricula
    # ===================================================================== #
    # === mandatory_assignment --2018
    # ===================================================================== #
    when /^-?-?(\d{4})$/
      the_year = $1.to_s.dup
      do_show_all_passed_mandatory_continuous_assessments_from_this_year(the_year)
      exit
    # ===================================================================== #
    # === mandatory_assessment --available
    # ===================================================================== #
    when /-?-?available/
      e; available_curricula?.each {|entry| e "  - #{sfancy(entry)}" }; e
    # ===================================================================== #
    # === mandatory_assessment --help
    # ===================================================================== #
    when /help/
      show_help
      exit
    # ===================================================================== #
    # === mandatory --compare-details
    #
    # This variant is different to --compare in that we will get a good
    # overview of the individual lectures as well.
    # ===================================================================== #
    when /^-?-?compare(-|_)?details?$/i,
         /^-?-?compare(-|_)?stats$/i,
         /^-?-?details$/i
      do_compare_the_registered_curricula(
        :show_more_details_but_without_the_title
      )
      exit
    end
  end
end

#n_ects_points(i = 120) ⇒ Object

#

n_ects_points

This method can be used to directly set the amount of ECTS points in the given curriculum.

#


836
837
838
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 836

def n_ects_points(i = 120)
  @internal_hash[:total_amount_of_ECTS_points_in_the_curriculum] = i.to_i
end

#obtain_default_datasetObject

#

obtain_default_dataset

Simply assign the default dataset, from the file with the passed exams, to the instance variable @dataset.

#


142
143
144
145
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 142

def obtain_default_dataset
  @internal_hash[:dataset] =
    ::Studium.sanitized_dataset_from_file_passed_exams_per_month
end

#padded_display_this_array_including_only_mandatory_continuous_assessment_lectures(array, be_verbose_in_the_subsequent_method_call = nil) ⇒ Object

#

padded_display_this_array_including_only_mandatory_continuous_assessment_lectures

#


409
410
411
412
413
414
415
416
417
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 409

def padded_display_this_array_including_only_mandatory_continuous_assessment_lectures(
    array, be_verbose_in_the_subsequent_method_call = nil
  )
  e if be_verbose?
  display_this_array_including_only_mandatory_continuous_assessment_lectures(
    array, be_verbose_in_the_subsequent_method_call
  )
  e if be_verbose?
end

#percentage?Boolean Also known as: n_percent?

#

percentage?

#

Returns:

  • (Boolean)


1001
1002
1003
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1001

def percentage?
  @internal_hash[:percentage]
end

#report_result(_ = result? ) ⇒ Object Also known as: report

#

report_result

Note that by default, this works on the variable @result. So if you modify that variable, you are already half-way done. Otherwise, if you need another dataset, you can pass in another dataset as an argument to this method.

#


1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1055

def report_result(
    _ = result?
  )
  if be_verbose?
    if _
      total_ects = 0
      n_ects_in_this_year = 0
      last_year = Time.now.year
      e; _.each_with_index {|line, index|
        # =================================================================== #
        # A line may look like this:
        #   21.04.2015 | 2.0 | 2.0 | 1 | UniWien | B | UE | 300632 | 2016S | Übungen zu Grundlagen in der Bioinformatik\n
        # =================================================================== #
        index               += 1
        splitted             = line.split('|').map(&:strip)
        name                 = splitted.last # The name of the lecture.
        exam_date            = splitted.first
        the_year             = exam_date.split('.').last.to_i
        lecture_type         = splitted[6]
        n_ects               = splitted[2].to_f # Amount of ECTS points.
        n_ects_in_this_year += n_ects
        total_ects          += n_ects
        padded_name          = name.ljust(90)
        if @internal_hash[:use_spacer_to_separate_a_new_year] and
          !(the_year == last_year)
          # =============================================================== #
          # Show a little coloured spacer next:
          # =============================================================== #
          show_coloured_spacer {{ n_ects: n_ects_in_this_year }}
          n_ects_in_this_year = 0 # And reset it again.
          last_year = the_year
        end
        # ================================================================= #
        # Report our findings finally. This begins with a leading
        # index in orange colour.
        # ================================================================= #
        e orange((index.to_s+')').rjust(4))+' '+
          padded_name+
          turquoise(' ('+exam_date.to_s+')')+' '+
          crimson(lecture_type.center(5))+' '+
          royalblue(n_ects.to_s.rjust(4)+' ECTS')
      }; e
      e "In total we completed #{violet(total_ects.to_s)} ECTS "\
        "points in #{orange(_.size.to_s)} different courses."
      e
    end
  end
end

#resetObject

#

reset (reset tag)

#


76
77
78
79
80
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 76

def reset
  super()
  infer_the_namespace
  reset_this_instance
end

#reset_this_instanceObject

#

reset_this_instance

#


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
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 85

def reset_this_instance
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  reset_the_internal_hash
  # ======================================================================= #
  # === :total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum
  #
  # The following ivar keeps track of how many ECTS points
  # are "prüfungsimmanent" in that curriculum.
  # ======================================================================= #
  @internal_hash[:total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum] = 0
  # ======================================================================= #
  # === :dataset
  # ======================================================================= #
  @internal_hash[:dataset] = dataset_from_file_lecture_information
  # ======================================================================= #
  # === :show_the_title_of_the_curriculum
  # ======================================================================= #
  @internal_hash[:show_the_title_of_the_curriculum] = true
  # ======================================================================= #
  # === :total_amount_of_ECTS_points_in_the_curriculum
  # ======================================================================= #
  @internal_hash[:total_amount_of_ECTS_points_in_the_curriculum] = 180
  # ======================================================================= #
  # === :percentage
  #
  # This variable stores how much percentage from the ECTS was passed.
  # ======================================================================= #
  @internal_hash[:percentage] = 0.0
  # ======================================================================= #
  # === :use_spacer_to_separate_a_new_year
  # ======================================================================= #
  @internal_hash[:use_spacer_to_separate_a_new_year] = false
  # ======================================================================= #
  # === :result
  #
  # Store the result of this class in this instance variable.
  # ======================================================================= #
  @internal_hash[:result] = nil
  # ======================================================================= #
  # === @display_split_line
  #
  # The next instance variable may display a colourized line, if set to
  # true, which will make it easier to visually distinguish between
  # Bachelor and Master-curricula. I like this so I have set it to
  # true, but others may want to not use it, hence why I made it a flag.
  # ======================================================================= #
  @internal_hash[:display_split_line] = true
end

#return_entries_that_are_of_mandatory_continuous_assessment_type(i) ⇒ Object

#

return_entries_that_are_of_mandatory_continuous_assessment_type

The input to this method is assumed to come from a file, but you can also load up a String. In that case, the method will split on newlines.

#


273
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
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 273

def return_entries_that_are_of_mandatory_continuous_assessment_type(i)
  if i.is_a? String
    i = i.split(N) # Split on newlines.
  end
  i.flatten! if i.is_a? Array
  i.reject! {|line|
    line.strip.start_with?('#') or
    line.strip.empty?
  }
  i.map!(&:strip)
  i.select! {|line|
    line.strip!
    # ===================================================================== #
    # We need to be careful here, because the line may either end with e.
    # g. "VO", or it may end with "VO, BOKU WIEN". The latter would then
    # cause the follow-up code to fail, so we have to filter way such
    # parts first.
    # ===================================================================== #
    if line.end_with? 'BOKU'
      line.sub!(/BOKU$/,'')
      line.strip!
    end
    if line.end_with?('WIEN') or line.end_with?('Wien')
      # =================================================================== #
      # First remove "WIEN" at the end of the line, then strip on the line.
      # =================================================================== #
      line.sub!(/WIEN$/,'')
      line.sub!(/Wien$/,'') if line.end_with? 'Wien'
      line.strip!
      line.sub!(/Uni$/,'')   if line.end_with? 'Uni'
      line.strip!
      # =================================================================== #
      # Still have TU, BOKU, VETMED and MEDUNI
      # =================================================================== #
      line.sub!(/BOKU$/,'')   if line.end_with? 'BOKU'
      line.sub!(/TU$/,'')     if line.end_with? 'TU'
      line.sub!(/VETMED$/,'') if line.end_with? 'VETMED'
      line.sub!(/MEDUNI$/,'') if line.include?  'MEDUNI' # Must come before "UNI".
      line.sub!(/UNI$/,'')    if line.end_with? 'UNI'
      line.strip!
    end
    line.chop! if line.end_with? ','
    last_two_characters = line[-2,2]
    ARRAY_LECTURE_TYPES_THAT_ARE_MANDATORY_CONTINUOUS_ASSESSMENT.include? last_two_characters
  }
  return i
end

#runObject

#

run (run tag)

#


969
970
971
972
973
974
975
976
977
978
979
980
981
982
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 969

def run
  _ = first_argument?
  menu
  if _.is_a?(String) and _.include?('# ') # Assume that the user passed in a String with all the lectures here.
    e if be_verbose?
    display_this_array_including_only_mandatory_continuous_assessment_lectures(_)
    e if be_verbose?
  else
    # =================================================================== #
    # Else we will try to find that particular curriculum at hand.
    # =================================================================== #
    do_determine_the_prüfungsimmanente_ECTS_of_this_curriculum(_)
  end
end

#set_percentage(i) ⇒ Object

#

set_percentage

#


994
995
996
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 994

def set_percentage(i)
  @internal_hash[:percentage] = i.to_f
end

#set_result(i) ⇒ Object

#

set_result

#


803
804
805
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 803

def set_result(i)
  @internal_hash[:result] = i
end

#show_all_available_curriculaObject

#

show_all_available_curricula

This is a powerhorse method - it will simply show all curricula and the respective “prüfungsimmanente Lehrveranstaltungen” in these curricula.

Invocation example:

mandatory --all_curricula
#


1038
1039
1040
1041
1042
1043
1044
1045
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1038

def show_all_available_curricula
  do_not_be_verbose
  _ = available_curricula?
  _.each_with_index {|curriculum, index| index += 1
    reset_this_instance
    try_to_find_this_curriculum(curriculum, index) { :be_verbose }
  }
end

#show_coloured_spacer(n_times = 112, &block) ⇒ Object

#

show_coloured_spacer

This method will show a little coloured spacer. It can also display the number of ECTS for that particular curriculum.

#


327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 327

def show_coloured_spacer(
    n_times = 112,
    &block
  )
  if be_verbose?
    result = steelblue('-' * n_times)
    if block_given?
      yielded = yield
      if yielded.is_a? Hash
        if yielded.has_key? :n_ects
          n_ects = yielded.delete(:n_ects)
          result = result.dup if result.frozen?
          result << slateblue(
            ("#{n_ects} ECTS").rjust(12)
          )
        end
      end
    end
    e result
  end
end

#show_helpObject

#

show_help (help tag)

Display the following help-instructions like so from the commandline:

mandatory --help
#


711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 711

def show_help
  e
  e "These options are available for "\
    "#{orange('class Studium::Exams::MandatoryContinuousAssessment')}:"
  e
  eparse '  --all       # show all mandatory continuous assessment '\
         'lectures that were already completed successfully'
  eparse '  --available # show the available curricula for '\
         'use with this class'
  e
  e "The other way to use this class is to pass in the "\
    "#{powderblue('name of a specific curriculum')}."
  e
  e 'The class will then figure out how much, in percent and '\
    'amount of ECTS numbers,'
  e 'that particular curriculum will have "prüfungsimmanente '\
    'Lehrveranstaltungen".'
  e
  e 'Usage examples:'
  e
  e lightseagreen('  mandatory vectorx')+'             '\
    '# vectorx ist Bachelor und Master kombiniert.'
  e "#{lightseagreen('  mandatory master-vectorx')}      "\
    "# Only show the master-lectures here"
  e lightseagreen('  mandatory --bachelor-genetics')+' '\
    '# the genetics curriculum at '\
    'the university of vienna'
  e
  e 'To show all curricula, do:'
  e
  epowderblue('  --all_curricula')
  e
  e 'To show passed exams per (specific) year, do:'
  e
  epowderblue('  --2017')
  epowderblue('  --2016')
  e
  e 'To show which mandatory lectures may be upcoming, you '\
    'can use any of the following:'
  e
  e '  mandatory --upcoming'
  e '  mandatory --todo'
  e '  mandatory --next'
  e
  e 'These will be sorted based on priority; higher priority '\
    'comes first'
  e
  e 'If you want to compare all registered (thus, available) '\
    'curricula, then use the following command:'
  e
  epowderblue('  mandatory --compare')
  e
  e 'And if you want more details:'
  e
  epowderblue('  mandatory --compare-detail')
  e
  e 'To only show master-lectures, try:'
  e
  epowderblue('  mandatory --only-master')
  e
  e 'If you only want lectures in the winter-semester, use this:'
  e
  epowderblue('  mandatory --wintersemester')
  e
  e 'To select only courses for summer or winter term, use either of the following:'
  e
  epowderblue('  mandatory --summer')
  epowderblue('  mandatory --winter')
  e
end

#show_the_title_of_the_curriculum?Boolean

#

show_the_title_of_the_curriculum?

#

Returns:

  • (Boolean)


366
367
368
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 366

def show_the_title_of_the_curriculum?
  @internal_hash[:show_the_title_of_the_curriculum]
end

#show_upcoming_mandatory_continuous_assessments(use_this_dataset = dataset? ) ⇒ Object

#

show_upcoming_mandatory_continuous_assessments

This method will show upcoming courses that have a mandatory assessment/attendance component (“prüfungsimmanente Lehrveranstaltungen”).

To invoke this method from the commandline, do:

mandatory --upcoming
#


1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 1115

def show_upcoming_mandatory_continuous_assessments(
    use_this_dataset = dataset?
  )
  _ = use_this_dataset
  # ======================================================================= #
  # First check if the commandline includes "master".
  # ======================================================================= #
  joined = commandline?.join(' ')
  if joined.include?('master') and joined.include?('only')
    _.select! {|name_of_the_lecture, inner_hash|
      curricula = obtain(:curricula, inner_hash)
      has_a_master_lecture?(curricula)
    }
  end
  # ======================================================================= #
  # Next, select only "prüfungsimmanente" courses that were NOT yet
  # solved:
  # ======================================================================= #
  _.select! {|name_of_the_lecture, inner_hash|
    lecture_type   = inner_hash[:type]
    already_solved = inner_hash[:already_solved]
    case lecture_type
    when *ARRAY_LECTURE_TYPES_THAT_ARE_MANDATORY_CONTINUOUS_ASSESSMENT
      keep_or_discard = true
    else
      keep_or_discard = false
    end
    # ======================================================================= #
    # Next, ignore the lectures that were already solved.
    # ======================================================================= #
    if already_solved
      keep_or_discard = false
    end
    keep_or_discard
  }
  # ======================================================================= #
  # Next, scan for filters. This is a bit hack-ish but for now it works.
  # ======================================================================= #
  if block_given?
    yielded = yield
    if yielded.is_a? Array
      joined = yielded.join(' ').strip
      # =================================================================== #
      # === übungen --summer
      # =================================================================== #
      if joined.include? '--summer'
        _.select! {|name_of_the_lecture, inner_hash|
          inner_hash[:semester].to_s.downcase == 'summer'
        }
      end
      # =================================================================== #
      # === übungen --winter
      # =================================================================== #
      if joined.include? '--winter'
        _.select! {|name_of_the_lecture, inner_hash|
          inner_hash[:semester].to_s.downcase == 'winter'
        }
      end
    end
  end
  # ======================================================================= #
  # Ok, we now have the courses that are "prüfungsimmanent" and NOT yet
  # solved.
  # ======================================================================= #
  display_these_lectures_sorted_by_priority(_)
end

#title?(i = nil) ⇒ Boolean

#

title?

#

Returns:

  • (Boolean)


401
402
403
404
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 401

def title?(i = nil)
  i = map_input_to_this_curriculum_filename(i)
  return_title_from_this_curriculum_file(i)+'  '
end

#total_amount_of_ects_points_in_the_curriculum?Boolean Also known as: n_total_ects_points, total_amount_of_ECTS_points_in_the_curriculum?

#

total_amount_of_ects_points_in_the_curriculum

#

Returns:

  • (Boolean)


537
538
539
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 537

def total_amount_of_ects_points_in_the_curriculum?
  @internal_hash[:total_amount_of_ECTS_points_in_the_curriculum]
end

#total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum?Boolean Also known as: n_prüfungsimmanente_ECTS?, n_mandatory_ects_points_in_this_curriculum?, n_mandatory_ects_points_in_this_curriculum

#

total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum?

#

Returns:

  • (Boolean)


528
529
530
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 528

def total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum?
  @internal_hash[:total_amount_of_mandatory_continuous_assessment_ECTS_points_in_this_curriculum]
end

#use_spacer_to_separate_a_new_year?Boolean

#

use_spacer_to_separate_a_new_year?

#

Returns:

  • (Boolean)


359
360
361
# File 'lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb', line 359

def use_spacer_to_separate_a_new_year?
  @internal_hash[:use_spacer_to_separate_a_new_year]
end