Class: Studium::GUI::Gtk::ExamQuestionWidget
- Inherits:
-
Gtk::Box
- Object
- Gtk::Box
- Studium::GUI::Gtk::ExamQuestionWidget
- Includes:
- Gtk::BaseModule
- Defined in:
- lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb
Overview
Studium::GUI::Gtk::ExamQuestionWidget
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect- TITLE =
#
TITLE
#
'Exam Question Widget'- WIDTH =
#
WIDTH
#
'75%'- HEIGHT =
#
HEIGHT
#
'85%'- USE_THIS_MARGIN =
#
USE_THIS_MARGIN
#
12- DEFAULT_DELAY =
#
DEFAULT_DELAY
This constant specifies how long to wait before the answer is revealed, if the user has set the checkbutton to “automatically answer the question”.
#
'18.0'- USE_THIS_AS_THE_DEFAULT_EXAM_TOPIC =
#
USE_THIS_AS_THE_DEFAULT_EXAM_TOPIC
This constant can be used to specify the default exam topic to be used on startup of this application.
#
'virus'- DEFAULT_PLACEHOLDER_TEXT =
#
DEFAULT_PLACEHOLDER_TEXT
#
'You can input your answer to the exam question here.'- USE_THIS_FONT =
#
USE_THIS_FONT
The older font was :dejavu_condensed_20 and the oldest font was :deja_vu_sans_25.
#
:hack_20- SMALLER_FONT =
#
SMALLER_FONT
This one should be matched onto the larger font defined above.
#
:hack_18- SMALLEST_FONT =
#
SMALLEST_FONT
#
:hack_15- WORD_WRAP_AT_N_CHARACTERS =
#
WORD_WRAP_AT_N_CHARACTERS
#
78- SQLITE_DATABASE_FILE =
#
SQLITE_DATABASE_FILE
This is experimental - one day we may want to query from a sqlite database rather than flat files.
#
'/Depot/jjjj/exam_questions.db'
Class Method Summary collapse
-
.gtk_accel_group ⇒ Object
# === Studium::GUI::Gtk::AskExamQuestion.gtk_accel_group ========================================================================= #.
-
.run(i = ARGV) ⇒ Object
# === Studium::GUI::Gtk::ExamQuestionWidget.run ========================================================================= #.
Instance Method Summary collapse
-
#activate_the_third_textview ⇒ Object
# === activate_the_third_textview ========================================================================= #.
-
#add_the_status_icon ⇒ Object
# === add_the_status_icon ========================================================================= #.
-
#all_questions_have_been_answered_in_this_topic?(this_topic = current_exam_topic? ) ⇒ Boolean
# === all_questions_have_been_answered_in_this_topic?.
-
#answer_is? ⇒ Boolean
# === answer_is? ========================================================================= #.
-
#array_all_exam_questions? ⇒ Boolean
# === array_all_exam_questions?.
-
#available_exam_topics? ⇒ Boolean
# === available_exam_topics? ========================================================================= #.
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#button_ask_the_exam_question? ⇒ Boolean
(also: #question_button?, #button_ask_the_question?)
# === button_ask_the_exam_question? ========================================================================= #.
-
#clear_reveal_the_answer ⇒ Object
# === clear_reveal_the_answer ========================================================================= #.
-
#connect_skeleton ⇒ Object
# === connect_skeleton (connect tag) ========================================================================= #.
-
#context_menu? ⇒ Boolean
# === context_menu? ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton (create tag) ========================================================================= #.
-
#create_text_buffer_for_the_answer ⇒ Object
# === create_text_buffer_for_the_answer ========================================================================= #.
-
#create_text_view_for_the_answer ⇒ Object
# === create_text_view_for_the_answer ========================================================================= #.
-
#create_the_ask_the_exam_question_button ⇒ Object
# === create_the_ask_the_exam_question_button ========================================================================= #.
-
#create_the_button_use_random_entry_from_the_ten_aliases ⇒ Object
# === create_the_button_use_random_entry_from_the_ten_aliases ========================================================================= #.
-
#create_the_buttons ⇒ Object
# === create_the_buttons (buttons tag, button tag) ========================================================================= #.
-
#create_the_checkbox ⇒ Object
# === create_the_checkbox.
-
#create_the_combobox ⇒ Object
# === create_the_combobox ========================================================================= #.
-
#create_the_context_menu ⇒ Object
# === create_the_context_menu.
-
#create_the_entries ⇒ Object
# === create_the_entries (entries tag, entry tag) ========================================================================= #.
-
#create_the_labels ⇒ Object
# === create_the_labels ========================================================================= #.
-
#create_the_main_grid ⇒ Object
# === create_the_main_grid (grid tag) ========================================================================= #.
-
#create_the_reveal_button ⇒ Object
# === create_the_reveal_button ========================================================================= #.
-
#current_exam_topic? ⇒ Boolean
(also: #main_exam_topic?, #exam_topic?, #current_topic?)
# === current_exam_topic? ========================================================================= #.
-
#debug ⇒ Object
# === debug ========================================================================= #.
-
#deselect_the_entry_containing_the_exam_topic ⇒ Object
# === deselect_the_entry_containing_the_exam_topic ========================================================================= #.
-
#do_assign_a_new_exam_topic ⇒ Object
# === do_assign_a_new_exam_topic ========================================================================= #.
-
#do_clear_the_free_form_textarea ⇒ Object
# === do_clear_the_free_form_textarea ========================================================================= #.
-
#do_clear_the_question_buffer ⇒ Object
# === do_clear_the_question_buffer.
-
#do_handle_the_click_event_for_the_ask_question_button ⇒ Object
# === do_handle_the_click_event_for_the_ask_question_button (clicked tag).
-
#do_jump_into_the_entry_containing_the_current_exam_topic ⇒ Object
# === do_jump_into_the_entry_containing_the_current_exam_topic ========================================================================= #.
-
#do_open_the_current_exam_topic_file(combo_box_available_exam_topics = @combo_box_available_exam_topics) ⇒ Object
# === do_open_the_current_exam_topic_file.
-
#do_popup_the_array_of_all_exam_questions ⇒ Object
# === do_popup_the_array_of_all_exam_questions ========================================================================= #.
-
#do_reveal_the_answer_after_timeout(answer = answer_is?, , use_this_as_timeout = @entry_delay_to_use.text) ⇒ Object
# === do_reveal_the_answer_after_timeout (revel tag).
-
#do_style_all_buttons_uniformly(i = return_all_buttons) ⇒ Object
# === do_style_all_buttons_uniformly ========================================================================= #.
-
#do_update_the_entry_n_answered(current_exam_topic = @combo_box_available_exam_topics.active_text.to_s.strip.dup, entry = @entry_containing_n_answers) ⇒ Object
(also: #update_n_answered)
# === do_update_the_entry_n_answered ========================================================================= #.
-
#do_update_the_entry_n_questions(current_exam_topic = current_exam_topic? ) ⇒ Object
(also: #update_n_questions)
# === do_update_the_entry_n_questions ========================================================================= #.
-
#do_update_the_entry_n_unanswered_questions ⇒ Object
(also: #update_the_entry_n_unanswered_questions, #update_n_unanswered)
# === do_update_the_entry_n_unanswered_questions.
-
#do_update_this_gtk_entry_with_that_exam_topic_for_its_percentage_value(entry_percentage = entry_percentage?, , use_this_exam_topic = current_exam_topic?.to_s) ⇒ Object
(also: #update_the_percentage_entry)
# === do_update_this_gtk_entry_with_that_exam_topic_for_its_percentage_value ========================================================================= #.
-
#do_updated_the_entries_n_answered_and_n_unanswered ⇒ Object
# === do_updated_the_entries_n_answered_and_n_unanswered ========================================================================= #.
-
#enable_all_key_combinations ⇒ Object
# === enable_all_key_combinations ========================================================================= #.
-
#enable_alt_1_key_combination ⇒ Object
# === enable_alt_1_key_combination ========================================================================= #.
-
#enable_alt_w_key_combination ⇒ Object
# === enable_alt_w_key_combination.
-
#enable_alt_y_key_combination ⇒ Object
# === enable_alt_y_key_combination ========================================================================= #.
-
#entry_holding_all_exam_topics? ⇒ Boolean
(also: #entry_ask_questions_from_this_topic?, #entry_ask_questions?, #entry_exam_topic?)
# === entry_holding_all_exam_topics? ========================================================================= #.
-
#entry_percentage? ⇒ Boolean
# === entry_percentage? ========================================================================= #.
-
#handle_CSS ⇒ Object
# === handle_CSS ========================================================================= #.
-
#handle_the_combo_box_available_exam_topics_on_changed_event(combo_box = @combo_box_available_exam_topics) ⇒ Object
# === handle_the_combo_box_available_exam_topics_on_changed_event ========================================================================= #.
-
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ ExamQuestionWidget
constructor
# === initialize ========================================================================= #.
-
#main_combo_box? ⇒ Boolean
# === main_combo_box? ========================================================================= #.
-
#main_font? ⇒ Boolean
# === main_font? ========================================================================= #.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#parse_for_URL(i = text_view_for_the_answer?.buffer.text) ⇒ Object
# === parse_for_URL.
-
#popup_pick_a_new_font ⇒ Object
# === popup_pick_a_new_font ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#return_available_exam_topics ⇒ Object
# === return_available_exam_topics ========================================================================= #.
-
#return_button_ask_the_exam_question(use_emoji = false) ⇒ Object
# === return_button_ask_the_exam_question (ask tag) ========================================================================= #.
-
#return_button_open_exam_topic_file ⇒ Object
# === return_button_open_exam_topic_file ========================================================================= #.
-
#return_button_solve_the_question ⇒ Object
# === return_button_solve_the_question.
-
#return_checkbox_shall_we_reveal_the_answer ⇒ Object
# === return_checkbox_shall_we_reveal_the_answer ========================================================================= #.
-
#return_combo_box_available_exam_topics ⇒ Object
# === return_combo_box_available_exam_topics ========================================================================= #.
-
#return_entry_percentage ⇒ Object
# === return_entry_percentage ========================================================================= #.
-
#return_event_box_for_asking_a_random_exam_topic ⇒ Object
# === return_event_box_for_asking_a_random_exam_topic ========================================================================= #.
-
#return_event_box_with_face_glasses ⇒ Object
# === return_event_box_with_face_glasses ========================================================================= #.
-
#return_eventbox_with_an_image_to_exit_the_application ⇒ Object
# === return_eventbox_with_an_image_to_exit_the_application ========================================================================= #.
-
#return_frame_containing_the_label_exam_topic ⇒ Object
# === return_frame_containing_the_label_exam_topic ========================================================================= #.
-
#return_hbox_containing_three_labels_and_three_entries ⇒ Object
# === return_hbox_containing_three_labels_and_three_entries.
-
#return_hbox_containing_two_icons_and_instructions_what_to_do_with_the_free_form_textarea ⇒ Object
# === return_hbox_containing_two_icons_and_instructions_what_to_do_with_the_free_form_textarea ========================================================================= #.
-
#return_n_answers_from_the_currently_selected_topic(i = exam_topic? ) ⇒ Object
# === return_n_answers_from_the_currently_selected_topic ========================================================================= #.
-
#return_n_questions_from_the_currently_selected_topic(i = exam_topic? ) ⇒ Object
# === return_n_questions_from_the_currently_selected_topic ========================================================================= #.
-
#return_scrolled_window_containing_the_text_view_for_the_answer(text_view_for_the_answer) ⇒ Object
# === return_scrolled_window_containing_the_text_view_for_the_answer ========================================================================= #.
-
#return_scrolled_window_containing_the_textarea3(textarea = @textarea3) ⇒ Object
# === return_scrolled_window_containing_the_textarea3 ========================================================================= #.
-
#return_scrolled_window_for_the_text_view_for_the_question(text_view_for_the_question) ⇒ Object
# === return_scrolled_window_for_the_text_view_for_the_question ========================================================================= #.
-
#return_string_how_many_exam_questions_are_already_answered ⇒ Object
# === return_string_how_many_exam_questions_are_already_answered ========================================================================= #.
-
#return_text_view_for_the_answer(text_buffer_for_the_answer) ⇒ Object
# === return_text_view_for_the_answer ========================================================================= #.
-
#return_text_view_for_the_question(text_buffer_for_the_question) ⇒ Object
# === return_text_view_for_the_question ========================================================================= #.
-
#return_textarea_number_three ⇒ Object
# === return_textarea_number_three ========================================================================= #.
-
#return_wikipedia_entry ⇒ Object
# === return_wikipedia_entry.
-
#reveal_the_answer_to_the_exam_question ⇒ Object
# === reveal_the_answer_to_the_exam_question ========================================================================= #.
-
#rinstall2 ⇒ Object
(also: #r2)
# === rinstall2 ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#set_exam_topic(i) ⇒ Object
# === set_exam_topic ======================================================================= #.
-
#show_ten_aliases? ⇒ Boolean
# === show_ten_aliases? ========================================================================= #.
-
#sync_entry_holding_all_exam_topics_onto_the_combo_box(value = @entry_holding_all_exam_topics.text?. downcase.delete(' ').delete('_')) ⇒ Object
(also: #sync_entry_holding_all_exam_topics_onto_the_main_combo_box)
# === sync_entry_holding_all_exam_topics_onto_the_combo_box.
-
#text_view_containing_the_current_question? ⇒ Boolean
# === text_view_containing_the_current_question? ========================================================================= #.
-
#text_view_for_the_answer? ⇒ Boolean
# === text_view_for_the_answer? ========================================================================= #.
-
#text_view_for_the_question? ⇒ Boolean
# === text_view_for_the_question? ========================================================================= #.
-
#the_button_ask_the_question_was_clicked ⇒ Object
(also: #do_ask_a_new_question, #do_ask_an_exam_question, #do_ask_the_exam_question, #ask_an_exam_question, #do_all_the_internal_actions_associated_with_the_button_ask_the_question_having_been_clicked)
# === the_button_ask_the_question_was_clicked ========================================================================= #.
-
#the_current_exam_question_is_now_solved ⇒ Object
# === the_current_exam_question_is_now_solved (solved tag) ========================================================================= #.
-
#top_textbuffer? ⇒ Boolean
# === top_textbuffer? ========================================================================= #.
-
#update_the_label_n_questions_were_answered(i = @label_n_questions_were_answered) ⇒ Object
# === update_the_label_n_questions_were_answered ========================================================================= #.
-
#update_three_important_widgets ⇒ Object
# === update_three_important_widgets ========================================================================= #.
-
#use_emoji? ⇒ Boolean
# === use_emoji? ========================================================================= #.
-
#use_the_internal_editor? ⇒ Boolean
# === use_the_internal_editor? ========================================================================= #.
Constructor Details
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ ExamQuestionWidget
#
initialize
#
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 129 def initialize( commandline_arguments = ARGV, run_already = true ) super(:vertical) reset set_commandline_arguments( commandline_arguments ) run if run_already end |
Class Method Details
.gtk_accel_group ⇒ Object
#
Studium::GUI::Gtk::AskExamQuestion.gtk_accel_group
#
1160 1161 1162 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1160 def self.gtk_accel_group ::Gtk::AccelGroup.new end |
.run(i = ARGV) ⇒ Object
#
Studium::GUI::Gtk::ExamQuestionWidget.run
#
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1140 def self.run( i = ARGV ) require 'gtk_paradise/app/app.rb' _ = ::Studium::GUI::Gtk::ExamQuestionWidget.new(i) r = ::Gtk.run r << _ r. r. { |, event| if ::Gtk.right_mouse_click?(event) # right mouse click event. _..popup_based_on_this_event(event) end } r.automatic_size_then_automatic_title r.top_left_then_run end |
Instance Method Details
#activate_the_third_textview ⇒ Object
#
activate_the_third_textview
#
636 637 638 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 636 def activate_the_third_textview @textarea3.do_focus_on_it end |
#add_the_status_icon ⇒ Object
#
add_the_status_icon
#
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 258 def add_the_status_icon status_icon = return_status_icon status_icon.favicon = Studium.project_base_directory?+ 'images/studies_favicon.png' status_icon.hint = 'Exam-question widget: train your brain!' = = (stock: ::Gtk::Stock::FIND) .signal_connect(:activate) { e 'Hello world!' } << = (stock: ::Gtk::Stock::QUIT) .signal_connect(:activate) { ::Gtk.main_quit } .append() .show_all status_icon.signal_connect(:popup_menu) { |icon, , time| .popup(nil, nil, , time) } end |
#all_questions_have_been_answered_in_this_topic?(this_topic = current_exam_topic? ) ⇒ Boolean
#
all_questions_have_been_answered_in_this_topic?
This method has to determine how many questions have been answered in the current exam topic.
#
620 621 622 623 624 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 620 def all_questions_have_been_answered_in_this_topic?( this_topic = current_exam_topic? ) (Studium.return_n_percent_solved_from_this_topic(this_topic).to_i == 100) end |
#answer_is? ⇒ Boolean
#
answer_is?
#
1793 1794 1795 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1793 def answer_is? @answer_is end |
#array_all_exam_questions? ⇒ Boolean
#
array_all_exam_questions?
Query-method to keep track of all exam-questions that were asked in the current run.
#
1803 1804 1805 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1803 def array_all_exam_questions? @user_configuration[:array_all_exam_questions] end |
#available_exam_topics? ⇒ Boolean
#
available_exam_topics?
#
1748 1749 1750 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1748 def available_exam_topics? @user_configuration[:available_exam_topics] end |
#border_size? ⇒ Boolean
#
border_size?
#
218 219 220 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 218 def border_size? 4 end |
#button_ask_the_exam_question? ⇒ Boolean Also known as: ,
#
button_ask_the_exam_question?
#
940 941 942 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 940 def @button_ask_the_exam_question end |
#clear_reveal_the_answer ⇒ Object
#
clear_reveal_the_answer
#
484 485 486 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 484 def clear_reveal_the_answer @text_view_for_the_answer.set_text('') end |
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
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 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 801 def connect_skeleton abort_on_exception # ======================================================================= # # Add the status icon and style it a little bit as well. # ======================================================================= # add_the_status_icon @grid.left(return_frame_containing_the_label_exam_topic) mini_hbox = gtk_hbox mini_hbox.minimal(@entry_holding_all_exam_topics, 2) mini_hbox.minimal(@combo_box_available_exam_topics, 2) mini_hbox.minimal(return_event_box_with_face_glasses, 2) mini_hbox.rpack(return_eventbox_with_an_image_to_exit_the_application, 2) @grid.right(mini_hbox) @grid.left(@button_ask_the_exam_question) # ======================================================================= # # === @text_view_for_the_question # ======================================================================= # @text_buffer_for_the_question = gtk_text_buffer @text_view_for_the_question = return_text_view_for_the_question(@text_buffer_for_the_question) @scrolled_window_containing_the_textarea1 = return_scrolled_window_for_the_text_view_for_the_question(@text_view_for_the_question) @grid.right(@scrolled_window_containing_the_textarea1) @grid.left(@button_reveal_the_answer) @scrolled_window_containing_the_textarea2 = return_scrolled_window_containing_the_text_view_for_the_answer( @text_view_for_the_answer ) @grid.right(@scrolled_window_containing_the_textarea2) hbox_with_two_icons = return_hbox_containing_two_icons_and_instructions_what_to_do_with_the_free_form_textarea @grid.full_line(hbox_with_two_icons) # ======================================================================= # # === @textarea3 # ======================================================================= # @textarea3 = return_textarea_number_three @scrolled_window_containing_the_textarea3 = return_scrolled_window_containing_the_textarea3(@textarea3) @grid.full_row(@scrolled_window_containing_the_textarea3) lower_vbox = gtk_vbox @hbox_containing_three_labels_and_three_entries = return_hbox_containing_three_labels_and_three_entries middle_hbox = gtk_hbox mini_hbox = gtk_hbox # ======================================================================= # # Add the checkbox for revealing the answer next: # ======================================================================= # mini_hbox.minimal(@checkbox_shall_we_reveal_the_answer, 2) mini_hbox.minimal(@entry_delay_to_use, 2) # ======================================================================= # # The middle-hbox contains the other hboxes. # ======================================================================= # middle_hbox.minimal(mini_hbox, 1) middle_hbox.minimal(@hbox_containing_three_labels_and_three_entries, 1) middle_hbox.minimal(@button_use_random_entry_from_the_ten_aliases, 5) middle_hbox.minimal(return_event_box_for_asking_a_random_exam_topic, 10) lower_vbox.minimal(middle_hbox, 1) small_hbox = gtk_hbox small_hbox.minimal(@button_solve_the_question, 2) small_hbox.minimal(, 2) small_hbox.minimal(return_wikipedia_entry, 2) small_hbox.minimal(gtk_hseparator) lower_vbox.minimal(small_hbox, 2) lower_vbox.minimal(@label_n_questions_were_answered, 8) draggable = draggable_up_and_down( @grid, lower_vbox ) maximal(draggable) end |
#context_menu? ⇒ Boolean
#
context_menu?
#
1469 1470 1471 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1469 def @context_menu end |
#create_skeleton ⇒ Object
#
create_skeleton (create tag)
#
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1454 def create_skeleton create_text_buffer_for_the_answer create_text_view_for_the_answer create_the_labels create_the_entries create_the_checkbox # This must come after the entries. create_the_combobox create_the_main_grid end |
#create_text_buffer_for_the_answer ⇒ Object
#
create_text_buffer_for_the_answer
#
244 245 246 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 244 def create_text_buffer_for_the_answer @text_buffer_for_the_answer = gtk_text_buffer end |
#create_text_view_for_the_answer ⇒ Object
#
create_text_view_for_the_answer
#
237 238 239 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 237 def create_text_view_for_the_answer @text_view_for_the_answer = return_text_view_for_the_answer(@text_buffer_for_the_answer) end |
#create_the_ask_the_exam_question_button ⇒ Object
#
create_the_ask_the_exam_question_button
#
904 905 906 907 908 909 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 904 def # ======================================================================= # # === @button_ask_the_exam_question # ======================================================================= # @button_ask_the_exam_question = (use_emoji?) end |
#create_the_button_use_random_entry_from_the_ten_aliases ⇒ Object
#
create_the_button_use_random_entry_from_the_ten_aliases
#
1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1685 def # ======================================================================= # # === @button_use_random_entry_from_the_ten_aliases # # This is an eventbox rather than a button, but I think this is still # fine. The unicode character "🕵" (U+1F575) is the spy character. # ======================================================================= # if use_emoji? label = gtk_label('🕵️') else label = image_avatar_default end # ======================================================================= # # === @button_use_random_entry_from_the_ten_aliases # ======================================================================= # @button_use_random_entry_from_the_ten_aliases = gtk_eventbox(label) @button_use_random_entry_from_the_ten_aliases.on_clicked { if @user_configuration[:show_ten_aliases] set_exam_topic( @user_configuration[:show_ten_aliases].return_random_entry ) update_n_questions update_n_unanswered do_ask_an_exam_question end } @button_use_random_entry_from_the_ten_aliases.set_size_request(40, 40) @button_use_random_entry_from_the_ten_aliases.lightblue @button_use_random_entry_from_the_ten_aliases.hint = 'Click on this small widget to randomly assign one of '\ 'the 10 exam-topics currently being studied as the '\ 'new main exam-topic in use.' return @button_use_random_entry_from_the_ten_aliases end |
#create_the_buttons ⇒ Object
#
create_the_buttons (buttons tag, button tag)
#
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 973 def # ======================================================================= # # === @button_solve_the_question # ======================================================================= # @button_solve_the_question = @button_solve_the_question.on_clicked { the_current_exam_question_is_now_solved do_update_this_gtk_entry_with_that_exam_topic_for_its_percentage_value( @entry_percentage, current_exam_topic? ) } end |
#create_the_checkbox ⇒ Object
#
create_the_checkbox
This has to be created after the entries are created.
#
769 770 771 772 773 774 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 769 def create_the_checkbox # ======================================================================= # # === @checkbox_shall_we_reveal_the_answer # ======================================================================= # @checkbox_shall_we_reveal_the_answer = return_checkbox_shall_we_reveal_the_answer end |
#create_the_combobox ⇒ Object
#
create_the_combobox
#
1379 1380 1381 1382 1383 1384 1385 1386 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1379 def create_the_combobox # ======================================================================= # # Next, create the combo-box that contains all exam-topics. It will be # a bit truncated, largely for display-reasons rather than any other # reason. # ======================================================================= # @combo_box_available_exam_topics = return_combo_box_available_exam_topics end |
#create_the_context_menu ⇒ Object
#
create_the_context_menu
This is the context-menu which will appear on a right-mouse click event.
#
1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1479 def # ======================================================================= # # === @context_menu # ======================================================================= # @context_menu = (self) {{ numbered_actions: { 'Ask an exam question': :ask_an_exam_question, 'Reveal the answer to the exam question': :reveal_the_answer_to_the_exam_question, 'Mark the exam question as solved': :mark_the_exam_question_as_solved, 'Pick a new font (show the widget)': :popup_pick_a_new_font, 'Debug': :debug #'Change the font in use': :do_interactively_change_the_font, } }} @context_menu.make_bold @context_menu.set_font(:hack_18) end |
#create_the_entries ⇒ Object
#
create_the_entries (entries tag, entry tag)
#
1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1513 def create_the_entries # ======================================================================= # # === The entry keeping track as to how many answers have been # given for that particular exam-topic. # ======================================================================= # @entry_containing_n_answers = gtk_entry('') @entry_containing_n_answers.center @entry_containing_n_answers.set_font(:hack_15) @entry_containing_n_answers.bblack1 # ======================================================================= # # === @entry_containing_n_questions # # Next, the entry containing the questions # ======================================================================= # @entry_containing_n_questions = gtk_entry('') @entry_containing_n_questions.center @entry_containing_n_questions.set_font(:hack_15) @entry_containing_n_questions.bblack1 # ======================================================================= # # === @entry_containing_n_unanswered_questions # ======================================================================= # @entry_containing_n_unanswered_questions = gtk_entry('') @entry_containing_n_unanswered_questions.center @entry_containing_n_unanswered_questions.set_font(:hack_15) @entry_containing_n_unanswered_questions.bblack1 # ======================================================================= # # === The entry holding all exam topics. # # This is the entry that the user can modify at his or her own # discretion. It is the most important entry, among the entries # used in this GUI application. # # This entry is positioned very close on top, on the left hand side. # The user can thus simply manipulate it by clicking on it. # # Another entry may depend on this entry, so it should come early # in this method. # ======================================================================= # @entry_holding_all_exam_topics = gtk_entry( USE_THIS_AS_THE_DEFAULT_EXAM_TOPIC ) # The next line of code was disabled as of September 2021. # @entry_holding_all_exam_topics.on_click_select_everything @entry_holding_all_exam_topics.set_font(SMALLER_FONT) @entry_holding_all_exam_topics.bblack1 @entry_holding_all_exam_topics.very_light_yellowish_background enhanced_gtk_entry = gtk_entry_completion enhanced_gtk_entry.populate_with_this_array( ::Studium.return_all_exam_topics ) @entry_holding_all_exam_topics.completion = enhanced_gtk_entry # ======================================================================= # # We need this entry to be fairly wide, hence the following method call. # ======================================================================= # @entry_holding_all_exam_topics.set_size_request(500, 40) @entry_holding_all_exam_topics.(false) @entry_holding_all_exam_topics.(false) # ======================================================================= # # Allow for scroll-events. # ======================================================================= # @entry_holding_all_exam_topics.enable_scroll_events @entry_holding_all_exam_topics.on_scroll_event {|, event| # ===================================================================== # # For now this simply sets a new, random topic. # ===================================================================== # if scroll_up?(event) set_exam_topic( available_exam_topics?.sample.downcase ) sync_entry_holding_all_exam_topics_onto_the_combo_box # Sync towards the combo-box. elsif scroll_down?(event) set_exam_topic( available_exam_topics?.sample.downcase ) sync_entry_holding_all_exam_topics_onto_the_combo_box # Sync towards the combo-box. end } # ======================================================================= # # Respond to the enter-key pressed next. # ======================================================================= # @entry_holding_all_exam_topics.on_enter_key_pressed { |, event| old_text = @entry_holding_all_exam_topics.text? new_possible_text = Studium.(old_text) unless old_text == new_possible_text @entry_holding_all_exam_topics.set_text(new_possible_text) end do_update_the_entry_n_questions .signal_emit(:clicked) sync_entry_holding_all_exam_topics_onto_the_main_combo_box } # ======================================================================= # # === @entry_delay_to_use # # Next create the delay-entry that keeps track how many seconds to wait, # before revealing the answer (IF the user has decided to make use of # that functionality). # ======================================================================= # @entry_delay_to_use = gtk_entry(DEFAULT_DELAY) @entry_delay_to_use.center @entry_delay_to_use.hint = 'Provide the delay here, as <b>n seconds</b>. '\ 'This will only work when the checkbox on the left-hand side is active.' @entry_delay_to_use.set_size_request(45, 20) @entry_delay_to_use.bblack1 # ======================================================================= # # === Percentage entry # # This is the percentage-entry, situated right next to a combo-box # entry. # ======================================================================= # @entry_percentage = return_entry_percentage end |
#create_the_labels ⇒ Object
#
create_the_labels
#
709 710 711 712 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 709 def create_the_labels @label_n_questions_were_answered = label update_the_label_n_questions_were_answered(@label_n_questions_were_answered) end |
#create_the_main_grid ⇒ Object
#
create_the_main_grid (grid tag)
#
316 317 318 319 320 321 322 323 324 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 316 def create_the_main_grid # ======================================================================= # # === @grid # ======================================================================= # @grid = default_grid @grid.spacing1 = 8 @grid.spacing2 = 8 @grid.pad8px end |
#create_the_reveal_button ⇒ Object
#
create_the_reveal_button
#
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1011 def # ======================================================================= # # === The reveal-button is created next, also known as the # "answer button". (answer tag) # The mnemonic-key is set to "A". # ======================================================================= # @button_reveal_the_answer = ( mnemonic: 'Reveal the _Answer' # This was the old emoji: ❗ ) @button_reveal_the_answer.set_size_request(78, 30) @button_reveal_the_answer.lightblue @button_reveal_the_answer.on_clicked { if all_questions_have_been_answered_in_this_topic? notify_the_user_that_all_questions_have_been_answered_in_this_topic( current_topic?, @button_reveal_the_answer ) else do_reveal_the_answer_after_timeout(answer_is?, 0) end } @button_reveal_the_answer.hint = 'Click on this button in order to '\ 'reveal the answer to the current exam question at hand.' end |
#current_exam_topic? ⇒ Boolean Also known as: main_exam_topic?, exam_topic?, current_topic?
#
current_exam_topic?
#
1210 1211 1212 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1210 def current_exam_topic? @entry_holding_all_exam_topics.text?.strip end |
#debug ⇒ Object
#
debug
#
1810 1811 1812 1813 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1810 def debug pp array_all_exam_questions? pp array_all_exam_questions?.size end |
#deselect_the_entry_containing_the_exam_topic ⇒ Object
#
deselect_the_entry_containing_the_exam_topic
#
308 309 310 311 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 308 def deselect_the_entry_containing_the_exam_topic @entry_holding_all_exam_topics.deselect text_view_containing_the_current_question?.set_focus(true) end |
#do_assign_a_new_exam_topic ⇒ Object
#
do_assign_a_new_exam_topic
#
1058 1059 1060 1061 1062 1063 1064 1065 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1058 def do_assign_a_new_exam_topic clear_reveal_the_answer this_topic = return_available_exam_topics.sample # Obtain a random exam topic here. @entry_holding_all_exam_topics.set_text(this_topic.to_s) sync_entry_holding_all_exam_topics_onto_the_combo_box do_ask_an_exam_question end |
#do_clear_the_free_form_textarea ⇒ Object
#
do_clear_the_free_form_textarea
#
491 492 493 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 491 def do_clear_the_free_form_textarea @textarea3.set_text('') end |
#do_clear_the_question_buffer ⇒ Object
#
do_clear_the_question_buffer
Clear the question-buffer via this method.
#
880 881 882 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 880 def do_clear_the_question_buffer @text_buffer_for_the_question.set_text('') end |
#do_handle_the_click_event_for_the_ask_question_button ⇒ Object
#
do_handle_the_click_event_for_the_ask_question_button (clicked tag)
This method requires the Studium.write_what_into() method.
#
950 951 952 953 954 955 956 957 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 950 def # ======================================================================= # # Determine what happens next when the ask-question button is clicked. # ======================================================================= # .on_clicked { } end |
#do_jump_into_the_entry_containing_the_current_exam_topic ⇒ Object
#
do_jump_into_the_entry_containing_the_current_exam_topic
#
329 330 331 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 329 def do_jump_into_the_entry_containing_the_current_exam_topic @entry_holding_all_exam_topics.do_focus_on_it end |
#do_open_the_current_exam_topic_file(combo_box_available_exam_topics = @combo_box_available_exam_topics) ⇒ Object
#
do_open_the_current_exam_topic_file
This method can either open the exam-file in the bluefish editor, or in the integrated ruby-gtk editor. Since as of July 2021 we will try the integrated variant. Unfortunately ruby-gtk is somehow buggy - reading a large file leads to a BadAlloc error.
#
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1768 def do_open_the_current_exam_topic_file( combo_box_available_exam_topics = @combo_box_available_exam_topics ) _ = Studium.find_corresponding_exam_topic( current_exam_topic? ) if _.empty? and combo_box_available_exam_topics _ = combo_box_available_exam_topics.active_text.to_s end _ = Studium.path_to_exam_topic?+_ if use_the_internal_editor? set_save_into_this_local_file(_) set_editor_buffer(File.read(_)) @notebook_tab.focus_on_this_tab(2) else # ===================================================================== # # Or simply use bluefish or whatever else the editor is. # ===================================================================== # esystem "#{@user_configuration[:use_this_editor]} #{_}" end end |
#do_popup_the_array_of_all_exam_questions ⇒ Object
#
do_popup_the_array_of_all_exam_questions
#
1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1818 def do_popup_the_array_of_all_exam_questions content = array_all_exam_questions?.map.with_index {|line, index| index += 1 line = line.dup line.prepend( "(#{index}) " ) line }.join("\n") text_buffer = gtk_text_buffer(content) text_view = gtk_text_view(text_buffer) scrolled_window = gtk_scrolled_window(text_view) scrolled_window.width_height(1400, 700) scrolled_window.pad8px ( entry_exam_topic?, scrolled_window ).popup end |
#do_reveal_the_answer_after_timeout(answer = answer_is?, , use_this_as_timeout = @entry_delay_to_use.text) ⇒ Object
#
do_reveal_the_answer_after_timeout (revel tag)
Note that the timeout will be in n ms (milliseconds).
#
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 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 378 def do_reveal_the_answer_after_timeout( answer = answer_is?, use_this_as_timeout = @entry_delay_to_use.text ) if use_this_as_timeout.is_a? String use_this_as_timeout = use_this_as_timeout.to_f * 1000 end if answer case answer # ===================================================================== # # === :default # ===================================================================== # when :default answer = answer_is? end answer.gsub!(/\<.+?\>/,'') #answer = ::Studium.word_wrap(answer, 78).to_s if use_this_as_timeout > 0 and @checkbox_shall_we_reveal_the_answer.is_it_active? # =================================================================== # # This clause here is only ever entered when we have a delay. We # have to check whether the main checkbox is active, because the # user may have de-selected it in-between the delay time span. # =================================================================== # GLib::Timeout.add(use_this_as_timeout) { @text_view_for_the_answer.set_text(answer) false } else @text_view_for_the_answer.set_text(answer) end end end |
#do_style_all_buttons_uniformly(i = return_all_buttons) ⇒ Object
#
do_style_all_buttons_uniformly
#
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 540 def ( i = ) # ======================================================================= # # Style all buttons uniformly next, via CSS. # ======================================================================= # i.each {|| # ===================================================================== # # Use the same CSS rule for each button. # ===================================================================== # .clear_background .css_class('bblack2') .set_size_request(75, 28) .set_name('button_hover_transition') } end |
#do_update_the_entry_n_answered(current_exam_topic = @combo_box_available_exam_topics.active_text.to_s.strip.dup, entry = @entry_containing_n_answers) ⇒ Object Also known as: update_n_answered
#
do_update_the_entry_n_answered
#
1735 1736 1737 1738 1739 1740 1741 1742 1743 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1735 def do_update_the_entry_n_answered( current_exam_topic = @combo_box_available_exam_topics.active_text.to_s.strip.dup, entry = @entry_containing_n_answers # The entry that is to be updated. ) current_exam_topic.strip! if current_exam_topic.end_with? '_' entry.set_text( return_n_answers_from_the_currently_selected_topic(current_exam_topic).to_s ) end |
#do_update_the_entry_n_questions(current_exam_topic = current_exam_topic? ) ⇒ Object Also known as: update_n_questions
#
do_update_the_entry_n_questions
#
1674 1675 1676 1677 1678 1679 1680 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1674 def do_update_the_entry_n_questions( current_exam_topic = current_exam_topic? ) @entry_containing_n_questions.set_text( return_n_questions_from_the_currently_selected_topic(current_exam_topic).to_s ) end |
#do_update_the_entry_n_unanswered_questions ⇒ Object Also known as: update_the_entry_n_unanswered_questions, update_n_unanswered
#
do_update_the_entry_n_unanswered_questions
This method depends on two entries being set correctly.
#
1725 1726 1727 1728 1729 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1725 def do_update_the_entry_n_unanswered_questions _ = @entry_containing_n_questions.text?.to_i - @entry_containing_n_answers.text?.to_i @entry_containing_n_unanswered_questions.set_text(_.to_s) end |
#do_update_this_gtk_entry_with_that_exam_topic_for_its_percentage_value(entry_percentage = entry_percentage?, , use_this_exam_topic = current_exam_topic?.to_s) ⇒ Object Also known as: update_the_percentage_entry
#
do_update_this_gtk_entry_with_that_exam_topic_for_its_percentage_value
#
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1080 def do_update_this_gtk_entry_with_that_exam_topic_for_its_percentage_value( entry_percentage = entry_percentage?, use_this_exam_topic = current_exam_topic?.to_s ) percentage_value = Studium.n_percent_questions_answered_of_this_topic?( use_this_exam_topic.downcase ) if percentage_value == false percentage_value = -1 end percentage_value = percentage_value.to_s.to_f.round(1) percentage_value = percentage_value.to_s.dup percentage_value << '%' unless percentage_value.end_with? '%' entry_percentage.set_text(percentage_value) # And sync it onto the proper entry. end |
#do_updated_the_entries_n_answered_and_n_unanswered ⇒ Object
#
do_updated_the_entries_n_answered_and_n_unanswered
#
1755 1756 1757 1758 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1755 def do_updated_the_entries_n_answered_and_n_unanswered do_update_the_entry_n_unanswered_questions update_n_unanswered end |
#enable_all_key_combinations ⇒ Object
#
enable_all_key_combinations
#
1500 1501 1502 1503 1504 1505 1506 1507 1508 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1500 def enable_all_key_combinations # ======================================================================= # # === @accel_group # ======================================================================= # @accel_group = create_and_add_gtk_accel_group enable_alt_w_key_combination enable_alt_y_key_combination enable_alt_1_key_combination end |
#enable_alt_1_key_combination ⇒ Object
#
enable_alt_1_key_combination
#
1127 1128 1129 1130 1131 1132 1133 1134 1135 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1127 def enable_alt_1_key_combination # ======================================================================= # # Add alt+1 key combination: # ======================================================================= # use_this_key = Gdk::Keyval::KEY_1 @accel_group.connect(use_this_key, :mod1_mask, :visible) { # alt+1 entry_ask_questions?.set_focus(true) } end |
#enable_alt_w_key_combination ⇒ Object
#
enable_alt_w_key_combination
This method will specifically enable the “alt+w” shortcut.
#
1114 1115 1116 1117 1118 1119 1120 1121 1122 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1114 def enable_alt_w_key_combination # ======================================================================= # # Add alt+w key combination, to open the current exam topic file: # ======================================================================= # use_this_key = Gdk::Keyval::KEY_W @accel_group.connect(use_this_key, :mod1_mask, :visible) { # alt+w do_open_the_current_exam_topic_file } end |
#enable_alt_y_key_combination ⇒ Object
#
enable_alt_y_key_combination
#
1099 1100 1101 1102 1103 1104 1105 1106 1107 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1099 def enable_alt_y_key_combination # ======================================================================= # # Add alt+y key combination, to assign a new exam topic: # ======================================================================= # use_this_key = Gdk::Keyval::KEY_Y @accel_group.connect(use_this_key, :mod1_mask, :visible) { # alt+y do_assign_a_new_exam_topic } end |
#entry_holding_all_exam_topics? ⇒ Boolean Also known as: entry_ask_questions_from_this_topic?, entry_ask_questions?, entry_exam_topic?
#
entry_holding_all_exam_topics?
#
1853 1854 1855 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1853 def entry_holding_all_exam_topics? @entry_holding_all_exam_topics end |
#entry_percentage? ⇒ Boolean
#
entry_percentage?
#
724 725 726 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 724 def entry_percentage? @entry_percentage end |
#handle_CSS ⇒ Object
#
handle_CSS
#
444 445 446 447 448 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 444 def handle_CSS use_gtk_paradise_project_css_file append_project_css_file apply_the_CSS_rules end |
#handle_the_combo_box_available_exam_topics_on_changed_event(combo_box = @combo_box_available_exam_topics) ⇒ Object
#
handle_the_combo_box_available_exam_topics_on_changed_event
#
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1350 def handle_the_combo_box_available_exam_topics_on_changed_event( combo_box = @combo_box_available_exam_topics ) # ======================================================================= # # The event where the combo-box is changed is handled next. # ======================================================================= # combo_box.on_changed { entry_ask_questions_from_this_topic?.set_text( combo_box.active_text.to_s.downcase.tr(' ','_') ) # ===================================================================== # # Get a reference to the current exam topic. # ===================================================================== # current_exam_topic = combo_box.active_text.to_s.strip.dup current_exam_topic.strip! if current_exam_topic.end_with? '_' do_update_this_gtk_entry_with_that_exam_topic_for_its_percentage_value( @entry_percentage, current_exam_topic ) @entry_containing_n_questions.set_text( return_n_questions_from_the_currently_selected_topic(current_exam_topic).to_s ) do_update_the_entry_n_answered(current_exam_topic) do_ask_a_new_question } end |
#main_combo_box? ⇒ Boolean
#
main_combo_box?
#
779 780 781 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 779 def main_combo_box? @combo_box_available_exam_topics end |
#main_font? ⇒ Boolean
#
main_font?
#
717 718 719 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 717 def main_font? USE_THIS_FONT end |
#padding? ⇒ Boolean
#
padding?
#
211 212 213 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 211 def padding? 8 end |
#parse_for_URL(i = text_view_for_the_answer?.buffer.text) ⇒ Object
#
parse_for_URL
This method can be used to return all URLs in a given text.
#
749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 749 def parse_for_URL( i = text_view_for_the_answer?.buffer.text ) array = ::Studium.return_all_URLs_from(i) if array.size > 0 first_entry = array.first # ===================================================================== # # We first have to assign it to the GUI part. Note that the "browser" # is part of the control-panel since the rewrite in January 2021. # ===================================================================== # control_panel?.browser?.assign_this_text(first_entry) ::Studium.open_this_remote_url(first_entry) end end |
#popup_pick_a_new_font ⇒ Object
#
popup_pick_a_new_font
#
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1167 def popup_pick_a_new_font _ = gtk_hbox _.minimal(text(' → ')) = ('Choose font here') .set_size_request(1200, 960) .css_class('bblack2') .set_size_request(500, 300) .disallow_resizing _.minimal() .on_click { result = gtk_font_chooser_dialog set_use_this_font(::Gtk.main_file?) result.destroy } # ======================================================================= # # Next create the popup for the font-choosing. # ======================================================================= # = ( text_view_for_the_question?, '', _ ) # popup_widget.no_arrow # ← This will only work on gtk4, I think. .popup end |
#reset ⇒ Object
#
reset (reset tag)
#
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 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 144 def reset reset_the_internal_variables Studium.set_runmode :gui # Make it known that we use the gui-runmode in this case. # ======================================================================= # # === @namespace # ======================================================================= # @namespace = NAMESPACE # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] # ======================================================================= # # === @title # ======================================================================= # title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT) use_gtk_paradise_project_css_file infer_the_size_automatically # ======================================================================= # # === @question_is # ======================================================================= # @question_is = ''.dup # ======================================================================= # # === @answer_is # ======================================================================= # @answer_is = ''.dup # ======================================================================= # # === @user_configuration # ======================================================================= # @user_configuration = {} # ======================================================================= # # === :available_exam_topics # # Keep a reference to the available exam topics. # ======================================================================= # @user_configuration[:available_exam_topics] = return_available_exam_topics.sort # ======================================================================= # # === :use_this_editor # # This may be :bluefish or :internal usually. # ======================================================================= # @user_configuration[:use_this_editor] = :bluefish # ======================================================================= # # === :show_ten_aliases # ======================================================================= # @user_configuration[:show_ten_aliases] = nil # ======================================================================= # # === :array_all_exam_questions # ======================================================================= # @user_configuration[:array_all_exam_questions] = [] # ======================================================================= # # The next if-clause must come after @user_configuration has been # defined. # ======================================================================= # if Object.const_defined?(:Roebe) begin require 'roebe/gui/gtk3/show_ten_aliases/show_ten_aliases.rb' @user_configuration[:show_ten_aliases] = ::Roebe::GUI::Gtk::ShowTenAliases.new rescue LoadError; end end handle_CSS enable_all_key_combinations upon_delete_event_quit_the_application end |
#return_available_exam_topics ⇒ Object
#
return_available_exam_topics
#
301 302 303 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 301 def return_available_exam_topics ::Studium.return_available_exam_topics end |
#return_button_ask_the_exam_question(use_emoji = false) ⇒ Object
#
return_button_ask_the_exam_question (ask tag)
#
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 914 def ( use_emoji = false ) # ======================================================================= # # Add the ask-exam-question button next. Note that its click-event # is handled separately via a method call. # # The question mark emoji is Unicode Character "❓" (U+2753). # ======================================================================= # if use_emoji? = (mnemonic: 'Ask a _Question ❓') else = (mnemonic: 'Ask a _Question') end .set_size_request(75, 28) .clear_background .pad2px .hint = 'Click on this button to ask an exam-question. '\ '(Or, use alt+q as shortcut)' return end |
#return_button_open_exam_topic_file ⇒ Object
#
return_button_open_exam_topic_file
#
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 422 def # ======================================================================= # # This button will have the symbol for :open_file, an emoji - if # emojis are used. Otherwise an image will be used instead. # ======================================================================= # if use_emoji? _ = (return_emoji(:open_box)) else _ = (image_open_file) end _.no_relief _.lightblue _.hint = 'Click this button to open the current exam-topic file.' _.on_clicked { do_open_the_current_exam_topic_file } return _ end |
#return_button_solve_the_question ⇒ Object
#
return_button_solve_the_question
.set_size_request() is not necessary as we use a separate method that controls the size of the widget at hand.
#
287 288 289 290 291 292 293 294 295 296 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 287 def = ( mnemonic: '😁️ Mark the question as _solved ✓' ) .lightblue .hint = 'Use this button to <b>mark the '\ 'question as solved</b> (that is, correctly answered).' # button_solve_the_question.set_size_request(78, 30) return end |
#return_checkbox_shall_we_reveal_the_answer ⇒ Object
#
return_checkbox_shall_we_reveal_the_answer
#
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 453 def return_checkbox_shall_we_reveal_the_answer _ = gtk_checkbox( "Automatically reveal the \nanswer after a delay" ) _.set_font(SMALLEST_FONT) # ======================================================================= # # Next determine whether the checkbox is active, on startup, or whether # it is not active when the GUI starts up. # ======================================================================= # _.mark_as_unchecked _.hint = 'Deselect this if you do not want to automatically reveal '\ 'the answer. In that case you have to manually click on '\ 'the Answer button.' _.on_toggled { || if _.active? @entry_delay_to_use.grey_in elsif not _.active? @entry_delay_to_use.grey_out end } if _.is_it_active? @entry_delay_to_use.grey_in else @entry_delay_to_use.grey_out end return _ end |
#return_combo_box_available_exam_topics ⇒ Object
#
return_combo_box_available_exam_topics
#
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1391 def return_combo_box_available_exam_topics use_this_sorted_array = return_available_exam_topics.map {|entry| if entry.size > 24 # Truncate it a bit in this case. entry = entry[0 .. 24] end entry }.sort _ = combo_box( use_this_sorted_array ) _.first_entry_is_active _.bblack1 _.set_size_request(100, 28) # ======================================================================= # # Wrap-width determines how many entries per row are shown when the # combo-box is expanded. We stick to the default of 1 here. # ======================================================================= # _.set_wrap_width(1) handle_the_combo_box_available_exam_topics_on_changed_event(_) return _ end |
#return_entry_percentage ⇒ Object
#
return_entry_percentage
#
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 993 def return_entry_percentage _ = entry('') _.hint = "This denotes how many questions have already\n"\ "been answered successfully, <b>in percent</b>.\n"\ "Note that this requires a specific exam topic to "\ "have been set, so no percentage value may be "\ "shown initially.\nSimply assign to an exam topic "\ "and it should work fine." _.do_center _.disable_user_input _.set_name('BG_bisque') _.bblack1 return _ end |
#return_event_box_for_asking_a_random_exam_topic ⇒ Object
#
return_event_box_for_asking_a_random_exam_topic
#
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1039 def return_event_box_for_asking_a_random_exam_topic event_box_for_image_view_refresh_symbolic_symbolic = gtk_event_box( image_view_refresh_symbolic_symbolic ) event_box_for_image_view_refresh_symbolic_symbolic.hint = 'Click on this icon to <b>set a random exam topic</b>, '\ 'and then ask an exam question from this topic.' # ======================================================================= # # Let the event-box respond to an on-click event. # ======================================================================= # event_box_for_image_view_refresh_symbolic_symbolic.on_clicked { do_assign_a_new_exam_topic } return event_box_for_image_view_refresh_symbolic_symbolic end |
#return_event_box_with_face_glasses ⇒ Object
#
return_event_box_with_face_glasses
#
1840 1841 1842 1843 1844 1845 1846 1847 1848 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1840 def return_event_box_with_face_glasses event_box = gtk_event_box image = gtk_icon('face-glasses') event_box.add(image) event_box.on_clicked { do_popup_the_array_of_all_exam_questions } return event_box end |
#return_eventbox_with_an_image_to_exit_the_application ⇒ Object
#
return_eventbox_with_an_image_to_exit_the_application
#
786 787 788 789 790 791 792 793 794 795 796 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 786 def return_eventbox_with_an_image_to_exit_the_application application_exit_image = return_this_image_based_on_the_default_icon_theme( 'system-log-out-symbolic.symbolic' ) # Or: :application_exit _ = gtk_eventbox(application_exit_image) _.hint = 'Click on this image to exit the program.' _.on_clicked { exit_application } return _ end |
#return_frame_containing_the_label_exam_topic ⇒ Object
#
return_frame_containing_the_label_exam_topic
#
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 511 def return_frame_containing_the_label_exam_topic # ======================================================================= # # Create the exam-topic label next, showing a watermelon emoji on the # left-hand side. The watermelon emoji used to be 🍉️; but it was # replaced with the electric light bulb emoji in January 2021, which # is 💡️. Unfortunately this does not work on every system, so it # was decided to replace this with an image that is determined by # the icon theme at hand. # ======================================================================= # label_exam_topic = bold_label(' Exam topic') # label_exam_topic.css_class('small_text_shadow') label_emoji = right_arrow_emoji label_emoji.set_size_request(30, 30) label_emoji.align_right tiny_hbox = gtk_hbox tiny_hbox.minimal(label_exam_topic) tiny_hbox.maximal(label_emoji) tiny_hbox.minimal(text(' ')) # Just a "spacer". frame_containing_the_label_exam_topic = gtk_frame(tiny_hbox) frame_containing_the_label_exam_topic.modify_background(:normal, :oldlace) frame_containing_the_label_exam_topic.css_class('bblack1') label_exam_topic.hint = 'Denote <b>the current exam </b> topic '\ 'to the <b>right</b> of this text.' return frame_containing_the_label_exam_topic end |
#return_hbox_containing_three_labels_and_three_entries ⇒ Object
#
return_hbox_containing_three_labels_and_three_entries
This should only be invoked after the entries were created.
#
1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1630 def return_hbox_containing_three_labels_and_three_entries _ = gtk_hbox # ======================================================================= # # === n questions # ======================================================================= # vbox1 = gtk_vbox label_n_questions = text('n questions').set_font(:hack_15) label_n_questions.center_and_make_bold vbox1.minimal(label_n_questions, 2) vbox1.minimal(@entry_containing_n_questions, 2) _.minimal(vbox1, 2) # ======================================================================= # # === n unanswered # ======================================================================= # vbox2 = gtk_vbox label_n_unanswered = text('n unanswered').set_font(:hack_15) label_n_unanswered.make_bold vbox2.minimal(label_n_unanswered, 2) vbox2.minimal(@entry_containing_n_unanswered_questions, 2) _.minimal(vbox2, 2) # ======================================================================= # # === n answered # ======================================================================= # vbox3 = gtk_vbox label_n_answered = text('n answered').set_font(:hack_15) label_n_answered.royalblue label_n_answered.center_and_make_bold vbox3.minimal(label_n_answered, 2) vbox3.minimal(@entry_containing_n_answers, 2) _.minimal(vbox3, 2) # ======================================================================= # # Last but not least, add the entry showing the percentage values. # ======================================================================= # _.minimal(@entry_percentage, 2) return _ end |
#return_hbox_containing_two_icons_and_instructions_what_to_do_with_the_free_form_textarea ⇒ Object
#
return_hbox_containing_two_icons_and_instructions_what_to_do_with_the_free_form_textarea
#
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 588 def return_hbox_containing_two_icons_and_instructions_what_to_do_with_the_free_form_textarea hbox_with_two_icons = gtk_hbox first_eventbox = gtk_event_box(image_accessories_text_editor) first_eventbox.on_clicked { do_clear_the_free_form_textarea } hbox_with_two_icons.minimal(first_eventbox, 2) text = gtk_label( 'Below this text you can input your assumed '\ 'answer to the exam question at hand.' ) text.left_align text.make_selectable text.set_font(:hack_18) hbox_with_two_icons.maximal(text, 4) event_box_for_image_accessories_text_editor = gtk_event_box(image_accessories_text_editor) event_box_for_image_accessories_text_editor.hint = 'Click here to '\ 'empty the free-form textarea below this icon.' event_box_for_image_accessories_text_editor.on_clicked { do_clear_the_free_form_textarea } hbox_with_two_icons.minimal(event_box_for_image_accessories_text_editor, 2) return hbox_with_two_icons end |
#return_n_answers_from_the_currently_selected_topic(i = exam_topic? ) ⇒ Object
#
return_n_answers_from_the_currently_selected_topic
#
693 694 695 696 697 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 693 def return_n_answers_from_the_currently_selected_topic( i = exam_topic? ) ::Studium.n_answers_available_in_this_topic(i) end |
#return_n_questions_from_the_currently_selected_topic(i = exam_topic? ) ⇒ Object
#
return_n_questions_from_the_currently_selected_topic
#
888 889 890 891 892 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 888 def return_n_questions_from_the_currently_selected_topic( i = exam_topic? ) ::Studium.n_questions_available_in_this_topic(i) end |
#return_scrolled_window_containing_the_text_view_for_the_answer(text_view_for_the_answer) ⇒ Object
#
return_scrolled_window_containing_the_text_view_for_the_answer
#
731 732 733 734 735 736 737 738 739 740 741 742 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 731 def return_scrolled_window_containing_the_text_view_for_the_answer( text_view_for_the_answer ) @scrolled_window_containing_the_textarea2 = gtk_scrolled_window( text_view_for_the_answer ) { :only_up_and_bottom } @scrolled_window_containing_the_textarea2.set_name('textview2') # Contains the answer. @scrolled_window_containing_the_textarea2.set_size_request(1000, 150) @scrolled_window_containing_the_textarea2.min_content_width = 100 @scrolled_window_containing_the_textarea2.min_content_height = 200 @scrolled_window_containing_the_textarea2. end |
#return_scrolled_window_containing_the_textarea3(textarea = @textarea3) ⇒ Object
#
return_scrolled_window_containing_the_textarea3
#
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 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 643 def return_scrolled_window_containing_the_textarea3(textarea = @textarea3) # ======================================================================= # # === scrolled_window_containing_the_textarea3 # # This is the scrolled-window containing the free-form text the user # can type. # ======================================================================= # scrolled_window_containing_the_textarea3 = gtk_scrolled_window(textarea) { :only_top_to_bottom } scrolled_window_containing_the_textarea3.set_name('textview3') scrolled_window_containing_the_textarea3.css_class('pad4px') scrolled_window_containing_the_textarea3.set_size_request( 1000, 180 ) scrolled_window_containing_the_textarea3. scrolled_window_containing_the_textarea3.min_content_width = 100 scrolled_window_containing_the_textarea3.min_content_height = 150 # ======================================================================= # # Next, enable select-all-on-click events: # ======================================================================= # scrolled_window_containing_the_textarea3.signal_connect(:event) {|, event| case event.event_type.name.to_s when 'GDK_BUTTON_PRESS' # e 'The left mouse-button was clicked! Selecting everything next.' # @text_view_for_simply_typing_anything.signal_emit(:select_all, event) textarea.select_everything(event) end } return scrolled_window_containing_the_textarea3 end |
#return_scrolled_window_for_the_text_view_for_the_question(text_view_for_the_question) ⇒ Object
#
return_scrolled_window_for_the_text_view_for_the_question
#
363 364 365 366 367 368 369 370 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 363 def return_scrolled_window_for_the_text_view_for_the_question(text_view_for_the_question) scrolled_window_containing_the_textarea1 = gtk_scrolled_window( text_view_for_the_question ) { :only_up_and_bottom } scrolled_window_containing_the_textarea1.set_name('textview1') # Contains the question. scrolled_window_containing_the_textarea1.set_size_request(1000, 150) return scrolled_window_containing_the_textarea1 end |
#return_string_how_many_exam_questions_are_already_answered ⇒ Object
#
return_string_how_many_exam_questions_are_already_answered
#
702 703 704 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 702 def return_string_how_many_exam_questions_are_already_answered ::Studium.return_string_how_many_exam_questions_are_already_answered end |
#return_text_view_for_the_answer(text_buffer_for_the_answer) ⇒ Object
#
return_text_view_for_the_answer
#
498 499 500 501 502 503 504 505 506 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 498 def return_text_view_for_the_answer( text_buffer_for_the_answer ) _ = gtk_text_view(text_buffer_for_the_answer) _.set_left_margin(USE_THIS_MARGIN) _.set_right_margin(USE_THIS_MARGIN) _.word_wrap return _ end |
#return_text_view_for_the_question(text_buffer_for_the_question) ⇒ Object
#
return_text_view_for_the_question
#
343 344 345 346 347 348 349 350 351 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 343 def return_text_view_for_the_question( text_buffer_for_the_question ) text_view_for_the_question = gtk_text_view(text_buffer_for_the_question) text_view_for_the_question.set_left_margin(USE_THIS_MARGIN) text_view_for_the_question.set_right_margin(USE_THIS_MARGIN) text_view_for_the_question.word_wrap return text_view_for_the_question end |
#return_textarea_number_three ⇒ Object
#
return_textarea_number_three
#
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 560 def return_textarea_number_three # ======================================================================= # # Next comes the textarea for "free typing", where the user can # simply write whatever he wants to. # ======================================================================= # textarea = gtk_textarea textarea.set_left_margin(USE_THIS_MARGIN) textarea.set_right_margin(USE_THIS_MARGIN) # ======================================================================= # # The next code sets up a default placeholder text. Upon a focus-in-event # that default placeholder text is removed. # ======================================================================= # textarea.buffer.set_placeholder_text( DEFAULT_PLACEHOLDER_TEXT ) textarea.buffer.sync_placeholder_text textarea.focus_in_event { if textarea.buffer.text? == DEFAULT_PLACEHOLDER_TEXT textarea.buffer.clear # Remove that placeholder text in this case. end } textarea.word_wrap return textarea end |
#return_wikipedia_entry ⇒ Object
#
return_wikipedia_entry
This method will return the widget that, upon user-mouse-button-click event, will open the corresponding wikipedia entry. This defaults to the german wikipedia entry right now; if others want to change the default then this could be changed easily.
#
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1422 def return_wikipedia_entry begin require 'roebe/classes/wikipedia.rb' rescue LoadError; end hbox = gtk_hbox wikipedia_entry = gtk_entry wikipedia_entry.clear_background wikipedia_entry.bblack2 wikipedia_entry.center wikipedia_entry.css_class('pad5px') wikipedia_entry.lightgreen_background wikipedia_entry.width_height(720, 32) wikipedia_entry.hint = 'Click the "enter" key to open the assorted keyword in the '\ 'german-wikipedia. Simply replace <b>de</b> with <b>en</b> in '\ 'the URL to have the english wikipedia.' wikipedia_entry.on_enter { if Object.const_defined?(:Roebe) and Roebe.const_defined?(:Wikipedia) Roebe::Wikipedia.new(wikipedia_entry.text?) else e 'You need to install the roebe gem for this functionality.' end } hbox.minimal(wikipedia_entry, 1) return hbox end |
#reveal_the_answer_to_the_exam_question ⇒ Object
#
reveal_the_answer_to_the_exam_question
#
897 898 899 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 897 def reveal_the_answer_to_the_exam_question do_reveal_the_answer_after_timeout(:default, 0) end |
#rinstall2 ⇒ Object Also known as: r2
#
rinstall2
#
676 677 678 679 680 681 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 676 def rinstall2 Roebe.rinstall2( use_this_directory: Studium.ruby_src_dir_at_home?+ 'studium/' ) end |
#run ⇒ Object
#
run (run tag)
#
1885 1886 1887 1888 1889 1890 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1885 def run super() deselect_the_entry_containing_the_exam_topic end |
#set_exam_topic(i) ⇒ Object
#
set_exam_topic
#
414 415 416 417 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 414 def set_exam_topic(i) i = i.to_s.downcase @entry_holding_all_exam_topics.set_text(i) end |
#show_ten_aliases? ⇒ Boolean
#
show_ten_aliases?
#
356 357 358 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 356 def show_ten_aliases? @user_configuration[:show_ten_aliases] end |
#sync_entry_holding_all_exam_topics_onto_the_combo_box(value = @entry_holding_all_exam_topics.text?. downcase.delete(' ').delete('_')) ⇒ Object Also known as: sync_entry_holding_all_exam_topics_onto_the_main_combo_box
#
sync_entry_holding_all_exam_topics_onto_the_combo_box
An alternative to the functionality in this method may be this:
Studium.find_corresponding_exam_topic "Festkörper Chemie und Geochemie" # => "geochemistry"
#
1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1867 def sync_entry_holding_all_exam_topics_onto_the_combo_box( value = @entry_holding_all_exam_topics.text?. downcase.delete(' ').delete('_') ) array = available_exam_topics?.map {|entry| entry.delete(' ').downcase } index = array.find_index {|entry| entry.include?(value) } if index @combo_box_available_exam_topics.set_active(index) else e 'The index was not found. Input was '+steelblue(value)+'.' end end |
#text_view_containing_the_current_question? ⇒ Boolean
#
text_view_containing_the_current_question?
#
251 252 253 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 251 def text_view_containing_the_current_question? @text_view_for_the_question end |
#text_view_for_the_answer? ⇒ Boolean
#
text_view_for_the_answer?
#
336 337 338 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 336 def text_view_for_the_answer? @text_view_for_the_answer end |
#text_view_for_the_question? ⇒ Boolean
#
text_view_for_the_question?
#
1196 1197 1198 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1196 def text_view_for_the_question? @text_view_for_the_question end |
#the_button_ask_the_question_was_clicked ⇒ Object Also known as: do_ask_a_new_question, do_ask_an_exam_question, do_ask_the_exam_question, ask_an_exam_question,
#
the_button_ask_the_question_was_clicked
#
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1219 def # ======================================================================= # # (1) First, clear the old question-buffer, just in case. # ======================================================================= # do_clear_the_question_buffer # ======================================================================= # # (2) Query the exam-topic that is part of the combo box # ======================================================================= # _ = @combo_box_available_exam_topics.text?.tr(' ','_').downcase if _.empty? = bold_label( 'You have to provide an exam-topic - see the text above.' ) ( , ).popup end # ======================================================================= # # (3) Check whether there is no exam-topic selected. We have to be # careful here, as an infinite loop may result. # ======================================================================= # unless entry_ask_questions_from_this_topic?.empty? # This clause is entered when the user has a gtk-entry point. _ = entry_ask_questions_from_this_topic?.text.to_s use_this_index = ::Studium.find_corresponding_exam_title(_) use_this_topic = available_exam_topics?.index(use_this_index) # ===================================================================== # # Next be careful - we don't want an infinite loop: # ===================================================================== # if use_this_topic #@combo_box_available_exam_topics.set_active(use_this_topic) #entry_ask_questions_from_this_topic?.set_text(_) # Need to sync it back again. do_updated_the_entries_n_answered_and_n_unanswered end end if @entry_percentage.text.to_f == 100.0 # ===================================================================== # # Handle the case where the exam-topic at hand has been answered # completely. # ===================================================================== # = gtk_bold_label( "All questions have been answered for the topic "\ "#{exam_topic?}.\n\n Please choose another exam topic.\n" ) ( , @button_ask_the_exam_question ).popup else # ===================================================================== # # Check whether the exam-topic is registered: # ===================================================================== # if ::Studium.is_this_exam_topic_available?(_) @question_answer = Studium.ask_question(_) { :do_not_run_yet } @question_answer.initial_steps line = @question_answer.line?.to_s.tr("\n", ' ').rstrip array_all_exam_questions? << line # =================================================================== # # Store it as well. # =================================================================== # into = ::Studium.file_last_question_asked? Studium.write_what_into(line, into) index = @question_answer.split_position? question = line[0 .. index] question.tr!("\n", ' ') question.rstrip! if line @answer_is = line[(index+1) .. -1].strip.dup @answer_is = ::Gtk.replace_all_URL_entries_in_this_string(@answer_is) @answer_is.lstrip! if @answer_is.start_with? 'A: ' @answer_is.sub!(/A: /,'') end # ================================================================= # # Replace all "(2) foo" entries with "(2) foo\n" entries. # ================================================================= # require 'studium/toplevel_methods/misc.rb' @answer_is = ::Studium.add_newlines_to_numbered_exam_question(@answer_is) end # =================================================================== # # Remove <one> and similar tags. # =================================================================== # question.gsub!(/\<.+?\>/,'') # @question = ::Studium.word_wrap(question, WORD_WRAP_AT_N_CHARACTERS).to_s @question = question.to_s.dup if @question.start_with?('- ') @question[0,2] = '' end # =================================================================== # # Replace all URL entries with <a href> entries next: # =================================================================== # @question = ::Gtk.replace_all_URL_entries_in_this_string(@question) @text_buffer_for_the_question.set_text(@question) @text_view_for_the_answer.set_text('') # ← This is needed to clear old entries. if @checkbox_shall_we_reveal_the_answer.active? do_reveal_the_answer_after_timeout(answer_is?) end # =================================================================== # # Reveal the exam-file onto the gtk-based editor as well. # Unfortunately this has a bug, in February 2021 - x11 # crashes. I may have to re-evaluate this at a later time # to determine WHY it crashes... # =================================================================== # # dataset = File.read( # ::Studium.directory_containing_the_exam_topics?+ # ::Studium.find_corresponding_exam_topic( # current_exam_topic? # ) # ) # @gtk_editor.update_the_main_buffer(dataset) else # else we can notify the user that this exam-topic is not registered. popover = return_popover( ' <b>⚠️</b> The exam topic `<b>'+ entry_ask_questions_from_this_topic?.text.to_s+ '</b>` could <b>not</b> be found. <b>⚠️</b>', ) popover.show_all popover.popup # Display it at once. end end end |
#the_current_exam_question_is_now_solved ⇒ Object
#
the_current_exam_question_is_now_solved (solved tag)
#
225 226 227 228 229 230 231 232 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 225 def the_current_exam_question_is_now_solved _ = Studium::Exams::Solved.new { :do_not_run_yet } _.set_commandline _.run if is_on_roebe? and Object.const_defined?(:Roebe) rinstall2 end end |
#top_textbuffer? ⇒ Boolean
#
top_textbuffer?
#
1203 1204 1205 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1203 def top_textbuffer? @text_view_for_the_question.buffer end |
#update_the_label_n_questions_were_answered(i = @label_n_questions_were_answered) ⇒ Object
#
update_the_label_n_questions_were_answered
#
962 963 964 965 966 967 968 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 962 def update_the_label_n_questions_were_answered( i = @label_n_questions_were_answered ) i.set_text( return_string_how_many_exam_questions_are_already_answered ) end |
#update_three_important_widgets ⇒ Object
#
update_three_important_widgets
#
1070 1071 1072 1073 1074 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 1070 def update_the_label_n_questions_were_answered update_the_entry_n_unanswered_questions update_the_percentage_entry end |
#use_emoji? ⇒ Boolean
#
use_emoji?
#
629 630 631 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 629 def use_emoji? @prefer_emoji_or_images == :emoji end |
#use_the_internal_editor? ⇒ Boolean
#
use_the_internal_editor?
#
686 687 688 |
# File 'lib/studium/gui/gtk3/exam_question_widget/exam_question_widget.rb', line 686 def use_the_internal_editor? @user_configuration[:use_this_editor] == :internal end |