Class: Studium::NExamsInTheseTopics
- Inherits:
-
Base
- Object
- Base
- Studium::NExamsInTheseTopics
show all
- Defined in:
- lib/studium/exams/n_exams_in_these_topics.rb
Overview
Studium::NExamsInTheseTopics
Constant Summary
collapse
- NAMESPACE =
inspect
- DEFAULT_TOPIC_TO_USE =
'meta_biochemistry'
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
-
.[](i = '') ⇒ Object
# === Studium::NExamsInTheseTopics[] ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#add_proper_year_entry_to_this_line, #already_solved_this_lva_number?, #append_what_into, #available_topics_as_short_name, #average_grade, #bachelor_master_or_diploma, #base_dir?, #be_silent, #be_verbose?, #beautiful_url, #change_directory, #cheering_person, #cliner, #colour_for_ects_points, #colourize_percentage, #commandline_arguments?, #commandline_arguments_joined, #commandline_arguments_with_hyphens?, #convert_this_array_of_lectures_into_the_full_dataset, #copy, #cpruby, #create_directory, #create_file, #csv_file?, #current_month?, #datum?, #day_month_year, #debug?, #delete_file, #directory_of_the_exam_topics?, #directory_to_my_exam_topics, #directory_to_the_exam_topics?, #disable_colours, #disable_colours_globally, #do_not_be_verbose, #do_not_use_opn, #do_these_curricula_include_both_a_bachelor_and_a_master_curriculum?, #does_this_line_include_a_german_weekday?, #does_this_line_include_a_html_colour?, #e, #ecomment, #editor?, #ee, #enable_colours, #enable_colours_globally, #enable_debug, #encoding?, #english_to_german_weekday, #ensure_main_encoding, #ensure_that_the_log_directory_exists, #eparse, #erev, #esystem, #etomato, #exit_program, #expand_topic, #extract_dd_mm_yyyy, #file_lecture_information?, #file_read_with_proper_encoding, #filter_away_invalid_questions, #find_corresponding_exam_topic, #first_argument?, #first_non_hyphen_argument?, #from_curriculum_id_to_university, #german_date_notation, #german_weekday?, #german_weekdays?, #has_a_bachelor_curriculum?, #has_a_master_curriculum?, #has_this_exam_topic_been_solved?, #has_year_entry?, #hh_mm_ss_dd_mm_yyyy, #horizontal_bar?, #html_log_directory?, #is_a_master_lecture?, #is_a_weekday?, #is_connected_to_the_www?, #is_on_roebe?, #is_prüfungsimmanent?, #is_this_a_valid_html_colour?, #is_this_day_today?, #konsole_support?, #last_file?, #lectures_from_indi1, #lectures_from_indi2, #lectures_from_indi3, #lectures_from_indi4, #lectures_from_the_bachelor_genetik_curriculum, #lectures_from_the_individual_vektor_curricula, #load_yaml_dataset, #move_file, #n_days_difference_from_today_to_this_day, #no_ext_name, #no_file_at, #number_to_month, #obtain, #obtain_lectures_from_this_curriculum, #open_in_editor, #path_to_exam_topic?, #read_dataset_from_a_curriculum_file, #read_in_exam_dataset_from_this_file, #read_this_file_with_default_encoding, #readlines_from_this_input_file, #register_sigint, #remove_empty_strings, #remove_escape_sequences, #remove_internal_comments, #remove_leading_comments, #remove_leading_weekday_names_from, #remove_newlines, #remove_tags_from_this_input, #rename_kde_konsole_tab, #rename_konsole_tab?, #replace_all_html_colours_in_this, #replace_bold_token_with_default_colour, #replace_italic_token_with_default_colour, #replace_italic_token_with_this_colour, #replace_regular_numbers_with_unicode_numbers, #replace_underline_token_with_default_colour, #replace_underline_token_with_this_colour, #return_all_bachelor_lectures, #return_all_exams_on_this_day, #return_all_numbers_from, #return_all_registered_curricula, #return_all_steop_lectures, #return_current_year, #return_dataset_for_this_topic, #return_dataset_from_this_curriculum_file, #return_dd_mm_yy_and_time_from, #return_directory_for, #return_ects_points_from_these_lectures, #return_either_grey_or_the_custom_colour_for_answers, #return_either_grey_or_the_custom_colour_for_questions, #return_file_for_this_curriculum, #return_german_name_for_this_english_month, #return_german_weekday_of?, #return_hh_mm_ss_from, #return_hour_from_this, #return_lectures_from_bachelor_vektor_curriculum, #return_lectures_with_at_the_least_one_upcoming_exam, #return_local_path_of_this_pwdstud, #return_lva_number_of_this_lecture, #return_month_fitting_to_this_input, #return_n_days_until_monday, #return_n_days_until_sunday, #return_n_exam_questions_in, #return_n_questions_were_answered_for_this_topic, #return_name_of_the_weekday, #return_name_of_this_curriculum, #return_name_of_this_curriculum_based_on_its_id_number, #return_opnn, #return_passed_courses, #return_pwd, #return_random_curriculum, #return_sanitized_dataset_from_the_file_lecture_information, #return_solved_lectures, #return_steop_lectures, #return_the_remote_homepage_url, #return_this_line_has_n_characters_as_html_colour_tags, #return_title_from_this_curriculum_file, #rev, #right_arrow?, #rinstall2, #roebe_exam_directory?, #ruby_src_dir_at_home?, #runmode?, #sanitize_this_topic, #sanitize_url, #select_lectures_with_this_key, #set_be_quiet, #set_be_verbose, #set_commandline_arguments, #set_commandline_mode, #set_runmode, #set_this_cd_alias_to, #set_www_mode, #sfancy, #shall_we_make_use_of_unicode_symbols?, #show_todays_date, #simp, #sort_these_lecture_names_by_time, #spacer, #swarn, #this_month_has_n_days?, #total_ects_points_passed, #translate_dd_mm_yyyy_to_weekday, #try_to_require_the_rcfiles, #turn_this_array_into_the_full_dataset, #unicode_blocks_line, #use_colours?, #use_opn?, #vertical_bar?, #web_liner, #weekday?, #weekdays?, #word_wrap, #write_what_into, #www_connection_is_unavailable, #www_mode?, #yaml_dir?
Methods included from Colours
#bold_blue, #bold_red, #bold_yellow, #cadetblue, #chartreuse, crimson, #darkgray, darkgreen, darkseagreen, deepskyblue, #deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #ewarn, #forestgreen, gold, #grey, lightblue, lightgreen, #lightslategray, #lightsteelblue, #mediumorchid, #mediumseagreen, #oldlace, #olivedrab, orange, orangered, #orchid, palevioletred, #papayawhip, rev, royalblue, sdir, #sdir, sfancy, #sfancy, sfile, #sfile, simp, #simp, slateblue, steelblue, #steelblue, #swarn, swarn, #teal, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow
Constructor Details
#initialize(i = DEFAULT_TOPIC_TO_USE, run_already = true) ⇒ NExamsInTheseTopics
43
44
45
46
47
48
49
50
51
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 43
def initialize(
i = DEFAULT_TOPIC_TO_USE,
run_already = true
)
reset
set_original_input(i)
set_input(i)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
Studium::NExamsInTheseTopics[]
#
398
399
400
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 398
def self.[](i = '')
new(i)
end
|
Instance Method Details
#colour_for_percentage(i) ⇒ Object
#
colour_for_percentage
#
243
244
245
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 243
def colour_for_percentage(i)
cadetblue(i) end
|
#colourize_backslash(i) ⇒ Object
236
237
238
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 236
def colourize_backslash(i)
mediumseagreen(i)
end
|
#consider_asking_an_exam_question(can_we_ask_an_exam_question = @ask_an_exam_question_for_this_topic_number) ⇒ Object
#
consider_asking_an_exam_question
This method can be used to ask an exam question.
The argument passed into this method should be an Array.
#
208
209
210
211
212
213
214
215
216
217
218
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 208
def consider_asking_an_exam_question(
can_we_ask_an_exam_question = @ask_an_exam_question_for_this_topic_number
)
if can_we_ask_an_exam_question
first_entry = can_we_ask_an_exam_question.first
ask_an_exam_question_from_this_topic = @input[first_entry - 1]
Studium.ask_exam_question(
ask_an_exam_question_from_this_topic
)
end
end
|
#
We may store the statistics into a special file.
#
343
344
345
346
347
348
349
350
351
352
353
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
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 343
def consider_storing_into_the_file_meta_topics_statistics
into = FILE_META_TOPICS_STATISTICS
hash = {}
meta_topic = @original_input
if meta_topic.is_a? Array
meta_topic = meta_topic.first.to_sym
end
hash[meta_topic] = {
n_questions: @n_total_questions,
n_answers: @n_total_questions_were_already_answered,
}
if File.exist? into
dataset = YAML.load_file(into)
if dataset.has_key? meta_topic
if @n_total_questions_were_already_answered > dataset[meta_topic][:n_answers]
merged_result = hash.merge(dataset)
what = YAML.dump(merged_result)
write_what_into(what, into)
end
else
merged_result = hash.merge(dataset)
what = YAML.dump(merged_result)
write_what_into(what, into)
end
else
what = YAML.dump(hash)
write_what_into(what, into)
end
end
|
155
156
157
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 155
def input?
@input
end
|
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 131
def (i)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when /^-?-?help$/
show_help
end
end
end
|
179
180
181
182
183
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 179
def meta_theme_as_string?
_ = @original_meta_theme
_ = _.first if _.is_a? Array
_.to_s
end
|
#notify_the_user_about_the_amount_of_questions_already_answered ⇒ Object
#
notify_the_user_about_the_amount_of_questions_already_answered
#
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 162
def notify_the_user_about_the_amount_of_questions_already_answered
n_percent = (
(@n_total_questions_were_already_answered * 100.0) / @n_total_questions
).round(2)
e 'There are a total of '+sfancy(@n_total_questions.to_s)+
' questions in these '+
lightgreen(@input.size.to_s)+' topics.'
e 'Of these, '+sfancy(@n_total_questions_were_already_answered.to_s)+
' questions were already answered. ('+
colour_for_percentage(n_percent.to_s.to_s+'%')+' were answered)'
e
consider_storing_into_the_file_meta_topics_statistics if is_on_roebe?
end
|
#notify_the_user_which_topics_will_be_handled ⇒ Object
#
notify_the_user_which_topics_will_be_handled
This method will do the actual reporting to the user.
#
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
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
329
330
331
332
333
334
335
336
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 252
def notify_the_user_which_topics_will_be_handled
n_total_questions = 0
n_total_answers = 0
e
e
e
e "#{rev}The following #{sfancy(@input.size.to_s)}"\
" topics will be handled for the meta-topic "\
"#{lightskyblue(meta_theme_as_string?.tr('_',' '))}:"
e
_ = {} @input.each {|this_topic|
_[this_topic] = Studium::Exams.n_questions_available_in_this_topic(this_topic)
}
sorted_hash = Hash[_.sort_by {|a, b| b }.reverse]
index = 0
sorted_hash.each_pair {|this_topic, n_questions_in_this_topic| index += 1
n_total_questions += n_questions_in_this_topic
n_questions_already_solved_in_this_topic = Studium::Exams.n_questions_already_solved_in_this_topic(this_topic)
n_total_answers += n_questions_already_solved_in_this_topic
@n_total_questions += n_questions_in_this_topic
@n_total_questions_were_already_answered += n_questions_already_solved_in_this_topic
padded_index = ('('+index.to_s).rjust(2 + (@input.size.to_s.size - 1))
colourized_index = mediumseagreen(' '+padded_index+') ')
percentage_value =
((n_questions_already_solved_in_this_topic.to_f * 100) / n_questions_in_this_topic.to_f).round(2).to_s
padded_percentage_value = '%.2f' % percentage_value
if this_topic.size > 25
this_topic = this_topic[0..24]+' [...]'
end
sanitized_topic = this_topic.ljust(32).tr('_',' ')
colourized_padded_percentage_value = padded_percentage_value.to_s.rjust(6)+'%' if padded_percentage_value.to_f == 100
colourized_padded_percentage_value = turquoise(colourized_padded_percentage_value)
elsif padded_percentage_value.to_f > 90
colourized_padded_percentage_value = skyblue(colourized_padded_percentage_value)
else
colourized_padded_percentage_value = colour_for_percentage(colourized_padded_percentage_value)
end
e colourized_index+
dodgerblue(sanitized_topic)+
mediumseagreen(' (')+
yellowgreen(n_questions_in_this_topic.to_s.rjust(4))+
olivedrab(' questions ')+
colourize_backslash('/ ')+
yellowgreen(n_questions_already_solved_in_this_topic.to_s.rjust(3))+
olivedrab(' answered ')+
colourize_backslash('/ ')+
colourized_padded_percentage_value+
mediumseagreen(')')
}
e ' '+('-'*80)
left_pad = ''.rjust(45 - n_total_questions.to_s.size)
percentage_value = (
(n_total_answers.to_f * 100) / n_total_questions.to_f
).round(2)
e left_pad+
yellowgreen(n_total_questions.to_s)+
olivedrab(' questions ')+
colourize_backslash('/ ')+
yellowgreen(n_total_answers.to_s)+
olivedrab(' answers')+
colour_for_percentage(' ('+percentage_value.to_s+'% answered)')
e
end
|
#opnn(i = NAMESPACE) ⇒ Object
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 188
def opnn(i = NAMESPACE)
unless i.is_a? Hash
hash = {}
hash[:namespace] = i if i.is_a? String
hash.update(append_colon: false)
i = hash
end
super(i)
end
|
#reset ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 56
def reset
super()
@ask_an_exam_question_for_this_topic_number = nil
@n_total_questions = 0
@n_total_questions_were_already_answered = 0
end
|
#run ⇒ Object
386
387
388
389
390
391
392
393
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 386
def run
if @ask_an_exam_question_for_this_topic_number
consider_asking_an_exam_question
else notify_the_user_which_topics_will_be_handled
notify_the_user_about_the_amount_of_questions_already_answered
end
end
|
#
Note that several “aliases” exist for the given input at hand, usually starting with the word “meta”.
#
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
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 89
def set_input(
i = DEFAULT_TOPIC_TO_USE
)
i = DEFAULT_TOPIC_TO_USE if i.nil?
i = [i].flatten.compact if i.any? {|line|
line =~ /^\d+$/
}
@ask_an_exam_question_for_this_topic_number = return_all_numbers_from(i).map(&:to_i)
i.reject! {|line| line =~ /^\d+$/ }
end
store_original_meta_theme(i)
i.map! {|line|
::Studium.map_meta_exam_theme_to_corresponding_exam_themes(line)
}
i.flatten!
(i)
@input = i
end
|
79
80
81
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 79
def set_original_input(i)
@original_input = i
end
|
#show_help ⇒ Object
223
224
225
226
227
228
229
230
231
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 223
def show_help
e
e 'Pass in a number to ask an exam question.'
e
e 'Example:'
e
e ' metagen 8'
e
end
|
148
149
150
|
# File 'lib/studium/exams/n_exams_in_these_topics.rb', line 148
def store_original_meta_theme(i)
@original_meta_theme = i
end
|