Class: Studium::Exams::ExamQuestion
- Inherits:
-
Base
- Object
- Base
- Studium::Exams::ExamQuestion
show all
- Defined in:
- lib/studium/exams/exam_question/menu.rb,
lib/studium/exams/exam_question/misc.rb,
lib/studium/exams/exam_question/reset.rb,
lib/studium/exams/exam_question/answer.rb,
lib/studium/exams/exam_question/question.rb,
lib/studium/exams/exam_question/constants.rb,
lib/studium/exams/exam_question/exam_question.rb
Overview
Studium::Exams::ExamQuestion
Constant Summary
collapse
- NAMESPACE =
inspect
- DEFAULT_COLOUR_TO_USE =
#
DEFAULT_COLOUR_TO_USE
#
:olivedrab
- USE_THESE_COLOURS =
#
USE_THESE_COLOURS
This Hash is used to set up colours. It will be passed to methods that belong to the Colours module (“namespace”), which in turn can be found in the gem called “colours”.
Using a Hash like this allows the user to customize the colours as well.
For the question, we prefer to use :olivedrab.
#
{
one: :steelblue,
two: :mediumseagreen,
three: :mediumpurple, four: :olivedrab,
five: :lightgreen,
default_colour: DEFAULT_COLOUR_TO_USE }
- DEFAULT_COLOUR_AS_ESCAPE_SEQUENCE =
#
DEFAULT_COLOUR_AS_ESCAPE_SEQUENCE
#
::Colours.remove_trailing_end_from(
::Colours.send(USE_THESE_COLOURS[:default_colour])
)
- EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_QUESTION =
#
EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_QUESTION
This constant is like the constant called EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_ANSWER, except that here we work on double-quotes, aka '“' characters, in a question.
As of November 2019, this defaults to false, since we already use many other colours at this point.
#
false
- EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_ANSWER =
#
EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_ANSWER
#
false
- DEFAULT_WORD_WRAP_AT_N_CHARACTERS_PER_LINE =
#
DEFAULT_WORD_WRAP_AT_N_CHARACTERS_PER_LINE
#
72
- MAY_WE_SHOW_THE_TOPIC =
false
- SHALL_WE_DEBUG =
#
SHALL_WE_DEBUG
Shall we debug or shall we not debug. This is specific to this class here.
#
false
- SHOW_STATISTICS =
#
SHOW_STATISTICS
If SHOW_STATISTICS is true then we will show the statistics.
#
true
- STORE_TEXT =
#
STORE_TEXT
Next comes the string that we will save if we set a new delay.
#
'# ====================================================================== #
# How long to wait before showing the answer in question, in seconds.
# ====================================================================== #
delay: '
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::Exams::ExamQuestion[] ========================================================================= #.
-
.rename_konsole_tab? ⇒ Boolean
# === Studium::Exams::ExamQuestion.rename_konsole_tab? ========================================================================= #.
-
.set_rename_konsole_tab(i) ⇒ Object
# === Studium::Exams::ExamQuestion.set_rename_konsole_tab ========================================================================= #.
Instance Method Summary
collapse
-
#ask_the_exam_question(exam_question = exam_question?, , use_this_colour = colour_for_questions? ) ⇒ Object
(also: #show_question, #ask_the_question, #ask_this_question)
# === ask_the_exam_question (question tag, ask tag).
-
#ask_the_question_then_sleep_then_reveal_the_answer_to_that_question ⇒ Object
(also: #ask_question_then_show_the_answer_after_a_delay, #do_ask_a_random_question_before_showing_the_answer, #show_question_then_sleep_then_show_answer, #ask_sleep_show, #ask_the_question_then_reveal_the_answer)
# === ask_the_question_then_sleep_then_reveal_the_answer_to_that_question ========================================================================= #.
-
#assign_url(i) ⇒ Object
# === assign_url.
-
#assign_url_or_colourize_https_substring(i) ⇒ Object
# === assign_url_or_colourize_https_substring ========================================================================= #.
-
#colour_for_answers? ⇒ Boolean
# === colour_for_answers? ========================================================================= #.
-
#colour_for_questions? ⇒ Boolean
# === colour_for_questions? ========================================================================= #.
-
#colourize_https_substring(i) ⇒ Object
# === colourize_https_substring.
-
#consider_renaming_konsole_tab ⇒ Object
# === consider_renaming_konsole_tab.
-
#consider_warning_the_user_if_there_are_too_many_exams_registered(threshold_value = THRESHOLD_VALUE_N_EXAMS_AT_MAXIMUM) ⇒ Object
# === consider_warning_the_user_if_there_are_too_many_exams_registered.
-
#custom_colours? ⇒ Boolean
# === custom_colours? ========================================================================= #.
-
#dataset? ⇒ Boolean
# === dataset? ========================================================================= #.
-
#default_colour? ⇒ Boolean
# === default_colour? ========================================================================= #.
-
#default_delay? ⇒ Boolean
# === default_delay? ========================================================================= #.
-
#delay? ⇒ Boolean
(also: #delay)
# === delay? ========================================================================= #.
-
#determine_whether_we_will_rename_the_konsole_tab ⇒ Object
# === determine_whether_we_will_rename_the_konsole_tab.
-
#do_log_related_and_backup_related_actions ⇒ Object
-
#do_not_rename_konsole_tab ⇒ Object
# === do_not_rename_konsole_tab ========================================================================= #.
-
#do_rename_konsole_tab ⇒ Object
# === do_rename_konsole_tab ========================================================================= #.
-
#download_exam_topics ⇒ Object
# === download_exam_topics.
-
#edit_sanitize_topics_in_vim ⇒ Object
# === edit_sanitize_topics_in_vim.
-
#exam_answer? ⇒ Boolean
(also: #answer?, #answer, #last)
# === exam_answer? ========================================================================= #.
-
#exam_file? ⇒ Boolean
(also: #file?)
# === exam_file?.
-
#exam_pool? ⇒ Boolean
# === exam_pool? ========================================================================= #.
-
#exam_question? ⇒ Boolean
(also: #question?, #question, #first)
# === exam_question? ========================================================================= #.
-
#exam_question_line? ⇒ Boolean
(also: #line?, #line, #full_question_line?)
# === exam_question_line? ========================================================================= #.
-
#fancy_cliner(optional_content_to_be_displayed = nil) ⇒ Object
# === fancy_cliner.
-
#generate_statistical_webpage ⇒ Object
# === generate_statistical_webpage.
-
#initialize(commandline_arguments = ARGV, run_already = true, &block) ⇒ ExamQuestion
constructor
# === initialize.
-
#internal_hash? ⇒ Boolean
# === internal_hash? ========================================================================= #.
-
#invoke_all_the_necessary_steps_before_the_question_is_asked ⇒ Object
(also: #initial_steps)
# === invoke_all_the_necessary_steps_before_the_question_is_asked ========================================================================= #.
-
#line_contains_bold_token?(i = line?) ) ⇒ Boolean
# === line_contains_bold_token? ========================================================================= #.
-
#line_contains_italic_token?(i = line?) ) ⇒ Boolean
# === line_contains_italic_token? ========================================================================= #.
-
#line_contains_underline_token?(i = line?) ) ⇒ Boolean
# === line_contains_underline_token? ========================================================================= #.
-
#load_file_rename_konsole_tab ⇒ Object
# === load_file_rename_konsole_tab ========================================================================= #.
-
#main_file_exists?(i = exam_file? ) ⇒ Boolean
# === main_file_exists? ========================================================================= #.
-
#may_we_show_the_topic? ⇒ Boolean
(also: #may_we_show_the_topic)
# === may_we_show_the_topic? ========================================================================= #.
-
#menu(i = commandline_arguments? ) ⇒ Object
-
#menu_on_the_commandline_as_a_string(i = commandline_as_string) ⇒ Object
# === menu_on_the_commandline_as_a_string ========================================================================= #.
-
#n_questions_already_answered? ⇒ Boolean
# === n_questions_already_answered? ========================================================================= #.
-
#n_questions_available? ⇒ Boolean
(also: #n_exam_questions?)
# === n_questions_available?.
-
#notify_the_user_that_all_questions_have_been_answered_already(which_topic = which_topic? ) ⇒ Object
# === notify_the_user_that_all_questions_have_been_answered_already ========================================================================= #.
-
#open_the_last_file_via_your_editor(this_file = last_file? ) ⇒ Object
# === open_the_last_file_via_your_editor ========================================================================= #.
-
#open_this_file_in_editor(this_file = __FILE__) ⇒ Object
# === open_this_file_in_editor.
-
#opnn ⇒ Object
# === opnn ========================================================================= #.
-
#parse_the_random_line_from_the_obtained_dataset(_ = ) ⇒ Object
(also: #determine_the_split_position, #determine_index_position, #parse_that_line, #determine_the_question_and_the_answer)
# === parse_the_random_line_from_the_obtained_dataset.
-
#pick_a_random_line_from_the_obtained_dataset ⇒ Object
# === pick_a_random_line_from_the_obtained_dataset ========================================================================= #.
-
#read_delay_from_file ⇒ Object
# === read_delay_from_file (load delay).
-
#register_last_modified_file(i = exam_file? ) ⇒ Object
# === register_last_modified_file ========================================================================= #.
-
#report_file_does_not_exist(this_file = exam_file? ) ⇒ Object
# === report_file_does_not_exist ========================================================================= #.
-
#report_how_many_registered_questions_are_available(n_questions = ::Studium.n_questions_available?) ⇒ Object
# === report_how_many_registered_questions_are_available ========================================================================= #.
-
#report_how_many_topics_are_available ⇒ Object
# === report_how_many_topics_are_available ========================================================================= #.
-
#report_the_default_topic_in_use(this_file = "#{log_dir?}use_this_exam_topic.yml") ⇒ Object
# === report_the_default_topic_in_use.
-
#report_the_delay ⇒ Object
# === report_the_delay ========================================================================= #.
-
#report_this_error(error = nil) ⇒ Object
# === report_this_error ========================================================================= #.
-
#report_whether_we_will_show_the_topic ⇒ Object
# === report_whether_we_will_show_the_topic ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#result? ⇒ Boolean
# === result? ========================================================================= #.
-
#return_the_full_expanded_exam_title(exam_title = exam_title?) ) ⇒ Object
# === return_the_full_expanded_exam_title ========================================================================= #.
-
#reveal_the_exam_answer(exam_answer = exam_answer?, , include_numbers_in_parens = false) ⇒ Object
(also: #show_this_answer, #show_the_answer, #show_answer, #reveal_the_answer)
# === reveal_the_exam_answer (answer tag, reveal tag).
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#sanitize_the_obtained_dataset ⇒ Object
# === sanitize_the_obtained_dataset (sanitized tag).
-
#set_all_questions_from_the_topic_to_solved ⇒ Object
# === set_all_questions_from_the_topic_to_solved.
-
#set_and_store_delay(i) ⇒ Object
# === set_and_store_delay.
-
#set_colour_for_answers(i) ⇒ Object
# === set_colour_for_answers ========================================================================= #.
-
#set_colour_for_questions(i) ⇒ Object
# === set_colour_for_questions ========================================================================= #.
-
#set_custom_colours(i) ⇒ Object
# === set_custom_colours.
-
#set_dataset(i) ⇒ Object
# === set_dataset ========================================================================= #.
-
#set_default_topic_for_the_gui(what, into = "#{log_dir?}use_this_exam_topic.yml") ⇒ Object
# === set_default_topic_for_the_gui ========================================================================= #.
-
#set_delay(i = :load_from_file) ⇒ Object
(also: #determine_the_default_delay, #delay=)
# === set_delay.
-
#set_exam_answer(i) ⇒ Object
(also: #set_answer)
# === set_exam_answer.
-
#set_exam_file(i) ⇒ Object
(also: #set_file)
# === set_exam_file.
-
#set_exam_pool(i = nil) ⇒ Object
# === set_exam_pool.
-
#set_exam_question(i) ⇒ Object
(also: #set_question)
# === set_exam_question ========================================================================= #.
-
#set_exam_question_line(i) ⇒ Object
(also: #set_line, #set_this_line)
# === set_exam_question_line.
-
#set_exam_question_line_and_then_parse_that_line(i) ⇒ Object
# === set_exam_question_line_and_then_parse_that_line ========================================================================= #.
-
#set_exam_topic(i = first_non_hyphen_argument? ) ⇒ Object
(also: #set_this_topic, #determine_the_topic, #determine_the_exam_topic)
# === set_exam_topic.
-
#set_may_we_show_the_topic(i = MAY_WE_SHOW_THE_TOPIC) ⇒ Object
(also: #may_we_show_the_topic=, #set_show_topic)
# === set_may_we_show_the_topic ========================================================================= #.
-
#set_split_position(i = nil) ⇒ Object
(also: #set_index_position)
# === set_split_position ========================================================================= #.
-
#show_all_finished_exam_topics ⇒ Object
# === show_all_finished_exam_topics.
-
#show_available_topics(shall_we_exit = true) ⇒ Object
# === show_available_topics (topics tag).
-
#show_content_of_this_topic(i = topic? ) ⇒ Object
# === show_content_of_this_topic.
-
#show_filesize_of_all_exams ⇒ Object
# === show_filesize_of_all_exams.
-
#show_help_usage(then_exit = false) ⇒ Object
# === show_help_usage (help tag).
-
#show_how_many_exam_questions_are_available ⇒ Object
(also: #total, #n_total_questions_available?)
# === show_how_many_exam_questions_are_available.
-
#show_how_many_exam_questions_were_already_solved ⇒ Object
# === show_how_many_exam_questions_were_already_solved.
-
#show_how_many_exam_questions_were_already_solved_in_german ⇒ Object
# === show_how_many_exam_questions_were_already_solved_in_german.
-
#show_last_question_asked(i = store_where? ) ⇒ Object
# === show_last_question_asked.
-
#show_line ⇒ Object
# === show_line ========================================================================= #.
-
#show_statistics(dataset = dataset? ) ⇒ Object
(also: #report_statistics)
# === show_statistics.
-
#show_the_last_topic(_ = FILE_LAST_TOPIC) ⇒ Object
# === show_the_last_topic.
-
#sleep_default_delay(i = delay? ) ⇒ Object
(also: #default_sleep, #do_sleep, #start_default_sleep)
# === sleep_default_delay.
-
#split_position? ⇒ Boolean
# === split_position? ========================================================================= #.
-
#store_delay(i) ⇒ Object
# === store_delay (store tag).
-
#store_last_topic_into_file(what = topic?, , into = FILE_LAST_TOPIC) ⇒ Object
# === store_last_topic_into_file.
-
#store_where? ⇒ Boolean
# === store_where? ========================================================================= #.
-
#tell_whether_we_will_rename_the_kde_konsole_tab ⇒ Object
# === tell_whether_we_will_rename_the_kde_konsole_tab ========================================================================= #.
-
#topic? ⇒ Boolean
(also: #exam_topic?, #exam_title?, #which_topic?, #topic, #title, #title?, #category?)
# === topic? ========================================================================= #.
-
#try_to_load_custom_colours ⇒ Object
# === try_to_load_custom_colours.
-
#try_to_read_in_the_dataset_from_the_corresponding_exam_file(_ = exam_topics_directory?+ topic?.to_s) ⇒ Object
# === try_to_read_in_the_dataset_from_the_corresponding_exam_file ========================================================================= #.
-
#try_to_save_the_line(i = line? ) ⇒ Object
# === try_to_save_the_line (save tag).
-
#word_wrap_at? ⇒ Boolean
# === word_wrap_at? ========================================================================= #.
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(commandline_arguments = ARGV, run_already = true, &block) ⇒ ExamQuestion
#
initialize
The very first argument given to this class is usually the topic that is sought, such as “bem1” or “amg1” or “plants”, and so forth.
#
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
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 99
def initialize(
commandline_arguments = ARGV,
run_already = true,
&block
)
set_commandline_arguments(
commandline_arguments
)
reset
if block_given?
yielded = yield
case yielded when :disable_colours,
:no_colours
disable_colours
set_mode :www when :then_determine_the_split_position_without_using_colours
@internal_hash[:do_determine_the_split_position] = true
disable_colours
when :then_determine_the_split_position
@internal_hash[:do_determine_the_split_position] = true
when :then_determine_the_split_position_while_disabling_the_colours
@internal_hash[:do_determine_the_split_position] = true
disable_colours
set_mode :www when :do_not_run_yet
run_already = false
end
end
case run_already
when :do_not_run,
:do_not,
:dont_run,
:dont_run_yet,
:do_not_run_yet
run_already = false
when :commandline
run_already = false
set_commandline
end
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
Studium::Exams::ExamQuestion[]
#
994
995
996
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 994
def self.[](i = '')
new(i)
end
|
.rename_konsole_tab? ⇒ Boolean
#
Studium::Exams::ExamQuestion.rename_konsole_tab?
#
81
82
83
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 81
def self.rename_konsole_tab?
@rename_konsole_tab
end
|
.set_rename_konsole_tab(i) ⇒ Object
#
Studium::Exams::ExamQuestion.set_rename_konsole_tab
#
88
89
90
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 88
def self.set_rename_konsole_tab(i)
@rename_konsole_tab = i
end
|
Instance Method Details
#ask_the_exam_question(exam_question = exam_question?,
, use_this_colour = colour_for_questions?
) ⇒ Object
Also known as:
show_question, ask_the_question, ask_this_question
#
ask_the_exam_question (question tag, ask tag)
Simply display the question via this method.
#
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
|
# File 'lib/studium/exams/exam_question/question.rb', line 20
def ask_the_exam_question(
exam_question = exam_question?,
use_this_colour = colour_for_questions?
)
e
if line_contains_underline_token?(exam_question) and use_colours?
exam_question = replace_underline_token_with_default_colour(exam_question, use_this_colour)
end
if line_contains_italic_token?(exam_question) and use_colours?
exam_question = replace_italic_token_with_default_colour(exam_question, use_this_colour)
end
if commandline?
consider_renaming_konsole_tab print return_either_grey_or_the_custom_colour_for_questions
if may_we_show_the_topic?
fancy_cliner(
Studium.find_corresponding_exam_title(exam_title?)
)
e
else
fancy_cliner
end
_ = ::Colours.replace_number_words_with_the_corresponding_html_colour(
DEFAULT_COLOUR_AS_ESCAPE_SEQUENCE+
exam_question,
USE_THESE_COLOURS
)
e ::Colours.fancy_parse(_, use_this_colour)
e if may_we_show_the_topic?
fancy_cliner
else result = ''.dup
result << "#{exam_question}#{N}<br><br>"
@internal_hash[:result_for_www] = result
e result unless www_mode?
end
e
end
|
#ask_the_question_then_sleep_then_reveal_the_answer_to_that_question ⇒ Object
Also known as:
ask_question_then_show_the_answer_after_a_delay, do_ask_a_random_question_before_showing_the_answer, show_question_then_sleep_then_show_answer, ask_sleep_show, ask_the_question_then_reveal_the_answer
#
ask_the_question_then_sleep_then_reveal_the_answer_to_that_question
#
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/studium/exams/exam_question/misc.rb', line 22
def ask_the_question_then_sleep_then_reveal_the_answer_to_that_question
consider_warning_the_user_if_there_are_too_many_exams_registered
ask_the_exam_question
sleep_default_delay
reveal_the_exam_answer
end
|
#assign_url(i) ⇒ Object
#
assign_url
Only call this method after making a line.include? 'URL:' check. The reason for this is that we will only apply this method on a line that has this substring representing a remote URL.
#
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
|
# File 'lib/studium/exams/exam_question/misc.rb', line 702
def assign_url(i)
if use_unicode_symbols?
nice_token = '➡' else
nice_token = '=>'
end
i =~ /URL:\s*(.*)( |)/
url = sanitize_url($1.to_s.dup) url = url.first if url.is_a? Array
i = i.dup if i.frozen?
begin
if $1 remote_URL = $1.to_s.dup
i.gsub!(/URL:\s*(.*)( |)/, nice_token+' \1') if is_on_roebe?
what = "#{remote_URL}\n"
into = log_dir?+'last_exam_questions_URL.md'
append_what_into(what, into)
end
end
i = i.to_s.dup
return i
rescue Exception => error
e "Debugging for `#{sfancy(i.to_s)}`:"
pp error
p url.class
e sfancy(url)
end
end
|
#assign_url_or_colourize_https_substring(i) ⇒ Object
#
assign_url_or_colourize_https_substring
#
503
504
505
506
507
508
509
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 503
def assign_url_or_colourize_https_substring(i)
if i.include?(' URL:')
assign_url(i)
elsif i.include?(' https://')
colourize_https_substring(i)
end
end
|
#colour_for_answers? ⇒ Boolean
864
865
866
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 864
def colour_for_answers?
@internal_hash[:colour_for_answers]
end
|
#colour_for_questions? ⇒ Boolean
#
colour_for_questions?
#
871
872
873
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 871
def colour_for_questions?
@internal_hash[:colour_for_questions]
end
|
#colourize_https_substring(i) ⇒ Object
#
colourize_https_substring
Input that passes into the following method, can look like this:
'Das "CDT-Toxin". => https://www.ncbi.nlm.nih.gov/pubmed/24253566'
#
491
492
493
494
495
496
497
498
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 491
def colourize_https_substring(i)
if i.include? 'https://'
use_this_regex = /(https:\/\/.+)/ i =~ use_this_regex
i.gsub!(use_this_regex, slateblue('\1')) if $1
end
return i
end
|
#consider_renaming_konsole_tab ⇒ Object
#
consider_renaming_konsole_tab
We will delegate to class SetTerminalTitle in order to rename the KDE konsole title.
#
#consider_warning_the_user_if_there_are_too_many_exams_registered(threshold_value = THRESHOLD_VALUE_N_EXAMS_AT_MAXIMUM) ⇒ Object
#
consider_warning_the_user_if_there_are_too_many_exams_registered
The threshold value of n exam questions at maximum is at 1000 usually.
#
#custom_colours? ⇒ Boolean
118
119
120
121
122
123
|
# File 'lib/studium/exams/exam_question/misc.rb', line 118
def custom_colours?
[
@internal_hash[:colour_for_questions],
@internal_hash[:colour_for_answers]
]
end
|
#dataset? ⇒ Boolean
332
333
334
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 332
def dataset?
@internal_hash[:dataset_from_the_file]
end
|
#default_colour? ⇒ Boolean
578
579
580
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 578
def default_colour?
USE_THESE_COLOURS[:default_colour]
end
|
#default_delay? ⇒ Boolean
479
480
481
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 479
def default_delay?
DEFAULT_DELAY
end
|
#delay? ⇒ Boolean
Also known as:
delay
250
251
252
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 250
def delay?
@internal_hash[:delay]
end
|
#determine_whether_we_will_rename_the_konsole_tab ⇒ Object
#
determine_whether_we_will_rename_the_konsole_tab
This method should be called from within the method called reset().
#
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
# File 'lib/studium/exams/exam_question/misc.rb', line 427
def determine_whether_we_will_rename_the_konsole_tab
if is_on_roebe?
if File.exist? FILE_RENAME_KONSOLE_TAB
_ = load_file_rename_konsole_tab
if _ == true
do_rename_konsole_tab
else
do_not_rename_konsole_tab
end
else
do_not_rename_konsole_tab
end
else
do_not_rename_konsole_tab
end
end
|
#
This method will backup files and similar activities.
#
#do_not_rename_konsole_tab ⇒ Object
#
do_not_rename_konsole_tab
#
#do_rename_konsole_tab ⇒ Object
#
do_rename_konsole_tab
#
#download_exam_topics ⇒ Object
#
download_exam_topics
You can use this method to download all exam topics.
To call this, do:
qa --dexamtopics
#
#edit_sanitize_topics_in_vim ⇒ Object
#
edit_sanitize_topics_in_vim
To trigger this, do:
qa --vim
#
278
279
280
281
282
283
284
|
# File 'lib/studium/exams/exam_question/misc.rb', line 278
def edit_sanitize_topics_in_vim
position_in_the_file = 445
file =
RUBY_STUDIUM_HOME_DIR+'toplevel_methods/find_exam_topic_and_exam_title.rb'
_ = 'vim '+file+' +'+position_in_the_file.to_s
esystem _
end
|
#exam_answer? ⇒ Boolean
Also known as:
answer?, answer, last
622
623
624
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 622
def exam_answer?
@internal_hash[:exam_answer]
end
|
#exam_file? ⇒ Boolean
Also known as:
file?
#
exam_file?
This query-method shows as to where the specific file at hand is.
#
159
160
161
|
# File 'lib/studium/exams/exam_question/misc.rb', line 159
def exam_file?
@internal_hash[:exam_file]
end
|
#exam_pool? ⇒ Boolean
555
556
557
|
# File 'lib/studium/exams/exam_question/misc.rb', line 555
def exam_pool?
@internal_hash[:exam_pool]
end
|
#exam_question? ⇒ Boolean
Also known as:
question?, question, first
521
522
523
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 521
def exam_question?
@internal_hash[:exam_question]
end
|
#exam_question_line? ⇒ Boolean
Also known as:
line?, line, full_question_line?
903
904
905
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 903
def exam_question_line?
@internal_hash[:exam_question_line]
end
|
#fancy_cliner(optional_content_to_be_displayed = nil) ⇒ Object
#
fancy_cliner
Since as of April 2022 this method can also optionally display some content. If this is the case then said content will be padded via '*'.
#
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/studium/exams/exam_question/misc.rb', line 45
def fancy_cliner(
optional_content_to_be_displayed = nil
)
print seagreen('') if optional_content_to_be_displayed
e mediumaquamarine('*' * 3)+' '+
forestgreen( optional_content_to_be_displayed
)+
' '+
mediumaquamarine(
'*' * (75 - optional_content_to_be_displayed.size)
)
else
cliner('*', :mediumaquamarine)
end
end
|
#generate_statistical_webpage ⇒ Object
#
generate_statistical_webpage
Invoke like so:
qa --www
#
361
362
363
364
365
366
367
368
|
# File 'lib/studium/exams/exam_question/misc.rb', line 361
def generate_statistical_webpage
require 'studium/statistics/report_how_many_exam_questions_were_answered.rb'
Studium::Statistics::ReportHowManyExamQuestionsWereAnswered.generate_webpage
require 'open'
Open.in_browser(
Dir.home+'/Studium/html/statistics.html'
)
end
|
#internal_hash? ⇒ Boolean
585
586
587
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 585
def internal_hash?
@internal_hash
end
|
#invoke_all_the_necessary_steps_before_the_question_is_asked ⇒ Object
Also known as:
initial_steps
#
invoke_all_the_necessary_steps_before_the_question_is_asked
#
975
976
977
978
979
980
981
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 975
def invoke_all_the_necessary_steps_before_the_question_is_asked
determine_the_topic
try_to_read_in_the_dataset_from_the_corresponding_exam_file
sanitize_the_obtained_dataset
pick_a_random_line_from_the_obtained_dataset
parse_the_random_line_from_the_obtained_dataset
end
|
#line_contains_bold_token?(i = line?)
) ⇒ Boolean
#
line_contains_bold_token?
#
949
950
951
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 949
def line_contains_bold_token?(i = line?)
(i.include?('<b>') and i.include?('</b>'))
end
|
#line_contains_italic_token?(i = line?)
) ⇒ Boolean
#
line_contains_italic_token?
#
933
934
935
936
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 933
def line_contains_italic_token?(i = line?)
(i.include?('<it>') and i.include?('</it>')) or
(i.include?('<i>') and i.include?('</i>'))
end
|
#line_contains_underline_token?(i = line?)
) ⇒ Boolean
#
line_contains_underline_token?
#
941
942
943
944
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 941
def line_contains_underline_token?(i = line?)
(i.include?('<ud>') and i.include?('</ud>')) or
(i.include?('<u>') and i.include?('</u>'))
end
|
#load_file_rename_konsole_tab ⇒ Object
#
load_file_rename_konsole_tab
#
150
151
152
|
# File 'lib/studium/exams/exam_question/misc.rb', line 150
def load_file_rename_konsole_tab
YAML.load_file(FILE_RENAME_KONSOLE_TAB)
end
|
#main_file_exists?(i = exam_file?
) ⇒ Boolean
166
167
168
169
170
|
# File 'lib/studium/exams/exam_question/misc.rb', line 166
def main_file_exists?(
i = exam_file?
)
i and File.exist?(i)
end
|
#may_we_show_the_topic? ⇒ Boolean
Also known as:
may_we_show_the_topic
#
may_we_show_the_topic?
#
718
719
720
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 718
def may_we_show_the_topic?
@internal_hash[:may_we_show_the_topic]
end
|
#
This is the main menu-interface of this class, the part of the code where we take the commandline (if the user has done so) and evaluate what is to be done.
By default, we will assume that the user has not given any special instructions, hence why the default argument is nil.
Next we show some usage examples:
qa "delay = 3.0"
qa delay?
#
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
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
|
# File 'lib/studium/exams/exam_question/menu.rb', line 31
def (
i = commandline_arguments?
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when /^-?-?ALL/,
/^-?-?TOPICS/,
/^-?-?available(_|-)?topics\??$/i,
/^-?-?topics\??$/i,
/^-?-?show(_|-)?topics$/i,
/^-?-?all(_|-)?topics$/i,
/^-?-?ALL(-|_| )?TOPICS$/i,
/^-?-?all(-|_| )?topics\??$/i,
/^-?-?all(-|_| )?topics\??$/i,
/^-?-?show(-|_| )?available(-|_| )?topics$/i,
/^-?-?show(-|_| )?all(-|_| )?exam(-|_| )?topics$/i,
'detailed_topic'
show_available_topics when /^-?-?also(-|_| )?ask(-|_| )?from(-|_| )?solved(-|_| )?questions$/i,
/^-?-?full(-|_| )?pool$/i,
/^-?-?full$/i,
/^-?-?all(-|_| )?questions$/i,
/^-?-?everything$/i
@internal_hash[:reject_lines_that_end_with_a_done_token] = false
when 'LAST?', /^-?-?last$/,
/^-?-?last(_|-)?question\??$/i
show_last_question_asked
exit_program
when /^-?-?TOTAL\??$/i show_how_many_exam_questions_are_available
exit_program
when /^-?-?show(_|-)?all$/i,
/^-?-?show(_|-)?everything$/i
show_content_of_this_topic(topic?)
exit
when /^-?-?default(_|-)?topic\??$/i
report_the_default_topic_in_use
exit
when /^-?-?n(_|-)?topics$/i report_how_many_topics_are_available
exit_program
when /^-?-?show(_|-| )?statistics/i
show_statistics
exit_program
when /^-?-?size\??/i,
/^-?-?filesize\??/i
show_filesize_of_all_exams
exit
when /^-?-?show(_|-| )?topic\??/i
report_whether_we_will_show_the_topic
exit_program
when 'examtopics?',
'upload_exam_topics',
/^upload_?exams/,
'uexams',
'uexam'
Studium.upload_exam_questions { :be_verbose }
when /^-?-?all(-|_| )?solved$/i
set_all_questions_from_the_topic_to_solved
exit
when /^-?-?n(_|-| )?questions\??$/i
report_how_many_registered_questions_are_available
exit
when 'OPEN',
'OPENALL',
'OALL',
/^-?-?open$/
open_this_file_in_editor
exit_program
when /^-?-?ask(_|-)?last(_|-)?topic$/
target_file = "#{log_dir?}use_this_exam_topic.yml"
if File.exist? target_file
use_this_topic = YAML.load_file(
target_file
)
set_use_this_topic(use_this_topic)
else
no_file_exists_at(target_file)
end
exit_program
when 'ftp',
/^ftp(_|-)?upload$/
Studium.upload_exam_questions { :be_verbose }
exit_program
when /^-?-?edit$/i,
/^-?-?vim$/i
edit_sanitize_topics_in_vim
exit_program
when /^-?-?set_default_topic=(.+)/,
/^-?-?set-default-topic=(.+)/,
/^-?-?topic=(.+)/,
/^-?-?setdefaulttopic=(.+)/
set_default_topic_for_the_gui($1.to_s)
exit
when 'rename_tab?',
'--rename-tab?',
'renametab',
'renametab?' tell_whether_we_will_rename_the_kde_konsole_tab
exit_program
when /download_?exam_?topics/,
/((_|-)+(_|-)+download(_|-)+exam(_|-)+topics)/,
/^-?-?dexamtopics/
download_exam_topics
when 'del?',
'DELAY?',
'speed?', 'del',
/^-?-?delay\??$/i
report_the_delay
exit_program(:no_newline)
when /^-?-?last(_|-)?topic$/i,
/^-?-?show(_|-)?last(_|-)?topic$/i,
'ltopic?'
show_the_last_topic
exit
when /^-?-?set(-|_| )?delay=(.+)/
set_and_store_delay($2.to_s.dup)
exit
when /^-?-?www$/i
generate_statistical_webpage
exit
when /^-?-?finished\??$/i
show_all_finished_exam_topics
exit
when 'log?',
'log_dir?',
'store_where?',
'store_where',
'--dir?',
'dir?',
/^-?-?log(-|_| )?dir\??$/i
e "#{rev}The log directory can be found at: "\
"#{sdir(log_dir?)}"
exit
when 'HELP',
'help',
'--help',
'--hep',
'--help?',
'help?'
show_help_usage(:do_exit)
when /^OPEN(_|-)?LAST$/i,
/^OLAST$/i
open_the_last_file_via_your_editor
exit
when 'SOLVED_GERMAN?',
'german',
'german?',
'in_german?',
'n_solved_in_german?',
'nsolved2?',
'n_german?',
'--german?',
/^-?-?solved(_|-)?in(_|-)?german$/i
show_how_many_exam_questions_were_already_solved_in_german
exit_program
when /SOLVED/,
'N_SOLVED?',
'n_solved?',
'--nsolved?',
'--nsolved',
'nsolved',
'--english?',
'--english',
'english',
'english?'
show_how_many_exam_questions_were_already_solved
exit_program
else
if ::Studium.is_this_an_exam_topic?(i)
set_exam_topic(i)
end
end
end
end
|
#menu_on_the_commandline_as_a_string(i = commandline_as_string) ⇒ Object
#
menu_on_the_commandline_as_a_string
#
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
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 814
def menu_on_the_commandline_as_a_string(
i = commandline_as_string
)
case i
when /open (.+)/,
/(.+) open/
topic = $1.to_s.dup topic = find_corresponding_exam_topic(topic)
topic = ::Studium.directory_to_my_exam_topics+File.basename(topic)
open_this_file_in_editor(topic)
exit
when /^DELAY =? ?(\d{0,1}.\d{1})/i,
/^DEL =? ?(\d{0,1}.\d{1})/i,
/^set_delay =? ?(\d{0,1}.\d{1})/i,
/^set_delay :? ?(\d{0,1}.\d{1})/i,
/^set_delay ?(\d{0,1}.\d{1})/i _ = $1.to_s.dup
set_and_store_delay(_)
end
end
|
#n_questions_already_answered? ⇒ Boolean
#
n_questions_already_answered?
#
878
879
880
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 878
def n_questions_already_answered?
@internal_hash[:n_exam_questions_answered]
end
|
#n_questions_available? ⇒ Boolean
Also known as:
n_exam_questions?
#
n_questions_available?
Return how many questions are available in the given dataset at hand.
#
887
888
889
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 887
def n_questions_available?
@internal_hash[:n_exam_questions_in_total]
end
|
#notify_the_user_that_all_questions_have_been_answered_already(which_topic = which_topic?
) ⇒ Object
#
notify_the_user_that_all_questions_have_been_answered_already
#
107
108
109
110
111
112
113
|
# File 'lib/studium/exams/exam_question/misc.rb', line 107
def notify_the_user_that_all_questions_have_been_answered_already(
which_topic = which_topic?
)
opnn; e 'All questions have already been answered '
opnn; e "for the topic `#{orange(which_topic)}`. "\
"#{slateblue(cheering_person?)}"
end
|
#open_the_last_file_via_your_editor(this_file = last_file?
) ⇒ Object
#
open_the_last_file_via_your_editor
#
81
82
83
84
85
|
# File 'lib/studium/exams/exam_question/misc.rb', line 81
def open_the_last_file_via_your_editor(
this_file = last_file?
)
open_this_file_in_editor(this_file)
end
|
#open_this_file_in_editor(this_file = __FILE__) ⇒ Object
#
open_this_file_in_editor
Open this file in the editor.
#
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/studium/exams/exam_question/misc.rb', line 92
def open_this_file_in_editor(
this_file = __FILE__
)
use_this_editor = editor?
use_this_editor = 'nano -w' if is_on_roebe?
_ = "#{use_this_editor} #{this_file}" esystem _
end
|
#opnn ⇒ Object
415
416
417
418
419
420
|
# File 'lib/studium/exams/exam_question/misc.rb', line 415
def opnn
super(
namespace: @namespace,
use_colours: use_colours?
)
end
|
#parse_the_random_line_from_the_obtained_dataset(_ = ) ⇒ Object
Also known as:
determine_the_split_position, determine_index_position, parse_that_line, determine_the_question_and_the_answer
#
parse_the_random_line_from_the_obtained_dataset
This method must also determine the split-position in the given exam-question-line, which is also called the “index” position.
Example string:
- Name abc def. A: <one>DNA-Methylation</one>.
#
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
856
857
858
|
# File 'lib/studium/exams/exam_question/misc.rb', line 789
def parse_the_random_line_from_the_obtained_dataset(
_ = @internal_hash[:exam_question_line]
)
if _.nil?
notify_the_user_that_all_questions_have_been_answered_already
exit_program
return
end
index_to_split_at = 0
if _.include?('?')
index_to_split_at = _.rindex('?')
if _.include?('?') and
_.include?(' A: ') and
!(_ =~ /\d{1}\) A: /) index_to_split_at = _.index(' A: ')
end
set_split_position(index_to_split_at)
elsif _.include?(' A: ') index_to_split_at = _.index(' A: ')
set_split_position(index_to_split_at)
else opnn; e 'No ? and no A: was found. Please check the following line:'
e
e " #{tomato(_)}"
e
opnn; e
opnn; report_this_error
opnn; e
end
set_exam_question(_[0 .. index_to_split_at])
set_exam_answer(_[index_to_split_at .. -1])
end
|
#pick_a_random_line_from_the_obtained_dataset ⇒ Object
#
pick_a_random_line_from_the_obtained_dataset
#
767
768
769
770
771
772
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 767
def pick_a_random_line_from_the_obtained_dataset
_ = dataset?.reject {|line| line.end_with?(' []') } use_this_sample = _.sample
set_exam_question_line(use_this_sample)
try_to_save_the_line(use_this_sample)
end
|
#read_delay_from_file ⇒ Object
#
read_delay_from_file (load delay)
Use this method here, read_delay_from_file(), to read in the default delay from a stored file.
#
#register_last_modified_file(i = exam_file?
) ⇒ Object
#
register_last_modified_file
#
#report_file_does_not_exist(this_file = exam_file?
) ⇒ Object
#
report_file_does_not_exist
#
373
374
375
376
377
|
# File 'lib/studium/exams/exam_question/misc.rb', line 373
def report_file_does_not_exist(
this_file = exam_file?
)
opnn; e "#{rev}No file at `#{sfile(this_file)}` exists."
end
|
#report_how_many_registered_questions_are_available(n_questions = ::Studium.n_questions_available?) ⇒ Object
#
report_how_many_registered_questions_are_available
#
245
246
247
248
249
250
|
# File 'lib/studium/exams/exam_question/misc.rb', line 245
def report_how_many_registered_questions_are_available(
n_questions = ::Studium.n_questions_available?
)
opnn; e "#{rev}There are #{simp(n_questions.to_s)} registered "\
"questions available."
end
|
#report_how_many_topics_are_available ⇒ Object
#
report_how_many_topics_are_available
#
550
551
552
553
554
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 550
def report_how_many_topics_are_available
opnn; e 'There are exactly '+
simp(Studium.available_topics?.size.to_s)+
' topics available.'
end
|
#report_the_default_topic_in_use(this_file = "#{log_dir?}use_this_exam_topic.yml") ⇒ Object
#
report_the_default_topic_in_use
This method will report the default topic in use. We must also check whether the file in questions exists, before proceeding.
To invoke this, do:
qa --default-topic?
#
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 600
def report_the_default_topic_in_use(
this_file = "#{log_dir?}use_this_exam_topic.yml"
)
if File.exist? this_file
topic = File.read(this_file).chomp
e "The default topic in use is: #{simp(topic)}"
else
e "#{rev}No file exists at `#{sfile(this_file)}`. This "\
"means that no"
e 'default topic has been set.'
e
e 'If you wish to designate a default topic, use this invocation:'
e
e steelblue(' qa --set_default_topic=amg')
e steelblue(' qa --set_default_topic=phys')
e
end
end
|
#report_the_delay ⇒ Object
243
244
245
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 243
def report_the_delay
e "#{rev}The delay is set to: #{sfancy(delay?.to_s)}"
end
|
#report_this_error(error = nil) ⇒ Object
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# File 'lib/studium/exams/exam_question/misc.rb', line 228
def report_this_error(error = nil)
opnn; e 'We encountered an '+swarn('error')+
'. The @index_position was probably '\
'out of range.'
opnn; e 'Feedbacking @line next:'
pp line?
opnn; e "Feedbacking #{royalblue('the split position')} next:"
pp split_position?
if error
pp error
pp error.class
end
end
|
#report_whether_we_will_show_the_topic ⇒ Object
#
report_whether_we_will_show_the_topic
#
894
895
896
897
898
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 894
def report_whether_we_will_show_the_topic
opnn; e 'Will we show the topic of the exams when '\
'asking a question: '+
simp(VerboseTruth[may_we_show_the_topic?])
end
|
#reset ⇒ Object
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
|
# File 'lib/studium/exams/exam_question/reset.rb', line 18
def reset
super()
register_sigint
@namespace = NAMESPACE
@internal_hash = {}
@internal_hash[:dataset_from_the_file] = nil
@internal_hash[:n_exam_questions_in_total] = 0
@internal_hash[:word_wrap_at] = DEFAULT_WORD_WRAP_AT_N_CHARACTERS_PER_LINE
@internal_hash[:colour_for_answers] = nil
@internal_hash[:exam_file] = nil
@internal_hash[:may_we_show_the_topic] = MAY_WE_SHOW_THE_TOPIC
@internal_hash[:colour_for_questions] = nil
@internal_hash[:reject_lines_that_end_with_a_done_token] = true
@internal_hash[:debug] = SHALL_WE_DEBUG
@internal_hash[:result_for_www] = nil
set_delay
set_split_position
if are_we_in_www_mode?
disable_colours
end
set_be_verbose try_to_load_custom_colours
end
|
#result? ⇒ Boolean
548
549
550
|
# File 'lib/studium/exams/exam_question/misc.rb', line 548
def result?
@internal_hash[:result_for_www]
end
|
#return_the_full_expanded_exam_title(exam_title = exam_title?)
) ⇒ Object
#
return_the_full_expanded_exam_title
#
857
858
859
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 857
def return_the_full_expanded_exam_title(exam_title = exam_title?)
return Studium.find_corresponding_exam_title(exam_title)
end
|
#reveal_the_exam_answer(exam_answer = exam_answer?,
, include_numbers_in_parens = false) ⇒ Object
Also known as:
show_this_answer, show_the_answer, show_answer, reveal_the_answer
#
reveal_the_exam_answer (answer tag, reveal tag)
This method will show the proper answer to the given exam question as hand.
The second argument to this method, called `include_numbers_in_parens`, can be used to keep track as to whether we have numbers such as (2).
#
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
|
# File 'lib/studium/exams/exam_question/answer.rb', line 24
def reveal_the_exam_answer(
exam_answer = exam_answer?,
include_numbers_in_parens = false
)
unless include_numbers_in_parens
string_without_tags = remove_tags_from_this_input(exam_answer.dup)
n_characters_to_consider_in_the_line = string_without_tags.size
if n_characters_to_consider_in_the_line > word_wrap_at?
exam_answer = word_wrap(exam_answer, word_wrap_at?) exam_answer.gsub!(/\n/, N+LEFT_PADDING) if exam_answer.include? N end
end
if exam_answer.include? '(2)'
include_numbers_in_parens = true
subrange = exam_answer[0 .. (exam_answer.index('(') - 1)].dup
subrange_size = subrange.size
if does_this_line_include_a_html_colour?(subrange)
subrange_size += return_this_line_has_n_characters_as_html_colour_tags(subrange)
end
if subrange_size > @internal_hash[:word_wrap_at]
exam_answer[0 .. (exam_answer.index('(') - 1)] = ''.dup
subrange = word_wrap(subrange, @internal_hash[:word_wrap_at]).dup+N
exam_answer[0,0] = subrange
end
12.times { |iteration_number_n|
if use_colours?
replace_with_this = N+
' '+
rev+
slategray('(')+
skyblue(iteration_number_n.to_s.chomp)+
slategray(')')
if use_colours?
use_this_colour = ::Colours.send(colour_for_answers?) { :omit_end }
replace_with_this << use_this_colour
end
exam_answer.gsub!(/\(#{iteration_number_n}\)/,replace_with_this)
else
exam_answer.gsub!(/\(#{iteration_number_n}\)/,
N+'('+iteration_number_n.to_s+')') end
} end
if exam_answer.include? ' URL:' exam_answer = assign_url(exam_answer)
elsif exam_answer.include? ' https://'
exam_answer = colourize_https_substring(exam_answer) if use_colours?
end
exam_answer = exam_answer.to_s
if exam_answer.include?(' URL:') or exam_answer.include?(' https://')
assign_url_or_colourize_https_substring(exam_answer) if use_colours?
end
_ = ::Colours.replace_number_words_with_the_corresponding_html_colour(
exam_answer,
USE_THESE_COLOURS.merge(default_colour: colour_for_answers?)
)
result = " #{::Colours.fancy_parse(_, colour_for_answers?)}\n\n"
if line_contains_underline_token?(result) and use_colours?
result = replace_underline_token_with_default_colour(result)+
colour_for_answers?
end
if line_contains_italic_token?(result) and use_colours?
result = replace_italic_token_with_default_colour(result)+
::Colours.send(use_this_colour,'')
end
if line_contains_bold_token?(result) and use_colours?
result = replace_bold_token_with_default_colour(result)+
use_this_colour
end
if use_colours? and result.include?('https://')
use_this_regex =
/(https:\/\/.+)$/ result.sub!(use_this_regex, mediumaquamarine('\\1'))
end
if www_mode?
e '<div id="answer_div">'+N
e result
e "</div>\n"
else
e result
end
end
|
#run ⇒ Object
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 956
def run
menu_on_the_commandline_as_a_string
invoke_all_the_necessary_steps_before_the_question_is_asked
ask_the_question_then_sleep_then_reveal_the_answer_to_that_question
show_statistics
do_log_related_and_backup_related_actions
register_last_modified_file
end
|
#sanitize_the_obtained_dataset ⇒ Object
#
sanitize_the_obtained_dataset (sanitized tag)
This method exists primarily to remove all trailing “n”, and then remove all [] entries, as well as show how many exam questions are in that given file.
#
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 350
def sanitize_the_obtained_dataset
dataset = dataset?.map {|entry| entry.strip }
set_dataset(dataset)
@internal_hash[:n_exam_questions_in_total] = dataset.size
_ = dataset.reject {|line|
line.end_with? '[]'
}
set_exam_pool(_) if _ @internal_hash[:n_exam_questions_unanswered] = _.size
@internal_hash[:n_exam_questions_answered] = (
@internal_hash[:n_exam_questions_in_total] - _.size
)
end
|
#set_all_questions_from_the_topic_to_solved ⇒ Object
#
set_all_questions_from_the_topic_to_solved
This will solve all questions from a given topic.
Invocation example:
qa ALL_SOLVED
#
215
216
217
218
219
220
221
222
223
|
# File 'lib/studium/exams/exam_question/misc.rb', line 215
def set_all_questions_from_the_topic_to_solved
if commandline?
require 'studium/exams/solve_all_questions_from_this_topic.rb'
this_topic = which_topic?
e "#{rev}Setting all questions from the topic "\
"#{sfancy(this_topic)} to solved."
Studium::SolveAllQuestionsFromThisTopic.new(this_topic)
end
end
|
#set_and_store_delay(i) ⇒ Object
#
set_and_store_delay
Combine two methods in one here.
#
295
296
297
298
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 295
def set_and_store_delay(i)
set_delay(i)
store_delay(i)
end
|
#set_colour_for_answers(i) ⇒ Object
#
set_colour_for_answers
#
740
741
742
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 740
def set_colour_for_answers(i)
@internal_hash[:colour_for_answers] = i.to_sym
end
|
#set_colour_for_questions(i) ⇒ Object
#
set_colour_for_questions
#
733
734
735
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 733
def set_colour_for_questions(i)
@internal_hash[:colour_for_questions] = i.to_sym
end
|
#set_custom_colours(i) ⇒ Object
#
set_custom_colours
This setter is, since as of January 2022, just calling two methods now. This was simpler to maintain than using another ad-hoc Hash.
Valid keys for the colours should be, for instance, “colour_for_questions” or “colour_for_answers”.
#
753
754
755
756
757
758
759
760
761
762
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 753
def set_custom_colours(i)
if i.is_a?(String) and i.include?('|')
splitted = i.split('|')
set_colour_for_questions(splitted.first)
set_colour_for_answers(splitted.last)
end
end
|
#set_dataset(i) ⇒ Object
339
340
341
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 339
def set_dataset(i)
@internal_hash[:dataset_from_the_file] = i
end
|
#set_default_topic_for_the_gui(what, into = "#{log_dir?}use_this_exam_topic.yml") ⇒ Object
#
set_default_topic_for_the_gui
#
912
913
914
915
916
917
918
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 912
def set_default_topic_for_the_gui(
what,
into = "#{log_dir?}use_this_exam_topic.yml"
)
opnn; e "Now setting the default topic to `#{simp(what)}`."
write_what_into(what, into)
end
|
#set_delay(i = :load_from_file) ⇒ Object
Also known as:
determine_the_default_delay, delay=
#
set_delay
Set the default delay value via this method.
#
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
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 259
def set_delay(
i = :load_from_file
)
case i
when :default,
:load_from_file,
nil
if File.exist? FILE_DELAY
i = YAML.load_file(FILE_DELAY)
i = i['delay'] if i.respond_to?('delay')
else
i = DEFAULT_DELAY
end
end
if i.is_a? Hash
i = i['delay']
end
@internal_hash[:delay] = i.to_f
end
|
#set_exam_answer(i) ⇒ Object
Also known as:
set_answer
#
set_exam_answer
This method can be used to keep track of the current exam-answer - that is the answer that fits to the exam-question at hand. Before it is set, though, this method will do various sanitizing actions, to make sure the answer is sufficiently “improved”, before it is displayed to the user (or whoever invoked this class).
Perhaps this should be factored out into a separate method, but for now it will remain as it is.
Note that every question must have an associated answer. This is the very basic assumption for the “studium” gem every question must adhere to.
#
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 644
def set_exam_answer(
i
)
i = i.first if i.is_a? Array
i = i.dup if i.frozen? i.strip! i[-3, 3] = '' if i.end_with?(' []') i[0, 3] = '' if i.start_with?('A: ') i[0, 2] = '' if i.start_with?('- ')
i[0, 2] = '' if i.start_with?(': ','? ','?:')
i.sub!(/^\?/,'') if i.start_with? '?' if i.include? '(a)' i.gsub!(/\(a\)/, N+' (a)')
i.gsub!(/\(b\)/, N+' (b)') if i.include? '(b)'
i.gsub!(/\(c\)/, N+' (c)') if i.include? '(c)'
i.gsub!(/\(d\)/, N+' (d)') if i.include? '(d)'
i.gsub!(/\(e\)/, N+' (e)') if i.include? '(e)'
i.gsub!(/\(f\)/, N+' (f)') if i.include? '(f)'
end
if debug?
e "We will now set the answer to: #{sfancy(i)}" if commandline?
end
i.gsub!(/<br>/, N) if i.include? '<br>'
if EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_ANSWER
if use_colours? and commandline? and (i.count('"') > 1)
use_this_regex = /"(.+?\s*.*?)"/ use_this_colour = ::Colours.send(colour_for_answers?) { :omit_end }
i.gsub!(
use_this_regex,
'"'+steelblue('\1'.delete(N))+
use_this_colour+'"'
)
end
end
@internal_hash[:exam_answer] = i
end
|
#set_exam_file(i) ⇒ Object
Also known as:
set_file
#
set_exam_file
The file location will be something like:
/Programs/Ruby/2.3.1/lib/ruby/site_ruby/2.3.0/studium/exam_topics/physiologie
#
472
473
474
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 472
def set_exam_file(i)
@internal_hash[:exam_file] = i
end
|
#set_exam_pool(i = nil) ⇒ Object
#
set_exam_pool
The “exam pool” constitutes the available, unanswered exams.
What this means, essentially, is that every line ending with a '[]' will be disregarded.
#
133
134
135
|
# File 'lib/studium/exams/exam_question/misc.rb', line 133
def set_exam_pool(i = nil)
@internal_hash[:exam_pool] = i
end
|
#set_exam_question(i) ⇒ Object
Also known as:
set_question
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 376
def set_exam_question(i)
i = i.dup if i.frozen?
i.strip! i[0, 2] = '' if i.start_with?('- ') i[-2, 2] = '' if i.end_with?(' A')
i[-2, 2] = '' if i.end_with?('?A')
i[-3, 3] = '' if i.end_with?(' A?')
i[-2, 2] = '' if i.end_with?('! ?') if i.end_with? '. ?' i[-2, 2] = '' end
if i.end_with? '.?','!?' i.chop! end
i.strip! unless i.rstrip.end_with?('?','.','!')
i << '?' end
trimmed_sequence = remove_escape_sequences(
remove_tags_from_this_input(i)
)
n_characters_to_consider_in_the_line = trimmed_sequence.size
if n_characters_to_consider_in_the_line > @internal_hash[:word_wrap_at]
i = word_wrap(i, @internal_hash[:word_wrap_at])
end
if EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_QUESTION
if use_colours? and commandline? and (i.count('"') > 1)
use_this_regex = /"(.+?\s*.*?)"/ use_this_colour = ::Colours.send(colour_for_questions?) { :omit_end }
i.gsub!(use_this_regex,
'"'+forestgreen('\1'.delete(N))+ use_this_colour+'"'
)
end
end
@internal_hash[:exam_question] = i
end
|
#set_exam_question_line(i) ⇒ Object
Also known as:
set_line, set_this_line
#
set_exam_question_line
A full exam-question line, also shorter called “line”, is a line that contains a question, and the associated answer to this question.
This setter may not modify anything - we just want to assign to the correct entry in our main Hash. Additionally the line itself may not be tampered with at all, so that we can act on that information, such as by storing that line into a local file.
#
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
|
# File 'lib/studium/exams/exam_question/misc.rb', line 874
def set_exam_question_line(i)
if i.is_a? Array
i = i.first.to_s.dup end
if block_given?
case yield
when :then_determine_the_split_position
determine_the_split_position
end
end
@internal_hash[:exam_question_line] = i
end
|
#set_exam_question_line_and_then_parse_that_line(i) ⇒ Object
#
set_exam_question_line_and_then_parse_that_line
#
986
987
988
989
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 986
def set_exam_question_line_and_then_parse_that_line(i)
set_exam_question_line(i)
parse_that_line
end
|
#set_exam_topic(i = first_non_hyphen_argument?
) ⇒ Object
Also known as:
set_this_topic, determine_the_topic, determine_the_exam_topic
#
set_exam_topic
We need to store the expanded topic name, so that something like “bioanalytik” is turned into “bioanalytik_und_biosensoren”.
Whenever a topic is set through this method, this will also be stored into a file. This then allows us to query what the last topic was, e. g. via “qa –last_topic?”.
#
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
|
# File 'lib/studium/exams/exam_question/misc.rb', line 616
def set_exam_topic(
i = first_non_hyphen_argument?
)
i = i.first if i.is_a? Array
if i.is_a?(Hash) and i.has_key?(:use_this_topic)
i = i[:use_this_topic]
end
case i
when nil, ''
i = 'random_topic' end
i = i.to_s.dup i.downcase! case i
when 'fetch_a_random_topic',
'random_topic',
'random',
'rand'
i = ::Studium::Exams.random_short_name_topic when 'molbio',
'molekularbiologie',
'molbio?'
i = 'amg|amg2|genex1|gentech1|gentech2|pcr'
when /^qlast$/i,
/^olast$/i _ = FILE_LAST_TOPIC
if File.exist? _
i = File.read(FILE_LAST_TOPIC).strip
else
opnn; no_file_exists_at(_)
end
end
if i.include? '|'
i = i.split('|').shuffle
end
if ::Studium.is_this_a_registered_exam_topic?(i)
i = Studium.find_corresponding_exam_topic(i)
else
opnn; e "Not a registered exam topic: #{i}"
end
@internal_hash[:topic] = i
unless in_www_mode?
store_last_topic_into_file(i)
end
end
|
#set_may_we_show_the_topic(i = MAY_WE_SHOW_THE_TOPIC) ⇒ Object
Also known as:
may_we_show_the_topic=, set_show_topic
#
set_may_we_show_the_topic
#
725
726
727
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 725
def set_may_we_show_the_topic(i = MAY_WE_SHOW_THE_TOPIC)
@internal_hash[:may_we_show_the_topic] = i
end
|
#set_split_position(i = nil) ⇒ Object
Also known as:
set_index_position
777
778
779
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 777
def set_split_position(i = nil)
@internal_hash[:split_position] = i
end
|
#show_all_finished_exam_topics ⇒ Object
#
show_all_finished_exam_topics
To invoke this method, do:
qa --finished?
#
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
# File 'lib/studium/exams/exam_question/misc.rb', line 491
def show_all_finished_exam_topics
stats = Studium::Statistics::ReportHowManyExamQuestionsWereAnswered.new {
:do_not_show_the_result
}.internal_dataset
e "#{rev}The following topics are completely answered "\
"(#{colourize_percentage('100%')} answered ratio)."
array_finished_topics = []
stats.select {|key, value|
percentage = value[:percentage_of_questions_answered]
if percentage == 100.0
array_finished_topics << ::Studium.beautify_this_topic(key)
end
}
e
array_finished_topics.each {|topic|
e " #{simp(topic)} is completely answered."
}
e
end
|
#show_available_topics(shall_we_exit = true) ⇒ Object
#
show_available_topics (topics tag)
This method will show which topics are all available.
By default, it will also exit after having done so.
To invoke this method, try:
qa topics?
qa --show-available-topics
#
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
|
# File 'lib/studium/exams/exam_question/misc.rb', line 572
def show_available_topics(
shall_we_exit = true
)
e
use_these_topics = Studium.available_topics.sort use_these_topics.each_with_index {|category, index|
index = '%4s' % ('('+(index+1).to_s)
result = ' '.dup
if use_colours?
result << ::Colours::CYAN if commandline?
end
result << "#{index}) - " if use_colours? result << rev if commandline?
end
category = category.to_s.delete('_')
category = steelblue(category) if use_colours?
result << category
e result
}
e
exit if shall_we_exit
end
|
#show_content_of_this_topic(i = topic?
) ⇒ Object
#
show_content_of_this_topic
Invocation example:
qa ethik --show-everything
#
#show_filesize_of_all_exams ⇒ Object
#
show_filesize_of_all_exams
To call this method, do:
qa --filesize?
#
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 447
def show_filesize_of_all_exams
this_exam_topic = directory_of_the_exam_topics?
all_filesizes = Dir["#{this_exam_topic}*"].map {|entry|
File.size?(entry)
}
sum = all_filesizes.sum
sum_in_kb = sum / 1000.0
sum_in_mb = sum_in_kb / 1000.0
e "#{rev}The total file size of all exams in "\
"#{sdir(this_exam_topic)} is:"
e
e ' '+simp(sum.to_s)+
' Bytes ('+
sfancy(sum_in_mb.round(2).to_s)+' MB)'
e
end
|
#show_help_usage(then_exit = false) ⇒ Object
#
show_help_usage (help tag)
We show help usage of this class here via this method. It is typically used from the commandline.
To show this help message, use this:
qa --help
#
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
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 185
def show_help_usage(
then_exit = false
)
case then_exit
when :do_exit,
:exit
then_exit = true
end
opnn; e "Currently the following extra commands can be issued:#{N}#{N}"
lpad = ' ' * 4
e "#{lpad}--set_default_topic= #{yellow(' Set a default topic.')}"
e lpad+'TOPICS '+
yellow(' List all available topics.')
e lpad+'TOTAL '+
yellow(" Show how many questions are known in total.")
e lpad+'FINISHED '+
yellow(' Show which topics are '\
'completely finished (100% answered).')
e lpad+'EDIT '+
yellow(' To edit the exam questions '\
'file, via vim.')
e lpad+'LAST_TOPIC '+
yellow(' Show the last topic used.')
e lpad+'BLOCK '+
yellow(' List all questions that '\
'were already answered for a given section.')
e lpad+'OPEN '+
yellow(' Open this file here in an editor.')
e lpad+'--download-exam-topics '+
yellow(' Download the exam topics.')
e lpad+'--all-questions '+
yellow(' Ask all questions, including those marked '\
'with a trailing "[]".')
e lpad+'delay? '+
yellow(' show the default delay.')
e lpad+"'delay = 5' "+
yellow(' to set a new delay to 5 seconds.')
e lpad+"'set-delay = 5' "+
yellow(' to set a new delay '\
'to 5 seconds. (as ^^^ above)')
if is_on_roebe? e lpad+'rename_tab? '+
yellow(' whether to rename the KDE konsole tab or not.')
e lpad+'rename_tab: true'+
yellow(' enable renaming of the KDE konsole tab.')
e lpad+'rename_tab: false'+
yellow(' disable rename of the KDE konsole tab.')
end
e
exit if then_exit
end
|
#show_how_many_exam_questions_are_available ⇒ Object
Also known as:
total, n_total_questions_available?
#
show_how_many_exam_questions_are_available
This method can be called by passing in 'TOTAL' as argument.
Example:
qa TOTAL?
#
400
401
402
403
404
405
406
407
408
409
|
# File 'lib/studium/exams/exam_question/misc.rb', line 400
def show_how_many_exam_questions_are_available
n_questions = ::Studium.n_questions_available?.to_s
result = 'Total amount of registered questions: '.dup
if commandline? and use_colours?
result << simp(n_questions.to_s)
else
result << n_questions.to_s
end
e result
end
|
#show_how_many_exam_questions_were_already_solved ⇒ Object
#show_how_many_exam_questions_were_already_solved_in_german ⇒ Object
#
show_how_many_exam_questions_were_already_solved_in_german
Similar to the above, except that we will report in german.
Invocation example:
qa --solved-in-german
#
#show_last_question_asked(i = store_where?
) ⇒ Object
#
show_last_question_asked
This will show the last question asked.
#
449
450
451
452
453
454
455
|
# File 'lib/studium/exams/exam_question/misc.rb', line 449
def show_last_question_asked(
i = store_where?
)
if File.exist? i
e File.read(i)
end
end
|
#show_line ⇒ Object
514
515
516
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 514
def show_line
e exam_question_line?
end
|
#show_statistics(dataset = dataset?
) ⇒ Object
Also known as:
report_statistics
#
show_statistics
To invoke this method from the commandline, try:
qa --show-statistics
#
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
|
# File 'lib/studium/exams/exam_question/misc.rb', line 752
def show_statistics(
dataset = dataset?
)
unless in_www_mode?
n_questions = n_questions_available?
n_answered = n_questions_already_answered?
percentage = (n_answered.to_f * 100) / n_questions
result = olivedrab(n_questions.to_s)+' questions available, '+
mediumaquamarine(n_answered.to_s)+
' ('+
colourize_percentage(percentage.round(2).to_s+'%')+
') already answered.'+N
padded_amount_of_questions_answered = (n_questions - n_answered).to_s
padded_amount_of_questions_answered =
padded_amount_of_questions_answered.rjust(n_questions.to_s.size)
result << "#{crimson(padded_amount_of_questions_answered)} questions "\
"could still be answered. Topic: "\
"#{olive(return_the_full_expanded_exam_title)}.#{rev}"
e result
end
end
|
#show_the_last_topic(_ = FILE_LAST_TOPIC) ⇒ Object
#
show_the_last_topic
Invocation example:
qa --show-last-topic
#
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/studium/exams/exam_question/misc.rb', line 180
def show_the_last_topic(
_ = FILE_LAST_TOPIC
)
if File.exist? _
e rev+'The last topic was `'+
simp(
expand_topic(File.read(_).chomp)
)+'`.'
else
opnn; no_file_exists_at(_.to_s)
end
end
|
#sleep_default_delay(i = delay?
) ⇒ Object
Also known as:
default_sleep, do_sleep, start_default_sleep
#
sleep_default_delay
This method can be used to sleep for the specified duration.
Since as of April 2012 the method will also handle SIGINT-events gracefully.
#
535
536
537
538
539
540
541
542
543
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 535
def sleep_default_delay(
i = delay?
)
begin
sleep(i)
rescue Interrupt exit_program
end
end
|
#split_position? ⇒ Boolean
784
785
786
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 784
def split_position?
@internal_hash[:split_position]
end
|
#store_delay(i) ⇒ Object
#
store_delay (store tag)
This method will store/save the delay into a file.
#
#store_last_topic_into_file(what = topic?,
, into = FILE_LAST_TOPIC) ⇒ Object
#
store_last_topic_into_file
By default we will not report this activity.
#
198
199
200
201
202
203
|
# File 'lib/studium/exams/exam_question/misc.rb', line 198
def store_last_topic_into_file(
what = topic?,
into = FILE_LAST_TOPIC
)
write_what_into(what, into)
end
|
#tell_whether_we_will_rename_the_kde_konsole_tab ⇒ Object
#
tell_whether_we_will_rename_the_kde_konsole_tab
#
923
924
925
926
927
928
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 923
def tell_whether_we_will_rename_the_kde_konsole_tab
e 'Will we rename the KDE konsole tab? '+
simp(
VerboseTruth[load_file_rename_konsole_tab.to_s]
)
end
|
#topic? ⇒ Boolean
Also known as:
exam_topic?, exam_title?, which_topic?, topic, title, title?, category?
319
320
321
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 319
def topic?
@internal_hash[:topic]
end
|
#try_to_load_custom_colours ⇒ Object
#
try_to_load_custom_colours
This method can be used to designate specific colours for use by this class.
#
562
563
564
565
566
567
568
569
570
571
572
573
|
# File 'lib/studium/exams/exam_question/exam_question.rb', line 562
def try_to_load_custom_colours
_ = "#{::Studium.project_yaml_directory?}custom_colours.yml"
if File.exist? _
dataset = YAML.load_file(_)
set_colour_for_questions(
dataset['colour_for_questions']
)
set_colour_for_answers(
dataset['colour_for_answers']
)
end
end
|
#try_to_read_in_the_dataset_from_the_corresponding_exam_file(_ = exam_topics_directory?+
topic?.to_s) ⇒ Object
#
try_to_read_in_the_dataset_from_the_corresponding_exam_file
#
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
# File 'lib/studium/exams/exam_question/misc.rb', line 514
def try_to_read_in_the_dataset_from_the_corresponding_exam_file(
_ = exam_topics_directory?+
topic?.to_s
)
if File.exist? _
set_exam_file(_)
@internal_hash[:dataset_from_the_file] =
read_in_exam_dataset_from_this_file(_)
else
report_file_does_not_exist(_)
end
end
|
#try_to_save_the_line(i = line?
) ⇒ Object
#
try_to_save_the_line (save tag)
This is called whenever the main line is obtained. The original line is copied, not any modified variant.
We will store into a file, which is kept at @store_where.
It usually defaults to the file /Depot/Studium/last_question_asked.md or wherever else the base-directory has been defined.
#
316
317
318
319
320
321
322
323
324
325
326
327
328
|
# File 'lib/studium/exams/exam_question/misc.rb', line 316
def try_to_save_the_line(
i = line?
)
_ = store_where? if File.exist?(File.dirname(_))
if debug?
opnn; e "Now saving: #{bold_blue(i)} into the file #{sfile(_)}"
end if commandline?
if File.writable?(File.dirname(_))
write_what_into(i, _) end
end
end
|
#word_wrap_at? ⇒ Boolean
602
603
604
|
# File 'lib/studium/exams/exam_question/misc.rb', line 602
def word_wrap_at?
@internal_hash[:word_wrap_at]
end
|