Class: Studium::Curricula::HandleCurricula

Inherits:
Base
  • Object
show all
Defined in:
lib/studium/curricula/handle_curricula/misc.rb,
lib/studium/curricula/handle_curricula/handle_curricula.rb

Overview

Studium::Curricula::HandleCurricula

Constant Summary

Constants inherited from Base

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

Constants included from Studium::Colours

Studium::Colours::COLOURS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_proper_year_entry_to_this_line, #already_solved_this_lva_number?, #append_what_into, #available_topics_as_short_name, #average_grade, #bachelor_master_or_diploma, #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?, #dataset?, #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 Studium::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 Studium::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(commandline_arguments = nil, run_already = true, &block) ⇒ HandleCurricula

#

initialize

#


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/studium/curricula/handle_curricula/handle_curricula.rb', line 35

def initialize(
    commandline_arguments = nil,
    run_already           = true,
    &block
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  # ======================================================================= #
  # === Handle blocks given to us next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :serve_as_is
    # ===================================================================== #
    when :serve_as_is
      set_runmode_for_this_class(:raw_serve)
    # ===================================================================== #
    # === :generate_HTML_file
    #
    # This will generate a standalone .html file.
    # ===================================================================== #
    when :generate_HTML_file
      this_must_generate_a_HTML_file
    else
      # ===================================================================== #
      # === Handle Hashes next
      # ===================================================================== #
      if yielded.is_a?(Hash)
        # =================================================================== #
        # === :serve_mode
        # =================================================================== #
        if yielded.has_key?(:serve_mode)
          set_runmode_for_this_class(yielded[:serve_mode])
        end
        # =================================================================== #
        # === :include_course_descriptions
        # =================================================================== #
        if yielded.has_key?(:include_course_descriptions)
          @internal_hash[:include_course_descriptions] = yielded[:include_course_descriptions]
        end
      end
    end
  end
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Studium::Curricula::HandleCurricula[]

#


88
89
90
# File 'lib/studium/curricula/handle_curricula/handle_curricula.rb', line 88

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

Instance Method Details

#assume_bachelor_or_master_or_otherwise(i = ) ⇒ Object

#

assume_bachelor_or_master_or_otherwise

#


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 98

def assume_bachelor_or_master_or_otherwise(
    i = @internal_hash[:total_ECTS]
  )
  case i # case tag
  when 90,
       120,
       122.5 # This one is just an ad-hoc "fix".
    @internal_hash[:curriculum_type] = :master
  when 180,
       181,
       165.0
    @internal_hash[:curriculum_type] = :bachelor
  else
    etomato(
      'Undefined as of yet. The number of ECTS points was: '+i.to_s
    )
  end
end

#courses?Boolean

#

courses?

#

Returns:

  • (Boolean)


281
282
283
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 281

def courses?
  @internal_hash[:courses]
end

#curriculum_type?Boolean

#

curriculum_type?

#

Returns:

  • (Boolean)


274
275
276
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 274

def curriculum_type?
  @internal_hash[:curriculum_type]
end

#determine_n_ECTS_from_this_dataset(array) ⇒ Object

#

determine_n_ECTS_from_this_dataset

#


127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 127

def determine_n_ECTS_from_this_dataset(array)
  sum = 0
  array.each {|entry|
    entry.strip! # Added in January 2023.
    pointer = @dataset_from_the_file_lecture_information[entry]
    if pointer.nil?
      cliner
      opne "There appears to be some incorrect entry for `#{entry}`."
      opne tomato('No ECTS entry was found for ')+
           steelblue(entry.to_s)+tomato('.')
      opne "The local file was: #{sfile(local_file?)}"
      e
      opne "The caller stack trace was:"
      e; pp caller; e
      cliner
      # exit
    else
      n_ECTS = pointer[:ects]
      sum += n_ECTS
    end
  }
  @internal_hash[:total_ECTS] = sum
  assume_bachelor_or_master_or_otherwise
end

#do_generate_a_HTML_file(i = courses? ) ⇒ Object

#

do_generate_a_HTML_file (HTML tag, html tag)

#


302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 302

def do_generate_a_HTML_file(
    i = courses?
  )
  this_file = "#{log_dir?}HTML/"\
              "#{title?.to_s.tr(' ','_')}.html"
  what = return_the_content_of_the_requested_curriculum
  unless File.directory? File.dirname(this_file)
    mkdir(File.dirname(this_file))
  end
  e 'Storing into `'+sfile(this_file)+'`.'
  write_what_into(what, this_file)
  if is_on_roebe? and File.exist?(this_file)
    Open.in_browser(this_file)
  end
end

#generates_a_HTML_file?Boolean

#

generates_a_HTML_file?

#

Returns:

  • (Boolean)


198
199
200
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 198

def generates_a_HTML_file?
  @internal_hash[:runmode_for_this_class] == :generate_a_HTML_file
end

#go_downwards_to_the_root_of_the_webserver(go_downwards_n_times = ) ⇒ Object

#

go_downwards_to_the_root_of_the_webserver

#


337
338
339
340
341
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 337

def go_downwards_to_the_root_of_the_webserver(
    go_downwards_n_times = @internal_hash[:go_downwards_n_times]
  )
  return ('../' * go_downwards_n_times)
end

#include_course_descriptions?Boolean

#

include_course_descriptions?

#

Returns:

  • (Boolean)


83
84
85
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 83

def include_course_descriptions?
  @internal_hash[:include_course_descriptions]
end
#

menu (menu tag)

#


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
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 212

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === Create a .html file
    # ===================================================================== #
    when /^-?-?create(-|_| )?a(-|_| )?html(-|_| )?file$/i,
         /^-?-?HTML$/i
      this_class_must_create_a_HTML_file
    # ===================================================================== #
    # === handle --show_help
    # ===================================================================== #
    when /^-?-?help$/i,
         /^-?-?show(-|_)?help$/i
      show_help
      exit
    else
      # =================================================================== #
      # === handle agrar
      #
      # Many other entries can be used as well such as "handle --indi1".
      #
      # All curricula should be handled by this entry point here. Right
      # now we only handle individual curricula.
      # =================================================================== #
      set_original_input(i)
      if i
        possible_different_result = Studium.map_input_to_this_curriculum_filename(i)
        unless possible_different_result == i
          i = possible_different_result
        end
      end
      if is_a_registered_curriculum?(i)
        set_title_of_the_curriculum(
          return_title_of_this_curriculum(i)
        )
        set_path_to_the_curriculum_file(
          return_path_to_the_curriculum_file(i)
        )
        _ = obtain_lectures_from_this_curriculum(i)
        @internal_hash[:courses] = _
        determine_n_ECTS_from_this_dataset(_)
      end
    end
  end
end

#n_ECTS?Boolean Also known as: n_ECTS_in_total?, total_ECTS?

#

n_ECTS?

#

Returns:

  • (Boolean)


266
267
268
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 266

def n_ECTS?
  @internal_hash[:total_ECTS]
end

#original_input?Boolean Also known as: original_input

#

original_input?

#

Returns:

  • (Boolean)


321
322
323
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 321

def original_input?
  @internal_hash[:original_input]
end

#path_to_the_curriculum_file?Boolean Also known as: path?, local_file?

#

path_to_the_curriculum_file?

#

Returns:

  • (Boolean)


346
347
348
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 346

def path_to_the_curriculum_file?
  @internal_hash[:path_to_the_curriculum_file]
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 16

def reset
  super()
  infer_the_namespace
  reset_the_internal_hash
  # ======================================================================= #
  # === @dataset_from_the_file_lecture_information
  # ======================================================================= #
  @dataset_from_the_file_lecture_information =
    return_dataset_from_the_file_lecture_information
  # ======================================================================= #
  # === :total_ECTS
  # ======================================================================= #
  @internal_hash[:total_ECTS] = 0
  # ======================================================================= #
  # === :title_of_the_curriculum
  # ======================================================================= #
  @internal_hash[:title_of_the_curriculum] = 0
  # ======================================================================= #
  # === :runmode_for_this_class
  #
  # The next variable determines the "runmode" for this class, e. g.
  # whether we will generate a .html file.
  #
  # The valid modes are:
  #
  #   :generate_a_HTML_file
  #   :raw_serve
  #
  # ======================================================================= #
  @internal_hash[:runmode_for_this_class] = :generate_a_HTML_file
  # ======================================================================= #
  # === :original_input
  # ======================================================================= #
  @internal_hash[:original_input] = nil
  # ======================================================================= #
  # === :go_downwards_n_times
  # ======================================================================= #
  @internal_hash[:go_downwards_n_times] = 8
  # ======================================================================= #
  # === :include_course_descriptions
  #
  # If this variable is set to true then the course descriptions will
  # be included as well, as part of the generated HTML code. Note that
  # this leads to a more verbose, longer content, which may be a bit
  # annoying to read compared to the shorter, more succint variant.
  # Thus, this is set to false by default; in the .cgi file it can
  # be set to true by the user, if the user decides to want to do
  # so via a checkbox (on/off).
  # ======================================================================= #
  @internal_hash[:include_course_descriptions] = false
  # ======================================================================= #
  # === :hash_ects_per_university
  # ======================================================================= #
  @internal_hash[:hash_ects_per_university] = {}
  @internal_hash[:hash_ects_per_university].default = 0
  # ======================================================================= #
  # === :hash_n_ECTS_per_curriculum
  #
  # The following Hash will keep track how many ECTS points are
  # listed per curriculum.
  # ======================================================================= #
  reset_the_hash_n_ECTS_per_curriculum
end

#reset_the_hash_n_ECTS_per_curriculumObject

#

reset_the_hash_n_ECTS_per_curriculum

#


90
91
92
93
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 90

def reset_the_hash_n_ECTS_per_curriculum
  @internal_hash[:hash_n_ECTS_per_curriculum] = {}
  @internal_hash[:hash_n_ECTS_per_curriculum].default = 0.0
end

#return_the_content_of_the_requested_curriculum(i = courses? ) ⇒ Object Also known as: content?

#

return_the_content_of_the_requested_curriculum

#


354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
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
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
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
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
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
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 354

def return_the_content_of_the_requested_curriculum(
    i = courses?
  )
  _ = ''.dup
  # ======================================================================= #
  # Build up our HTML String here, starting with the outer <div> tag:
  # ======================================================================= #
  title = title?
  _ << '<div style=\"margin: 0px\">'
  _ << "<h1 style=\"margin-top: 2px;\" class=\"darkblue\">#{title}</h1>\n"
  path = path_to_the_curriculum_file?
  if path.is_a? Array
    _ << "<b class=\"mediumslateblue\" style=\"font-size: 1.5em\">"\
         "The dataset was loaded from the following files:</b>"\
         "<br>\n"
    _ << "<p class=\"marl3em\"><b class=\"royalblue\">"
    path.each {|entry|
      _ << entry+'<br>'
    }
    _ << "</b></p></div>\n"
  else
    _ << "<b class=\"mediumslateblue\" style=\"font-size: 1.5em\">"\
         "The dataset was loaded from the following file:</b>"\
         "<br>\n"
    _ << "<p class=\"marl3em\"><b class=\"royalblue\">"\
         "#{path}"\
         "</b></p></div>\n"
  end
  n_lectures_are_already_solved = 0
  dataset = @dataset_from_the_file_lecture_information
  passed_n_ECTS_in_total = 0
  # ======================================================================= #
  # Iterate over our designated lectures next:
  # ======================================================================= #
  if i.nil? or i.empty?
    return '<div style="margin: 1em">No curriculum was found fitting to the given '\
           'input name `<b>'+original_input?.to_s.strip+'</b>`.'+
           'The assumed path was: '+path.to_s+
           '</div>'
  end
  currently_displayed_module_is = nil
  reset_the_hash_n_ECTS_per_curriculum
  @internal_hash[:hash_ects_per_university].clear
  # ======================================================================= #
  # Big iteration time! We go over each registered course next.
  # ======================================================================= #
  i.each_with_index {|entry, index| index += 1
    lva_number              = entry.split(' ').first.to_s
    pointer                 = dataset[entry]
    university_course       = Studium::UniversityCourse.new(pointer)
    university_course.set_lecture_name(entry)
    is_a_STEOP_lecture      = university_course.is_a_steop_lecture?
    remote_URL              = university_course.remote_URL?
    university              = university_course.university?
    lecture_type            = university_course.lecture_type?
    already_solved          = university_course.already_solved?
    absolviert_am           = university_course.already_solved_at?
    n_ECTS                  = university_course.ects?
    course_description      = university_course.description_in_german?.to_s
    @internal_hash[:hash_ects_per_university][university] += n_ECTS
    curricula               = university_course.curricula?
    # ===================================================================== #
    # Next, store the number of ECTS per curriculum in a Hash:
    # ===================================================================== #
    if curricula
      curricula.each {|this_curriculum|
        @internal_hash[:hash_n_ECTS_per_curriculum][this_curriculum] += n_ECTS
      }
    end
    individual_curriculum   = university_course.is_an_individual_curriculum?
    if individual_curriculum
      university_course.set_we_work_on_this_individual_curriculum(title)
    end
    is_this_course_outdated = university_course.is_this_course_outdated?
    moodle_entry            = university_course.moodle?
    moodle_entry            = moodle_entry.first if moodle_entry and moodle_entry.is_a?(Array)
    if already_solved
      n_lectures_are_already_solved += 1
      passed_n_ECTS_in_total += n_ECTS
    end
    semester                = university_course.semester?.to_s.dup
    case semester
    when 'both'
      semester = 'Sommer / Winter'
    else
      semester.capitalize!
    end
    if individual_curriculum
      if (currently_displayed_module_is == university_course.individual_curriculum_module?.to_s) 
        # pass through and don't display it in this case.
      else
        _ << '<h1>Module '+
             '<span class="chocolate">'+
             university_course.individual_curriculum_module?.to_s+
             '</span> '+
             university_course.name_of_the_curriculum_module?.to_s+
             '</h1>'
        currently_displayed_module_is = university_course.individual_curriculum_module?.to_s
      end
    end
    case university.to_s
    # ===================================================================== #
    # === Uni Wien
    # ===================================================================== #
    when 'Uni Wien'
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           Studium.path_to_the_university_of_vienna_logo_image?.sub(/\/home\/x/,'')+
           '" style="margin-right: 0.5em; border: 0px solid black;">'
    # ===================================================================== #
    # === Vetmed
    # ===================================================================== #
    when 'Vetmed'
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           Studium.path_to_the_vetmed_logo_image?.sub(/\/home\/x/,'')+
           '" style="margin-right: 0.5em; border: 0px solid black;">'
    # ===================================================================== #
    # === TU Vienna
    # ===================================================================== #
    when 'TU Vienna'
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           Studium.path_to_the_tu_vienna_logo_image?.sub(/\/home\/x/,'')+
           '" style="margin-right: 0.5em; border: 0px solid black;">'
    # ===================================================================== #
    # === :BOKU
    # ===================================================================== #
    when 'BOKU'
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           Studium.path_to_the_boku_logo_image?.sub(/\/home\/x/,'')+
           '" style="margin-right: 0.5em; border: 0px solid black;">'
    # ===================================================================== #
    # === :Uni Graz
    # ===================================================================== #
    when 'Uni Graz'
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           'data/images/studium/UNIVERSITY_OF_GRAZ_LOGO_IMAGE.png'\
           '" style="margin-right: 0.5em; border: 0px solid black;">'
    # ===================================================================== #
    # === :Meduni
    # ===================================================================== #
    when 'Meduni'
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           'data/images/studium/MEDUNI_LOGO_IMAGE.png'\
           '" style="margin-right: 0.5em; border: 0px solid black;">'
    else
      e "Unknown symbol: #{university}"
    end
    _ << "<span>Lehrveranstaltung <b>##{index}</b>: </span>".dup
    # ===================================================================== #
    # Next add a link to the remote lecture's homepage:
    # ===================================================================== #
    _ << HtmlTags.a(
      remote_URL,
      "<span class=\"link BOLD\">→ #{entry}</span>"
    )
    append_this = german_yes_or_no(already_solved).to_s.capitalize.dup
    case append_this
    # ===================================================================== #
    # === Ja
    # ===================================================================== #
    when 'Ja'
      append_this = '<b class="forestgreen">'+
                    append_this+', absolviert am '+
                    absolviert_am+'.</b>'
    # ===================================================================== #
    # === Nein
    # ===================================================================== #
    when 'Nein'
      append_this = '<b class="orangered">'+
                    append_this+'.</b>'
    end
    _ << ', Bereits <b>absolviert</b>? '+append_this
    # ===================================================================== #
    # If it is outdated:
    # ===================================================================== #
    if is_this_course_outdated
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           'programming/ruby/src/studium/lib/studium/images/outdated.png" '\
           'style="margin-left: 0.5em; border: 2px solid black;">'
    end
    # ===================================================================== #
    # Consider showing the STEOP lecture image next:
    # ===================================================================== #
    if is_a_STEOP_lecture
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           'data/images/universities/STEOP.png" '\
           'style="margin-left: 0.5em; width: 28px; height: 28px; border: 0px solid black;">'
    end
    # ===================================================================== #
    # Consider showing the practical course next:
    # ===================================================================== #
    if is_it_a_practical_course?(entry, lecture_type)
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           Studium.path_to_the_practical_course_image?.sub(/\/home\/x/,'')+'" '\
           'style="margin-left: 0.6em; border: 1px solid black;">'
    end
    # ===================================================================== #
    # Show an image depending on whether we have a bachelor or a master
    # course next. Some courses are available in both a bachelor and
    # a master curriculum, so we will show this as well.
    # ===================================================================== #
    if is_a_bachelor_curriculum?(curricula)
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           'data/images/studium/BACHELOR.png" '\
           'style="margin-left: 0.6em; border: 1px solid black;">'
    end
    if is_a_master_curriculum?(curricula)
      _ << '<img src="'+go_downwards_to_the_root_of_the_webserver+
           'data/images/studium/MASTER.png" '\
           'style="margin-left: 0.6em; border: 1px solid black;">'
    end
    if already_solved
      _ << '<img class="marl0_5em" style="width: 100px" '\
           'src="'+
           go_downwards_to_the_root_of_the_webserver+
           'programming/ruby/src/studium/lib/studium/images/small_logos/solved.png">'
    end
    # ===================================================================== #
    # Next add some more details to this course:
    # ===================================================================== #
    which_year = '2022W'
    which_year = ::Studium.infer_the_year_of_this_lecture(
      entry,
      @dataset_from_the_file_lecture_information
    )
    _ << "<br>\n<span class=\"marl6_8em\">"\
         "(LVA Nummer: <b>#{lva_number}</b>; "\
         "ECTS: <b>#{n_ECTS}</b>; "\
         "Lecture Type: <b>#{lecture_type}</b>; "\
         "Semester: <b>#{semester.to_s}, of #{which_year}</b>; "\
         "University: <b>#{university}</b>"\
         ")</span><br>\n"
    # ===================================================================== #
    # Next, show a moodle-entry if it exists.
    # ===================================================================== #
    if moodle_entry
      moodle_entry_string = ::Studium.return_semester_for_this_moodle_entry(moodle_entry).to_s
      if moodle_entry_string.empty? and is_on_roebe? # Only for my home system.
        e 'Some outdated entry: '+steelblue(moodle_entry)
      end
      _ << '<img class="marl6_8em marr0_5em" src="'+
           go_downwards_to_the_root_of_the_webserver+
           'data/images/STD/PFEIL6_red.png">'+
           '<a href="'+moodle_entry+'" class="BOLD">'+
           '[Moodle entry at: '+moodle_entry+']</a> # <b>'+
           moodle_entry_string+
           '</b>'
    else
      _ << '<span class="marl6_8em darkblue BOLD">[No remote moodle-entry '\
           'is known for this course.]</span>'
    end
    _ << "<br>\n"
    unless already_solved
      if university_course.next_exam? and !university_course.next_exam?.empty?
        _ << '<span class="marl6_8em BOLD">'\
             '^^^ <b class="teal">Next exam</b>: '+
             university_course.next_exam?.to_s+'</span><br>'+"\n"
      end
    end
    # ===================================================================== #
    # Show the description of the course, if requested to do so:
    # ===================================================================== #
    if include_course_descriptions?
      _ << '<pre style="margin-left: 8%">'
      _ << course_description
      _ << '</pre>'
    end
  }
  _ << "<br>\n"
  # ======================================================================= #
  # Next show some statistics:
  # ======================================================================= #
  n_percent_finished = ((n_lectures_are_already_solved * 100.0) / i.size).round(2)
  _ << "<div style=\"margin-top: 0.8em; padding: 15px; border: 3px dotted steelblue\">"\
       "A total of <b>#{i.size}</b> lectures are part of this "\
       "Curriculum. <b>#{n_lectures_are_already_solved}</b> of these "\
       "are already solved. <b>(#{n_percent_finished}% finished)"\
       "</b><br><br>"
  n_percent_continuous_mandatory_assessment = Studium.percentage_mandatory_continuous_assessment(
    title?.downcase.tr(' ','_'), 2
  )
  n_ECTS = (
    (n_ECTS_in_total? * n_percent_continuous_mandatory_assessment) / 100.0
  ).round(2) # Must round here to avoid rounding-up errors.
  _ << "This curriculum has <b>#{n_ECTS_in_total?} ECTS</b> points "\
       "in total, of which <b>#{n_ECTS} ECTS</b> "\
       "(<b>#{n_percent_continuous_mandatory_assessment}%</b>) require "\
       "<b>continuous mandatory assessment</b> "\
       "(<i>prüfungsimmanent</i>).<br>\n<br>\n"
  n_percentage_of_n_ECTS_were_passed_so_far = (
    (passed_n_ECTS_in_total * 100) / n_ECTS_in_total?
  ).round(2)
  _ << "In total <b>#{passed_n_ECTS_in_total} ECTS points</b> "\
       "(<b>#{n_percentage_of_n_ECTS_were_passed_so_far}%</b>) have been "\
       "passed so far in the "\
       "<b>#{title?}</b>.<br>\n<br>\n"
  _ << "There are still "\
       "<b>#{i.size - n_lectures_are_already_solved}</b> "\
       "lectures missing before this curriculum has "\
       "been completed successfully.<br>\n<br>\n"
  _ << "The average grade of the passed courses is: "\
       "<b>#{Studium.average_grade_of_this_curriculum(title?)}</b>"
  # ======================================================================= #
  # Display the universities in its own <div> tag:
  # ======================================================================= #
  total_ECTS = total_ECTS?
  _ << '<div style="margin-left: 4%; padding: 0.25em; '\
       'font-family: monospace; white-space: pre;">'
  _ << h2('Attributed universities:', 
       css_style: 'color: royalblue; font-weight: bold; margin-top: 2px;')
  _ << '<table style="margin: 2px">'
  @internal_hash[:hash_ects_per_university].each_pair {|this_university, n_ECTS|
    percentage_value = ((n_ECTS.to_f * 100.0) / total_ECTS).round(2)
    _ << '<tr><td><b style="font-family: monospace; white-space: pre">'+
         (this_university.to_s+':'.ljust(15))+'</b></td><td> <b>'+
         n_ECTS.to_f.to_s.rjust(10)+' ECTS</b> (<b>'+
         percentage_value.to_s.rjust(5)+'%</b>)</td></tr>'
  }
  _ << '</table></div>'
  # ======================================================================= #
  # === Curricula IDs
  #
  # Next display the different curricula ID that are part of this
  # curriculum:
  # ======================================================================= #
  _ << '<h3>Curricula IDs that are represented in this curriculum:<h3>'
  sorted = Hash[@internal_hash[:hash_n_ECTS_per_curriculum].sort_by {|a, b| b }.reverse]
  sorted.each_pair {|key, value|
    key   = key.to_s.rjust(12,' ')
    value = value.to_s.rjust(6,' ')
    translated_name = Studium.map_curriculum_number_to_curriculum_name(key.to_s.strip).to_s
    percentage_value = ((value.to_f * 100) / n_ECTS_in_total?).round(2)
    percentage_value = percentage_value.to_s
    percentage_value = '%.2f' % percentage_value
    percentage_value = percentage_value.rjust(5, ' ')
    _ << "<b style=\"margin-left: 4em; white-space: pre\">"\
         "#{key} "+
         ('('+translated_name+'):').ljust(66,' ')+
         " <span style=\"midnightblue\">#{value} ECTS</span> "\
         "(#{percentage_value}% of #{n_ECTS_in_total?} out of ECTS)</b><br>\n"
  }
  # ======================================================================= #
  # Next add the upcoming exams, should they exist:
  # ======================================================================= #
  require 'studium/exams/upcoming_exams/upcoming_exams.rb'
  upcoming_exams = Studium::Exams::UpcomingExams.in_this_curriculum(title)
  _ << h2('The following exams are coming up next:', 
       css_style: 'color: royalblue; font-weight: bold; '\
                  'margin-top: 2px; margin-left: 3em;')
  if upcoming_exams.nil?
    _ << p('No upcoming exams are known for this curriculum.')
  else
    _ << '<pre>'
    # ===================================================================== #
    # We have to time-sort the dataset next:
    # ===================================================================== #
    regex_to_use = /(\d{2}\.\d{2}\.\d{4})/
    sorted = upcoming_exams.sort_by {|a, b|
      exams = b['exams']
      exams = exams.first if exams.is_a? Array
      exams =~ regex_to_use
      raw_date = $1.to_s.dup
      ::Time.parse(raw_date)
    }
    upcoming_exams = Hash[sorted]
    upcoming_exams.each_pair {|name_of_the_course, inner_hash|
      exams = inner_hash['exams']
      if exams.is_a? Array
        exams = exams.first
      end
      remote_URL = Studium.remote_URL_for_this_university_course(name_of_the_course).to_s
      _ << '    <b><a href="'+remote_URL+'">'+
           name_of_the_course+
           '</b></a> (am <b>'+exams+'</b>)<br>'
    }
    _ << '</pre>'
  end
  # ======================================================================= #
  # Delegate towards class HtmlTemplate next.                (template tag)
  # ======================================================================= #
  what = Cyberweb.rendered_template(
    body:            _,
    title:          curriculum_title?,
    css_classes:    'royalblue darkblue mar1em mar0_5em BOLD pad8px bblack1 '\
                    'pad5px mediumslateblue smaller forestgreen '\
                    'pad14px tomato mediumaquamarine orangered teal '\
                    'marl3em marl6em marl7em marl6_8em darkslateblue '\
                    'marr1em marr2em marr0_5em marl0_5em '\
                    's0_4em s0_5em s0_8em mar0em',
    css_style:      '
      a,
      a:link,
      a:visited {
        text-decoration: none;
        color: royalblue;
      }
      a:hover     {
        text-decoration: none;
        color: mediumaquamarine;
      }
      .link       {
        color: darkblue;
        text-decoration: none;
      }
      .link:hover {
        color: darkslateblue;
        text-decoration: none;
      }
      .leftwards_center {
        margin: auto;
        width:   85%;
        padding:  8px;
      }
    ', # CSS tag
    body_css_class: 'mar0em pad14px s0_5em bblack1',
    body_css_style: 'font-size: 1.3em;
                     font-family: monospace;'
  )
  return what.result?
end

#runObject

#

run (run tag)

#


777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 777

def run
  menu
  case runmode_for_this_class?
  # ======================================================================= #
  # === :generate_a_HTML_file
  # ======================================================================= #
  when :generate_a_HTML_file
    set_go_downwards_n_times(3)
    do_generate_a_HTML_file
  # ======================================================================= #
  # === :raw
  # ======================================================================= #
  when :raw,
       :raw_serve
    # Do nothing in this case.
  else
    e "Runmode not yet implemented: "\
      "#{steelblue(runmode_for_this_class?)}"
  end
end

#runmode_for_this_class?Boolean

#

runmode_for_this_class?

#

Returns:

  • (Boolean)


162
163
164
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 162

def runmode_for_this_class?
  @internal_hash[:runmode_for_this_class]
end

#set_go_downwards_n_times(i) ⇒ Object

#

set_go_downwards_n_times

#


120
121
122
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 120

def set_go_downwards_n_times(i)
  @internal_hash[:go_downwards_n_times] = i
end

#set_original_input(i) ⇒ Object

#

set_original_input

This must retain the original input.

#


191
192
193
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 191

def set_original_input(i)
  @internal_hash[:original_input] = i
end

#set_path_to_the_curriculum_file(i) ⇒ Object

#

set_path_to_the_curriculum_file

#


205
206
207
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 205

def set_path_to_the_curriculum_file(i)
  @internal_hash[:path_to_the_curriculum_file] = i
end

#set_runmode_for_this_class(i) ⇒ Object

#

set_runmode_for_this_class

#


169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 169

def set_runmode_for_this_class(i)
  i = i.to_sym
  case i
  # ======================================================================= #
  # === :serve_as_is
  # ======================================================================= #
  when :serve_as_is
    i = :raw_serve
  # ======================================================================= #
  # === :create_a_HTML_file
  # ======================================================================= #
  when :create_a_HTML_file
    i = :generate_a_HTML_file
  end
  @internal_hash[:runmode_for_this_class] = i
end

#set_title_of_the_curriculum(i) ⇒ Object

#

set_title_of_the_curriculum

#


295
296
297
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 295

def set_title_of_the_curriculum(i)
  @internal_hash[:title_of_the_curriculum] = i
end

#show_helpObject

#

show_help (help tag)

#


328
329
330
331
332
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 328

def show_help
  e
  e 'Help-options are currently not implemented.'
  e
end

#this_class_must_create_a_HTML_fileObject Also known as: this_must_generate_a_HTML_file

#

this_class_must_create_a_HTML_file

#


155
156
157
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 155

def this_class_must_create_a_HTML_file
  set_runmode_for_this_class(:create_a_HTML_file)
end

#title?Boolean Also known as: curriculum_title?

#

title?

#

Returns:

  • (Boolean)


288
289
290
# File 'lib/studium/curricula/handle_curricula/misc.rb', line 288

def title?
  @internal_hash[:title_of_the_curriculum]
end