Class: Studium::ExamsPerMonth
- Inherits:
-
Base
- Object
- Base
- Studium::ExamsPerMonth
show all
- Defined in:
- lib/studium/exams/exams_per_month/run.rb,
lib/studium/exams/exams_per_month/help.rb,
lib/studium/exams/exams_per_month/menu.rb,
lib/studium/exams/exams_per_month/open.rb,
lib/studium/exams/exams_per_month/reset.rb,
lib/studium/exams/exams_per_month/colours.rb,
lib/studium/exams/exams_per_month/dataset.rb,
lib/studium/exams/exams_per_month/sanitize.rb,
lib/studium/exams/exams_per_month/constants.rb,
lib/studium/exams/exams_per_month/initialize.rb,
lib/studium/exams/exams_per_month/exams_per_month.rb,
lib/studium/exams/exams_per_month/show_and_report.rb
Overview
Constant Summary
collapse
- NAMESPACE =
inspect
- TITLE =
'Exams per Month'
- LAST_YEAR =
Time.now.year
- SHOW_N_BEST_MONTHS =
#
SHOW_N_BEST_MONTHS
Determine how many “best months” to show, by default.
#
30
- ARRAY_REGISTERED_MONTHS =
#
ARRAY_REGISTERED_MONTHS
The months are stored in both the german and the english language.
#
%w(
januar
februar
feb
märz
april
mai
juni
juli
august
september
oktober
november
dezember
january
february
march
april
may
june
july
october
december
)
Constants inherited
from Base
Base::ARRAY_HTML_COLOURS_IN_USE, Base::CHECK_FOR_INCORRECT_ENTRIES_IN_THE_QUESTION_ANSWER_FILE_THAT_SHOULD_BE_COMMENTS, Base::COLOURS, Base::COMMON_YEAR_DAYS_IN_MONTH, Base::GRAY, Base::LEFT_PADDING, Base::N_CHARACTERS_PER_LINE, Base::UNICODE_RIGHT_ARROW
Constants included
from Colours
Colours::COLOURS
Class Method Summary
collapse
Instance Method Summary
collapse
-
#calculate_the_average_amount_per_passed_exam ⇒ Object
# === calculate_the_average_amount_per_passed_exam ========================================================================= #.
-
#colour_for_hours(i) ⇒ Object
(also: #colourize_hours)
# === colour_for_hours.
-
#colourize_ects_points(i) ⇒ Object
(also: #colourize_ects, #colour_ects)
# === colourize_ects_points.
-
#colourize_month_year(i) ⇒ Object
# === colourize_month_year.
-
#colourize_n_exams(i, use_this_colour = :lightslategray) ⇒ Object
# === colourize_n_exams.
-
#colourize_year(i) ⇒ Object
# === colourize_year ========================================================================= #.
-
#current_year? ⇒ Boolean
(also: #current_year)
# === current_year? ========================================================================= #.
-
#dataset? ⇒ Boolean
# === dataset? ========================================================================= #.
-
#determine_n_ects_points_in_total ⇒ Object
# === determine_n_ects_points_in_total.
-
#determine_n_exams_in_total_were_passed ⇒ Object
# === determine_n_exams_in_total_were_passed ========================================================================= #.
-
#determine_n_hours_were_passed_in_total ⇒ Object
# === determine_n_hours_were_passed_in_total ========================================================================= #.
-
#do_show_ects_points ⇒ Object
# === do_show_ects_points ========================================================================= #.
-
#do_show_only_grade_for(i = nil) ⇒ Object
# === do_show_only_grade_for ========================================================================= #.
-
#do_show_only_this_year_here(i) ⇒ Object
# === do_show_only_this_year_here.
-
#do_show_the_grades_statistics ⇒ Object
# === do_show_the_grades_statistics.
-
#do_show_yearly_average_grades ⇒ Object
# === do_show_yearly_average_grades ========================================================================= #.
-
#draw_image_with_gruff ⇒ Object
# === draw_image_with_gruff.
-
#file_lecture_information? ⇒ Boolean
-
#initialize(commandline_arguments = nil, run_already = true) ⇒ ExamsPerMonth
constructor
# === initialize ========================================================================= #.
-
#input? ⇒ Boolean
-
#is_this_sommersemester_or_wintersemester?(i) ⇒ Boolean
# === is_this_sommersemester_or_wintersemester?.
-
#last_year? ⇒ Boolean
(also: #last_year)
# === last_year? ========================================================================= #.
-
#main_file? ⇒ Boolean
# === main_file? ========================================================================= #.
-
#menu(i = input? ) ⇒ Object
(also: #check_against_menu)
-
#menu_file? ⇒ Boolean
-
#n_exams_passed?(for_this_year = @current_year) ⇒ Boolean
# === n_exams_passed? ========================================================================= #.
-
#obtain_dataset(use_this_file = main_file? ) ⇒ Object
# === obtain_dataset.
-
#open_result_in_gimp ⇒ Object
# === open_result_in_gimp.
-
#open_the_curricula_assigned_exams_file_in_the_editor ⇒ Object
# === open_the_curricula_assigned_exams_file_in_the_editor ========================================================================= #.
-
#open_the_file_lecture_information_in_the_editor ⇒ Object
-
#open_the_main_file_in_the_editor ⇒ Object
# === open_the_main_file_in_the_editor ========================================================================= #.
-
#open_the_main_files_in_the_editor ⇒ Object
# === open_the_main_files_in_the_editor (open tag).
-
#open_the_menu_file_in_the_editor ⇒ Object
-
#output_colourized_year_and_colourized_hours(year) ⇒ Object
# === output_colourized_year_and_colourized_hours ========================================================================= #.
-
#output_the_csv_file ⇒ Object
# === output_the_csv_file.
-
#raw_dataset?(use_this_file = main_file? ) ⇒ Boolean
# === raw_dataset?.
-
#report_how_many_ects_points_have_been_gathered_so_far(n_ljust = 52) ⇒ Object
# === report_how_many_ects_points_have_been_gathered_so_far ========================================================================= #.
-
#report_how_many_exams_were_passed_in_total(i = @n_exams_in_total_passed, ljust_n_times = 76, n_rjust = 4) ⇒ Object
# === report_how_many_exams_were_passed_in_total ========================================================================= #.
-
#report_how_many_hours_were_passed_in_total(i = @n_hours_passed_in_total, n_ljust = 76, n_rjust = 6) ⇒ Object
# === report_how_many_hours_were_passed_in_total.
-
#report_how_many_of_these_ects_points_required_mandatory_presence(n_ects_points_in_mandatory_presence_courses = Studium.n_ects_points_in_mandatory_presence_courses, n_ljust = 77) ⇒ Object
# === report_how_many_of_these_ects_points_required_mandatory_presence.
-
#report_month_year_hours_ects_n_exams_passed_in_this_month(month, year, n_hours, n_ECTS, n_exams_passed_in_this_month) ⇒ Object
# === report_month_year_hours_ects_n_exams_passed_in_this_month ========================================================================= #.
-
#report_the_average_amount_of_ects_per_passed_exam(ects_per_exams_passed = calculate_the_average_amount_per_passed_exam, ljust_n_times = 76, rjust_n_times = 12) ⇒ Object
# === report_the_average_amount_of_ects_per_passed_exam ========================================================================= #.
-
#report_the_average_grade(n_ljust = 76, n_rjust = 4) ⇒ Object
# === report_the_average_grade ========================================================================= #.
-
#report_total_amount_of_ects_points(total_ects_points, bachelor_or_master = :bachelor, ljust_to_use = 41) ⇒ Object
# === report_total_amount_of_ects_points ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#reset_ects_points ⇒ Object
(also: #reset_ects)
# === reset_ects_points ========================================================================= #.
-
#reset_main_hash ⇒ Object
# === reset_main_hash ========================================================================= #.
-
#reset_n_hours ⇒ Object
(also: #reset_hours)
# === reset_n_hours ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#sanitize_dataset(i = dataset?, , modify_time_entry = true) ⇒ Object
# === sanitize_dataset.
-
#set_current_year(i = Time.now.strftime('%Y').to_i) ⇒ Object
# === set_current_year.
-
#set_dataset(i) ⇒ Object
# === set_dataset ========================================================================= #.
-
#set_input(i = nil) ⇒ Object
-
#set_last_year(i = current_year?) ) ⇒ Object
# === set_last_year ========================================================================= #.
-
#set_n_ects_points_in_total(i) ⇒ Object
# === set_n_ects_points_in_total ========================================================================= #.
-
#set_n_exams_in_total_passed(i) ⇒ Object
# === set_n_exams_in_total_passed ========================================================================= #.
-
#set_store_where(i) ⇒ Object
# === set_store_where ========================================================================= #.
-
#show_all_exams_from_this_month(i = 'januar') ⇒ Object
# === show_all_exams_from_this_month.
-
#show_best_months(do_show_n_months = @show_n_best_months) ⇒ Object
# === show_best_months.
-
#show_colourized_line(n_times = 34) ⇒ Object
# === show_colourized_line ========================================================================= #.
-
#show_ects_passed_per_university ⇒ Object
# === show_ects_passed_per_university ========================================================================= #.
-
#show_ects_points? ⇒ Boolean
# === show_ects_points? ========================================================================= #.
-
#show_exam_ects_points_passed_per_semester ⇒ Object
# === show_exam_ects_points_passed_per_semester ========================================================================= #.
-
#show_half_split_exams_per_year ⇒ Object
# === show_half_split_exams_per_year.
-
#show_help ⇒ Object
# === show_help (help tag).
-
#show_how_many_exams_we_have_passed_in_this_curriculum(i) ⇒ Object
# === show_how_many_exams_we_have_passed_in_this_curriculum.
-
#show_n_exams_passed_per_month(i = @hash) ⇒ Object
(also: #report_main_hash, #report)
# === show_n_exams_passed_per_month (report tag).
-
#show_number_then_name_of_the_lecture_then_n_ECTS_points_then_leistung_erbracht_then_which_university(index, name_of_the_lecture, n_ects, leistung_erbracht_am, which_university) ⇒ Object
# === show_number_then_name_of_the_lecture_then_n_ECTS_points_then_leistung_erbracht_then_which_university.
-
#show_numbered_exams(normal_or_reversed = :normal) ⇒ Object
# === show_numbered_exams.
-
#show_only_bachelor_exams ⇒ Object
# === show_only_bachelor_exams.
-
#show_only_bachelor_lectures ⇒ Object
# === show_only_bachelor_lectures.
-
#show_only_exams_at_the_boku ⇒ Object
# === show_only_exams_at_the_boku.
-
#show_only_exams_at_the_meduni ⇒ Object
# === show_only_exams_at_the_meduni.
-
#show_only_exams_at_the_tu ⇒ Object
# === show_only_exams_at_the_tu.
-
#show_only_exams_at_the_uniwien ⇒ Object
# === show_only_exams_at_the_uniwien.
-
#show_only_exams_at_the_vetmed_uni ⇒ Object
# === show_only_exams_at_the_vetmed_uni.
-
#show_only_exams_before_this_date(this_date) ⇒ Object
# === show_only_exams_before_this_date.
-
#show_only_exams_past_this_date(this_date) ⇒ Object
# === show_only_exams_past_this_date.
-
#show_only_master_lectures ⇒ Object
# === show_only_master_lectures.
-
#show_only_practical_courses_that_were_passed_already ⇒ Object
# === show_only_practical_courses_that_were_passed_already.
-
#show_the_summary ⇒ Object
(also: #show_only_the_summary)
# === show_the_summary.
-
#show_the_years_in_a_short_table_overview ⇒ Object
# === show_the_years_in_a_short_table_overview.
-
#show_total_summary_for_year_hours_ects_n_exams(last_year, total_n_hours_passed_in_this_year, total_n_ects_passed_in_this_year, total_n_exams_passed_in_this_year, optional_average_grade_per_exam = nil) ⇒ Object
# === show_total_summary_for_year_hours_ects_n_exams.
-
#store_result ⇒ Object
# === store_result ========================================================================= #.
-
#store_where? ⇒ Boolean
# === store_where? ========================================================================= #.
-
#title? ⇒ Boolean
# === title? ========================================================================= #.
-
#use_colours? ⇒ Boolean
# === use_colours? ========================================================================= #.
-
#use_only_master_lectures ⇒ Object
# === use_only_master_lectures ========================================================================= #.
Methods inherited from Base
#add_proper_year_entry_to_this_line, #already_solved_this_lva_number?, #append_what_into, #available_topics_as_short_name, #average_grade, #bachelor_master_or_diploma, #base_dir?, #be_silent, #be_verbose?, #beautiful_url, #change_directory, #cheering_person, #cliner, #colour_for_ects_points, #colourize_percentage, #commandline_arguments?, #commandline_arguments_joined, #commandline_arguments_with_hyphens?, #convert_this_array_of_lectures_into_the_full_dataset, #copy, #cpruby, #create_directory, #create_file, #csv_file?, #current_month?, #datum?, #day_month_year, #debug?, #delete_file, #directory_of_the_exam_topics?, #directory_to_my_exam_topics, #directory_to_the_exam_topics?, #disable_colours, #disable_colours_globally, #do_not_be_verbose, #do_not_use_opn, #do_these_curricula_include_both_a_bachelor_and_a_master_curriculum?, #does_this_line_include_a_german_weekday?, #does_this_line_include_a_html_colour?, #e, #ecomment, #editor?, #ee, #enable_colours, #enable_colours_globally, #enable_debug, #encoding?, #english_to_german_weekday, #ensure_main_encoding, #ensure_that_the_log_directory_exists, #eparse, #erev, #esystem, #etomato, #exit_program, #expand_topic, #extract_dd_mm_yyyy, #file_read_with_proper_encoding, #filter_away_invalid_questions, #find_corresponding_exam_topic, #first_argument?, #first_non_hyphen_argument?, #from_curriculum_id_to_university, #german_date_notation, #german_weekday?, #german_weekdays?, #has_a_bachelor_curriculum?, #has_a_master_curriculum?, #has_this_exam_topic_been_solved?, #has_year_entry?, #hh_mm_ss_dd_mm_yyyy, #horizontal_bar?, #html_log_directory?, #is_a_master_lecture?, #is_a_weekday?, #is_connected_to_the_www?, #is_on_roebe?, #is_prüfungsimmanent?, #is_this_a_valid_html_colour?, #is_this_day_today?, #konsole_support?, #last_file?, #lectures_from_indi1, #lectures_from_indi2, #lectures_from_indi3, #lectures_from_indi4, #lectures_from_the_bachelor_genetik_curriculum, #lectures_from_the_individual_vektor_curricula, #load_yaml_dataset, #move_file, #n_days_difference_from_today_to_this_day, #no_ext_name, #no_file_at, #number_to_month, #obtain, #obtain_lectures_from_this_curriculum, #open_in_editor, #opnn, #path_to_exam_topic?, #read_dataset_from_a_curriculum_file, #read_in_exam_dataset_from_this_file, #read_this_file_with_default_encoding, #readlines_from_this_input_file, #register_sigint, #remove_empty_strings, #remove_escape_sequences, #remove_internal_comments, #remove_leading_comments, #remove_leading_weekday_names_from, #remove_newlines, #remove_tags_from_this_input, #rename_kde_konsole_tab, #rename_konsole_tab?, #replace_all_html_colours_in_this, #replace_bold_token_with_default_colour, #replace_italic_token_with_default_colour, #replace_italic_token_with_this_colour, #replace_regular_numbers_with_unicode_numbers, #replace_underline_token_with_default_colour, #replace_underline_token_with_this_colour, #return_all_bachelor_lectures, #return_all_exams_on_this_day, #return_all_numbers_from, #return_all_registered_curricula, #return_all_steop_lectures, #return_current_year, #return_dataset_for_this_topic, #return_dataset_from_this_curriculum_file, #return_dd_mm_yy_and_time_from, #return_directory_for, #return_ects_points_from_these_lectures, #return_either_grey_or_the_custom_colour_for_answers, #return_either_grey_or_the_custom_colour_for_questions, #return_file_for_this_curriculum, #return_german_name_for_this_english_month, #return_german_weekday_of?, #return_hh_mm_ss_from, #return_hour_from_this, #return_lectures_from_bachelor_vektor_curriculum, #return_lectures_with_at_the_least_one_upcoming_exam, #return_local_path_of_this_pwdstud, #return_lva_number_of_this_lecture, #return_month_fitting_to_this_input, #return_n_days_until_monday, #return_n_days_until_sunday, #return_n_exam_questions_in, #return_n_questions_were_answered_for_this_topic, #return_name_of_the_weekday, #return_name_of_this_curriculum, #return_name_of_this_curriculum_based_on_its_id_number, #return_opnn, #return_passed_courses, #return_pwd, #return_random_curriculum, #return_sanitized_dataset_from_the_file_lecture_information, #return_solved_lectures, #return_steop_lectures, #return_the_remote_homepage_url, #return_this_line_has_n_characters_as_html_colour_tags, #return_title_from_this_curriculum_file, #rev, #right_arrow?, #rinstall2, #roebe_exam_directory?, #ruby_src_dir_at_home?, #runmode?, #sanitize_this_topic, #sanitize_url, #select_lectures_with_this_key, #set_be_quiet, #set_be_verbose, #set_commandline_arguments, #set_commandline_mode, #set_runmode, #set_this_cd_alias_to, #set_www_mode, #sfancy, #shall_we_make_use_of_unicode_symbols?, #show_todays_date, #simp, #sort_these_lecture_names_by_time, #spacer, #swarn, #this_month_has_n_days?, #total_ects_points_passed, #translate_dd_mm_yyyy_to_weekday, #try_to_require_the_rcfiles, #turn_this_array_into_the_full_dataset, #unicode_blocks_line, #use_opn?, #vertical_bar?, #web_liner, #weekday?, #weekdays?, #word_wrap, #write_what_into, #www_connection_is_unavailable, #www_mode?, #yaml_dir?
Methods included from Colours
#bold_blue, #bold_red, #bold_yellow, #cadetblue, #chartreuse, crimson, #darkgray, darkgreen, darkseagreen, deepskyblue, #deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #ewarn, #forestgreen, gold, #grey, lightblue, lightgreen, #lightslategray, #lightsteelblue, #mediumorchid, #mediumseagreen, #oldlace, #olivedrab, orange, orangered, #orchid, palevioletred, #papayawhip, rev, royalblue, sdir, #sdir, sfancy, #sfancy, sfile, #sfile, simp, #simp, slateblue, steelblue, #steelblue, #swarn, swarn, #teal, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ ExamsPerMonth
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/studium/exams/exams_per_month/initialize.rb', line 12
def initialize(
commandline_arguments = nil,
run_already = true
)
reset
case commandline_arguments
when :dont_run_yet,
:do_not_run_yet
run_already = false
else
set_input(commandline_arguments)
end
if block_given?
yielded = yield
case yielded
when /^-?-?yearly(-|_)?average(-|_)?grades$/
sanitize_dataset
do_show_yearly_average_grades
report
end
end
run if run_already
end
|
Class Method Details
.curricula_assigned_exams_file? ⇒ Boolean
#
Studium::ExamsPerMonth.curricula_assigned_exams_file?
#
.main_file? ⇒ Boolean
#
ExamsPerMonth.main_file?
#
23
24
25
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 23
def self.main_file?
PASSED_EXAMS_PER_MONTH end
|
16
17
18
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 16
def self.
MENU_FILE
end
|
.open_main_files_in_the_editor ⇒ Object
#
Studium::ExamsPerMonth.open_main_files_in_the_editor
In the past file_theme_of_exams? was part of the Array defined below, but as of 26.03.2019 I decided that this file is no longer useful to me - it will eventually be phased out.
Invocation example to use this method from the commandline:
studium --open
#
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 115
def self.open_main_files_in_the_editor
array_open_these_files = [
main_file?,
curricula_assigned_exams_file?
]
unless Object.const_defined? :Open
begin
require 'open'
rescue LoadError; end
end
array_open_these_files.each {|file|
Open.in_editor(file)
}
end
|
.show_passed_bachelor_lectures ⇒ Object
#
Studium::ExamsPerMonth.show_passed_bachelor_lectures
#
272
273
274
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 272
def self.show_passed_bachelor_lectures
Studium::ExamsPerMonth.new('--show_only_bachelor_lectures')
end
|
.show_passed_master_lectures ⇒ Object
#
Studium::ExamsPerMonth.show_passed_master_lectures
#
265
266
267
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 265
def self.show_passed_master_lectures
Studium::ExamsPerMonth.new('--show_only_master_lectures')
end
|
Instance Method Details
#calculate_the_average_amount_per_passed_exam ⇒ Object
#
calculate_the_average_amount_per_passed_exam
#
17
18
19
20
21
22
23
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 17
def calculate_the_average_amount_per_passed_exam
ects_per_exams_passed = (
@n_ects_points_in_total.to_f / @n_exams_in_total_passed.to_f
).round(2)
return ects_per_exams_passed
end
|
#colour_for_hours(i) ⇒ Object
Also known as:
colourize_hours
#
colour_for_hours
Mediumorchid is the colour for hours.
#
21
22
23
24
|
# File 'lib/studium/exams/exams_per_month/colours.rb', line 21
def colour_for_hours(i)
return mediumorchid(i) if @use_colours return i
end
|
#colourize_ects_points(i) ⇒ Object
Also known as:
colourize_ects, colour_ects
#
colourize_ects_points
No need to check inside this method for konsole support because we already do so before that.
#
52
53
54
55
|
# File 'lib/studium/exams/exams_per_month/colours.rb', line 52
def colourize_ects_points(i)
return dodgerblue(i) if @use_colours
return i
end
|
#colourize_month_year(i) ⇒ Object
#
colourize_month_year
This method will colourize strings such as '04.2017'.
The current colour used here is 'goldenrod'.
#
41
42
43
44
|
# File 'lib/studium/exams/exams_per_month/colours.rb', line 41
def colourize_month_year(i)
return goldenrod(i) if @use_colours
return i
end
|
#colourize_n_exams(i, use_this_colour = :lightslategray) ⇒ Object
#
colourize_n_exams
Combound method to allow different colours.
#
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/studium/exams/exams_per_month/colours.rb', line 63
def colourize_n_exams(
i,
use_this_colour = :lightslategray
)
if use_colours?
case use_this_colour when :lightslategray i = lightslategray(i)
when :oldlace
i = oldlace(i)
when :mediumseagreen
i = mediumseagreen(i)
when :papayawhip
i = papayawhip(i)
end
end
return i
end
|
#colourize_year(i) ⇒ Object
29
30
31
32
|
# File 'lib/studium/exams/exams_per_month/colours.rb', line 29
def colourize_year(i)
return swarn(i) if @use_colours
return i
end
|
#current_year? ⇒ Boolean
Also known as:
current_year
114
115
116
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 114
def current_year?
@current_year
end
|
#dataset? ⇒ Boolean
28
29
30
|
# File 'lib/studium/exams/exams_per_month/dataset.rb', line 28
def dataset?
@dataset
end
|
#determine_n_ects_points_in_total ⇒ Object
#
determine_n_ects_points_in_total
The main Hash will look like this:
{"07.2018"=>[9.0, 14.0, ["+", "4", "1", "1"], "uniwien", 4]
The relevant ECTS entries are in the value part, at the second position, so [1].
#
684
685
686
687
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 684
def determine_n_ects_points_in_total
n_ects_points = @hash.values.map {|entry| entry[1] }.sum
set_n_ects_points_in_total(n_ects_points)
end
|
#determine_n_exams_in_total_were_passed ⇒ Object
#
determine_n_exams_in_total_were_passed
#
692
693
694
695
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 692
def determine_n_exams_in_total_were_passed
n_exams = @hash.values.map {|entry| entry.last }.sum
set_n_exams_in_total_passed(n_exams)
end
|
#determine_n_hours_were_passed_in_total ⇒ Object
#
determine_n_hours_were_passed_in_total
#
1229
1230
1231
1232
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 1229
def determine_n_hours_were_passed_in_total
i = @hash.values.map {|entry| entry[0].to_f }.sum.to_f
@n_hours_passed_in_total = i
end
|
#do_show_ects_points ⇒ Object
192
193
194
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 192
def do_show_ects_points
@show_ects_points = true end
|
#do_show_only_grade_for(i = nil) ⇒ Object
#
do_show_only_grade_for
#
168
169
170
171
172
173
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 168
def do_show_only_grade_for(
i = nil
)
i = i.to_i if i
@show_only_grade_for = i
end
|
#do_show_only_this_year_here(i) ⇒ Object
#
do_show_only_this_year_here
Use this method if you only want to show a specific year, such as 2013 or 2017 and so forth.
#
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
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 87
def do_show_only_this_year_here(i)
@show_only_this_year = i _ = dataset?.select {|entry| the_year = entry.first.strip.split('.').last.to_s
is_it_included = false
is_it_included = true if @show_only_this_year == the_year
if @show_only_this_year.include? '-'
range = Range.new(*@show_only_this_year.split('-').map(&:to_i))
if range.include? the_year.to_i is_it_included = true
end
end
is_it_included
}
reset_main_hash sanitize_dataset(_, :leave_time_entry_alone)
end
|
#do_show_the_grades_statistics ⇒ Object
#
do_show_the_grades_statistics
Show all grade statistics.
Invocation example:
emo --grades
#
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
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 549
def do_show_the_grades_statistics
_ = dataset?
hash_containing_the_relevant_entries = {}
hash_containing_the_relevant_entries[1] = [0,0,0]
hash_containing_the_relevant_entries[2] = [0,0,0]
hash_containing_the_relevant_entries[3] = [0,0,0]
hash_containing_the_relevant_entries[4] = [0,0,0]
_.each {|line|
this_grade = line[3].to_i
if this_grade == 0
else
n_ects_points = line[1].to_f
n_hours = line[2].to_f
array = hash_containing_the_relevant_entries[this_grade]
array[0] += 1
array[1] += n_ects_points array[2] += n_hours hash_containing_the_relevant_entries[this_grade] = array
end
}
e
e lightgreen('The grades that were passed successfully, are as follows:')
e
average_grade = 0
average_grade_weighted_by_ects_points = 0
n_total_exams = hash_containing_the_relevant_entries.values.map {|array|
array.first
}.sum
hash_containing_the_relevant_entries.each_pair {|grade, array_dataset|
n_exams_passed = array_dataset.first
total_n_ects_points = array_dataset[1]
total_n_hours = array_dataset.last
n_percent = (n_exams_passed.to_i * 100 / n_total_exams).round(3).to_s
e "For the grade #{simp(grade)} #{crimson(n_exams_passed.to_s)} "\
"exams were passed successfully. (#{crimson(n_percent.to_s+'%')})"
e " n ECTS points: #{mediumorchid(total_n_ects_points.to_s.rjust(5))}"
e " n hours: #{mediumpurple(total_n_hours.to_s.rjust(5))}"
e
}
hash = hash_containing_the_relevant_entries
average_grade = (1 * hash[1][0]+
2 * hash[2][0]+
3 * hash[3][0]+
4 * hash[4][0])
total_n_ects_points = hash[1][1].to_f+
hash[2][1].to_f+
hash[3][1].to_f+
hash[4][1].to_f
average_grade_weighted_by_ects_points = (
1 * hash[1][1].to_f+
2 * hash[2][1].to_f+
3 * hash[3][1].to_f+
4 * hash[4][1].to_f
)
average_grade_weighted_by_ects_points =
average_grade_weighted_by_ects_points.to_f / total_n_ects_points.to_f average_grade = average_grade.to_f / (
hash[1][0]+
hash[2][0]+
hash[3][0]+
hash[4][0]
) average_grade = average_grade.round(2)
e 'This means that the average grade is: '+
slateblue(average_grade.to_s)
e 'And the average grade, weighted per single (1.0) ECTS point, is: '+
lightblue(average_grade_weighted_by_ects_points.round(2).to_s)
e
end
|
#do_show_yearly_average_grades ⇒ Object
#
do_show_yearly_average_grades
#
178
179
180
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 178
def do_show_yearly_average_grades
@show_yearly_average_grades = true
end
|
#draw_image_with_gruff ⇒ Object
#
draw_image_with_gruff
If we wish to draw an image with gruff then we use this method here.
#
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
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 34
def draw_image_with_gruff
begin
require 'gruff'
rescue LoadError; end
opnn; e 'Startup of class '+sfancy(self.class.name)+'.'
@g = Gruff::Line.new(800)
@g.theme_keynote
@g.title_font_size = 25
@g.title = title?
@g.labels = {
1 => '25.10.2005',
11 => '08.04.2014',
20 => Time.now.strftime('%d.%m.%Y')
}
@g.data('Amount of exams per month',
[
274,340,851,1114,1168,1195,1230,
1245,1270,1315,1352,2524,2621],
'slateblue')
@g.minimum_value = 1
store_result
open_result_in_gimp
end
|
#
On Roebe, we will use the file in the home system.
#
93
94
95
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 93
def input?
@input
end
|
#is_this_sommersemester_or_wintersemester?(i) ⇒ Boolean
#
is_this_sommersemester_or_wintersemester?
This method will return SS or WS, as String.
The following months are Sommersemester (SS):
März, April, Mai, Juni, Juli, August, September (3-9)
The following months are Wintersemester (WS):
Oktober, November, Dezember, Jänner, Februar (10-2)
#
218
219
220
221
222
223
224
225
226
227
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 218
def is_this_sommersemester_or_wintersemester?(i)
return_this_string = '' case i.to_i when 3..9
return_this_string = 'SS'
when 10,11,12,1,2 return_this_string = 'WS'
end
return return_this_string
end
|
#last_year? ⇒ Boolean
Also known as:
last_year
107
108
109
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 107
def last_year?
@last_year
end
|
#main_file? ⇒ Boolean
43
44
45
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 43
def main_file?
self.class.main_file?
end
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/studium/exams/exams_per_month/menu.rb', line 18
def (
i = input?
)
case i when /^-?-?universities$/i,
/^-?-?unis$/i
show_ects_passed_per_university
exit
when /^-?-?OPEN$/i
open_the_main_files_in_the_editor
exit
when /^-?-?boku$/,'BOKU'
show_only_exams_at_the_boku
when /^-?-?since (\d{1,4}\.?\d{0,2}\.?\d{0,4})$/, /^-?-?after (\d{1,4}\.?\d{0,2}\.?\d{0,4})$/ show_only_exams_past_this_date($1.to_s.dup)
when /^-?-?best(_|-)?month(_|-)?stats$/,
/^-?-?show(_|-)?best(_|-)?months?$/,
/^-?-?best(_|-)?months?$/
show_best_months
exit
when /^-?-?master$/
@hash.clear
use_only_master_lectures
when /^-?-?years$/,
/^-?-?table/,
/^-?-?short$/
show_the_years_in_a_short_table_overview
exit
when /^-?-?summary$/i
e; show_only_the_summary; e
exit
when /--half-split/
show_half_split_exams_per_year
exit
when /nl/,
/^-?-?show(_|-)?numbered(_|-)?exams$/, /^-?-?show(_|-)?passed(_|-)?lectures$/i
show_numbered_exams
exit
when /^-?-?only(_|-)?bachelor$/,
/^-?-?only(_|-)?bachelor(_|-)?lectures$/,
/^-?-?only(_|-)?bachelorcurricula$/,
/^-?-?show(_|-)?only(_|-)?bachelor(_|-)?lectures$/,
/^-?-?show(_|-)?bachelor(_|-)?lectures$/
show_only_bachelor_lectures
exit
when /^-?-?only(_|-)?master$/,
/^-?-?only(_|-)?master(_|-)?lectures$/,
/^-?-?only(_|-)?mastercurricula$/,
/^-?-?show(_|-)?only(_|-)?master(_|-)?lectures$/,
/^-?-?show(_|-)?master(_|-)?lectures$/
show_only_master_lectures
exit
when /-?-?disable-?colours/,
/-?-?nocolours/,
/-?-?dcolours/,
/-?-?nocol/
disable_colours
show_n_exams_passed_per_month
when /^-?-?yearly(_|-)?average(_|-)?grades$/,
/^-?-?yearly(_|-)?grades$/
do_show_yearly_average_grades
when /-?-?grades/
do_show_the_grades_statistics
exit
when /--grade=(\d+)/
do_show_only_grade_for($1.to_s.dup)
show_n_exams_passed_per_month
when /-?-?TU$/,
/-?-?tu$/,
/-?-?tuwien/
show_only_exams_at_the_tu
when /-?-?before (\d{1,4}\.?\d{0,2}\.?\d{0,4})/, /-?-?until (\d{1,4}\.?\d{0,2}\.?\d{0,4})/
show_only_exams_before_this_date($1.to_s.dup)
when /-?-?year=(\d+-?\d*)/,
/-?-?(\d{4})/,
/-?-?(\d{4}-?\d*)/ do_show_only_this_year_here($1.to_s.dup)
when /-?-?uniwien/,'--uniw',/-?-?wien/,'UNIWIEN','WIEN',
/-?-?vienna/
show_only_exams_at_the_uniwien
when /-?-?meduni$/,'--medu','--med','MEDUNI','MED','meduniwien',
'meduni'
show_only_exams_at_the_meduni
when /-?-?vetmed/,'--vet','VET','VETMED'
show_only_exams_at_the_vetmed_uni
when /-?-?only-?bachelor/ show_only_bachelor_exams
when /-?-?(individuell(_|-| )?bachelor)/
show_how_many_exams_we_have_passed_in_this_curriculum($1.to_s.dup)
exit
when /-?-?übungen/,
/--practical/
show_only_practical_courses_that_were_passed_already
when /-?-?semesters\??/
show_exam_ects_points_passed_per_semester
exit
when /-?-?reversed?-?nl/
show_numbered_exams(:reversed)
exit
when /-?-?(master-?lmbt)/
show_how_many_exams_we_have_passed_in_this_curriculum($1.to_s.dup)
exit
when /-?-?(lmbt)/,/-?-?(lbt)/
show_how_many_exams_we_have_passed_in_this_curriculum($1.to_s.dup)
exit
when /-?-?(agrarwissenschaften)/,/-?-?(AW)/
show_how_many_exams_we_have_passed_in_this_curriculum($1.to_s.dup)
exit
when '--show','--output'
output_the_csv_file
exit
when 'HELP',/^-?-?help$/
show_help
exit
when 'gruff','--gruff','image'
draw_image_with_gruff else if i and i.is_a?(String) and i.start_with?('/') and
(i.count('/') > 1) use_this_regexp = Regexp.new(i.delete('/'), Regexp::IGNORECASE)
Studium.try_to_report_exams_that_match_to_this_regexp(use_this_regexp)
exit
elsif i and ARRAY_REGISTERED_MONTHS.include?(i.delete('-').downcase)
show_all_exams_from_this_month(i.downcase)
exit
else end
end
end
|
50
51
52
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 50
def
self.class.
end
|
#n_exams_passed?(for_this_year = @current_year) ⇒ Boolean
121
122
123
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 121
def n_exams_passed?(for_this_year = @current_year)
@n_exams_passed
end
|
#obtain_dataset(use_this_file = main_file?
) ⇒ Object
#
obtain_dataset
The default value for the first argument is PASSED_EXAMS_PER_MONTH, which is represented by the method called main_file?.
#
17
18
19
20
21
22
23
|
# File 'lib/studium/exams/exams_per_month/dataset.rb', line 17
def obtain_dataset(
use_this_file = main_file?
)
set_dataset(
raw_dataset?(use_this_file)
)
end
|
#open_result_in_gimp ⇒ Object
#
open_result_in_gimp
This method is, quite obviously, for image-files.
#
135
136
137
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 135
def open_result_in_gimp
esystem "gimp #{store_where?} &"
end
|
#open_the_curricula_assigned_exams_file_in_the_editor ⇒ Object
#
open_the_curricula_assigned_exams_file_in_the_editor
#
86
87
88
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 86
def open_the_file_lecture_information_in_the_editor
Open.in_editor(file_lecture_information?)
end
|
#open_the_main_file_in_the_editor ⇒ Object
#
open_the_main_file_in_the_editor
#
72
73
74
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 72
def open_the_main_file_in_the_editor
Open.in_editor(main_file?)
end
|
#open_the_main_files_in_the_editor ⇒ Object
#
open_the_main_files_in_the_editor (open tag)
This method bundles together some other open-related methods. It should ideally come last in this file here, so that it can be updated at a later time if my use case has changed.
#
97
98
99
100
101
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 97
def open_the_main_files_in_the_editor
open_the_main_file_in_the_editor
open_the_file_lecture_information_in_the_editor
end
|
79
80
81
|
# File 'lib/studium/exams/exams_per_month/open.rb', line 79
def
Open.in_editor()
end
|
#output_colourized_year_and_colourized_hours(year) ⇒ Object
#
output_colourized_year_and_colourized_hours
#
232
233
234
235
236
237
238
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 232
def output_colourized_year_and_colourized_hours(year)
unless @compare_these_numbers and !@compare_these_numbers.include?(year)
e colourize_year(year.to_s) e " "\
"#{colourize_hours('n hours')}"
end
end
|
#output_the_csv_file ⇒ Object
#
output_the_csv_file
We will either use Cat[], if it is available, or just File.read().
#
201
202
203
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 201
def output_the_csv_file
e File.read(csv_file?)
end
|
#raw_dataset?(use_this_file = main_file?
) ⇒ Boolean
#
raw_dataset?
This method will return an Array. The Array came from the file 'passed_exams_per_month.csv'.
#
56
57
58
59
60
61
62
|
# File 'lib/studium/exams/exams_per_month/dataset.rb', line 56
def raw_dataset?(
use_this_file = main_file?
)
readlines_from_this_input_file(use_this_file).reject! {|entry|
entry.start_with? '#'
}.map(&:chomp).reject(&:empty?)
end
|
#report_how_many_ects_points_have_been_gathered_so_far(n_ljust = 52) ⇒ Object
#
report_how_many_ects_points_have_been_gathered_so_far
#
1174
1175
1176
1177
1178
1179
1180
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 1174
def report_how_many_ects_points_have_been_gathered_so_far(
n_ljust = 52
)
e "In total, #{slategray('n ECTS points')} have been "\
"gathered so far: ".ljust(n_ljust)+
"#{sfancy(@n_ects_points_in_total.to_s)}"
end
|
#report_how_many_exams_were_passed_in_total(i = @n_exams_in_total_passed, ljust_n_times = 76, n_rjust = 4) ⇒ Object
#
report_how_many_exams_were_passed_in_total
#
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 1237
def report_how_many_exams_were_passed_in_total(
i = @n_exams_in_total_passed,
ljust_n_times = 76,
n_rjust = 4
)
if ljust_n_times == :default
ljust_n_times = 76
end
e (
"In total, #{slategray('n exams')} have been passed:"
).ljust(ljust_n_times)+
sfancy(i.to_s.rjust(n_rjust))
end
|
#report_how_many_hours_were_passed_in_total(i = @n_hours_passed_in_total, n_ljust = 76, n_rjust = 6) ⇒ Object
#
report_how_many_hours_were_passed_in_total
This method will report how many hours were passed in total.
#
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 1256
def report_how_many_hours_were_passed_in_total(
i = @n_hours_passed_in_total,
n_ljust = 76,
n_rjust = 6
)
if n_ljust == :default
n_ljust = 76
end
left_side_string = "In total, #{slategray('n hours')} were completed: ".ljust(n_ljust)
i = i.round(1) if i.is_a? Float
e left_side_string+
sfancy(i.to_s.rjust(n_rjust))
end
|
#report_how_many_of_these_ects_points_required_mandatory_presence(n_ects_points_in_mandatory_presence_courses = Studium.n_ects_points_in_mandatory_presence_courses, n_ljust = 77) ⇒ Object
#
report_how_many_of_these_ects_points_required_mandatory_presence
Report how many ECTS points have been passed that required a mandatory presence (aka “prüfungsimmanent” in german).
#
#report_month_year_hours_ects_n_exams_passed_in_this_month(month, year, n_hours, n_ECTS, n_exams_passed_in_this_month) ⇒ Object
#
report_month_year_hours_ects_n_exams_passed_in_this_month
#
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 243
def report_month_year_hours_ects_n_exams_passed_in_this_month(
month, year, n_hours, n_ECTS, n_exams_passed_in_this_month
)
result = (
colourize_month_year(month.to_s.rjust(2,'0')+'.'+year.to_s)+
':'+(' ' * 13)+ colourize_hours(n_hours.to_s.rjust(6))+' '
).dup
if show_ects_points?
result << colourize_ects('('+n_ECTS.to_f.to_s.rjust(4)+' ECTS points)')
end
result << colourize_n_exams(' (n exams passed that month: '+
n_exams_passed_in_this_month.to_s.rjust(2)+')')
e result
end
|
#report_the_average_amount_of_ects_per_passed_exam(ects_per_exams_passed = calculate_the_average_amount_per_passed_exam, ljust_n_times = 76, rjust_n_times = 12) ⇒ Object
#
report_the_average_amount_of_ects_per_passed_exam
#
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 1185
def report_the_average_amount_of_ects_per_passed_exam(
ects_per_exams_passed = calculate_the_average_amount_per_passed_exam,
ljust_n_times = 76,
rjust_n_times = 12
)
if ljust_n_times == :default
ljust_n_times = 76
end
left_padded_side = "On average, the "\
"#{slategray('ECTS per passed exam')} "\
"are: ".ljust(ljust_n_times)
e left_padded_side+
sfancy(
(ects_per_exams_passed.to_s+' ECTS').rjust(rjust_n_times)
)
end
|
#report_the_average_grade(n_ljust = 76, n_rjust = 4) ⇒ Object
#
report_the_average_grade
#
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 1158
def report_the_average_grade(
n_ljust = 76,
n_rjust = 4
)
if n_ljust == :default
n_ljust = 76
end
e "The #{slategray('average grade')} for these exams is: ".ljust(n_ljust+3)+
sfancy(
average_grade.to_s.rjust(n_rjust)
)
end
|
#report_total_amount_of_ects_points(total_ects_points, bachelor_or_master = :bachelor, ljust_to_use = 41) ⇒ Object
#
report_total_amount_of_ects_points
#
454
455
456
457
458
459
460
461
462
463
464
465
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 454
def report_total_amount_of_ects_points(
total_ects_points,
bachelor_or_master = :bachelor,
ljust_to_use = 41 )
bachelor_or_master = bachelor_or_master.to_s.capitalize e
e 'Total ECTS points from '+bachelor_or_master+' lectures: '.
ljust(ljust_to_use)+
slateblue(total_ects_points.to_s+' ECTS')
e
end
|
#reset ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/studium/exams/exams_per_month/reset.rb', line 12
def reset
super() do_show_ects_points
@namespace = NAMESPACE
@shall_we_report = true @show_only_grade_for = nil @total_grade = 0
@n_exams_in_total_passed = 0
@n_ects_points_belonging_to_mandatory_presence_courses = 0
@total_ects_points = 0 @n_ects_points = 0 @n_ects_points_in_total = 0 @n_hours_passed_in_total = 0 @compare_these_numbers = nil
@show_only_this_year = nil
@use_colours = true @show_average_ects_passed_per_exam = true
@show_yearly_average_grades = false
@show_n_best_months = SHOW_N_BEST_MONTHS
@dataset_from_the_file_lecture_information =
return_dataset_from_the_file_lecture_information
set_current_year(Time.now.strftime('%Y').to_i)
set_last_year
reset_main_hash
obtain_dataset end
|
#reset_ects_points ⇒ Object
Also known as:
reset_ects
111
112
113
|
# File 'lib/studium/exams/exams_per_month/reset.rb', line 111
def reset_ects_points
@n_ects_points = 0
end
|
#reset_main_hash ⇒ Object
96
97
98
99
|
# File 'lib/studium/exams/exams_per_month/reset.rb', line 96
def reset_main_hash
@hash = {}
@hash.default = []
end
|
#reset_n_hours ⇒ Object
Also known as:
reset_hours
104
105
106
|
# File 'lib/studium/exams/exams_per_month/reset.rb', line 104
def reset_n_hours
@n_hours_passed_in_total = 0
end
|
#run ⇒ Object
12
13
14
15
16
|
# File 'lib/studium/exams/exams_per_month/run.rb', line 12
def run
sanitize_dataset
report if @shall_we_report
end
|
#sanitize_dataset(i = dataset?,
, modify_time_entry = true) ⇒ Object
#
sanitize_dataset
Purpose of this method is to give us a sorted hash with the specific entries. In order for this to work, simply pass in your dataset into this method. By default, we will use the dataset? object, which is essentially just the @dataset instance variable.
The initial dataset should have 6 entries, thus 5 occurrences of '|'.
Example for such a dataset/line:
"06.07.2018 | 1.0 | 1.0 | 1 | UniWien | M | VO | 270073 | 2018S | Nukleinsäureanalytik-Genomics"
#
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/studium/exams/exams_per_month/sanitize.rb', line 28
def sanitize_dataset(
i = dataset?,
modify_time_entry = true
)
@n_ects_points_belonging_to_mandatory_presence_courses = 0 case modify_time_entry
when :leave_time_entry_alone
modify_time_entry = false
end
@dataset = i.map {|entry|
if entry.is_a? Array
splitted = entry
else
encoding_to_use = ::Studium.encoding?
unless entry.encoding.to_s.include? encoding_to_use
entry = entry.force_encoding(encoding_to_use)
end
splitted = entry.split(' | ') end
if splitted.size <= 2 splitted = nil
else
if modify_time_entry
formatted_time = splitted[0].split('.')[1..-1].join('.') splitted[0] = formatted_time
end
if @compare_these_numbers and formatted_time
the_year = formatted_time.split('.').last.to_i
unless @compare_these_numbers.include? the_year
splitted = nil
end
end
end
splitted
}
@dataset.compact! @n_exams_passed = 0
@dataset.each {|entry|
entry.map!(&:strip)
month_and_year = entry[0] n_hours = entry[1].to_f n_ects_points = entry[2].to_f grade = entry[3] university = entry[4].strip.downcase _curriculum_type = entry[5].strip lecture_type = entry[6].strip if is_a_prüfungsimmanent_course?(lecture_type)
@n_ects_points_belonging_to_mandatory_presence_courses += n_ects_points
end
@n_exams_passed += 1
if @hash.has_key? month_and_year
new_n_hours = @hash[month_and_year][0]+n_hours
new_n_ects_points = @hash[month_and_year][1]+n_ects_points
array_grade = @hash[month_and_year][2] << grade
@hash[month_and_year] = [
new_n_hours, new_n_ects_points, array_grade, university, @n_exams_passed
]
else @n_exams_passed = 0 @n_exams_passed += 1 @hash[month_and_year] = [
n_hours, n_ects_points, [grade], university, @n_exams_passed
]
end
}
end
|
#set_current_year(i = Time.now.strftime('%Y').to_i) ⇒ Object
#
set_current_year
This must be an Integer.
#
130
131
132
133
134
135
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 130
def set_current_year(
i = Time.now.strftime('%Y').to_i
)
i = i.to_i
@current_year = i
end
|
#set_dataset(i) ⇒ Object
46
47
48
|
# File 'lib/studium/exams/exams_per_month/dataset.rb', line 46
def set_dataset(i)
@dataset = i
end
|
#
The input can be an Array such as [“2013”, “2015”], in which case we will only output certain numbers matching these criteria.
#
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 143
def set_input(i = nil)
if i.is_a? Array
unless i.empty? only_numbers = i.all? {|number|
number.to_s =~ /^\d+$/ }
if only_numbers
@compare_these_numbers = i.map(&:to_i)
end
end
i = i.join(' ').strip
end
@input = i
end
|
#set_last_year(i = current_year?)
) ⇒ Object
100
101
102
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 100
def set_last_year(i = current_year?)
@last_year = i
end
|
#set_n_ects_points_in_total(i) ⇒ Object
#
set_n_ects_points_in_total
#
670
671
672
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 670
def set_n_ects_points_in_total(i)
@n_ects_points_in_total = i.to_f
end
|
#set_n_exams_in_total_passed(i) ⇒ Object
#
set_n_exams_in_total_passed
#
663
664
665
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 663
def set_n_exams_in_total_passed(i)
@n_exams_in_total_passed = i.to_f
end
|
#set_store_where(i) ⇒ Object
70
71
72
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 70
def set_store_where(i)
@store_where = i
end
|
#show_all_exams_from_this_month(i = 'januar') ⇒ Object
#
show_all_exams_from_this_month
Use this method to show all exams from a given month only.
We also support english names for the months, since as of April 2017.
Usage example:
emo --januar
#
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
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 201
def show_all_exams_from_this_month(i = 'januar')
i.delete!('-') if i.include? '-'
i.downcase!
case i when 'januar','january'
i = '01'
when 'februar','february',/feb/
i = '02'
when 'märz','march'
i = '03'
when 'april'
i = '04'
when 'mai','may'
i = '05'
when 'juni','june'
i = '06'
when 'juli','july'
i = '07'
when 'august'
i = '08'
when 'september'
i = '09'
when 'oktober','october'
i = '10'
when 'november'
i = '11'
when 'dezember','december'
i = '12'
end
_ = dataset?.select {|inner_array|
month_and_year = inner_array.first
splitted = month_and_year.split('.')
month = splitted.first
month == i
}
reset_main_hash
sanitize_dataset(_, :leave_time_entry_alone)
end
|
#show_best_months(do_show_n_months = @show_n_best_months) ⇒ Object
#
show_best_months
This method will show the best months, sorted. Best comes first.
Invocation example:
emo --show-best-months
#
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
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 756
def show_best_months(
do_show_n_months = @show_n_best_months
)
opnn; e 'Showing the '+slateblue(do_show_n_months.to_s)+' best '\
'months next, sorted by n ECTS points passed:'
e
hash_month_statistics = {}
_ = @hash.sort_by {|key, inner_array|
n_ECTS_points = inner_array[1].to_f
n_ECTS_points
}.reverse
array_to_display = []
_.each {|month, inner_array|
array_to_display << [ month, inner_array[1].to_f ]
}
array_to_display = array_to_display[0..(do_show_n_months - 1)]
exam_number_n = 0 array_to_display.each {|month, n_ECTS_points_passed|
exam_number_n += 1
left_pad = ((exam_number_n.to_s+')').rjust(5)).ljust(6)
rounded_n_ECTS_points_passed = n_ECTS_points_passed.to_s.to_f.round(1)
e yellow(left_pad)+'In the month '+
sfancy(month)+', '+
violet(rounded_n_ECTS_points_passed.to_s.rjust(4))+
' ECTS points were completed.'
this_month = month.split('.').first.to_i this_month = Studium::MONTH_NUMBER_TO_MONTH_NAME[this_month]
hash = {
:n_ects => n_ECTS_points_passed,
:n_times_mentioned => 1
}
if hash_month_statistics.has_key? this_month
hash_month_statistics[this_month][:n_ects] += n_ECTS_points_passed
hash_month_statistics[this_month][:n_times_mentioned] += 1
else
hash_month_statistics[this_month] = hash
end
}
e
colourized_n_best_months = orange(do_show_n_months)
opnn; e "The best #{colourized_n_best_months} (top) months "\
"seem to be the following ones:"
e
_ = hash_month_statistics
_ = _.sort_by {|name_of_the_month, hash_containing_n_ects_and_n_times_mentioned|
n_ects = hash_containing_n_ects_and_n_times_mentioned[:n_ects]
n_ects
}.reverse
counter = 0
_.each {|name_of_the_month, hash_containing_n_ects_and_n_times_mentioned|
next if counter > 7 n_ects = hash_containing_n_ects_and_n_times_mentioned[:n_ects]
n_times_mentioned = hash_containing_n_ects_and_n_times_mentioned[:n_times_mentioned]
counter += 1
e ' '+
sfancy((name_of_the_month+':').ljust(12))+
orange(n_times_mentioned.to_s.rjust(2))+ olivedrab(' (ECTS in total: ')+
colourize_ects_points(n_ects.to_s.rjust(5))+
olivedrab('; average ECTS in that month: ')+
colourize_ects_points(
(n_ects.to_f / n_times_mentioned.to_i).round(1).to_s.rjust(4)
)+
olivedrab(')')
}
e
end
|
#show_colourized_line(n_times = 34) ⇒ Object
742
743
744
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 742
def show_colourized_line(n_times = 34)
e simp('-' * n_times)
end
|
#show_ects_passed_per_university ⇒ Object
#
show_ects_passed_per_university
#
1277
1278
1279
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 1277
def show_ects_passed_per_university
Studium::EctsPerUniversity.new { :sort_by_highest_first }
end
|
#show_ects_points? ⇒ Boolean
185
186
187
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 185
def show_ects_points?
@show_ects_points
end
|
#show_exam_ects_points_passed_per_semester ⇒ Object
#
show_exam_ects_points_passed_per_semester
#
271
272
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
320
321
322
323
324
325
326
327
328
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 271
def show_exam_ects_points_passed_per_semester
hash = {}
_ = dataset?
opnn; e 'We will next show how many exams were passed in a given semester.'
_.each {|inner_array|
_n_wochenstunden = inner_array[1]
n_ects_points = inner_array[2]
_name_of_the_lecture = inner_array.last
month_year = inner_array.first
year = month_year.dup
if month_year.include? '.'
splitted = month_year.split('.')
month_year = splitted.first
year = splitted.last.to_i
end
sommersemester_or_wintersemester = is_this_sommersemester_or_wintersemester?(
month_year
)
month_as_number = month_year.split('.').first.to_i
if (sommersemester_or_wintersemester == 'WS') and
[1,2].include?(month_as_number)
year -= 1
end
hash_key_to_use = sommersemester_or_wintersemester+' '+year.to_s
if hash.has_key? hash_key_to_use hash[hash_key_to_use] = hash[hash_key_to_use]+n_ects_points.to_f
else
hash[hash_key_to_use] = n_ects_points.to_f
end
}
e 'We have determined these ECTS points per semester:'; e
hash.each_pair {|semester_and_year, n_ects_points|
e ' '+simp(semester_and_year.ljust(8))+' '+
sfancy(((n_ects_points.to_s.rjust(4))+' ECTS').rjust(8))
}
e; e 'Total ECTS points: '+simp(hash.values.sum.to_s)
end
|
#show_half_split_exams_per_year ⇒ Object
#
show_half_split_exams_per_year
This method can be used to show how many exams were passed, per year, in each half of that year.
Invocation example:
emo --half-split
#
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
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 36
def show_half_split_exams_per_year
array_early_months = %w( 1 2 3 4 5 6 ).map(&:to_i)
array_late_months = %w( 7 8 9 10 11 12 ).map(&:to_i)
hash = {}
raw_dataset?.each {|this_line|
next unless this_line.include? '|'
splitted = this_line.strip.split('|').map(&:strip)
first_element = splitted.first n_ects = splitted[2].to_f
year = first_element.split('.').last
hash[year] = {
:early_months => 0,
:late_months => 0
} unless hash.has_key? year
month = first_element.split('.')[1].to_i
if array_early_months.include? month
hash[year][:early_months] += n_ects
elsif array_late_months.include? month
hash[year][:late_months] += n_ects
end
}
hash.each_pair {|year, value|
n_ljust = 28
first_half_ects_points = value[:early_months].to_f
second_half_ects_points = value[:late_months].to_f
unless ( (first_half_ects_points == 0) and (second_half_ects_points == 0) )
e slateblue(year+':')
e
if first_half_ects_points > 0
e (' Start of the year '+year+': ').ljust(n_ljust)+
orange(first_half_ects_points.to_s.rjust(4)+' ECTS points')
end
if second_half_ects_points > 0
e (' End of the year '+year+':').ljust(n_ljust)+
orange(second_half_ects_points.to_s.rjust(4)+' ECTS points')
end
e
end
}
end
|
#show_help ⇒ Object
#
show_help (help tag)
To invoke this method, do:
emo --help
#
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
|
# File 'lib/studium/exams/exams_per_month/help.rb', line 17
def show_help
left_indent = (' ' * 26)+'# ' opnn; e 'Currently these options are supported:'
e
e ' input numbers only to compare years, such as: '
e
e " #{sfancy('emo 2013 2015')}"
e
e ' --disable-colours # Do not use colours'
e ' --gruff # draw an image with gruff'
e ' --nl # show a numbered listing of the '\
'passed exams, starting from 1 (== most recent exam)'
e ' --only-bachelor # show only Bachelor exams'
e ' --open # open the .csv file in the editor'
e ' --show # show / output the .csv file on '\
'the terminal'
e ' --semesters # show the amount of ECTS points passed '\
'per (full) semester'
e " --übungen # show only practical courses that were "\
"passed (#{sfancy('--practical')} is an alias to this)"
e ' --grades # show a distribution of my grades (1,2,3,4)'
e ' --grade={1,2,3,4,5] # show only grades that qualify for this'
e ' --yearly-average-grades # show the yearly average grades'
e ' --year=(dddd) # show only this specific year, such '\
'as "year=2016"; year=1996-2013 is also'
e left_indent+'supported; you can also omit --"year" such as '\
'in: emo --2005'
e ' --master # show only entries registered in '\
'a master curriculum'
e ' --boku # show only exams at this given '\
'university; also works with TU, UniWien etc'
e ' --summary # show only the summary over the '\
'exam-dataset'
e ' --only-master-lectures # show only lectures that are part '\
'of a (at the least one) master-curriculum.'
e ' --show-best-months # This will show the best 10-'+
SHOW_N_BEST_MONTHS.to_s+' months '\
'or so, in regards to'
e left_indent+'n ECTS points accumulated'
e ' --years # show only the amount of ECTS '\
'passed per year'
e ' --month # show the month, such as "emo --february"'
e ' "since 18.01.2013" # show only exams past this '\
'specified date (in the mandatory format dd.mm.yyyy)'
e ' "before 18.01.2013" # show only exams before this '\
'specified date (in the mandatory format dd.mm.yyyy)'
e
e 'The next options show how many exams were passed already '\
'in a given curriculum:'
e
e ' emo --agrarwissenschaften'
e ' emo --lmbt'
e
end
|
#show_how_many_exams_we_have_passed_in_this_curriculum(i) ⇒ Object
#
show_how_many_exams_we_have_passed_in_this_curriculum
This method will show how many exams we have already passed for a given curriculum xyz.
To invoke this, do:
emo --agrarwissenschaften
#
649
650
651
652
653
654
655
656
657
658
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 649
def show_how_many_exams_we_have_passed_in_this_curriculum(i)
require 'studium/utility_scripts/show_lectures_on_the_commandline/show_lectures_on_the_commandline.rb'
i = i.to_s.delete('_')
_ = ::Studium::ShowLecturesOnTheCommandline.new(
i, :do_not_run_yet
)
_.do_not_report_anything
_.iterate_over_the_lectures
_.report_how_many_exams_have_been_passed_already
end
|
#show_n_exams_passed_per_month(i = @hash) ⇒ Object
Also known as:
report_main_hash, report
#
show_n_exams_passed_per_month (report tag)
This is the main report-method for this class.
Make sure that the input to this method is correct.
#
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
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
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
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 940
def show_n_exams_passed_per_month(
i = @hash
)
month = 0
year = 0
n_hours = 0
n_ECTS = 0
grade = 0
n_exams_passed_in_this_month = 0
total_n_ects_passed_in_this_year = 0
total_n_hours_passed_in_this_year = 0
total_n_exams_passed_in_this_year = 0
total_grade_count_in_this_year = 0
exclude_n_exams_from_the_grade_list = 0
last_year = LAST_YEAR this_year = Time.now.year.to_i
if @show_only_grade_for
opnn; e "We will only show grades that are equal to "\
"#{simp(@show_only_grade_for.to_s)}."
end
e
opnn; e 'We will show how many hours / ECTS we passed per '\
'given month and then year.'
e
spacer
if @show_only_this_year and
@show_only_this_year.include?('-') and
@show_only_this_year.split('-').last.to_i < last_year
elsif @show_only_this_year and
(@show_only_this_year != last_year) and
(this_year != last_year)
else output_colourized_year_and_colourized_hours(last_year)
end
i.each {|month_year, n_hours_n_ECTS_grade_university_n_exams_passed|
month, year = month_year.split('.').map(&:to_i)
n_hours, n_ECTS, grade, _university, n_exams_passed_in_this_month =
n_hours_n_ECTS_grade_university_n_exams_passed
if @show_only_grade_for
next unless grade == @show_only_grade_for
end
if year != last_year
show_total_summary_for_year_hours_ects_n_exams(
last_year, total_n_hours_passed_in_this_year,
total_n_ects_passed_in_this_year,
total_n_exams_passed_in_this_year,
total_grade_count_in_this_year
) {{ exclude_n_exams_from_the_grade_list: exclude_n_exams_from_the_grade_list }}
total_n_ects_passed_in_this_year = 0
total_n_hours_passed_in_this_year = 0
total_n_exams_passed_in_this_year = 0
total_grade_count_in_this_year = 0
exclude_n_exams_from_the_grade_list = 0
spacer unless @show_only_this_year and (@show_only_this_year != last_year)
output_colourized_year_and_colourized_hours(year)
last_year = year
end
total_n_hours_passed_in_this_year += n_hours
@n_hours_passed_in_total += n_hours
total_n_ects_passed_in_this_year += n_ECTS
@n_ects_points_in_total += n_ECTS
total_n_exams_passed_in_this_year += n_exams_passed_in_this_month
@n_exams_in_total_passed += n_exams_passed_in_this_month.to_i
if grade.include? '+'
exclude_n_exams_from_the_grade_list += grade.count('+')
grade.reject! {|entry| entry == '+' }
end
add_this_number = grade.map(&:to_i).sum
total_grade_count_in_this_year += add_this_number
report_month_year_hours_ects_n_exams_passed_in_this_month(
month, year, n_hours, n_ECTS, n_exams_passed_in_this_month
)
}
show_total_summary_for_year_hours_ects_n_exams(
last_year,
total_n_hours_passed_in_this_year,
total_n_ects_passed_in_this_year,
total_n_exams_passed_in_this_year,
total_grade_count_in_this_year
) {{ exclude_n_exams_from_the_grade_list: exclude_n_exams_from_the_grade_list }}
e
ljust_it_n_times = :default
report_how_many_exams_were_passed_in_total(@n_exams_in_total_passed, ljust_it_n_times)
if show_ects_points? ects_per_exams_passed = (
@n_ects_points_in_total.to_f / @n_exams_in_total_passed.to_f
).round(2)
report_how_many_hours_were_passed_in_total(
@n_hours_passed_in_total, ljust_it_n_times
)
report_how_many_ects_points_have_been_gathered_so_far
report_how_many_of_these_ects_points_required_mandatory_presence(
@n_ects_points_belonging_to_mandatory_presence_courses
)
if @show_average_ects_passed_per_exam
report_the_average_amount_of_ects_per_passed_exam(
ects_per_exams_passed, ljust_it_n_times
)
end
report_the_average_grade(ljust_it_n_times)
end
end
|
#show_number_then_name_of_the_lecture_then_n_ECTS_points_then_leistung_erbracht_then_which_university(index, name_of_the_lecture, n_ects, leistung_erbracht_am, which_university) ⇒ Object
#
show_number_then_name_of_the_lecture_then_n_ECTS_points_then_leistung_erbracht_then_which_university
This long compound method is only used from within the following two methods:
show_only_bachelor_lectures
show_only_master_lectures
#
477
478
479
480
481
482
483
484
485
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 477
def show_number_then_name_of_the_lecture_then_n_ECTS_points_then_leistung_erbracht_then_which_university(
index, name_of_the_lecture, n_ects, leistung_erbracht_am, which_university
)
e lightgreen((index.to_s+')').rjust(6))+' '+
orange(name_of_the_lecture.ljust(74))+' '+
slateblue(n_ects.to_s+' ECTS')+crimson(
' '+leistung_erbracht_am.to_s
)+' '+which_university
end
|
#show_numbered_exams(normal_or_reversed = :normal) ⇒ Object
#
show_numbered_exams
This method will output the passed exams.
To output this method, try this:
emo --show-numbered-exams
emo --reversed-nl
#
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 143
def show_numbered_exams(normal_or_reversed = :normal)
dataset = File.readlines(csv_file?).reject {|entry|
entry.start_with? '#'
}.reject {|entry|
entry.to_s.strip.empty?
}
size_of_the_dataset = dataset.size
e; dataset.each_with_index {|line, index|
index += 1
if normal_or_reversed == :reversed
index = (size_of_the_dataset - index)+1
end
e ' '+orange(index.to_s.rjust(4))+') '+simp(line.chomp)
}; e
end
|
#show_only_bachelor_exams ⇒ Object
#
show_only_bachelor_exams
Use this method to show only exams relevant for the Bachelor.
Invocation example:
emo --show-only-bachelor
#
370
371
372
373
374
375
376
377
378
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 370
def show_only_bachelor_exams
opnn; e 'Showing only Bachelor exams.'
_ = dataset?.select {|entry|
curriculum_type = entry[5].strip curriculum_type.include? 'B'
}
reset_main_hash
sanitize_dataset(_, :leave_time_entry_alone)
end
|
#show_only_bachelor_lectures ⇒ Object
#
show_only_bachelor_lectures
As the variant for master lectures, just for bachelor lectures.
To invoke it, do:
emo --show-only-bachelor-lectures
#
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 430
def show_only_bachelor_lectures
_ = @dataset.select {|array|
bachelor_or_master_curriculum = array[5].strip
bachelor_or_master_curriculum.include? 'B'
}
total_ects_points = 0
e
_.each_with_index {|lecture_data, index|
index += 1
n_ects = lecture_data[2]
total_ects_points += n_ects.to_f
name_of_the_lecture = lecture_data.last
leistung_erbracht_am = lecture_data.first
which_university = mediumturquoise(lecture_data[4])
show_number_then_name_of_the_lecture_then_n_ECTS_points_then_leistung_erbracht_then_which_university(
index, name_of_the_lecture, n_ects, leistung_erbracht_am, which_university
)
}
report_total_amount_of_ects_points(total_ects_points, :bachelor)
end
|
#show_only_exams_at_the_boku ⇒ Object
#
show_only_exams_at_the_boku
Show only exams at the BOKU.
#
923
924
925
926
927
928
929
930
931
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 923
def show_only_exams_at_the_boku
opnn; e 'Showing all exams passed at the BOKU.'
_ = dataset?.select {|entry|
name_of_university = entry[4]
(name_of_university.strip.downcase == 'boku')
}
reset_main_hash
sanitize_dataset(_, :leave_time_entry_alone)
end
|
#show_only_exams_at_the_meduni ⇒ Object
#
show_only_exams_at_the_meduni
Invoke this method like so:
emo --meduni
#
181
182
183
184
185
186
187
188
189
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 181
def show_only_exams_at_the_meduni
opnn; e 'Showing all exams passed at the MedUni Wien.'
_ = dataset?.select {|entry|
name_of_university = entry[4]
(name_of_university.strip.downcase == 'meduni')
}
reset_main_hash
sanitize_dataset(_, :leave_time_entry_alone)
end
|
#show_only_exams_at_the_tu ⇒ Object
#
show_only_exams_at_the_tu
Show only exams at the TU.
#
531
532
533
534
535
536
537
538
539
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 531
def show_only_exams_at_the_tu
opnn; e 'Showing all exams passed at the TU.'
_ = dataset?.select {|entry|
name_of_university = entry[4]
(name_of_university.strip.downcase.start_with? 'tu')
}
reset_main_hash
sanitize_dataset(_, :leave_time_entry_alone)
end
|
#show_only_exams_at_the_uniwien ⇒ Object
#
show_only_exams_at_the_uniwien
Invoke this method like so:
emo --uniwien
#
165
166
167
168
169
170
171
172
173
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 165
def show_only_exams_at_the_uniwien
opnn; e 'Showing all exams passed at the UniWien.'
_ = dataset?.select {|entry|
name_of_university = entry[4]
(name_of_university.strip.downcase == 'uniwien')
}
reset_main_hash
sanitize_dataset(_, :leave_time_entry_alone)
end
|
#show_only_exams_at_the_vetmed_uni ⇒ Object
#
show_only_exams_at_the_vetmed_uni
Invoke this method like so:
emo --vetmed
#
124
125
126
127
128
129
130
131
132
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 124
def show_only_exams_at_the_vetmed_uni
opnn; e 'Showing all exams passed at the Vetmed Uni.'
_ = dataset?.select {|entry|
name_of_university = entry[4]
(name_of_university.strip.downcase == 'vetmed')
}
reset_main_hash
sanitize_dataset(_, :leave_time_entry_alone)
end
|
#show_only_exams_before_this_date(this_date) ⇒ Object
#
show_only_exams_before_this_date
The argument to this method should be the starting time, the day at which you wish to keep track of exams made BEFORE this date.
To invoke this method, do:
emo "before 10.01.2011"
#
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 339
def show_only_exams_before_this_date(this_date)
unless this_date.include? '.'
this_date.prepend('01.01.') end
opnn; e 'Showing only passed exams before the date '+simp(this_date.to_s)+'.'
this_date = Time.parse(this_date) if this_date.is_a? String
a = this_date _ = dataset?
new_array_with_matches = []
_.each {|entry|
date = Time.parse('01.'+entry.first.strip) b = date
if a > b
new_array_with_matches << entry
end
}
reset_main_hash
sanitize_dataset(new_array_with_matches, :leave_time_entry_alone)
end
|
#show_only_exams_past_this_date(this_date) ⇒ Object
#
show_only_exams_past_this_date
The argument to this method should be the starting time, the day at which you wish to keep track of exams made afterwards.
To invoke this method, do:
emo "since 10.02.2014"
#
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
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 496
def show_only_exams_past_this_date(this_date)
unless this_date.include? '.'
this_date.prepend('01.01.') end
opnn; e 'Showing only passed exams past the date '+simp(this_date.to_s)+'.'
this_date = Time.parse(this_date) if this_date.is_a? String
a = this_date _ = dataset?
new_array_with_matches = []
_.each {|entry|
first = '01.'+entry.first.strip
date = Time.parse(first) b = date
if a < b
new_array_with_matches << entry end
}
reset_main_hash sanitize_dataset(new_array_with_matches, :leave_time_entry_alone)
end
|
#show_only_master_lectures ⇒ Object
#
show_only_master_lectures
This method is tasked to show only master lectures. For this purpose, we define a lecture to be a “master” lecture if it is part of at the least one master-curriculum. With this definition, a lecture that is registered in both a bachelor and a master curriculum, will satisfy this defintion and thus be listed.
We will take the file passed_exams_per_month.csv for this.
That file will have entries such as:
28.11.2016 | 3.0 | 6.0 | 1 | UniWien | M | 330011 | Zell- und Molekularbiologie
So we can pick field number 6. If that field has an upcased 'M' then it qualifies.
To invoke this method from the commandline, do:
emo --show-only-master-lectures
#
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 401
def show_only_master_lectures
_ = @dataset.select {|array|
bachelor_or_master_curriculum = array[5].strip
bachelor_or_master_curriculum.include? 'M'
}
total_ects_points = 0
e
_.each_with_index {|lecture_data, index|
index += 1
n_ects = lecture_data[2]
total_ects_points += n_ects.to_f
name_of_the_lecture = lecture_data.last
leistung_erbracht_am = lecture_data.first
which_university = mediumturquoise(lecture_data[4])
show_number_then_name_of_the_lecture_then_n_ECTS_points_then_leistung_erbracht_then_which_university(
index, name_of_the_lecture, n_ects, leistung_erbracht_am, which_university
)
}
report_total_amount_of_ects_points(total_ects_points, :master)
end
|
#show_only_practical_courses_that_were_passed_already ⇒ Object
#
show_only_practical_courses_that_were_passed_already
Use this method if you wish to show only practical courses that were passed already.
The currently acknowledged practical courses include UE, PR and LU.
Invocation example:
emo --übungen
#
254
255
256
257
258
259
260
261
262
263
264
265
266
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 254
def show_only_practical_courses_that_were_passed_already
@show_average_ects_passed_per_exam = false _ = dataset?
_.select! {|entry|
type_of_lecture = entry[6].strip
type_of_lecture.include?('UE') or
type_of_lecture.include?('PR') or
type_of_lecture.include?('LU')
}
reset_main_hash
sanitize_dataset(_, :leave_time_entry_alone)
report_main_hash
end
|
#show_the_summary ⇒ Object
Also known as:
show_only_the_summary
#
show_the_summary
To use this method from the commandline, do:
emo --summary
#
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 1210
def show_the_summary
determine_n_ects_points_in_total
determine_n_exams_in_total_were_passed
determine_n_hours_were_passed_in_total report_how_many_exams_were_passed_in_total(@n_exams_in_total_passed)
report_how_many_hours_were_passed_in_total
report_how_many_ects_points_have_been_gathered_so_far
if @show_average_ects_passed_per_exam
report_the_average_amount_of_ects_per_passed_exam
end
report_the_average_grade
end
|
#show_the_years_in_a_short_table_overview ⇒ Object
#
show_the_years_in_a_short_table_overview
To invoke this method, do:
emo --years
#
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
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 703
def show_the_years_in_a_short_table_overview
total_ects = 0
_ = dataset? _.map! {|inner_array|
n_ects_points = inner_array[2] [inner_array[0].split('.').last, n_ects_points]
}
current_year = Date.today.year total_ects_points_in_that_year = 0
e
e steelblue('Year')+
sfancy(' n ECTS points')
show_colourized_line
_.each {|year, n_ects_points|
year = year.to_i
n_ects_points = n_ects_points.to_f
total_ects += n_ects_points
if current_year == year
total_ects_points_in_that_year += n_ects_points
else
e ' '+
steelblue(( (current_year.to_s+': ') ).ljust(15))+
sfancy(total_ects_points_in_that_year.to_s.rjust(5)+' ECTS points')
total_ects_points_in_that_year = 0
current_year = year
total_ects_points_in_that_year += n_ects_points
end
}
show_colourized_line
e (' ' * 16)+sfancy(total_ects.to_s+' ECTS points')
e
end
|
#show_total_summary_for_year_hours_ects_n_exams(last_year, total_n_hours_passed_in_this_year, total_n_ects_passed_in_this_year, total_n_exams_passed_in_this_year, optional_average_grade_per_exam = nil) ⇒ Object
#
show_total_summary_for_year_hours_ects_n_exams
This method will show the total summary for a given year.
#
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
|
# File 'lib/studium/exams/exams_per_month/show_and_report.rb', line 862
def show_total_summary_for_year_hours_ects_n_exams(
last_year,
total_n_hours_passed_in_this_year,
total_n_ects_passed_in_this_year,
total_n_exams_passed_in_this_year,
optional_average_grade_per_exam = nil )
if @show_only_this_year and
@show_only_this_year.include?('-') and
@show_only_this_year.split('-').last.to_i < last_year
elsif @show_only_this_year and
(@show_only_this_year != last_year)
else
e result = 'Total Summary in '+sfancy(last_year.to_s)+': '+
colourize_hours(
total_n_hours_passed_in_this_year.to_s.rjust(4)
)+' '
if show_ects_points?
result << colourize_ects(
total_n_ects_passed_in_this_year.to_f.to_s.rjust(5)+
' ECTS passed'
)
end
result << colourize_n_exams(' (n exams passed that year: '+
total_n_exams_passed_in_this_year.to_s.rjust(3)+')',
:mediumseagreen
)
e result
if @show_yearly_average_grades and optional_average_grade_per_exam
if block_given?
yielded = yield
if yielded.is_a? Hash
if yielded.has_key? :exclude_n_exams_from_the_grade_list
total_n_exams_passed_in_this_year -= yielded[:exclude_n_exams_from_the_grade_list].to_i
end
end
end
_ = (
optional_average_grade_per_exam.to_f / total_n_exams_passed_in_this_year.to_f
).round(2)
_ = _.to_s.ljust(4,'0')
e 'The average grade of the exams passed in this year is: '+
sfancy(_)
end
end
end
|
#store_result ⇒ Object
77
78
79
80
81
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 77
def store_result
set_store_where '/SOURCE_FILES.png'
opnn; e "We will store at `#{sfile(store_where?)}`."
@g.write(store_where?)
end
|
#store_where? ⇒ Boolean
63
64
65
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 63
def store_where?
@store_where
end
|
#title? ⇒ Boolean
86
87
88
|
# File 'lib/studium/exams/exams_per_month/exams_per_month.rb', line 86
def title?
TITLE
end
|
#use_colours? ⇒ Boolean
12
13
14
|
# File 'lib/studium/exams/exams_per_month/colours.rb', line 12
def use_colours?
@use_colours
end
|
#use_only_master_lectures ⇒ Object
#
use_only_master_lectures
#
35
36
37
38
39
40
41
|
# File 'lib/studium/exams/exams_per_month/dataset.rb', line 35
def use_only_master_lectures
set_dataset(
dataset?.select {|entry| entry[5].include? 'M' }
)
reset_main_hash
sanitize_dataset(dataset?)
end
|