studium 0.18.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (821) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +3310 -0
  3. data/bin/all_passed_exams +14 -0
  4. data/bin/check_description_of_these_lectures +7 -0
  5. data/bin/curriculum_module_displayer +7 -0
  6. data/bin/cycle +7 -0
  7. data/bin/d10 +7 -0
  8. data/bin/d100 +7 -0
  9. data/bin/d15 +7 -0
  10. data/bin/d150 +7 -0
  11. data/bin/d20 +7 -0
  12. data/bin/d25 +7 -0
  13. data/bin/d3 +7 -0
  14. data/bin/d30 +7 -0
  15. data/bin/d5 +7 -0
  16. data/bin/determine_curricula +7 -0
  17. data/bin/display_lecture_url +7 -0
  18. data/bin/exam_registration_at +7 -0
  19. data/bin/exam_statistics +7 -0
  20. data/bin/exams_per_month +9 -0
  21. data/bin/finished_exams_at_this_university +7 -0
  22. data/bin/flashcards +7 -0
  23. data/bin/from_curriculum_id_to_university +9 -0
  24. data/bin/location_to_this_exam_topic.rb +7 -0
  25. data/bin/mandatory_continuous_assessment +7 -0
  26. data/bin/mandatory_upcoming_courses +10 -0
  27. data/bin/n_ECTS +7 -0
  28. data/bin/n_exam_questions_already_answered +15 -0
  29. data/bin/names_of_all_solved_exams +7 -0
  30. data/bin/not_completed_exams +7 -0
  31. data/bin/nquestions +7 -0
  32. data/bin/nsolved +7 -0
  33. data/bin/open_last_exam_question_asked_file +7 -0
  34. data/bin/passed_exams +7 -0
  35. data/bin/passed_pr/303/274fungsimmanente_courses +7 -0
  36. data/bin/passed_this_exam_on +10 -0
  37. data/bin/pdf_for +7 -0
  38. data/bin/question_answer +7 -0
  39. data/bin/random_exam_topic +7 -0
  40. data/bin/registered_for_this_exam +15 -0
  41. data/bin/report_solved_topics +7 -0
  42. data/bin/return_n_ects_from_this_file +7 -0
  43. data/bin/return_n_questions_solved_in_total +7 -0
  44. data/bin/rti_conflict +7 -0
  45. data/bin/search_for_n_ects +7 -0
  46. data/bin/show_lectures_on_the_commandline +7 -0
  47. data/bin/show_passed_exams_having_this_grade +7 -0
  48. data/bin/show_themes +7 -0
  49. data/bin/solved +9 -0
  50. data/bin/solved_ects +7 -0
  51. data/bin/studienkennzahl +7 -0
  52. data/bin/studium +7 -0
  53. data/bin/studium_actions +7 -0
  54. data/bin/studium_skeleton +7 -0
  55. data/bin/ufind +7 -0
  56. data/bin/upcoming_exams +7 -0
  57. data/bin/week_parser +7 -0
  58. data/doc/ECTS_CONSIDERATIONS/ECTS_CONSIDERATIONS.md +85 -0
  59. data/doc/HOW_TO_DETERMINE_WHICH_PART_IS_THE_QUESTION_AND_WHICH_PART_IS_THE_ANSWER/HOW_TO_DETERMINE_WHICH_PART_IS_THE_QUESTION_AND_WHICH_PART_IS_THE_ANSWER.md +44 -0
  60. data/doc/README.gen +3263 -0
  61. data/doc/SQL_database_specification/SQL_database_specification.md +46 -0
  62. data/doc/deprecated_components/deprecated_components.md +46 -0
  63. data/doc/documentation_for_the_file_lecture_information/documentation_for_the_file_lecture_information.md +311 -0
  64. data/doc/elegant_colours/elegant_colours.md +21 -0
  65. data/doc/statistics/yearly_statistics.md +8 -0
  66. data/doc/todo/todo_for_the_graphical_parts_of_the_studium_gem_including_www_related_aspects.md +92 -0
  67. data/doc/todo/todo_for_the_studium_gem.md +55 -0
  68. data/img/STUDIES.png +0 -0
  69. data/lib/studium/actions/actions.rb +134 -0
  70. data/lib/studium/autoinclude.rb +7 -0
  71. data/lib/studium/base/base.rb +3554 -0
  72. data/lib/studium/base/commandline_arguments_module/commandline_arguments_module.rb +115 -0
  73. data/lib/studium/base/html_colours_module.rb +632 -0
  74. data/lib/studium/base/runmode_module/runmode_module.rb +103 -0
  75. data/lib/studium/c/README.md +2 -0
  76. data/lib/studium/c/a.out +0 -0
  77. data/lib/studium/c/obtain_random_entry.c +11 -0
  78. data/lib/studium/check_and_sanitize/README.md +15 -0
  79. data/lib/studium/check_and_sanitize/check_curriculum_for_correct_separation_of_bachelor_and_master.rb +141 -0
  80. data/lib/studium/check_and_sanitize/check_for_all_exam_topics_being_registered.rb +118 -0
  81. data/lib/studium/check_and_sanitize/check_for_correct_themes_of_each_course.rb +100 -0
  82. data/lib/studium/check_and_sanitize/check_for_existing_description_of_this_lecture.rb +194 -0
  83. data/lib/studium/check_and_sanitize/check_important_exams.rb +138 -0
  84. data/lib/studium/check_and_sanitize/check_the_lecture_information_file.rb +166 -0
  85. data/lib/studium/check_and_sanitize/correct_all_dates_in_the_file_lecture_information.rb +115 -0
  86. data/lib/studium/check_and_sanitize/date_sanitizer.rb +350 -0
  87. data/lib/studium/check_and_sanitize/find_duplicate_lectures.rb +124 -0
  88. data/lib/studium/check_and_sanitize/missing_priority_entry.rb +44 -0
  89. data/lib/studium/check_and_sanitize/sanitize_lecture_information.rb +434 -0
  90. data/lib/studium/colours/colours.rb +1711 -0
  91. data/lib/studium/commandline/commandline.rb +1848 -0
  92. data/lib/studium/constants/constants.rb +2063 -0
  93. data/lib/studium/css/project.css +273 -0
  94. data/lib/studium/curricula/attribute_lecture_to_curriculum/attribute_boku_lecture_to_curriculum.rb +384 -0
  95. data/lib/studium/curricula/attribute_lecture_to_curriculum/attribute_lecture_to_curriculum.rb +238 -0
  96. data/lib/studium/curricula/curricula_from_this_website/curricula_from_this_website.rb +141 -0
  97. data/lib/studium/curricula/curriculum.rb +213 -0
  98. data/lib/studium/curricula/curriculum_as_string.rb +280 -0
  99. data/lib/studium/curricula/curriculum_module_displayer/constants.rb +33 -0
  100. data/lib/studium/curricula/curriculum_module_displayer/curriculum_module_displayer.rb +417 -0
  101. data/lib/studium/curricula/curriculum_module_displayer/initialize.rb +25 -0
  102. data/lib/studium/curricula/curriculum_module_displayer/menu.rb +45 -0
  103. data/lib/studium/curricula/curriculum_module_displayer/reset.rb +74 -0
  104. data/lib/studium/curricula/curriculum_module_displayer/run.rb +20 -0
  105. data/lib/studium/curricula/curriculum_module_displayer/set_use_this_curriculum.rb +93 -0
  106. data/lib/studium/curricula/curriculum_module_displayer/show_and_report.rb +190 -0
  107. data/lib/studium/curricula/determine_curricula/constants.rb +11 -0
  108. data/lib/studium/curricula/determine_curricula/determine_curricula.rb +36 -0
  109. data/lib/studium/curricula/determine_curricula/help.rb +39 -0
  110. data/lib/studium/curricula/determine_curricula/initialize.rb +48 -0
  111. data/lib/studium/curricula/determine_curricula/menu.rb +151 -0
  112. data/lib/studium/curricula/determine_curricula/misc.rb +403 -0
  113. data/lib/studium/curricula/determine_curricula/report.rb +141 -0
  114. data/lib/studium/curricula/determine_curricula/reset.rb +59 -0
  115. data/lib/studium/curricula/determine_curricula/run.rb +19 -0
  116. data/lib/studium/curricula/determine_elective_courses_in_this_curriculum.rb +112 -0
  117. data/lib/studium/curricula/display_bachelor_curricula.rb +90 -0
  118. data/lib/studium/curricula/handle_curricula/README.md +9 -0
  119. data/lib/studium/curricula/handle_curricula/handle_curricula.rb +99 -0
  120. data/lib/studium/curricula/handle_curricula/misc.rb +798 -0
  121. data/lib/studium/curricula/mitteilungsbl/303/244tter/mitteilungsbl/303/244tter.rb +323 -0
  122. data/lib/studium/curricula/modules/display_on_the_commandline.rb +319 -0
  123. data/lib/studium/curricula/modules/return_n_ects_in_this_module.rb +74 -0
  124. data/lib/studium/curricula/n_percent_solved_in_this_curriculum.rb +73 -0
  125. data/lib/studium/curricula/prepare_individual_curriculum.rb +304 -0
  126. data/lib/studium/curricula/random_curriculum_creator/random_curriculum_creator.rb +164 -0
  127. data/lib/studium/curricula/show_all_unfinished_courses_of_this_curriculum/show_all_unfinished_courses_of_this_curriculum.rb +116 -0
  128. data/lib/studium/curricula/show_lectures_of_this_curriculum.rb +114 -0
  129. data/lib/studium/curricula/show_lectures_of_this_curriculum_id/show_lectures_of_this_curriculum_id.rb +554 -0
  130. data/lib/studium/curricula/show_solved_percentage_among_the_registered_curricula.rb +87 -0
  131. data/lib/studium/curricula/sorted_individual_curricula.rb +121 -0
  132. data/lib/studium/ects/boku_ects_splitter.rb +128 -0
  133. data/lib/studium/ects/ects_per_university/ects_per_university.rb +179 -0
  134. data/lib/studium/ects/ects_scanner.rb +141 -0
  135. data/lib/studium/ects/ects_to_university_parser.rb +142 -0
  136. data/lib/studium/ects/last_entry_is_curriculum.rb +150 -0
  137. data/lib/studium/ects/n_ects_in_these_lectures.rb +196 -0
  138. data/lib/studium/ects/n_ects_points_in_mandatory_presence_courses.rb +47 -0
  139. data/lib/studium/ects/return_n_ects_from_this_file.rb +59 -0
  140. data/lib/studium/ects/return_n_ects_from_this_url.rb +197 -0
  141. data/lib/studium/ects/search_for_n_ects/search_for_n_ects.rb +719 -0
  142. data/lib/studium/ects/show_completed_ects_in_all_curricula.rb +245 -0
  143. data/lib/studium/ects/show_passed_credits_per_curriculum.rb +276 -0
  144. data/lib/studium/ects/simple_total_ects_points.rb +135 -0
  145. data/lib/studium/ects/solved_ects/constants.rb +19 -0
  146. data/lib/studium/ects/solved_ects/reset.rb +50 -0
  147. data/lib/studium/ects/solved_ects/solved_ects.rb +325 -0
  148. data/lib/studium/ects/solved_ects_per_university/reset.rb +25 -0
  149. data/lib/studium/ects/solved_ects_per_university/solved_ects_per_university.rb +116 -0
  150. data/lib/studium/ects/still_missing.rb +129 -0
  151. data/lib/studium/ects/sum_of_ects.rb +144 -0
  152. data/lib/studium/encoding/encoding.rb +109 -0
  153. data/lib/studium/exam_topics/RNAi_siRNA_and_miRNA +100 -0
  154. data/lib/studium/exam_topics/abfall_als_ressource +86 -0
  155. data/lib/studium/exam_topics/advanced_biochemistry +937 -0
  156. data/lib/studium/exam_topics/advanced_biotechnology +234 -0
  157. data/lib/studium/exam_topics/advanced_cellbiology +251 -0
  158. data/lib/studium/exam_topics/advanced_chemistry +547 -0
  159. data/lib/studium/exam_topics/advanced_immunology +225 -0
  160. data/lib/studium/exam_topics/advanced_microbiology +49 -0
  161. data/lib/studium/exam_topics/advanced_topics_in_plant_sciences +117 -0
  162. data/lib/studium/exam_topics/advanced_virology +273 -0
  163. data/lib/studium/exam_topics/ageing +154 -0
  164. data/lib/studium/exam_topics/agrar_ecology +67 -0
  165. data/lib/studium/exam_topics/agrarmarkt +73 -0
  166. data/lib/studium/exam_topics/agrarphysik +35 -0
  167. data/lib/studium/exam_topics/alcohols +30 -0
  168. data/lib/studium/exam_topics/algorithms +104 -0
  169. data/lib/studium/exam_topics/allergie +76 -0
  170. data/lib/studium/exam_topics/allgemeine_genetik +1006 -0
  171. data/lib/studium/exam_topics/allgemeine_mikrobiologie +1012 -0
  172. data/lib/studium/exam_topics/aminoacids +469 -0
  173. data/lib/studium/exam_topics/analytische_chemie_1 +134 -0
  174. data/lib/studium/exam_topics/analytische_chemie_2 +31 -0
  175. data/lib/studium/exam_topics/anatomie +378 -0
  176. data/lib/studium/exam_topics/anorganische_chemie +357 -0
  177. data/lib/studium/exam_topics/anthropologie +239 -0
  178. data/lib/studium/exam_topics/antibodies_and_antigens +790 -0
  179. data/lib/studium/exam_topics/apoptosis +35 -0
  180. data/lib/studium/exam_topics/archaea +112 -0
  181. data/lib/studium/exam_topics/archaeo_viruses +7 -0
  182. data/lib/studium/exam_topics/archaeology +5 -0
  183. data/lib/studium/exam_topics/architecture +8 -0
  184. data/lib/studium/exam_topics/artificial_intelligence +90 -0
  185. data/lib/studium/exam_topics/atomemissionsspektrometrie +6 -0
  186. data/lib/studium/exam_topics/audio +11 -0
  187. data/lib/studium/exam_topics/bacteriophages +266 -0
  188. data/lib/studium/exam_topics/basic_biochemistry +1008 -0
  189. data/lib/studium/exam_topics/basic_biotechnology +1011 -0
  190. data/lib/studium/exam_topics/basic_chemistry +1007 -0
  191. data/lib/studium/exam_topics/basic_virology +1008 -0
  192. data/lib/studium/exam_topics/bauwesen +6 -0
  193. data/lib/studium/exam_topics/betriebssysteme +128 -0
  194. data/lib/studium/exam_topics/betriebswirtschaftslehre +29 -0
  195. data/lib/studium/exam_topics/bioanalytik_und_biosensoren +451 -0
  196. data/lib/studium/exam_topics/biochips +80 -0
  197. data/lib/studium/exam_topics/bioelektrochemie +57 -0
  198. data/lib/studium/exam_topics/biofilms +58 -0
  199. data/lib/studium/exam_topics/bioinformatics +523 -0
  200. data/lib/studium/exam_topics/biological_therapeutics +156 -0
  201. data/lib/studium/exam_topics/biologie +152 -0
  202. data/lib/studium/exam_topics/biomarkers +137 -0
  203. data/lib/studium/exam_topics/biomaterials +90 -0
  204. data/lib/studium/exam_topics/biomedical_studies +16 -0
  205. data/lib/studium/exam_topics/biomembranes +6 -0
  206. data/lib/studium/exam_topics/bionik +65 -0
  207. data/lib/studium/exam_topics/biophysik +34 -0
  208. data/lib/studium/exam_topics/biopolymers +10 -0
  209. data/lib/studium/exam_topics/bioprozesstechnik +149 -0
  210. data/lib/studium/exam_topics/bioressourcenmanagement +78 -0
  211. data/lib/studium/exam_topics/birds +5 -0
  212. data/lib/studium/exam_topics/bodenkunde +384 -0
  213. data/lib/studium/exam_topics/bodenmikrobiologie +40 -0
  214. data/lib/studium/exam_topics/cancerbiology +488 -0
  215. data/lib/studium/exam_topics/cell_cultures +229 -0
  216. data/lib/studium/exam_topics/cellbiology +1011 -0
  217. data/lib/studium/exam_topics/cellular_transport_and_protein_secretion +27 -0
  218. data/lib/studium/exam_topics/cellular_vesicles +11 -0
  219. data/lib/studium/exam_topics/cellulose +6 -0
  220. data/lib/studium/exam_topics/chemische_technologie_anorganischer_stoffe +210 -0
  221. data/lib/studium/exam_topics/chemische_technologie_organischer_stoffe +25 -0
  222. data/lib/studium/exam_topics/chemisches_labor +60 -0
  223. data/lib/studium/exam_topics/chemokines_and_cytokines +45 -0
  224. data/lib/studium/exam_topics/chemotaxis_quorum_sensing_and_motility_in_prokaryotes +116 -0
  225. data/lib/studium/exam_topics/citric_acid_cycle +84 -0
  226. data/lib/studium/exam_topics/clinical_microbiology +520 -0
  227. data/lib/studium/exam_topics/computer_science +309 -0
  228. data/lib/studium/exam_topics/computer_vision_and_computer_graphics +15 -0
  229. data/lib/studium/exam_topics/crispr +51 -0
  230. data/lib/studium/exam_topics/cyanobacteria +45 -0
  231. data/lib/studium/exam_topics/cytogenetics_and_chromosome_biology +598 -0
  232. data/lib/studium/exam_topics/databases_and_sql +126 -0
  233. data/lib/studium/exam_topics/dna_mutation_and_dna_repair +186 -0
  234. data/lib/studium/exam_topics/dna_replication +80 -0
  235. data/lib/studium/exam_topics/ecogenetics +26 -0
  236. data/lib/studium/exam_topics/ecological_agriculture +12 -0
  237. data/lib/studium/exam_topics/ecology +332 -0
  238. data/lib/studium/exam_topics/economy +226 -0
  239. data/lib/studium/exam_topics/electron_microscopy +7 -0
  240. data/lib/studium/exam_topics/elektronenmikroskopie +356 -0
  241. data/lib/studium/exam_topics/elektrophorese +132 -0
  242. data/lib/studium/exam_topics/elektrotechnik_und_elektrizit/303/244t +42 -0
  243. data/lib/studium/exam_topics/elisa +55 -0
  244. data/lib/studium/exam_topics/embryologie_und_entwicklung +657 -0
  245. data/lib/studium/exam_topics/endospores_and_spores +104 -0
  246. data/lib/studium/exam_topics/enzymes_and_cofactors +395 -0
  247. data/lib/studium/exam_topics/epigenetik +188 -0
  248. data/lib/studium/exam_topics/erste_hilfe +414 -0
  249. data/lib/studium/exam_topics/ethik +143 -0
  250. data/lib/studium/exam_topics/evolution_and_evolutionary_genetics +372 -0
  251. data/lib/studium/exam_topics/excel +7 -0
  252. data/lib/studium/exam_topics/fish +19 -0
  253. data/lib/studium/exam_topics/fluorescence_microscopy +10 -0
  254. data/lib/studium/exam_topics/food_microbiology_and_food_biotechnology +92 -0
  255. data/lib/studium/exam_topics/forensik +65 -0
  256. data/lib/studium/exam_topics/forstwirtschaft +53 -0
  257. data/lib/studium/exam_topics/fortgeschrittene_genetik +692 -0
  258. data/lib/studium/exam_topics/fortgeschrittene_gentechnik +221 -0
  259. data/lib/studium/exam_topics/fortgeschrittene_physik +6 -0
  260. data/lib/studium/exam_topics/fungi +119 -0
  261. data/lib/studium/exam_topics/genetische_krankheiten +209 -0
  262. data/lib/studium/exam_topics/genexpression +1008 -0
  263. data/lib/studium/exam_topics/genomics_and_metagenomics +290 -0
  264. data/lib/studium/exam_topics/gentechnik_und_praktische_biochemie +961 -0
  265. data/lib/studium/exam_topics/geochemistry +67 -0
  266. data/lib/studium/exam_topics/geography +9 -0
  267. data/lib/studium/exam_topics/geologie_und_mineralogie +624 -0
  268. data/lib/studium/exam_topics/geometrie +56 -0
  269. data/lib/studium/exam_topics/geschichte +95 -0
  270. data/lib/studium/exam_topics/gluconeogenesis +72 -0
  271. data/lib/studium/exam_topics/glycogen +45 -0
  272. data/lib/studium/exam_topics/glycolysis +118 -0
  273. data/lib/studium/exam_topics/glykomik +131 -0
  274. data/lib/studium/exam_topics/glyoxylatzyklus +31 -0
  275. data/lib/studium/exam_topics/grassland_cultivation +32 -0
  276. data/lib/studium/exam_topics/hormone +152 -0
  277. data/lib/studium/exam_topics/html +8 -0
  278. data/lib/studium/exam_topics/human_ecology +8 -0
  279. data/lib/studium/exam_topics/hygiene +224 -0
  280. data/lib/studium/exam_topics/imaging_and_microscopy +270 -0
  281. data/lib/studium/exam_topics/immunanalytik +94 -0
  282. data/lib/studium/exam_topics/immunologie +1011 -0
  283. data/lib/studium/exam_topics/informatik +117 -0
  284. data/lib/studium/exam_topics/innate_immunity +52 -0
  285. data/lib/studium/exam_topics/insekten +66 -0
  286. data/lib/studium/exam_topics/insulin_and_diabetes +57 -0
  287. data/lib/studium/exam_topics/java +624 -0
  288. data/lib/studium/exam_topics/javascript +29 -0
  289. data/lib/studium/exam_topics/klima +6 -0
  290. data/lib/studium/exam_topics/kryptographie +10 -0
  291. data/lib/studium/exam_topics/landtechnik +26 -0
  292. data/lib/studium/exam_topics/lebensmittel_und_getr/303/244nke +224 -0
  293. data/lib/studium/exam_topics/lebensmitteltechnologie +16 -0
  294. data/lib/studium/exam_topics/light_microscopy +19 -0
  295. data/lib/studium/exam_topics/linux_and_unix +36 -0
  296. data/lib/studium/exam_topics/lipids +145 -0
  297. data/lib/studium/exam_topics/macroeconomics +39 -0
  298. data/lib/studium/exam_topics/marketing +53 -0
  299. data/lib/studium/exam_topics/mathematics +311 -0
  300. data/lib/studium/exam_topics/medizin_und_biomedizinische_technik +254 -0
  301. data/lib/studium/exam_topics/medizinische_chemie_und_pharmazie +441 -0
  302. data/lib/studium/exam_topics/messtechnik_und_regeltechnik +104 -0
  303. data/lib/studium/exam_topics/metabolismus +482 -0
  304. data/lib/studium/exam_topics/meteorologie_und_atmosph/303/244re +120 -0
  305. data/lib/studium/exam_topics/microbial_ecology +37 -0
  306. data/lib/studium/exam_topics/microcontrollers +11 -0
  307. data/lib/studium/exam_topics/mikrobielle_lebensgemeinschaften +58 -0
  308. data/lib/studium/exam_topics/mikrobielle_physiologie +313 -0
  309. data/lib/studium/exam_topics/mitochondria +57 -0
  310. data/lib/studium/exam_topics/mixed +287 -0
  311. data/lib/studium/exam_topics/molecular_biology_of_plants +281 -0
  312. data/lib/studium/exam_topics/molekulare_medizin +133 -0
  313. data/lib/studium/exam_topics/nanotechnologie +456 -0
  314. data/lib/studium/exam_topics/nature_conservation_and_biodiversity +247 -0
  315. data/lib/studium/exam_topics/naturstoffe +9 -0
  316. data/lib/studium/exam_topics/netzwerke +63 -0
  317. data/lib/studium/exam_topics/neuroanatomie +25 -0
  318. data/lib/studium/exam_topics/neurobiology +356 -0
  319. data/lib/studium/exam_topics/nucleotide_sequencing +41 -0
  320. data/lib/studium/exam_topics/nutztierethologie +11 -0
  321. data/lib/studium/exam_topics/object_oriented_modeling +15 -0
  322. data/lib/studium/exam_topics/obstbau +249 -0
  323. data/lib/studium/exam_topics/organische_chemie +1007 -0
  324. data/lib/studium/exam_topics/organische_chemie_2 +137 -0
  325. data/lib/studium/exam_topics/paleobiology +39 -0
  326. data/lib/studium/exam_topics/parasitic_diseases_and_molecular_infection_biology +336 -0
  327. data/lib/studium/exam_topics/patent_law +55 -0
  328. data/lib/studium/exam_topics/pathologie +761 -0
  329. data/lib/studium/exam_topics/pcr +155 -0
  330. data/lib/studium/exam_topics/pentosephosphatweg +61 -0
  331. data/lib/studium/exam_topics/peroxisomes_glycosomes_and_lysosomes +66 -0
  332. data/lib/studium/exam_topics/pflanzenanatomie +262 -0
  333. data/lib/studium/exam_topics/pflanzenbau +24 -0
  334. data/lib/studium/exam_topics/pflanzenschutz +35 -0
  335. data/lib/studium/exam_topics/pflanzenwissenschaften +1009 -0
  336. data/lib/studium/exam_topics/pharmaceutical_biotechnology +252 -0
  337. data/lib/studium/exam_topics/physik +449 -1
  338. data/lib/studium/exam_topics/physikalische_chemie +79 -0
  339. data/lib/studium/exam_topics/physiology_and_histology +592 -0
  340. data/lib/studium/exam_topics/phytochemie +33 -0
  341. data/lib/studium/exam_topics/plant_biotechnology +132 -0
  342. data/lib/studium/exam_topics/plant_breeding +64 -0
  343. data/lib/studium/exam_topics/plant_development +50 -0
  344. data/lib/studium/exam_topics/populationsgenetik +143 -0
  345. data/lib/studium/exam_topics/posttranslationale_modifikation_von_proteinen +198 -0
  346. data/lib/studium/exam_topics/programming +41 -0
  347. data/lib/studium/exam_topics/projektmanagement +226 -0
  348. data/lib/studium/exam_topics/prokaryote_genetics +587 -0
  349. data/lib/studium/exam_topics/protein_engineering +35 -0
  350. data/lib/studium/exam_topics/proteolyse +39 -0
  351. data/lib/studium/exam_topics/proteomik +42 -0
  352. data/lib/studium/exam_topics/protozoans +24 -0
  353. data/lib/studium/exam_topics/prozesstechnik +95 -0
  354. data/lib/studium/exam_topics/psychologie +21 -0
  355. data/lib/studium/exam_topics/python +391 -0
  356. data/lib/studium/exam_topics/quality_management +266 -0
  357. data/lib/studium/exam_topics/rechtsgrundlagen +126 -0
  358. data/lib/studium/exam_topics/research_topics_in_immunobiology +42 -0
  359. data/lib/studium/exam_topics/rna_and_dna +535 -0
  360. data/lib/studium/exam_topics/rna_seq +13 -0
  361. data/lib/studium/exam_topics/robotics +12 -0
  362. data/lib/studium/exam_topics/ruby +240 -0
  363. data/lib/studium/exam_topics/ruby_on_rails +63 -0
  364. data/lib/studium/exam_topics/scientific_writing_and_publishing +38 -0
  365. data/lib/studium/exam_topics/semisynthese_von_proteinen_und_nukleotiden +120 -0
  366. data/lib/studium/exam_topics/sexualbiologie +327 -0
  367. data/lib/studium/exam_topics/signal_transduction_and_laser_systems +215 -0
  368. data/lib/studium/exam_topics/sozialbiologie +17 -0
  369. data/lib/studium/exam_topics/soziologie +5 -0
  370. data/lib/studium/exam_topics/splicing_exons_and_introns +67 -0
  371. data/lib/studium/exam_topics/sport_und_sportverletzungen +6 -0
  372. data/lib/studium/exam_topics/statistik +306 -0
  373. data/lib/studium/exam_topics/stemcells +182 -0
  374. data/lib/studium/exam_topics/stickstofffixierung +91 -0
  375. data/lib/studium/exam_topics/structural_bioinformatics +54 -0
  376. data/lib/studium/exam_topics/strukturbiologie +445 -0
  377. data/lib/studium/exam_topics/system_biology_and_synthetic_biology +108 -0
  378. data/lib/studium/exam_topics/systematische_zoologie +446 -0
  379. data/lib/studium/exam_topics/technical_ecology +144 -0
  380. data/lib/studium/exam_topics/technik +5 -0
  381. data/lib/studium/exam_topics/technische_chemie +208 -0
  382. data/lib/studium/exam_topics/technische_grundlagen_der_informatik +43 -0
  383. data/lib/studium/exam_topics/technische_mikrobiologie +393 -0
  384. data/lib/studium/exam_topics/technisches_zeichnen +5 -0
  385. data/lib/studium/exam_topics/the_bacterial_cell_wall +98 -0
  386. data/lib/studium/exam_topics/the_c_plus_plus_programming_language +531 -0
  387. data/lib/studium/exam_topics/the_c_programming_language +133 -0
  388. data/lib/studium/exam_topics/the_cellcycle +102 -0
  389. data/lib/studium/exam_topics/the_european_union +121 -0
  390. data/lib/studium/exam_topics/the_interferon_system +40 -0
  391. data/lib/studium/exam_topics/the_microbiome +164 -0
  392. data/lib/studium/exam_topics/the_universe +32 -0
  393. data/lib/studium/exam_topics/theoretische_chemie +5 -0
  394. data/lib/studium/exam_topics/theoretische_informatik +161 -0
  395. data/lib/studium/exam_topics/thermodynamics +21 -0
  396. data/lib/studium/exam_topics/tierzucht +139 -0
  397. data/lib/studium/exam_topics/toxikologie +508 -0
  398. data/lib/studium/exam_topics/transcription +188 -0
  399. data/lib/studium/exam_topics/translation_ribosomes_and_translational_control +155 -0
  400. data/lib/studium/exam_topics/umweltbiotechnologie +64 -0
  401. data/lib/studium/exam_topics/umweltchemie +233 -0
  402. data/lib/studium/exam_topics/urbanism_and_traffic +19 -0
  403. data/lib/studium/exam_topics/urea_cycle +56 -0
  404. data/lib/studium/exam_topics/vaccines_and_vaccination +253 -0
  405. data/lib/studium/exam_topics/vectors_and_gene_therapy +247 -0
  406. data/lib/studium/exam_topics/verfahrenstechnik +37 -0
  407. data/lib/studium/exam_topics/verhaltensbiologie +79 -0
  408. data/lib/studium/exam_topics/veterinary_medicine +10 -0
  409. data/lib/studium/exam_topics/vitamine +32 -0
  410. data/lib/studium/exam_topics/wasserkunde +144 -0
  411. data/lib/studium/exam_topics/weinbau +86 -0
  412. data/lib/studium/exam_topics/wissenschaft +20 -0
  413. data/lib/studium/exam_topics/yeast +104 -0
  414. data/lib/studium/exam_topics/zoologie +338 -0
  415. data/lib/studium/exams/afterburn/afterburn.rb +304 -0
  416. data/lib/studium/exams/ask_exam_from_the_upcoming_exams_pool.rb +150 -0
  417. data/lib/studium/exams/ask_exam_topic_question.rb +112 -0
  418. data/lib/studium/exams/ask_question_from_alias.rb +141 -0
  419. data/lib/studium/exams/ask_question_from_any_of_the_still_missing_lectures.rb +130 -0
  420. data/lib/studium/exams/ask_question_from_grouped_themes.rb +141 -0
  421. data/lib/studium/exams/ask_question_from_last_topic.rb +91 -0
  422. data/lib/studium/exams/ask_random_question.rb +195 -0
  423. data/lib/studium/exams/autoinclude.rb +7 -0
  424. data/lib/studium/exams/average_grade/average_grade.rb +404 -0
  425. data/lib/studium/exams/csv/create_csv_passed_exams_file.rb +217 -0
  426. data/lib/studium/exams/cycle.rb +291 -0
  427. data/lib/studium/exams/dataset/dataset.rb +126 -0
  428. data/lib/studium/exams/designate_ten_random_exam_topics/designate_ten_random_exam_topics.rb +88 -0
  429. data/lib/studium/exams/exam/exam.rb +130 -0
  430. data/lib/studium/exams/exam_bubble/exam_bubble.rb +444 -0
  431. data/lib/studium/exams/exam_bubble/menu_for_the_main_loop.rb +111 -0
  432. data/lib/studium/exams/exam_question/README.md +3 -0
  433. data/lib/studium/exams/exam_question/exam_question.rb +434 -0
  434. data/lib/studium/exams/exam_registration_at/constants.rb +49 -0
  435. data/lib/studium/exams/exam_registration_at/exam_registration_at.rb +242 -0
  436. data/lib/studium/exams/exam_registration_at/help.rb +46 -0
  437. data/lib/studium/exams/exam_registration_at/menu.rb +81 -0
  438. data/lib/studium/exams/exam_registration_at/report_and_show.rb +133 -0
  439. data/lib/studium/exams/exam_registration_at/reset.rb +54 -0
  440. data/lib/studium/exams/exam_statistics_from_this_file/exam_statistics_from_this_file.rb +119 -0
  441. data/lib/studium/exams/exam_topics.rb +194 -0
  442. data/lib/studium/exams/exams.rb +20 -0
  443. data/lib/studium/exams/exams_per_month/exams_per_month.rb +2442 -0
  444. data/lib/studium/exams/exams_this_week.rb +182 -0
  445. data/lib/studium/exams/fix_exam_dates.rb +121 -0
  446. data/lib/studium/exams/frozen.rb +36 -0
  447. data/lib/studium/exams/last_exams/last_exams.rb +479 -0
  448. data/lib/studium/exams/lectures_without_exam_entry.rb +137 -0
  449. data/lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb +1358 -0
  450. data/lib/studium/exams/move_all_unsolved_exam_questions_to_the_top_of_the_file.rb +173 -0
  451. data/lib/studium/exams/move_the_last_exam_question_to_the_top_of_the_file/move_the_last_exam_question_to_the_top_of_the_file.rb +111 -0
  452. data/lib/studium/exams/n_exams_in_these_topics.rb +477 -0
  453. data/lib/studium/exams/next_exam.rb +106 -0
  454. data/lib/studium/exams/next_exams.rb +378 -0
  455. data/lib/studium/exams/not_completed/README.md +5 -0
  456. data/lib/studium/exams/not_completed/not_completed.rb +143 -0
  457. data/lib/studium/exams/open_exam_associated_url/open_exam_associated_url.rb +154 -0
  458. data/lib/studium/exams/open_last_exam_question_asked_file/constants.rb +15 -0
  459. data/lib/studium/exams/open_last_exam_question_asked_file/initialize.rb +29 -0
  460. data/lib/studium/exams/open_last_exam_question_asked_file/open_last_exam_question_asked_file.rb +110 -0
  461. data/lib/studium/exams/push_solved_questions_on_top.rb +180 -0
  462. data/lib/studium/exams/question_answer/question_answer.rb +2936 -0
  463. data/lib/studium/exams/questions_solved_from_day_to_day/questions_solved_from_day_to_day.rb +379 -0
  464. data/lib/studium/exams/remote_ftp_url.rb +52 -0
  465. data/lib/studium/exams/repeat_last_question.rb +78 -0
  466. data/lib/studium/exams/report_total_amount_of_questions_and_answers_for.rb +116 -0
  467. data/lib/studium/exams/show_all_passed_exams_of_this_university.rb +252 -0
  468. data/lib/studium/exams/show_backlog_of_exams/show_backlog_of_exams.rb +114 -0
  469. data/lib/studium/exams/show_exams_for/show_exams_for.rb +172 -0
  470. data/lib/studium/exams/show_themes/constants.rb +28 -0
  471. data/lib/studium/exams/show_themes/menu.rb +61 -0
  472. data/lib/studium/exams/show_themes/misc.rb +538 -0
  473. data/lib/studium/exams/show_themes/reset.rb +62 -0
  474. data/lib/studium/exams/show_themes/show_themes.rb +27 -0
  475. data/lib/studium/exams/show_upcoming_exams/show_upcoming_exams.rb +1537 -0
  476. data/lib/studium/exams/solve_all_questions_from_this_topic.rb +114 -0
  477. data/lib/studium/exams/solved/solved.rb +434 -0
  478. data/lib/studium/exams/timetable/constants.rb +142 -0
  479. data/lib/studium/exams/timetable/timetable.rb +448 -0
  480. data/lib/studium/exams/unsolve_all_questions_from_this_topic.rb +163 -0
  481. data/lib/studium/exams/upcoming_exams/upcoming_exams.rb +555 -0
  482. data/lib/studium/exams/upcoming_exams_at_the_boku/constants.rb +23 -0
  483. data/lib/studium/exams/upcoming_exams_at_the_boku/html.rb +64 -0
  484. data/lib/studium/exams/upcoming_exams_at_the_boku/upcoming_exams_at_the_boku.rb +194 -0
  485. data/lib/studium/exams/upcoming_exams_dataset.rb +247 -0
  486. data/lib/studium/exams/upcoming_registered_exams/upcoming_registered_exams.rb +257 -0
  487. data/lib/studium/exams/upload_exam_topics.rb +360 -0
  488. data/lib/studium/graphviz/README.md +4 -0
  489. data/lib/studium/graphviz/bachelor_vector_based_strategies.dot +160 -0
  490. data/lib/studium/graphviz/master_vector_based_strategies.dot +46 -0
  491. data/lib/studium/gui/gtk3/control_panel/control_panel.rb +40 -0
  492. data/lib/studium/gui/gtk3/lecture_information/lecture_information.rb +191 -0
  493. data/lib/studium/gui/java/exam_question/ExamQuestion$1.class +0 -0
  494. data/lib/studium/gui/java/exam_question/ExamQuestion.class +0 -0
  495. data/lib/studium/gui/java/exam_question/ExamQuestion.java +215 -0
  496. data/lib/studium/gui/javafx/exam_question_widget/exam_question_widget.rb +58 -0
  497. data/lib/studium/gui/jruby/exam_trainer/exam_trainer.rb +637 -0
  498. data/lib/studium/gui/jruby/show_upcoming_exams/show_upcoming_exams.rb +85 -0
  499. data/lib/studium/gui/libui/ask_exam_question/ask_exam_question.rb +347 -0
  500. data/lib/studium/gui/shared_code/control_panel/control_panel_module.rb +305 -0
  501. data/lib/studium/gui/shared_code/exam_trainer/exam_trainer_widget_module.rb +0 -0
  502. data/lib/studium/gui/shared_code/information_about_a_lecture/information_about_a_lecture_module.rb +0 -0
  503. data/lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb +129 -0
  504. data/lib/studium/gui/universal_widgets/curriculum_viewer/curriculum_viewer.rb +549 -0
  505. data/lib/studium/gui/universal_widgets/ects_per_university/ects_per_university.rb +302 -0
  506. data/lib/studium/gui/universal_widgets/exam_trainer/exam_trainer.config +6 -0
  507. data/lib/studium/gui/universal_widgets/exam_trainer/exam_trainer.rb +3266 -0
  508. data/lib/studium/gui/universal_widgets/exam_trainer/manifest.yml +12 -0
  509. data/lib/studium/gui/universal_widgets/expand_time_range/expand_time_range.rb +309 -0
  510. data/lib/studium/gui/universal_widgets/information_about_a_lecture/information_about_a_lecture.rb +242 -0
  511. data/lib/studium/gui/universal_widgets/show_upcoming_exams/show_upcoming_exams.rb +252 -0
  512. data/lib/studium/images/libui_ask_exam_question.png +0 -0
  513. data/lib/studium/images/outdated.png +0 -0
  514. data/lib/studium/images/small_logos/DNA.png +0 -0
  515. data/lib/studium/images/small_logos/README.md +2 -0
  516. data/lib/studium/images/small_logos/solved.png +0 -0
  517. data/lib/studium/images/studies_favicon.png +0 -0
  518. data/lib/studium/java/README.md +5 -0
  519. data/lib/studium/java/studium/AskExamQuestion.java +461 -0
  520. data/lib/studium/java/studium/Base.java +123 -0
  521. data/lib/studium/java/studium/Constants.java +122 -0
  522. data/lib/studium/java/studium/EnsureThatTheLogDirectoryExists.java +57 -0
  523. data/lib/studium/java/studium/Mkdir.java +13 -0
  524. data/lib/studium/java/studium/OpenLastExamQuestionurlLinkViaTheBrowser.java +90 -0
  525. data/lib/studium/java/studium/ReturnNQuestionsSolvedInTotal.java +69 -0
  526. data/lib/studium/java/studium/Solved.java +112 -0
  527. data/lib/studium/java/studium/Test.java +60 -0
  528. data/lib/studium/java/studium/studium/AskExamQuestion.class +0 -0
  529. data/lib/studium/java/studium/studium/Base.class +0 -0
  530. data/lib/studium/java/studium/studium/Constants.class +0 -0
  531. data/lib/studium/java/studium/studium/EnsureThatTheLogDirectoryExists.class +0 -0
  532. data/lib/studium/java/studium/studium/Mkdir.class +0 -0
  533. data/lib/studium/java/studium/studium/OpenLastExamQuestionurlLinkViaTheBrowser.class +0 -0
  534. data/lib/studium/java/studium/studium/ReturnNQuestionsSolvedInTotal.class +0 -0
  535. data/lib/studium/java/studium/studium/Solved.class +0 -0
  536. data/lib/studium/java/studium/studium/Test.class +0 -0
  537. data/lib/studium/jobs/jobs.rb +80 -0
  538. data/lib/studium/logging/README.md +2 -0
  539. data/lib/studium/logging/ensure_that_the_log_directory_exists.rb +58 -0
  540. data/lib/studium/logging/html_log_directory.rb +42 -0
  541. data/lib/studium/logging/log_directory.rb +112 -0
  542. data/lib/studium/logging/store_last_question_asked_into_file.rb +138 -0
  543. data/lib/studium/parsers/README.md +2 -0
  544. data/lib/studium/parsers/custom_exam_results_parser.rb +209 -0
  545. data/lib/studium/parsers/parse_remote_lecture.rb +331 -0
  546. data/lib/studium/project/project.rb +88 -0
  547. data/lib/studium/requires/common_popular_requires.rb +37 -0
  548. data/lib/studium/requires/commonly_used_requires.rb +14 -0
  549. data/lib/studium/requires/require_class_exams_solved.rb +7 -0
  550. data/lib/studium/requires/require_ects_scripts.rb +27 -0
  551. data/lib/studium/requires/require_encoding.rb +7 -0
  552. data/lib/studium/requires/require_the_check_and_sanitize_files.rb +31 -0
  553. data/lib/studium/requires/require_the_curricula_files.rb +28 -0
  554. data/lib/studium/requires/require_the_exam_question_class.rb +7 -0
  555. data/lib/studium/requires/require_the_exams_files.rb +46 -0
  556. data/lib/studium/requires/require_the_logging_files.rb +23 -0
  557. data/lib/studium/requires/require_the_parsers.rb +28 -0
  558. data/lib/studium/requires/require_the_studium_constants.rb +7 -0
  559. data/lib/studium/requires/require_the_studium_project.rb +72 -0
  560. data/lib/studium/requires/require_the_toplevel_methods.rb +27 -0
  561. data/lib/studium/requires/require_the_utility_scripts.rb +34 -0
  562. data/lib/studium/requires/require_upcoming_exams.rb +7 -0
  563. data/lib/studium/requires/require_yaml.rb +7 -0
  564. data/lib/studium/requires/return_remote_homepage_of_this_lecture.rb +7 -0
  565. data/lib/studium/requires/with_GUI.rb +13 -0
  566. data/lib/studium/requires/www_mode.rb +17 -0
  567. data/lib/studium/statistics/README.md +4 -0
  568. data/lib/studium/statistics/best_exam_months.rb +92 -0
  569. data/lib/studium/statistics/curriculum_comparer/curriculum_comparer.rb +423 -0
  570. data/lib/studium/statistics/determine_exam_statistics_from_this_file.rb +142 -0
  571. data/lib/studium/statistics/exam_topics_that_are_about_to_be_completed.rb +117 -0
  572. data/lib/studium/statistics/max_stats.rb +169 -0
  573. data/lib/studium/statistics/new_questions_per_year.rb +147 -0
  574. data/lib/studium/statistics/report_how_many_ects_points_per_curriculum_were_completed.rb +167 -0
  575. data/lib/studium/statistics/report_how_many_exam_questions_were_answered.rb +473 -0
  576. data/lib/studium/statistics/show_exam_statistics.rb +75 -0
  577. data/lib/studium/statistics/show_which_courses_are_in_a_bachelor_or_master_curriculum_respectively.rb +104 -0
  578. data/lib/studium/statistics/top_stats.rb +126 -0
  579. data/lib/studium/toplevel_methods/e_and_esystem.rb +34 -0
  580. data/lib/studium/toplevel_methods/find_exam_topic_and_exam_title.rb +3986 -0
  581. data/lib/studium/toplevel_methods/install_the_project_on_the_given_hostsystem.rb +31 -0
  582. data/lib/studium/toplevel_methods/return_remote_homepage_of_this_lecture.rb +11611 -0
  583. data/lib/studium/toplevel_methods/return_remote_moodle_link_of_this_lecture.rb +2405 -0
  584. data/lib/studium/toplevel_methods/roebe.rb +16 -0
  585. data/lib/studium/toplevel_methods/runmode.rb +45 -0
  586. data/lib/studium/toplevel_methods/toplevel_methods.rb +7295 -0
  587. data/lib/studium/universities_in_austria/README.md +2 -0
  588. data/lib/studium/universities_in_austria/boku/README.md +4 -0
  589. data/lib/studium/universities_in_austria/boku/boku_/303/266ffnungszeiten.rb +28 -0
  590. data/lib/studium/universities_in_austria/boku/show_three_pillars_of_these_lectures.rb +110 -0
  591. data/lib/studium/universities_in_austria/boku/three_pillars.rb +237 -0
  592. data/lib/studium/universities_in_austria/tu_vienna/README.md +6 -0
  593. data/lib/studium/universities_in_austria/tu_vienna/tu_ferien.rb +42 -0
  594. data/lib/studium/universities_in_austria/tu_vienna/tu_/303/266ffnungszeiten.rb +34 -0
  595. data/lib/studium/university_course/university_course.rb +409 -0
  596. data/lib/studium/utility_scripts/attribute_lectures_to_university/attribute_lectures_to_university.rb +375 -0
  597. data/lib/studium/utility_scripts/audio_stats.rb +171 -0
  598. data/lib/studium/utility_scripts/auto_stud/auto_stud.rb +252 -0
  599. data/lib/studium/utility_scripts/auto_stud/constants.rb +18 -0
  600. data/lib/studium/utility_scripts/auto_stud/initialize.rb +23 -0
  601. data/lib/studium/utility_scripts/auto_stud/misc.rb +18 -0
  602. data/lib/studium/utility_scripts/autogeneration/autogeneration.rb +158 -0
  603. data/lib/studium/utility_scripts/autopurge_this_lecture_date.rb +100 -0
  604. data/lib/studium/utility_scripts/average_grade_of_this_curriculum.rb +153 -0
  605. data/lib/studium/utility_scripts/blocked_courses.rb +146 -0
  606. data/lib/studium/utility_scripts/calendar/README.md +2 -0
  607. data/lib/studium/utility_scripts/calendar/calendar.rb +251 -0
  608. data/lib/studium/utility_scripts/calendar/misc.rb +35 -0
  609. data/lib/studium/utility_scripts/check_description_of_these_lectures.rb +221 -0
  610. data/lib/studium/utility_scripts/course_registrations/course_registrations.rb +98 -0
  611. data/lib/studium/utility_scripts/courses/courses.rb +177 -0
  612. data/lib/studium/utility_scripts/create/README.md +2 -0
  613. data/lib/studium/utility_scripts/create/webpage_of_university.rb +129 -0
  614. data/lib/studium/utility_scripts/create/webpage_of_university_BOKU.rb +61 -0
  615. data/lib/studium/utility_scripts/create/webpage_of_university_TU.rb +60 -0
  616. data/lib/studium/utility_scripts/create/webpage_of_university_UniWien.rb +60 -0
  617. data/lib/studium/utility_scripts/create_database/create_database.rb +126 -0
  618. data/lib/studium/utility_scripts/current_lectures_belonging_to_both_bachelor_and_master_curriculum.rb +113 -0
  619. data/lib/studium/utility_scripts/currently_participating_in_these_lectures/currently_participating_in_these_lectures.rb +104 -0
  620. data/lib/studium/utility_scripts/display_lecture_url/display_lecture_url.rb +176 -0
  621. data/lib/studium/utility_scripts/expand_time_range/expand_time_range.rb +521 -0
  622. data/lib/studium/utility_scripts/finished_exams_at_this_university/finished_exams_at_this_university.rb +171 -0
  623. data/lib/studium/utility_scripts/foreign_language_percentage/constants.rb +23 -0
  624. data/lib/studium/utility_scripts/foreign_language_percentage/foreign_language_percentage.rb +149 -0
  625. data/lib/studium/utility_scripts/foreign_language_percentage/help.rb +31 -0
  626. data/lib/studium/utility_scripts/foreign_language_percentage/initialize.rb +25 -0
  627. data/lib/studium/utility_scripts/foreign_language_percentage/menu.rb +158 -0
  628. data/lib/studium/utility_scripts/foreign_language_percentage/report.rb +62 -0
  629. data/lib/studium/utility_scripts/foreign_language_percentage/reset.rb +50 -0
  630. data/lib/studium/utility_scripts/foreign_language_percentage/run.rb +19 -0
  631. data/lib/studium/utility_scripts/generate_spreadsheet/generate_spreadsheet.rb +353 -0
  632. data/lib/studium/utility_scripts/generate_spreadsheet/misc.rb +144 -0
  633. data/lib/studium/utility_scripts/holidays/holidays.rb +154 -0
  634. data/lib/studium/utility_scripts/homepage_of_these_courses/homepage_of_these_courses.rb +125 -0
  635. data/lib/studium/utility_scripts/lectures_attributed_to_universities/lectures_attributed_to_universities.rb +336 -0
  636. data/lib/studium/utility_scripts/lva_dates_of_the_important_courses.rb +111 -0
  637. data/lib/studium/utility_scripts/lva_nummer/lva_nummer.rb +427 -0
  638. data/lib/studium/utility_scripts/mandatory_lectures_in_this_month/mandatory_lectures_in_this_month.rb +316 -0
  639. data/lib/studium/utility_scripts/moodle/moodle.rb +214 -0
  640. data/lib/studium/utility_scripts/name_of_this_lva_id/name_of_this_lva_id.rb +110 -0
  641. data/lib/studium/utility_scripts/new_stud.rb +324 -0
  642. data/lib/studium/utility_scripts/next_week/next_week.rb +103 -0
  643. data/lib/studium/utility_scripts/not_yet_registered/not_yet_registered.rb +120 -0
  644. data/lib/studium/utility_scripts/open_last_exam_question_url_link_via_the_browser.rb +76 -0
  645. data/lib/studium/utility_scripts/passed_ects_per_year/passed_ects_per_year.rb +313 -0
  646. data/lib/studium/utility_scripts/passed_pr/303/274fungsimmanente_courses/passed_pr/303/274fungsimmanente_courses.rb +181 -0
  647. data/lib/studium/utility_scripts/pdf/README.md +2 -0
  648. data/lib/studium/utility_scripts/pdf/create_pdf_file_for_this_exam_topic.rb +352 -0
  649. data/lib/studium/utility_scripts/pdf/hexapdf_support.rb +50 -0
  650. data/lib/studium/utility_scripts/preparatory_meetings/preparatory_meetings.rb +317 -0
  651. data/lib/studium/utility_scripts/priority/priority.rb +164 -0
  652. data/lib/studium/utility_scripts/priority_points/priority_points.rb +261 -0
  653. data/lib/studium/utility_scripts/publish_my_exams/publish_my_exams.rb +174 -0
  654. data/lib/studium/utility_scripts/regexes/README.md +1 -0
  655. data/lib/studium/utility_scripts/regexes/generate_regex.rb +314 -0
  656. data/lib/studium/utility_scripts/regexes/generate_regexes_for_the_available_moodle_links.rb +55 -0
  657. data/lib/studium/utility_scripts/regexes/generate_regexes_for_the_registered_lectures.rb +48 -0
  658. data/lib/studium/utility_scripts/report_outdated_timetable_entries/report_outdated_timetable_entries.rb +142 -0
  659. data/lib/studium/utility_scripts/report_whether_this_lecture_is_registered_in_the_file_lecture_information/report_whether_this_lecture_is_registered_in_the_file_lecture_information.rb +129 -0
  660. data/lib/studium/utility_scripts/resolve_practical_courses_date_conflicts/individual_resolve_practical_courses_date_conflicts.rb +254 -0
  661. data/lib/studium/utility_scripts/resolve_practical_courses_date_conflicts/resolve_practical_courses_date_conflicts.rb +265 -0
  662. data/lib/studium/utility_scripts/scrape_remote_university_url.rb +138 -0
  663. data/lib/studium/utility_scripts/semester_schedule_creator/semester_container.rb +144 -0
  664. data/lib/studium/utility_scripts/semester_schedule_creator/semester_schedule_creator.rb +373 -0
  665. data/lib/studium/utility_scripts/semesterplaner/semesterplaner.rb +311 -0
  666. data/lib/studium/utility_scripts/set_aliases_based_on_this_file.rb +96 -0
  667. data/lib/studium/utility_scripts/show_all_passed_master_lectures/show_all_passed_master_lectures.rb +126 -0
  668. data/lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb +1385 -0
  669. data/lib/studium/utility_scripts/show_descriptions_of_lectures_belonging_to_this_module/constants.rb +23 -0
  670. data/lib/studium/utility_scripts/show_descriptions_of_lectures_belonging_to_this_module/menu.rb +63 -0
  671. data/lib/studium/utility_scripts/show_descriptions_of_lectures_belonging_to_this_module/reset.rb +33 -0
  672. data/lib/studium/utility_scripts/show_descriptions_of_lectures_belonging_to_this_module/run.rb +50 -0
  673. data/lib/studium/utility_scripts/show_descriptions_of_lectures_belonging_to_this_module/show_descriptions_of_lectures_belonging_to_this_module.rb +145 -0
  674. data/lib/studium/utility_scripts/show_lecturers/show_lecturers.rb +147 -0
  675. data/lib/studium/utility_scripts/show_lectures/show_lectures.rb +906 -0
  676. data/lib/studium/utility_scripts/show_lectures_fitting_to_this_language/show_lectures_fitting_to_this_language.rb +121 -0
  677. data/lib/studium/utility_scripts/show_lectures_fitting_to_this_theme/show_lectures_fitting_to_this_theme.rb +105 -0
  678. data/lib/studium/utility_scripts/show_lectures_on_the_commandline/show_lectures_on_the_commandline.rb +3160 -0
  679. data/lib/studium/utility_scripts/show_lectures_on_this_day/show_lectures_on_this_day.rb +150 -0
  680. data/lib/studium/utility_scripts/show_lva_dates_of_this_lecture/show_lva_dates_of_this_lecture.rb +182 -0
  681. data/lib/studium/utility_scripts/show_mixed_bachelor_master_courses/show_mixed_bachelor_master_courses.rb +92 -0
  682. data/lib/studium/utility_scripts/show_outdated_lva_dates/show_outdated_lva_dates.rb +214 -0
  683. data/lib/studium/utility_scripts/show_passed_exams_having_this_grade/show_passed_exams_having_this_grade.rb +91 -0
  684. data/lib/studium/utility_scripts/show_solved_english_lectures/show_solved_english_lectures.rb +139 -0
  685. data/lib/studium/utility_scripts/steop/README.md +4 -0
  686. data/lib/studium/utility_scripts/steop/show_all_steop_lectures.rb +93 -0
  687. data/lib/studium/utility_scripts/steop/steop_lectures_in_this_curriculum.rb +284 -0
  688. data/lib/studium/utility_scripts/steop/steop_lva_dates.rb +119 -0
  689. data/lib/studium/utility_scripts/studienkennzahl/studienkennzahl.rb +116 -0
  690. data/lib/studium/utility_scripts/studium_skeleton/studium_skeleton.rb +241 -0
  691. data/lib/studium/utility_scripts/stundenplan.rb +600 -0
  692. data/lib/studium/utility_scripts/sync_studium_relevant_entries_one_level_downwards.rb +217 -0
  693. data/lib/studium/utility_scripts/ufind/ufind.rb +106 -0
  694. data/lib/studium/utility_scripts/upcoming_mandatory_presence_courses/constants.rb +26 -0
  695. data/lib/studium/utility_scripts/upcoming_mandatory_presence_courses/run.rb +20 -0
  696. data/lib/studium/utility_scripts/upcoming_mandatory_presence_courses/upcoming_mandatory_presence_courses.rb +187 -0
  697. data/lib/studium/utility_scripts/video_lecture_downloader/video_lecture_downloader.rb +107 -0
  698. data/lib/studium/utility_scripts/week_parser/constants.rb +23 -0
  699. data/lib/studium/utility_scripts/week_parser/help.rb +32 -0
  700. data/lib/studium/utility_scripts/week_parser/menu.rb +59 -0
  701. data/lib/studium/utility_scripts/week_parser/misc.rb +373 -0
  702. data/lib/studium/utility_scripts/week_parser/reset.rb +65 -0
  703. data/lib/studium/utility_scripts/week_parser/run.rb +18 -0
  704. data/lib/studium/utility_scripts/week_parser/show.rb +236 -0
  705. data/lib/studium/utility_scripts/week_parser/week_parser.rb +49 -0
  706. data/lib/studium/utility_scripts/weekday_parser.rb +155 -0
  707. data/lib/studium/utility_scripts/weekly_schedule.rb +198 -0
  708. data/lib/studium/utility_scripts/wochenplanung/wochenplanung.rb +267 -0
  709. data/lib/studium/version/version.rb +46 -0
  710. data/lib/studium/www/exams/exams.cgi +54 -0
  711. data/lib/studium/www/fast_ask_exam_question/fast_ask_exam_question.cgi +156 -0
  712. data/lib/studium/www/handle_curricula/handle_curricula.cgi +154 -0
  713. data/lib/studium/www/next_generation_exam_question_trainer/next_generation_exam_question_trainer.cgi +112 -0
  714. data/lib/studium/www/next_generation_exam_question_trainer/solved.cgi +26 -0
  715. data/lib/studium/www/sinatra/app.rb +231 -0
  716. data/lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb +162 -0
  717. data/lib/studium/www/sinatra/misc.rb +115 -0
  718. data/lib/studium/www/statistics/statistics.cgi +82 -0
  719. data/lib/studium/www/upcoming_exams/upcoming_exams.cgi +36 -0
  720. data/lib/studium/yaml/ad_hoc_trainer/README.md +2 -0
  721. data/lib/studium/yaml/ad_hoc_trainer/exam_topics.md +22 -0
  722. data/lib/studium/yaml/allowed_themes_for_courses/allowed_themes_for_courses.yml +348 -0
  723. data/lib/studium/yaml/array_allowed_entries_for_the_file_lecture_information/array_allowed_entries_for_the_file_lecture_information.yml +71 -0
  724. data/lib/studium/yaml/available_exam_topics/available_exam_topics.yml +234 -0
  725. data/lib/studium/yaml/backlog_of_exams.yml +37 -0
  726. data/lib/studium/yaml/colours/custom_colours.yml +50 -0
  727. data/lib/studium/yaml/colours/use_colours.yml +1 -0
  728. data/lib/studium/yaml/current_exams.yml +30 -0
  729. data/lib/studium/yaml/curricula/README.md +39 -0
  730. data/lib/studium/yaml/curricula/bachelor/bachelor_agrarwissenschaften_033255.yml +147 -0
  731. data/lib/studium/yaml/curricula/bachelor/bachelor_biologie_basisblock_033630.yml +71 -0
  732. data/lib/studium/yaml/curricula/bachelor/bachelor_biologie_botanik_033630.yml +100 -0
  733. data/lib/studium/yaml/curricula/bachelor/bachelor_biologie_ecology_033630.yml +74 -0
  734. data/lib/studium/yaml/curricula/bachelor/bachelor_biologie_mikrobiologie_und_genetik_033630.yml +122 -0
  735. data/lib/studium/yaml/curricula/bachelor/bachelor_biologie_molekulare_biologie_033630.yml +106 -0
  736. data/lib/studium/yaml/curricula/bachelor/bachelor_biologie_zoologie_033630.yml +87 -0
  737. data/lib/studium/yaml/curricula/bachelor/bachelor_chemie_033662.yml +165 -0
  738. data/lib/studium/yaml/curricula/bachelor/bachelor_dummy_curriculum.yml +182 -0
  739. data/lib/studium/yaml/curricula/bachelor/bachelor_elektrotechnik_und_informationstechnik_033235.yml +13 -0
  740. data/lib/studium/yaml/curricula/bachelor/bachelor_forstwirtschaft_033225.yml +115 -0
  741. data/lib/studium/yaml/curricula/bachelor/bachelor_informatik_033521.yml +134 -0
  742. data/lib/studium/yaml/curricula/bachelor/bachelor_ktww_033231.yml +84 -0
  743. data/lib/studium/yaml/curricula/bachelor/bachelor_lmbt_033217.yml +121 -0
  744. data/lib/studium/yaml/curricula/bachelor/bachelor_medizinische_informatik_033533.yml +283 -0
  745. data/lib/studium/yaml/curricula/bachelor/bachelor_molekularbiologie_033665.yml +95 -0
  746. data/lib/studium/yaml/curricula/bachelor/bachelor_nutrition_science_033638.yml +119 -0
  747. data/lib/studium/yaml/curricula/bachelor/bachelor_pharmazie_033305.yml +170 -0
  748. data/lib/studium/yaml/curricula/bachelor/bachelor_technische_chemie_033290.yml +131 -0
  749. data/lib/studium/yaml/curricula/bachelor/bachelor_technische_informatik_033535.yml +23 -0
  750. data/lib/studium/yaml/curricula/bachelor/bachelor_ubrm_033227.yml +142 -0
  751. data/lib/studium/yaml/curricula/bachelor/bachelor_verfahrenstechnik_033273.yml +167 -0
  752. data/lib/studium/yaml/curricula/bachelor/bachelor_wirtschaftsinformatik_033526.yml +29 -0
  753. data/lib/studium/yaml/curricula/experimental/bachelor_informatik_in_den_lebenswissenschaften.yml +137 -0
  754. data/lib/studium/yaml/curricula/individual/bachelor_formale_logik.yml +88 -0
  755. data/lib/studium/yaml/curricula/individual/bachelor_informatik_und_molekulare_biologie.yml +1161 -0
  756. data/lib/studium/yaml/curricula/individual/bachelor_vector_based_strategies_in_life_sciences_molecular_medicine_and_biotechnology.yml +1157 -0
  757. data/lib/studium/yaml/curricula/individual/master_bioinformatics_and_nanobiotechnology_in_molecular_medicine.yml +306 -0
  758. data/lib/studium/yaml/curricula/individual/master_vector_based_strategies_in_life_sciences_molecular_medicine_and_biotechnology.yml +741 -0
  759. data/lib/studium/yaml/curricula/master/master_bioinformatik_066875.yml +75 -0
  760. data/lib/studium/yaml/curricula/master/master_biologie_molekulare_mikrobiologie_mikrobielle_oekologie_und_immunbiologie_066830.yml +78 -0
  761. data/lib/studium/yaml/curricula/master/master_biologische_chemie_066863.yml +66 -0
  762. data/lib/studium/yaml/curricula/master/master_dummy_curriculum.yml +197 -0
  763. data/lib/studium/yaml/curricula/master/master_genetik_und_entwicklungsbiologie_066877.yml +89 -0
  764. data/lib/studium/yaml/curricula/master/master_lmbt_066418.yml +112 -0
  765. data/lib/studium/yaml/curricula/master/master_molecular_biology_066865.yml +72 -0
  766. data/lib/studium/yaml/curricula/master/master_molekulare_biologie_066834.yml +151 -0
  767. data/lib/studium/yaml/curricula/master/master_pharmazie_066605.yml +176 -0
  768. data/lib/studium/yaml/curricula/master/master_technische_chemie_066490.yml +123 -0
  769. data/lib/studium/yaml/curricula/outdated/master_bioinformatics_and_molecular_biotechnology_including_aspects_from_molecular_medicine.yml +438 -0
  770. data/lib/studium/yaml/curricula/outdated/master_food_science_and_plant_biotechnology.yml +31 -0
  771. data/lib/studium/yaml/curricula.yml +562 -0
  772. data/lib/studium/yaml/daily_questions_solved/daily_questions_solved.yml +2019 -0
  773. data/lib/studium/yaml/daily_questions_solved/daily_questions_solved.yml~ +1983 -0
  774. data/lib/studium/yaml/default_delay.yml +4 -0
  775. data/lib/studium/yaml/default_encoding.yml +1 -0
  776. data/lib/studium/yaml/directory_to_the_exam_topics.yml +0 -0
  777. data/lib/studium/yaml/editor.yml +1 -0
  778. data/lib/studium/yaml/exams/next_exams_to_do.md +9 -0
  779. data/lib/studium/yaml/file_for_exam_questions.yml +1 -0
  780. data/lib/studium/yaml/german/README.md +2 -0
  781. data/lib/studium/yaml/german/german_to_english_month_names.yml +16 -0
  782. data/lib/studium/yaml/grouped_themes/grouped_themes.yml +264 -0
  783. data/lib/studium/yaml/holidays/holidays.yml +201 -0
  784. data/lib/studium/yaml/important_exams.yml +286 -0
  785. data/lib/studium/yaml/inscription_dates_of_universities.yml +60 -0
  786. data/lib/studium/yaml/lecture_aliases.yml +138 -0
  787. data/lib/studium/yaml/lecture_information/lecture_information.yml +66145 -0
  788. data/lib/studium/yaml/log_dir.yml +1 -0
  789. data/lib/studium/yaml/main_topic/main_topic.yml +11 -0
  790. data/lib/studium/yaml/max_stats/max_stats.yml +262 -0
  791. data/lib/studium/yaml/max_stats.yml +263 -0
  792. data/lib/studium/yaml/meta_themes +1 -0
  793. data/lib/studium/yaml/mitbelegung/README.md +4 -0
  794. data/lib/studium/yaml/mitbelegung/mitbelegung.yml +21 -0
  795. data/lib/studium/yaml/mitteilungsbl/303/244tter/mitteilungsbl/303/244tter.yml +363 -0
  796. data/lib/studium/yaml/n_total_questions.yml +1 -0
  797. data/lib/studium/yaml/rename_konsole_tab.yml +1 -0
  798. data/lib/studium/yaml/roebe/ad_hoc_exam_topics.md +19 -0
  799. data/lib/studium/yaml/roebe/sommersemester_2024_opportunities.md +441 -0
  800. data/lib/studium/yaml/semester_planner/README.md +4 -0
  801. data/lib/studium/yaml/semester_planner/semester_planner.yml +189 -0
  802. data/lib/studium/yaml/show_topic.yml +1 -0
  803. data/lib/studium/yaml/statistics/lecture_information.yml +1 -0
  804. data/lib/studium/yaml/statistics/max_stats.yml +239 -0
  805. data/lib/studium/yaml/statistics/statistics.yml +77 -0
  806. data/lib/studium/yaml/week/01_monday.yml +25 -0
  807. data/lib/studium/yaml/week/02_tuesday.yml +68 -0
  808. data/lib/studium/yaml/week/03_wednesday.yml +63 -0
  809. data/lib/studium/yaml/week/04_thursday.yml +20 -0
  810. data/lib/studium/yaml/week/05_friday.yml +31 -0
  811. data/lib/studium/yaml/week/06_saturday.yml +16 -0
  812. data/lib/studium/yaml/week/07_sunday.yml +0 -0
  813. data/lib/studium/yaml/week/README.md +10 -0
  814. data/lib/studium.rb +5 -0
  815. data/studium.gemspec +82 -0
  816. data/test/testing_colourized_question_and_answer.rb +18 -0
  817. data/test/testing_studium.rb +244 -0
  818. data/test/testing_studium_base_class.rb +31 -0
  819. data/test/testing_the_file_lecture_information.rb +18 -0
  820. data/test/testing_time_component.rb +29 -0
  821. metadata +1042 -0
@@ -0,0 +1,2936 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Studium::Exams::QuestionAnswer
6
+ #
7
+ # This class can handle exam questions and study-related questions.
8
+ #
9
+ # The default use case for this class is from a commandline point of view,
10
+ # e. g. via a terminal.
11
+ #
12
+ # The user can pass a given topic to this class, as a String, such as
13
+ # "microbiology", and then this class will randomly select one of the
14
+ # existing entries fitting to that particular topic at hand. After that
15
+ # step, the exam-question is asked, before the answer is then revealed
16
+ # after a delay. The specified delay is usually fairly small, at about
17
+ # 3 seconds, but this can be set by the user to any different value.
18
+ #
19
+ # The delay, e. g. 3 seconds, is read in from a yaml file (if that
20
+ # file exists, otherwise we will use a default value). Alternatively
21
+ # the delay can be set from the commandline via, for instance:
22
+ #
23
+ # qa 'delay = 5'
24
+ #
25
+ # The topic given thus determines which exam question is to be handled.
26
+ #
27
+ # By default, if no argument is provided to this class, then a random
28
+ # topic (and thus a random question) will be picked, from all the
29
+ # available topics.
30
+ #
31
+ # Take note that every time a question is asked, the "last asked question"
32
+ # information is stored into a file.
33
+ #
34
+ # The "exam pool" constitutes the available, unanswered exams.
35
+ #
36
+ # The method Studium.runmode? will tell us whether we are on
37
+ # the commandline or whether we are used on the www, such as
38
+ # from a .cgi script.
39
+ #
40
+ # This class can operate on one question at a time, or in batch
41
+ # mode, which will call "all questions". (By default, I usually
42
+ # prefer to just have one question asked).
43
+ #
44
+ # Usage examples in ruby code:
45
+ #
46
+ # x = Studium::Exams::QuestionAnswer.new('- Wir können Melanome nach der "ABCDE" Regel beurteilen. Wofür stehen diese Abkürzungen? (1) A: Asymmetry (2) B: Border (3) C: Color (4) D: Diameter (5) E: Evolving')
47
+ # x = Studium::Exams::QuestionAnswer.new('- Nenne die beiden wichtigsten Mechanismen zur Verhinderung der Selbstbefruchtung. A: (1) physische Trennung von männlichen und weiblichen Gametophyten (2) genetisch, über die Selbst-Inkompatibilität')
48
+ # x = Studium::Exams::QuestionAnswer.new('- Nenne die Zucker des Calvin-Zyklus, beginnend von RUBISCO, im "Uhrzeigersinn"! A: (1) 3-Phosphoglycerat (2) 1,3-Bisphosphoglycerat (3) G3P (4) 5-G3P und Ribulose-1-5-Bisphosphat.')
49
+ # x = Studium::Exams::QuestionAnswer.new('- abc? def? ya') { :do_not_run_yet }
50
+ #
51
+ # =========================================================================== #
52
+ # require 'studium/exams/question_answer/question_answer.rb'
53
+ # x = Studium.ask_question 'amg'
54
+ # Studium::Exams::QuestionAnswer.new(ARGV)
55
+ # Studium.return_an_array_for_this_exam_topic
56
+ # y = Studium.ask_question('amg2') { :do_not_run_yet }
57
+ # =========================================================================== #
58
+ require 'studium/base/base.rb'
59
+
60
+ module Studium
61
+
62
+ module Exams
63
+
64
+ class QuestionAnswer < Base # === Studium::Exams::QuestionAnswer
65
+
66
+ require 'studium/exams/exam_question/exam_question.rb'
67
+ require 'studium/statistics/report_how_many_exam_questions_were_answered.rb'
68
+
69
+ # ========================================================================= #
70
+ # === DEFAULT_COLOUR_TO_USE
71
+ # ========================================================================= #
72
+ DEFAULT_COLOUR_TO_USE = :olivedrab
73
+
74
+ # ========================================================================= #
75
+ # === USE_THESE_COLOURS
76
+ #
77
+ # This Hash is used to set up colours. It will be passed to methods
78
+ # that belong to the Colours module ("namespace"), which in turn
79
+ # can be found in the gem called "colours".
80
+ #
81
+ # Using a Hash like this allows the user to customize the colours as
82
+ # well.
83
+ #
84
+ # For the question, we prefer to use :olivedrab.
85
+ # ========================================================================= #
86
+ USE_THESE_COLOURS = {
87
+ one: :steelblue,
88
+ two: :mediumseagreen,
89
+ three: :mediumpurple, # ← Used to be 'peru' up until 23.11.2019.
90
+ four: :olivedrab,
91
+ five: :lightgreen,
92
+ default_colour: DEFAULT_COLOUR_TO_USE # Make use of the colour defined above ^^^ here.
93
+ }
94
+
95
+ # ========================================================================= #
96
+ # === EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_QUESTION
97
+ #
98
+ # This constant is like the constant called
99
+ # EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_ANSWER, except that here
100
+ # we work on double-quotes, aka '"' characters, in a question.
101
+ #
102
+ # As of November 2019, this defaults to false, since we already
103
+ # use many other colours at this point.
104
+ # ========================================================================= #
105
+ EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_QUESTION = false
106
+
107
+ # ========================================================================= #
108
+ # === EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_ANSWER
109
+ # ========================================================================= #
110
+ EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_ANSWER = false
111
+
112
+ # ========================================================================= #
113
+ # === MAY_WE_SHOW_THE_TOPIC
114
+ #
115
+ # If MAY_WE_SHOW_THE_TOPIC is true then we show the topic.
116
+ #
117
+ # We will grab the entry from the yaml file, but we have to make sure
118
+ # that the file exists, before loading it..
119
+ # ========================================================================= #
120
+ _ = "#{::Studium.yaml_directory?}show_topic.yml"
121
+ if File.exist? _
122
+ MAY_WE_SHOW_THE_TOPIC = YAML.load_file(_)
123
+ else
124
+ MAY_WE_SHOW_THE_TOPIC = false
125
+ end
126
+
127
+ # ========================================================================= #
128
+ # === SHALL_WE_DEBUG
129
+ #
130
+ # Shall we debug or shall we not debug. This is specific to this
131
+ # class here.
132
+ # ========================================================================= #
133
+ SHALL_WE_DEBUG = false
134
+
135
+ # ========================================================================= #
136
+ # === SHOW_STATISTICS
137
+ #
138
+ # If SHOW_STATISTICS is true then we will show the statistics.
139
+ # ========================================================================= #
140
+ SHOW_STATISTICS = true
141
+
142
+ # ========================================================================= #
143
+ # === STORE_TEXT
144
+ #
145
+ # Next comes the string that we will save if we set a new delay.
146
+ # ========================================================================= #
147
+ STORE_TEXT = '# ====================================================================== #
148
+ # How long to wait before showing the answer in question, in seconds.
149
+ # ====================================================================== #
150
+ delay: '
151
+
152
+
153
+ # ========================================================================= #
154
+ # === @rename_konsole_tab
155
+ # ========================================================================= #
156
+ @rename_konsole_tab = false
157
+
158
+ # ========================================================================= #
159
+ # === Studium::Exams::QuestionAnswer.rename_konsole_tab?
160
+ # ========================================================================= #
161
+ def self.rename_konsole_tab?
162
+ @rename_konsole_tab
163
+ end
164
+
165
+ # ========================================================================= #
166
+ # === Studium::Exams::QuestionAnswer.set_rename_konsole_tab
167
+ # ========================================================================= #
168
+ def self.set_rename_konsole_tab(i)
169
+ @rename_konsole_tab = i
170
+ end
171
+
172
+ # ========================================================================= #
173
+ # === initialize
174
+ #
175
+ # The very first argument given to this class is usually the topic
176
+ # that is sought - such as "bem1" or "amg1" or "plants", and so
177
+ # forth.
178
+ # ========================================================================= #
179
+ def initialize(
180
+ commandline_arguments = ARGV,
181
+ run_already = true,
182
+ &block
183
+ )
184
+ reset
185
+ set_commandline_arguments(
186
+ commandline_arguments
187
+ )
188
+ # ======================================================================= #
189
+ # === Handle blocks next
190
+ # ======================================================================= #
191
+ if block_given?
192
+ yielded = yield
193
+ case yielded # (case tag)
194
+ # ===================================================================== #
195
+ # === :disable_colours
196
+ # ===================================================================== #
197
+ when :disable_colours,
198
+ :no_colours
199
+ # =================================================================== #
200
+ # The user does not want to use colours in this case, so let's
201
+ # disable colours then.
202
+ # =================================================================== #
203
+ disable_colours
204
+ set_mode :www # ← Experimental as of 13.04.2019.
205
+ # ===================================================================== #
206
+ # === :then_determine_the_split_position_without_using_colours
207
+ # ===================================================================== #
208
+ when :then_determine_the_split_position_without_using_colours
209
+ @internal_hash[:do_determine_the_split_position] = true
210
+ disable_colours
211
+ # ===================================================================== #
212
+ # === :then_determine_the_split_position
213
+ # ===================================================================== #
214
+ when :then_determine_the_split_position
215
+ @internal_hash[:do_determine_the_split_position] = true
216
+ # ===================================================================== #
217
+ # === :then_determine_the_split_position_while_disabling_the_colours
218
+ # ===================================================================== #
219
+ when :then_determine_the_split_position_while_disabling_the_colours
220
+ @internal_hash[:do_determine_the_split_position] = true
221
+ disable_colours
222
+ set_mode :www # ← Experimental as of 13.04.2019.
223
+ # ===================================================================== #
224
+ # === :do_not_run_yet
225
+ # ===================================================================== #
226
+ when :do_not_run_yet
227
+ run_already = false
228
+ end
229
+ end
230
+ case run_already
231
+ # ======================================================================= #
232
+ # === :do_not_run
233
+ #
234
+ # Handle the situation when we do not want to run automatically.
235
+ #
236
+ # This is for arguments such as :dont_run_yet.
237
+ # ======================================================================= #
238
+ when :do_not_run,
239
+ :do_not,
240
+ :dont_run,
241
+ :dont_run_yet,
242
+ :do_not_run_yet
243
+ run_already = false
244
+ # ======================================================================= #
245
+ # === :commandline
246
+ # ======================================================================= #
247
+ when :commandline
248
+ run_already = false
249
+ set_commandline
250
+ end
251
+ run if run_already
252
+ end
253
+
254
+ # ========================================================================= #
255
+ # === reset (reset tag)
256
+ # ========================================================================= #
257
+ def reset
258
+ super()
259
+ infer_the_namespace
260
+ set_be_verbose # Be verbose, output lots of stuff to the user.
261
+ # ======================================================================= #
262
+ # === :exam_question
263
+ #
264
+ # This class is the one that can parse an individual question-answer
265
+ # line.
266
+ # ======================================================================= #
267
+ @internal_hash[:exam_question] = Studium::Exams::ExamQuestion.new { :do_not_run_yet }
268
+ # ======================================================================= #
269
+ # === :dataset_from_the_chosen_exam_topic
270
+ #
271
+ # The next variable must be initially nil, in order to distinguish
272
+ # it from the the startup-situation, before any exam file has been
273
+ # read in.
274
+ # ======================================================================= #
275
+ @internal_hash[:dataset_from_the_chosen_exam_topic] = nil
276
+ # ======================================================================= #
277
+ # === :exam_file
278
+ #
279
+ # This instance variable will keep track where the full path to the
280
+ # exam file can be found.
281
+ # ======================================================================= #
282
+ @internal_hash[:exam_file] = nil
283
+ # ======================================================================= #
284
+ # === :topic_to_use
285
+ # ======================================================================= #
286
+ @internal_hash[:topic_to_use] = nil
287
+ # ======================================================================= #
288
+ # === :debug
289
+ # ======================================================================= #
290
+ @internal_hash[:debug] = SHALL_WE_DEBUG
291
+ # ======================================================================= #
292
+ # === :delay
293
+ # ======================================================================= #
294
+ @internal_hash[:delay] = DEFAULT_DELAY
295
+ # ======================================================================= #
296
+ # === :n_exam_questions_in_total
297
+ # ======================================================================= #
298
+ @internal_hash[:n_exam_questions_in_total] = 0
299
+ # ======================================================================= #
300
+ # === :n_exam_questions_answered
301
+ # ======================================================================= #
302
+ @internal_hash[:n_exam_questions_answered] = 0
303
+ # ======================================================================= #
304
+ # === :may_we_show_the_topic
305
+ # ======================================================================= #
306
+ @internal_hash[:may_we_show_the_topic] = MAY_WE_SHOW_THE_TOPIC
307
+ # ======================================================================= #
308
+ # === :colour_for_answers
309
+ # ======================================================================= #
310
+ @internal_hash[:colour_for_answers] = nil
311
+ # ======================================================================= #
312
+ # === :colour_for_questions
313
+ # ======================================================================= #
314
+ @internal_hash[:colour_for_questions] = nil
315
+ # ======================================================================= #
316
+ # === :result_for_www
317
+ #
318
+ # This can be a String, which is then used for display on the www.
319
+ #
320
+ # Initially it is set to nil, though, to indicate that we will not
321
+ # need it when in commandline-mode.
322
+ # ======================================================================= #
323
+ @internal_hash[:result_for_www] = nil
324
+ # ======================================================================= #
325
+ # === :use_these_colours
326
+ # ======================================================================= #
327
+ @internal_hash[:use_these_colours] = USE_THESE_COLOURS
328
+ # ======================================================================= #
329
+ # === :numbers_in_parens
330
+ # ======================================================================= #
331
+ @internal_hash[:numbers_in_parens] = false
332
+ # ======================================================================= #
333
+ # === :reject_lines_that_end_with_a_done_token
334
+ #
335
+ # If this variable is set to true (which is the default) then all
336
+ # entries that end with [] will be removed.
337
+ # ======================================================================= #
338
+ @internal_hash[:reject_lines_that_end_with_a_done_token] = true
339
+ # ======================================================================= #
340
+ # === :separator_token_to_use_when_asking_questions_and_revealing_the_answer
341
+ #
342
+ # This determines the separator token to be used, when using cliner()
343
+ # or fancy_cliner().
344
+ # ======================================================================= #
345
+ if Studium.shall_we_make_use_of_unicode_symbols?
346
+ @internal_hash[:separator_token_to_use_when_asking_questions_and_revealing_the_answer] = Studium.unicode_horizontal_bar
347
+ else
348
+ @internal_hash[:separator_token_to_use_when_asking_questions_and_revealing_the_answer] = '*'
349
+ end
350
+ set_delay
351
+ # ======================================================================= #
352
+ # The default colours will not be made available when we run in the
353
+ # www-mode. This should come last in the reset() method.
354
+ # ======================================================================= #
355
+ disable_colours if are_we_in_www_mode?
356
+ try_to_load_custom_colours # This must come after disable_colours().
357
+ end
358
+
359
+ # ========================================================================= #
360
+ # === numbers_in_parens?
361
+ # ========================================================================= #
362
+ def numbers_in_parens?
363
+ @internal_hash[:numbers_in_parens]
364
+ end
365
+
366
+ # ========================================================================= #
367
+ # === show_available_topics (topics tag)
368
+ #
369
+ # This method will show which topics are all available.
370
+ #
371
+ # By default, it will also exit after having done so.
372
+ #
373
+ # To invoke this method, try:
374
+ #
375
+ # qa topics?
376
+ # qa --show-available-topics
377
+ #
378
+ # ========================================================================= #
379
+ def show_available_topics(
380
+ shall_we_exit = true
381
+ )
382
+ e
383
+ use_these_topics = Studium.available_topics.sort # And sort it.
384
+ use_these_topics.each_with_index {|category, index|
385
+ # ===================================================================== #
386
+ # Number the results via the index.
387
+ # ===================================================================== #
388
+ index = '%4s' % ('('+(index+1).to_s)
389
+ result = ' '.dup
390
+ if use_colours?
391
+ result << ::Colours::CYAN if commandline?
392
+ end
393
+ result << "#{index}) - " # Add the index here.
394
+ if use_colours? # And "close" the escape-sequences next.
395
+ result << rev if commandline?
396
+ end
397
+ category = category.to_s.delete('_')
398
+ category = steelblue(category) if use_colours?
399
+ result << category
400
+ e result
401
+ }
402
+ e
403
+ exit if shall_we_exit
404
+ end
405
+
406
+ require 'studium/logging/store_last_question_asked_into_file.rb'
407
+ # ========================================================================= #
408
+ # === do_log_related_and_backup_related_actions
409
+ #
410
+ # This method will backup files and similar activities.
411
+ #
412
+ # Note that the method exam_file?() will return a String such as:
413
+ #
414
+ # "/home/x/programming/ruby/src/studium/lib/studium/exam_topics/protein_engineering"
415
+ #
416
+ # ========================================================================= #
417
+ def do_log_related_and_backup_related_actions
418
+ unless Studium.is_in_www_mode?
419
+ Studium.backup_this_exam_file(exam_file?) # { :be_verbose }
420
+ hash = {} # Build up our data structure here, as a Hash.
421
+ hash[:question_was_asked_when] = Time.now
422
+ hash[:question_full_line] = line?
423
+ Studium::Log::StoreLastQuestionAskedIntoFile.new(hash) # { :be_verbose }
424
+ append_into_onto_daily_exam_questions_file
425
+ end
426
+ end
427
+
428
+ # ========================================================================= #
429
+ # === n_questions_already_answered?
430
+ # ========================================================================= #
431
+ def n_questions_already_answered?
432
+ @internal_hash[:n_exam_questions_answered]
433
+ end
434
+
435
+ # ========================================================================= #
436
+ # === show_statistics
437
+ #
438
+ # To invoke this method from the commandline, try:
439
+ #
440
+ # qa --show-statistics
441
+ #
442
+ # ========================================================================= #
443
+ def show_statistics(
444
+ dataset = dataset?
445
+ )
446
+ unless in_www_mode?
447
+ n_questions = n_questions_available?
448
+ n_answered = n_questions_already_answered?
449
+ percentage = (n_answered.to_f * 100) / n_questions
450
+ result = olivedrab(n_questions.to_s)+
451
+ grey(' questions available, ')+
452
+ mediumaquamarine(n_answered.to_s)+
453
+ grey(' (')+
454
+ colourize_percentage(percentage.round(2).to_s+'%')+
455
+ grey(") already answered.#{N}")
456
+ # ===================================================================== #
457
+ # Also add how many questions in absolute numbers have to be answered
458
+ # still.
459
+ # ===================================================================== #
460
+ padded_amount_of_questions_answered = (n_questions - n_answered).to_s
461
+ padded_amount_of_questions_answered =
462
+ padded_amount_of_questions_answered.rjust(n_questions.to_s.size)
463
+ result << "#{crimson(padded_amount_of_questions_answered)} "\
464
+ "#{grey('questions could still be answered. Topic: ')}"\
465
+ "#{olive(return_the_full_expanded_exam_title)}"\
466
+ "#{grey('.')}#{rev}"
467
+ e result
468
+ end
469
+ end; alias report_statistics show_statistics # === report_statistics
470
+
471
+ # ========================================================================= #
472
+ # === result_for_www?
473
+ # ========================================================================= #
474
+ def result_for_www?
475
+ @internal_hash[:result_for_www]
476
+ end; alias result? result_for_www? # === result?
477
+
478
+ # ========================================================================= #
479
+ # === try_to_load_custom_colours
480
+ #
481
+ # This method can be used to designate specific colours for use by
482
+ # this class.
483
+ # ========================================================================= #
484
+ def try_to_load_custom_colours(
485
+ _ = "#{project_yaml_directory?}colours/custom_colours.yml"
486
+ )
487
+ if File.exist? _
488
+ dataset = YAML.load_file(_)
489
+
490
+ if dataset.has_key?('colour_for_one')
491
+ hash_use_these_colours?[:one] = dataset['colour_for_one']
492
+ end
493
+
494
+ if dataset.has_key?('colour_for_two')
495
+ hash_use_these_colours?[:two] = dataset['colour_for_two']
496
+ end
497
+
498
+ if dataset.has_key?('colour_for_three')
499
+ hash_use_these_colours?[:three] = dataset['colour_for_three']
500
+ end
501
+
502
+ if dataset.has_key?('colour_for_four')
503
+ hash_use_these_colours?[:four] = dataset['colour_for_four']
504
+ end
505
+
506
+ if dataset.has_key?('colour_for_five')
507
+ hash_use_these_colours?[:five] = dataset['colour_for_five']
508
+ end
509
+
510
+ set_colour_for_questions(
511
+ dataset['colour_for_questions']
512
+ )
513
+ set_colour_for_answers(
514
+ dataset['colour_for_answers']
515
+ )
516
+ else
517
+ if is_on_roebe?
518
+ opne 'No file could be found at '+sfile(_)+'.'
519
+ end
520
+ end
521
+ end
522
+
523
+ # ========================================================================= #
524
+ # === show_filesize_of_all_exams
525
+ #
526
+ # To call this method, do:
527
+ #
528
+ # qa --filesize?
529
+ #
530
+ # ========================================================================= #
531
+ def show_filesize_of_all_exams
532
+ this_exam_topic = directory_of_the_exam_topics?
533
+ all_filesizes = Dir["#{this_exam_topic}*"].map {|entry|
534
+ File.size?(entry)
535
+ }
536
+ sum = all_filesizes.sum
537
+ sum_in_kb = sum / 1000.0
538
+ sum_in_mb = sum_in_kb / 1000.0
539
+ e "#{rev}The total file size of all exams in "\
540
+ "#{sdir(this_exam_topic)} is:"
541
+ e
542
+ e ' '+simp(sum.to_s)+
543
+ ' Bytes ('+
544
+ sfancy(sum_in_mb.round(2).to_s)+' MB)'
545
+ e
546
+ end
547
+
548
+ # ========================================================================= #
549
+ # === hash_use_these_colours?
550
+ # ========================================================================= #
551
+ def hash_use_these_colours?
552
+ @internal_hash[:use_these_colours]
553
+ end
554
+
555
+ # ========================================================================= #
556
+ # === colourize_https_substring
557
+ #
558
+ # Input that passes into the following method, can look like this:
559
+ #
560
+ # 'Das "CDT-Toxin". => https://www.ncbi.nlm.nih.gov/pubmed/24253566'
561
+ #
562
+ # ========================================================================= #
563
+ def colourize_https_substring(i)
564
+ if i.include? 'https://'
565
+ use_this_regex = /(https:\/\/.+)/ # See: https://rubular.com/r/4quDI8hKxS
566
+ i =~ use_this_regex
567
+ i.gsub!(use_this_regex, slateblue('\1')) if $1
568
+ end
569
+ return i
570
+ end
571
+
572
+ # ========================================================================= #
573
+ # === do_rename_konsole_tab
574
+ # ========================================================================= #
575
+ def do_rename_konsole_tab
576
+ Studium::Exams::QuestionAnswer.set_rename_konsole_tab(true)
577
+ end
578
+
579
+ # ========================================================================= #
580
+ # === do_not_rename_konsole_tab
581
+ # ========================================================================= #
582
+ def do_not_rename_konsole_tab
583
+ Studium::Exams::QuestionAnswer.set_rename_konsole_tab(false)
584
+ end
585
+
586
+ # ========================================================================= #
587
+ # === open_the_last_file_via_your_editor
588
+ # ========================================================================= #
589
+ def open_the_last_file_via_your_editor(
590
+ this_file = last_file?
591
+ )
592
+ open_this_file_in_editor(this_file)
593
+ end
594
+
595
+ # ========================================================================= #
596
+ # === open_this_file_in_editor
597
+ #
598
+ # Open this file in the editor.
599
+ # ========================================================================= #
600
+ def open_this_file_in_editor(
601
+ this_file = __FILE__
602
+ )
603
+ use_this_editor = editor?
604
+ # ======================================================================= #
605
+ # Since as of December 2017, on my home system, I will use nano instead.
606
+ # ======================================================================= #
607
+ use_this_editor = 'nano -w' if is_on_roebe?
608
+ _ = "#{use_this_editor} #{this_file}" #&
609
+ esystem _
610
+ end
611
+
612
+ # ========================================================================= #
613
+ # === custom_colours?
614
+ # ========================================================================= #
615
+ def custom_colours?
616
+ [
617
+ @internal_hash[:colour_for_questions],
618
+ @internal_hash[:colour_for_answers]
619
+ ]
620
+ end
621
+
622
+ # ========================================================================= #
623
+ # === assign_url
624
+ #
625
+ # Only call this method after making a line.include? 'URL:' check.
626
+ # The reason for this is that we will only apply this method on
627
+ # a line that has this substring representing a remote URL.
628
+ # ========================================================================= #
629
+ def assign_url(i)
630
+ if use_unicode_symbols?
631
+ nice_token = '➡' # We will use a slightly prettier symbol for Unicode in this case.
632
+ else
633
+ nice_token = '=>'
634
+ end
635
+ i =~ /URL:\s*(.*)( |)/
636
+ url = sanitize_url($1.to_s.dup) # URL is something like: "http://de.wikipedia.org/wiki/Ester"
637
+ url = url.first if url.is_a? Array
638
+ i = i.dup if i.frozen?
639
+ begin
640
+ # ===================================================================== #
641
+ # The next regex shall also check for input such as:
642
+ #
643
+ # URL: https://en.wikipedia.org/wiki/2,4-Dinitrophenol
644
+ # URL: https://en.wikipedia.org/wiki/File:Histidin_-_Histidine.svg
645
+ #
646
+ # Since as of 11.11.2018, we also include any other entry that
647
+ # starts with 'https:'.
648
+ # ===================================================================== #
649
+ if $1 # See: https://rubular.com/r/rNeLS2MH6f
650
+ remote_URL = $1.to_s.dup
651
+ i.gsub!(/URL:\s*(.*)( |)/, nice_token+' \1') # ← Also add a '=>' token.
652
+ if is_on_roebe?
653
+ # =================================================================== #
654
+ # Store this on my home system in a file, in this case.
655
+ # =================================================================== #
656
+ what = "#{remote_URL}\n"
657
+ into = log_dir?+'last_exam_questions_URL.md'
658
+ append_what_into(what, into)
659
+ end
660
+ end
661
+ i = i.to_s.dup
662
+ return i
663
+ rescue Exception => error
664
+ e "Debugging for `#{sfancy(i.to_s)}`:"
665
+ pp error
666
+ p url.class
667
+ e sfancy(url)
668
+ end
669
+ end
670
+
671
+ # ========================================================================= #
672
+ # === download_exam_topics
673
+ #
674
+ # You can use this method to download all exam topics.
675
+ #
676
+ # To call this, do:
677
+ #
678
+ # qa --dexamtopics
679
+ #
680
+ # ========================================================================= #
681
+ def download_exam_topics
682
+ Studium.download_exam_topics
683
+ end
684
+
685
+ # ========================================================================= #
686
+ # === exam_pool?
687
+ # ========================================================================= #
688
+ def exam_pool?
689
+ @internal_hash[:exam_pool]
690
+ end
691
+
692
+ # ========================================================================= #
693
+ # === return_the_full_expanded_exam_title
694
+ # ========================================================================= #
695
+ def return_the_full_expanded_exam_title(
696
+ exam_title = exam_title?
697
+ )
698
+ return Studium.find_corresponding_exam_title(exam_title)
699
+ end
700
+
701
+ # ========================================================================= #
702
+ # === n_questions_available?
703
+ #
704
+ # Return how many questions are available in the given dataset at hand.
705
+ # ========================================================================= #
706
+ def n_questions_available?
707
+ @internal_hash[:n_exam_questions_in_total]
708
+ end; alias n_exam_questions? n_questions_available? # === n_exam_questions?
709
+ alias n_questions? n_questions_available? # === n_questions?
710
+
711
+ # ========================================================================= #
712
+ # === set_topic_to_use
713
+ #
714
+ # This method has to store the expanded topic name, so that something
715
+ # like "bioanalytik" is actually turned into
716
+ # "bioanalytik_und_biosensoren". The method that handles this part is
717
+ # Studium.find_corresponding_exam_topic().
718
+ #
719
+ # Usage example for this above-mentioned method:
720
+ #
721
+ # x = Studium.find_corresponding_exam_topic('bioanalytik') # => "bioanalytik_und_biosensoren"
722
+ #
723
+ # Whenever a topic is set through this method, this will also be stored
724
+ # into a file. This then allows us to query what the last topic was, e.
725
+ # g. via "qa --last_topic?".
726
+ # ========================================================================= #
727
+ def set_topic_to_use(
728
+ i = first_non_hyphen_argument?
729
+ )
730
+ # ======================================================================= #
731
+ # === Handle Arrays first
732
+ # ======================================================================= #
733
+ i = i.first if i.is_a? Array
734
+ # ======================================================================= #
735
+ # === Handle Hashes next
736
+ #
737
+ # If a Hash is given then we will try to find a specific key in that
738
+ # Hash.
739
+ # ======================================================================= #
740
+ if i.is_a?(Hash) and i.has_key?(:use_this_topic)
741
+ i = i[:use_this_topic]
742
+ end
743
+ case i
744
+ # ======================================================================= #
745
+ # === :random
746
+ #
747
+ # We fetch a random topic via this entry-point.
748
+ # ======================================================================= #
749
+ when :random,
750
+ :random_topic,
751
+ :default,
752
+ 'fetch_a_random_topic',
753
+ 'random_topic',
754
+ 'random',
755
+ 'rand',
756
+ '',
757
+ nil
758
+ i = Studium.random_exam_topic
759
+ # ======================================================================= #
760
+ # === molbio
761
+ #
762
+ # This entry point is special.
763
+ # ======================================================================= #
764
+ when /molbio$/,
765
+ /molekularbiologie$/,
766
+ /molbio\??$/
767
+ i = 'amg|amg2|genex1|gentech1|gentech2|pcr'
768
+ # ======================================================================= #
769
+ # === OLAST
770
+ #
771
+ # Invocation example:
772
+ #
773
+ # qa olast
774
+ #
775
+ # ======================================================================= #
776
+ when /^qlast$/i,
777
+ /^olast$/i # === olast tag
778
+ _ = Studium.file_last_topic?
779
+ if File.exist? _
780
+ i = File.read(_).strip
781
+ else
782
+ opnn; no_file_exists_at(_)
783
+ exit
784
+ end
785
+ end
786
+ i = i.to_s.dup # Work with a non-frozen String past this point.
787
+ # ======================================================================= #
788
+ # If the input has a '|', we assume that the user wants to randomly
789
+ # pick one entry from the given list.
790
+ # ======================================================================= #
791
+ i = i.split('|').shuffle if i.include? '|'
792
+ i.tr!(' ','_') if i.include? ' '
793
+ i.downcase! # Convention is to store the file downcased.
794
+ # ======================================================================= #
795
+ # Before we do the real assignment, we will sanitize this through
796
+ # the Studium.find_corresponding_exam_topic "filter".
797
+ # ======================================================================= #
798
+ if Studium.is_this_a_registered_exam_topic?(i)
799
+ i = Studium.find_corresponding_exam_topic(i)
800
+ @internal_hash[:topic_to_use] = i
801
+ # ===================================================================== #
802
+ # Next we will store the topic into a file, unless we are in www-mode.
803
+ # We may have to lift this restriction eventually, though.
804
+ # ===================================================================== #
805
+ unless in_www_mode?
806
+ store_last_topic_into_file(i)
807
+ end
808
+ else
809
+ opne "Not a registered exam topic: #{i}" if be_verbose?
810
+ end
811
+ end; alias set_exam_topic set_topic_to_use # === set_exam_topic
812
+ alias set_exam_topic_to_use set_topic_to_use # === set_exam_topic_to_use
813
+ alias set_this_topic set_topic_to_use # === set_this_topic
814
+
815
+ # ========================================================================= #
816
+ # === show_all_finished_exam_topics
817
+ #
818
+ # To invoke this method, do:
819
+ #
820
+ # qa --finished?
821
+ #
822
+ # ========================================================================= #
823
+ def show_all_finished_exam_topics
824
+ stats = Studium::Statistics::ReportHowManyExamQuestionsWereAnswered.new {
825
+ :do_not_show_the_result
826
+ }.internal_dataset
827
+ e "#{rev}The following topics are completely answered "\
828
+ "(#{colourize_percentage('100%')} answered ratio)."
829
+ array_finished_topics = []
830
+ stats.select {|key, value|
831
+ percentage = value[:percentage_of_questions_answered]
832
+ if percentage == 100.0
833
+ array_finished_topics << ::Studium.beautify_this_topic(key)
834
+ end
835
+ }
836
+ e
837
+ array_finished_topics.each {|topic|
838
+ e " #{simp(topic)} is completely answered."
839
+ }
840
+ e
841
+ end
842
+
843
+ # ========================================================================= #
844
+ # === show_help_usage (help tag)
845
+ #
846
+ # We show help usage of this class here via this method. It is typically
847
+ # used from the commandline.
848
+ #
849
+ # To show this help message, use this:
850
+ #
851
+ # qa --help
852
+ #
853
+ # ========================================================================= #
854
+ def show_help_usage(
855
+ then_exit = false
856
+ )
857
+ case then_exit
858
+ # ======================================================================= #
859
+ # === :do_exit
860
+ # ======================================================================= #
861
+ when :do_exit,
862
+ :exit
863
+ then_exit = true
864
+ end
865
+ opne "Currently the following extra commands can be issued:#{N}#{N}"
866
+ lpad = ' ' * 4
867
+ e "#{lpad}--set_default_topic= #{yellowrev(' Set a default topic.')}"
868
+ e "#{lpad}TOPICS #{yellowrev(' List all available topics.')}"
869
+ e lpad+'TOTAL '+
870
+ yellowrev(" Show how many questions are known in total.")
871
+ e lpad+'FINISHED '+
872
+ yellowrev(' Show which topics are '\
873
+ 'completely finished (100% answered).')
874
+ e lpad+'EDIT '+
875
+ yellowrev(' To edit the exam questions '\
876
+ 'file, via vim.')
877
+ e lpad+'LAST_TOPIC '+
878
+ yellowrev(' Show the last topic used.')
879
+ e lpad+'BLOCK '+
880
+ yellowrev(' List all questions that '\
881
+ 'were already answered for a given section.')
882
+ e lpad+'OPEN '+
883
+ yellowrev(' Open this file here in an editor.')
884
+ e lpad+'--download-exam-topics '+
885
+ yellowrev(' Download the exam topics.')
886
+ e lpad+'--all-questions '+
887
+ yellowrev(' Ask all questions, including those marked '\
888
+ 'with a trailing "[]".')
889
+ e lpad+'delay? '+
890
+ yellowrev(' show the default delay.')
891
+ e lpad+"'delay = 5' "+
892
+ yellowrev(' to set a new delay to 5 seconds.')
893
+ e lpad+"'set-delay = 5' "+
894
+ yellowrev(' to set a new delay '\
895
+ 'to 5 seconds. (as ^^^ above)')
896
+ if is_on_roebe? # Show more options only on my system.
897
+ e lpad+'rename_tab? '+
898
+ yellowrev(' whether to rename the KDE konsole tab or not.')
899
+ e lpad+'rename_tab: true'+
900
+ yellowrev(' enable renaming of the KDE konsole tab.')
901
+ e lpad+'rename_tab: false'+
902
+ yellowrev(' disable rename of the KDE konsole tab.')
903
+ end
904
+ e
905
+ exit if then_exit
906
+ end
907
+
908
+ # ========================================================================= #
909
+ # === determine_whether_there_are_numbers_in_parens_in_the_answer
910
+ # ========================================================================= #
911
+ def determine_whether_there_are_numbers_in_parens_in_the_answer(
912
+ i = exam_answer?
913
+ )
914
+ if i.include?('(2)') and i.include?('(1)') # We also have to check for (1)
915
+ # ===================================================================== #
916
+ # at the same time, because some answers to exam questions contain
917
+ # just a "(2)" without a corresponding "(1)".
918
+ # ===================================================================== #
919
+ @internal_hash[:numbers_in_parens] = true
920
+ end
921
+ end
922
+
923
+ # ========================================================================= #
924
+ # === exam_answer?
925
+ #
926
+ # This method will always delegate onto the exam-question object.
927
+ # ========================================================================= #
928
+ def exam_answer?
929
+ exam_question_object?.answer?
930
+ end; alias answer? exam_answer? # === answer
931
+
932
+ # ========================================================================= #
933
+ # === store_relevant_information_pertaining_to_the_last_exam_question_asked
934
+ # ========================================================================= #
935
+ def store_relevant_information_pertaining_to_the_last_exam_question_asked
936
+ _ = studium_log_dir?
937
+ mkdir(
938
+ File.dirname(Studium.file_last_topic?)
939
+ )
940
+ # ======================================================================= #
941
+ # Store the last exam topic first:
942
+ # ======================================================================= #
943
+ write_what_into(last_topic?, Studium.file_last_topic?)
944
+ target_directory = "#{_}information_pertaining_to_the_last_exam_question_asked/"
945
+ mkdir(target_directory) unless File.directory?(target_directory)
946
+ # ======================================================================= #
947
+ # === Store the last exam-question-answer next, as a line
948
+ # ======================================================================= #
949
+ last_exam_question_answer = Studium.file_last_question_asked?
950
+ what = line?
951
+ into = last_exam_question_answer
952
+ write_what_into(what, into)
953
+ # ======================================================================= #
954
+ # Store the last exam-question time next:
955
+ # ======================================================================= #
956
+ last_exam_question_answer_time = target_directory+'last_exam_question_answer_time.yml'
957
+ what = YAML.dump(Time.now)
958
+ into = last_exam_question_answer_time
959
+ write_what_into(what, into)
960
+ # ======================================================================= #
961
+ # Store the last exam-question next - this is just the question-part:
962
+ # ======================================================================= #
963
+ last_exam_question = "#{target_directory}last_exam_question.md"
964
+ what = exam_question?
965
+ into = last_exam_question
966
+ write_what_into(what, into)
967
+ end
968
+
969
+ # ========================================================================= #
970
+ # === parse_the_random_line_from_the_obtained_dataset
971
+ # ========================================================================= #
972
+ def parse_the_random_line_from_the_obtained_dataset(i)
973
+ @internal_hash[:exam_question].parse(i)
974
+ end
975
+
976
+ # ========================================================================= #
977
+ # === pick_this_question_answer
978
+ # ========================================================================= #
979
+ def pick_this_question_answer(i)
980
+ set_exam_topic('Custom exam topic')
981
+ parse_the_random_line_from_the_obtained_dataset(i)
982
+ ask_the_question_then_sleep_then_reveal_the_answer_to_that_question
983
+ end
984
+
985
+ # ========================================================================= #
986
+ # === have_all_the_exam_questions_for_this_topic_been_answered_already?
987
+ # ========================================================================= #
988
+ def have_all_the_exam_questions_for_this_topic_been_answered_already?(
989
+ i = topic?
990
+ )
991
+ _ = dataset?.reject {|line| line.end_with?("[]\n") }.size
992
+ _ == 0
993
+ end
994
+
995
+ # ========================================================================= #
996
+ # === default_delay?
997
+ # ========================================================================= #
998
+ def default_delay?
999
+ DEFAULT_DELAY
1000
+ end
1001
+
1002
+ # ========================================================================= #
1003
+ # === delay?
1004
+ # ========================================================================= #
1005
+ def delay?
1006
+ @internal_hash[:delay]
1007
+ end; alias delay delay? # === delay
1008
+
1009
+ # ========================================================================= #
1010
+ # === set_exam_file
1011
+ #
1012
+ # The file location will be something like:
1013
+ #
1014
+ # /Programs/Ruby/3.2.1/lib/ruby/site_ruby/2.3.0/studium/exam_topics/physiologie
1015
+ #
1016
+ # ========================================================================= #
1017
+ def set_exam_file(i)
1018
+ @internal_hash[:exam_file] = i
1019
+ end; alias set_file set_exam_file # === set_file
1020
+
1021
+ # ========================================================================= #
1022
+ # === exam_file?
1023
+ #
1024
+ # This query-method shows as to where the specific file at hand is.
1025
+ # ========================================================================= #
1026
+ def exam_file?
1027
+ @internal_hash[:exam_file]
1028
+ end; alias file? exam_file? # === file?
1029
+ alias which_file? exam_file? # === which_file?
1030
+
1031
+ # ========================================================================= #
1032
+ # === show_the_last_topic
1033
+ #
1034
+ # Invocation example:
1035
+ #
1036
+ # qa --show-last-topic
1037
+ #
1038
+ # ========================================================================= #
1039
+ def show_the_last_topic(
1040
+ _ = Studium.file_last_topic?
1041
+ )
1042
+ if File.exist? _
1043
+ e "#{rev}The last topic was `"+
1044
+ simp(
1045
+ expand_topic(File.read(_).chomp)
1046
+ )+'`.'
1047
+ else
1048
+ opnn; no_file_exists_at(_.to_s)
1049
+ end
1050
+ end
1051
+
1052
+ # ========================================================================= #
1053
+ # === store_delay (store tag)
1054
+ #
1055
+ # This method will store/save the delay into a file.
1056
+ # ========================================================================= #
1057
+ def store_delay(i)
1058
+ Studium.save_this_delay_between_questions_and_answers(i)
1059
+ end
1060
+
1061
+ # ========================================================================= #
1062
+ # === load_file_rename_konsole_tab
1063
+ # ========================================================================= #
1064
+ def load_file_rename_konsole_tab
1065
+ YAML.load_file(FILE_RENAME_KONSOLE_TAB)
1066
+ end
1067
+
1068
+ # ========================================================================= #
1069
+ # === set_all_questions_from_the_topic_to_solved
1070
+ #
1071
+ # This will solve all questions from a given topic.
1072
+ #
1073
+ # Invocation example:
1074
+ #
1075
+ # qa ALL_SOLVED
1076
+ #
1077
+ # ========================================================================= #
1078
+ def set_all_questions_from_the_topic_to_solved
1079
+ if commandline?
1080
+ require 'studium/exams/solve_all_questions_from_this_topic.rb'
1081
+ this_topic = which_topic?
1082
+ e "#{rev}Setting all questions from the topic "\
1083
+ "#{sfancy(this_topic)} to solved."
1084
+ Studium::SolveAllQuestionsFromThisTopic.new(this_topic)
1085
+ end
1086
+ end
1087
+
1088
+ # ========================================================================= #
1089
+ # === report_this_error
1090
+ # ========================================================================= #
1091
+ def report_this_error(
1092
+ error = nil
1093
+ )
1094
+ opne 'We encountered an '+swarn('error')+
1095
+ '. The @index_position was probably '\
1096
+ 'out of range.'
1097
+ opne 'Feedbacking @line next:'
1098
+ pp line?
1099
+ opne "Feedbacking #{royalblue('the split position')} next:"
1100
+ pp split_position?
1101
+ if error
1102
+ pp error
1103
+ pp error.class
1104
+ end
1105
+ end
1106
+
1107
+ # ========================================================================= #
1108
+ # === set_colour_for_questions
1109
+ # ========================================================================= #
1110
+ def set_colour_for_questions(i)
1111
+ @internal_hash[:colour_for_questions] = i.to_sym
1112
+ end
1113
+
1114
+ # ========================================================================= #
1115
+ # === set_colour_for_answers
1116
+ # ========================================================================= #
1117
+ def set_colour_for_answers(i)
1118
+ @internal_hash[:colour_for_answers] = i.to_sym
1119
+ end
1120
+
1121
+ # ========================================================================= #
1122
+ # === report_how_many_topics_are_available
1123
+ # ========================================================================= #
1124
+ def report_how_many_topics_are_available
1125
+ opne 'There are exactly '+
1126
+ simp(Studium.available_topics?.size.to_s)+
1127
+ ' topics available.'
1128
+ end
1129
+
1130
+ # ========================================================================= #
1131
+ # === may_we_show_the_topic?
1132
+ # ========================================================================= #
1133
+ def may_we_show_the_topic?
1134
+ @internal_hash[:may_we_show_the_topic]
1135
+ end; alias may_we_show_the_topic may_we_show_the_topic? # === may_we_show_the_topic
1136
+
1137
+ # ========================================================================= #
1138
+ # === set_may_we_show_the_topic
1139
+ # ========================================================================= #
1140
+ def set_may_we_show_the_topic(
1141
+ i = MAY_WE_SHOW_THE_TOPIC
1142
+ )
1143
+ @internal_hash[:may_we_show_the_topic] = i
1144
+ end; alias may_we_show_the_topic= set_may_we_show_the_topic # === may_we_show_the_topic=
1145
+ alias set_show_topic set_may_we_show_the_topic # === set_show_topic
1146
+
1147
+ # ========================================================================= #
1148
+ # === menu_on_the_commandline_as_a_string
1149
+ # ========================================================================= #
1150
+ def menu_on_the_commandline_as_a_string(
1151
+ i = commandline_as_string
1152
+ )
1153
+ case i
1154
+ # ======================================================================= #
1155
+ # === qa --open
1156
+ #
1157
+ # This entry point can be used to open an exam topic file via the
1158
+ # editor.
1159
+ #
1160
+ # A commandline example follows:
1161
+ #
1162
+ # qa ab2 open
1163
+ #
1164
+ # ======================================================================= #
1165
+ when /open (.+)/,
1166
+ /(.+) open/
1167
+ topic = $1.to_s.dup # Example: qa --open amg
1168
+ topic = find_corresponding_exam_topic(topic)
1169
+ topic = ::Studium.directory_to_my_exam_topics+File.basename(topic)
1170
+ open_this_file_in_editor(topic)
1171
+ exit
1172
+ # ======================================================================= #
1173
+ # === qa "delay = 3.0"
1174
+ #
1175
+ # Invoke this like so:
1176
+ #
1177
+ # qa delay = 3.0
1178
+ #
1179
+ # ======================================================================= #
1180
+ when /^DELAY =? ?(\d{0,1}.\d{1})/i,
1181
+ /^DEL =? ?(\d{0,1}.\d{1})/i,
1182
+ /^set_delay =? ?(\d{0,1}.\d{1})/i,
1183
+ /^set_delay :? ?(\d{0,1}.\d{1})/i,
1184
+ /^set_delay ?(\d{0,1}.\d{1})/i # === qa set_delay 3.1
1185
+ _ = $1.to_s.dup
1186
+ set_and_store_delay(_)
1187
+ end
1188
+ end
1189
+
1190
+ # ========================================================================= #
1191
+ # === topic_to_use?
1192
+ # ========================================================================= #
1193
+ def topic_to_use?
1194
+ @internal_hash[:topic_to_use]
1195
+ end; alias category? topic_to_use? # === category?
1196
+ alias exam_topic? topic_to_use? # === exam_topic?
1197
+ alias exam_title? topic_to_use? # === exam_title?
1198
+ alias which_topic? topic_to_use? # === which_topic?
1199
+ alias last_topic? topic_to_use? # === last_topic?
1200
+ alias topic? topic_to_use? # === topic?
1201
+ alias topic topic_to_use? # === topic
1202
+ alias title? topic_to_use? # === title?
1203
+ alias title topic_to_use? # === title
1204
+
1205
+ # ========================================================================= #
1206
+ # === set_custom_colours
1207
+ #
1208
+ # This setter is, since as of January 2022, just calling two methods now.
1209
+ # This was simpler to maintain than using another ad-hoc Hash.
1210
+ #
1211
+ # Valid keys for the colours should be, for instance, "colour_for_questions"
1212
+ # or "colour_for_answers".
1213
+ # ========================================================================= #
1214
+ def set_custom_colours(i)
1215
+ if i.is_a?(String) and i.include?('|')
1216
+ # ===================================================================== #
1217
+ # Allow custom input, as String, so users can override this.
1218
+ # ===================================================================== #
1219
+ splitted = i.split('|')
1220
+ set_colour_for_questions(splitted.first)
1221
+ set_colour_for_answers(splitted.last)
1222
+ end
1223
+ end
1224
+
1225
+ # ========================================================================= #
1226
+ # === generate_statistical_webpage
1227
+ #
1228
+ # Invoke like so:
1229
+ #
1230
+ # qa --www
1231
+ #
1232
+ # ========================================================================= #
1233
+ def generate_statistical_webpage
1234
+ require 'studium/statistics/report_how_many_exam_questions_were_answered.rb'
1235
+ Studium::Statistics::ReportHowManyExamQuestionsWereAnswered.generate_webpage
1236
+ target = return_pwd+'/Studium/html/statistics.html'
1237
+ open_in_browser(target)
1238
+ end
1239
+
1240
+ # ========================================================================= #
1241
+ # === exam_question?
1242
+ # ========================================================================= #
1243
+ def exam_question?
1244
+ @internal_hash[:exam_question].question?
1245
+ end; alias question? exam_question? # === question?
1246
+
1247
+ # ========================================================================= #
1248
+ # === exam_question_object?
1249
+ # ========================================================================= #
1250
+ def exam_question_object?
1251
+ @internal_hash[:exam_question]
1252
+ end
1253
+
1254
+ # ========================================================================= #
1255
+ # === report_the_delay
1256
+ # ========================================================================= #
1257
+ def report_the_delay
1258
+ e "#{rev}The delay is set to: #{sfancy(delay?.to_s)}"
1259
+ end
1260
+
1261
+ # ========================================================================= #
1262
+ # === set_and_store_delay
1263
+ #
1264
+ # Combine two methods in one here.
1265
+ # ========================================================================= #
1266
+ def set_and_store_delay(i)
1267
+ set_delay(i)
1268
+ store_delay(i)
1269
+ end
1270
+
1271
+ # ========================================================================= #
1272
+ # === read_delay_from_file (load delay)
1273
+ #
1274
+ # Use this method here, read_delay_from_file(), to read in the
1275
+ # default delay from a stored file.
1276
+ # ========================================================================= #
1277
+ def read_delay_from_file(
1278
+ this_file = DELAY_CONSTANT_STORED_HERE
1279
+ )
1280
+ if File.exist? this_file
1281
+ _ = YAML.load_file(DELAY_CONSTANT_STORED_HERE)
1282
+ result = _['delay']
1283
+ else # Else the file does not exist, so we use the default delay.
1284
+ result = DEFAULT_DELAY
1285
+ end
1286
+ return result
1287
+ end
1288
+
1289
+ # ========================================================================= #
1290
+ # === separator_token_to_use_when_asking_questions_and_revealing_the_answer?
1291
+ # ========================================================================= #
1292
+ def separator_token_to_use_when_asking_questions_and_revealing_the_answer?
1293
+ @internal_hash[:separator_token_to_use_when_asking_questions_and_revealing_the_answer]
1294
+ end; alias separator_token_to_be_used? separator_token_to_use_when_asking_questions_and_revealing_the_answer? # === separator_token_to_be_used?
1295
+ alias separator_token? separator_token_to_use_when_asking_questions_and_revealing_the_answer? # === separator_token?
1296
+
1297
+ # ========================================================================= #
1298
+ # === fancy_cliner
1299
+ #
1300
+ # Since as of April 2022 this method can also optionally display some
1301
+ # content. If this is the case then said content will be padded
1302
+ # via '*'.
1303
+ # ========================================================================= #
1304
+ def fancy_cliner(
1305
+ optional_content_to_be_displayed = nil,
1306
+ use_this_as_the_separator_token = separator_token_to_be_used?
1307
+ )
1308
+ print seagreen('') # Always reset the colour here first.
1309
+ if optional_content_to_be_displayed
1310
+ e mediumaquamarine(use_this_as_the_separator_token * 3)+' '+
1311
+ forestgreen( # or lightskyblue
1312
+ optional_content_to_be_displayed
1313
+ )+
1314
+ ' '+
1315
+ mediumaquamarine(
1316
+ use_this_as_the_separator_token * (75 - optional_content_to_be_displayed.size)
1317
+ )
1318
+ else
1319
+ cliner(use_this_as_the_separator_token, :mediumaquamarine)
1320
+ end
1321
+ end
1322
+
1323
+ # ========================================================================= #
1324
+ # === report_the_default_topic_in_use
1325
+ #
1326
+ # This method will report the default topic in use. We must also check
1327
+ # whether the file in questions exists, before proceeding.
1328
+ #
1329
+ # To invoke this, do:
1330
+ #
1331
+ # qa --default-topic?
1332
+ #
1333
+ # ========================================================================= #
1334
+ def report_the_default_topic_in_use(
1335
+ this_file = "#{log_dir?}use_this_exam_topic.yml"
1336
+ )
1337
+ if File.exist? this_file
1338
+ topic = File.read(this_file).chomp
1339
+ e "The default topic in use is: #{simp(topic)}"
1340
+ else
1341
+ e "#{rev}No file exists at `#{sfile(this_file)}`. This "\
1342
+ "means that"
1343
+ e 'no default topic has been set.'
1344
+ e
1345
+ e 'If you wish to designate a default topic, use this invocation:'
1346
+ e
1347
+ e steelblue(' qa --set_default_topic=amg')
1348
+ e steelblue(' qa --set_default_topic=phys')
1349
+ e
1350
+ end
1351
+ end
1352
+
1353
+ # ========================================================================= #
1354
+ # === show_how_many_exam_questions_were_already_solved
1355
+ #
1356
+ # Use this method to show how many exam questions were already solved.
1357
+ #
1358
+ # To invoke this method, do:
1359
+ #
1360
+ # qa SOLVED?
1361
+ #
1362
+ # Or in code, do:
1363
+ #
1364
+ # Studium::Exams.report_how_many_exam_questions_were_already_solved
1365
+ #
1366
+ # ========================================================================= #
1367
+ def show_how_many_exam_questions_were_already_solved
1368
+ Studium.report_how_many_exam_questions_were_already_solved
1369
+ end
1370
+
1371
+ # ========================================================================= #
1372
+ # === report_whether_we_will_show_the_topic
1373
+ # ========================================================================= #
1374
+ def report_whether_we_will_show_the_topic
1375
+ opne 'Will we show the topic of the exams when '\
1376
+ 'asking a question: '+
1377
+ simp(VerboseTruth[may_we_show_the_topic?])
1378
+ end
1379
+
1380
+ # ========================================================================= #
1381
+ # === report_how_many_registered_questions_are_available
1382
+ # ========================================================================= #
1383
+ def report_how_many_registered_questions_are_available(
1384
+ n_questions = ::Studium.n_questions_available?
1385
+ )
1386
+ opne "#{rev}There are #{simp(n_questions.to_s)}#{rev} registered "\
1387
+ "questions available."
1388
+ end
1389
+
1390
+ # ========================================================================= #
1391
+ # === set_exam_question_line
1392
+ # ========================================================================= #
1393
+ def set_exam_question_line(i)
1394
+ @internal_hash[:exam_question].set_exam_question_line(i)
1395
+ end
1396
+
1397
+ # ========================================================================= #
1398
+ # === set_default_topic_for_the_gui
1399
+ # ========================================================================= #
1400
+ def set_default_topic_for_the_gui(
1401
+ what,
1402
+ into = "#{log_dir?}use_this_exam_topic.yml"
1403
+ )
1404
+ opne "Now setting the default topic to `#{simp(what)}`."
1405
+ write_what_into(what, into)
1406
+ end
1407
+
1408
+ # ========================================================================= #
1409
+ # === determine_whether_we_will_rename_the_konsole_tab
1410
+ #
1411
+ # This method should be called from within the method called reset().
1412
+ # ========================================================================= #
1413
+ def determine_whether_we_will_rename_the_konsole_tab
1414
+ if is_on_roebe?
1415
+ if File.exist? FILE_RENAME_KONSOLE_TAB
1416
+ _ = load_file_rename_konsole_tab
1417
+ if _ == true
1418
+ do_rename_konsole_tab
1419
+ else
1420
+ do_not_rename_konsole_tab
1421
+ end
1422
+ else
1423
+ do_not_rename_konsole_tab
1424
+ end
1425
+ else
1426
+ do_not_rename_konsole_tab
1427
+ end
1428
+ end
1429
+
1430
+ # ========================================================================= #
1431
+ # === show_last_question_asked
1432
+ #
1433
+ # This will show the last question asked.
1434
+ # ========================================================================= #
1435
+ def show_last_question_asked(
1436
+ i = store_where?
1437
+ )
1438
+ if File.exist? i
1439
+ e File.read(i)
1440
+ end
1441
+ end
1442
+
1443
+ # ========================================================================= #
1444
+ # === consider_renaming_konsole_tab
1445
+ #
1446
+ # We will delegate to class SetTerminalTitle in order to rename the KDE
1447
+ # konsole title.
1448
+ # ========================================================================= #
1449
+ def consider_renaming_konsole_tab
1450
+ if Studium::Exams::QuestionAnswer.rename_konsole_tab?
1451
+ rename_kde_konsole_tab(topic?)
1452
+ end
1453
+ end
1454
+
1455
+ # ========================================================================= #
1456
+ # === assign_url_or_colourize_https_substring
1457
+ # ========================================================================= #
1458
+ def assign_url_or_colourize_https_substring(i)
1459
+ if i.include?(' URL:')
1460
+ assign_url(i)
1461
+ elsif i.include?(' https://')
1462
+ colourize_https_substring(i)
1463
+ end
1464
+ end
1465
+
1466
+ # ========================================================================= #
1467
+ # === consider_warning_the_user_if_there_are_too_many_exams_registered
1468
+ #
1469
+ # The threshold value of n exam questions at maximum is at 1000
1470
+ # usually.
1471
+ # ========================================================================= #
1472
+ def consider_warning_the_user_if_there_are_too_many_exams_registered(
1473
+ threshold_value = THRESHOLD_VALUE_N_EXAMS_AT_MAXIMUM
1474
+ )
1475
+ if WARN_THE_USER_IF_THERE_ARE_TOO_MANY_QUESTIONS_REGISTERED_IN_AN_EXAM_TOPIC and
1476
+ # ===================================================================== #
1477
+ # Check if we have more questions than we are allowed to have.
1478
+ # ===================================================================== #
1479
+ (n_exam_questions? > threshold_value)
1480
+ e
1481
+ opne swarn('Do note that there are too many exam questions '\
1482
+ 'registered in the file:')
1483
+ e
1484
+ e " #{sfile(which_file?)}"
1485
+ e
1486
+ end
1487
+ end
1488
+
1489
+ # ========================================================================= #
1490
+ # === line?
1491
+ #
1492
+ # Delegate onto class QuestionAnswer here.
1493
+ # ========================================================================= #
1494
+ def line?
1495
+ @internal_hash[:exam_question].line?
1496
+ end
1497
+
1498
+ # ========================================================================= #
1499
+ # === sleep_default_delay
1500
+ #
1501
+ # This method can be used to sleep for the specified duration.
1502
+ #
1503
+ # Since as of April 2012 the method will also handle SIGINT-events
1504
+ # gracefully.
1505
+ # ========================================================================= #
1506
+ def sleep_default_delay(
1507
+ i = delay?
1508
+ )
1509
+ begin
1510
+ sleep(i)
1511
+ rescue Interrupt # We are silent here.
1512
+ exit_program
1513
+ end
1514
+ end; alias default_sleep sleep_default_delay # === default_sleep
1515
+ alias start_default_sleep sleep_default_delay # === start_default_sleep
1516
+ alias do_sleep sleep_default_delay # === do_sleep
1517
+
1518
+ # ========================================================================= #
1519
+ # === show_how_many_exam_questions_were_already_solved_in_german
1520
+ #
1521
+ # Similar to the above, except that we will report in german.
1522
+ #
1523
+ # Invocation example:
1524
+ #
1525
+ # qa --solved-in-german
1526
+ #
1527
+ # ========================================================================= #
1528
+ def show_how_many_exam_questions_were_already_solved_in_german
1529
+ Studium::Exams.report_how_many_exam_questions_were_already_solved(:german)
1530
+ end
1531
+
1532
+ # ========================================================================= #
1533
+ # === main_file_exists?
1534
+ # ========================================================================= #
1535
+ def main_file_exists?(
1536
+ i = exam_file?
1537
+ )
1538
+ i and File.exist?(i)
1539
+ end
1540
+
1541
+ # ========================================================================= #
1542
+ # === edit_sanitize_topics_in_vim
1543
+ #
1544
+ # To trigger this, do:
1545
+ #
1546
+ # qa --vim
1547
+ #
1548
+ # ========================================================================= #
1549
+ def edit_sanitize_topics_in_vim
1550
+ position_in_the_file = 445
1551
+ file =
1552
+ RUBY_STUDIUM_HOME_DIR+'toplevel_methods/find_exam_topic_and_exam_title.rb'
1553
+ _ = 'vim '+file+' +'+position_in_the_file.to_s
1554
+ esystem _
1555
+ end
1556
+
1557
+ # ========================================================================= #
1558
+ # === show_content_of_this_topic
1559
+ #
1560
+ # Invocation example:
1561
+ #
1562
+ # qa ethik --show-everything
1563
+ #
1564
+ # ========================================================================= #
1565
+ def show_content_of_this_topic(
1566
+ i = topic?
1567
+ )
1568
+ dataset = filter_away_invalid_questions(
1569
+ File.readlines(directory_to_the_exam_topics?+i)
1570
+ )
1571
+ dataset.each {|line|
1572
+ e " #{simp(line.chomp)}"
1573
+ }
1574
+ end
1575
+
1576
+ # ========================================================================= #
1577
+ # === try_to_save_the_line (save tag)
1578
+ #
1579
+ # This is called whenever the main line is obtained. The original line
1580
+ # is copied, not any modified variant.
1581
+ #
1582
+ # We will store into a file, which is kept at @store_where.
1583
+ #
1584
+ # It usually defaults to the file /Depot/Studium/last_question_asked.md
1585
+ # or wherever else the base-directory has been defined.
1586
+ # ========================================================================= #
1587
+ def try_to_save_the_line(
1588
+ i = line?
1589
+ )
1590
+ _ = store_where? # Where to store.
1591
+ if File.exist?(File.dirname(_))
1592
+ if debug?
1593
+ opne "Now saving: #{bold_blue(i)} into the file #{sfile(_)}"
1594
+ end if commandline?
1595
+ if File.writable?(File.dirname(_)) # Make sure the base-directory is writeable here.
1596
+ write_what_into(i, _) # Save it.
1597
+ end
1598
+ end
1599
+ end
1600
+
1601
+ # ========================================================================= #
1602
+ # === tell_whether_we_will_rename_the_kde_konsole_tab
1603
+ # ========================================================================= #
1604
+ def tell_whether_we_will_rename_the_kde_konsole_tab
1605
+ e 'Will we rename the KDE konsole tab? '+
1606
+ simp(
1607
+ VerboseTruth[load_file_rename_konsole_tab.to_s]
1608
+ )
1609
+ end
1610
+
1611
+ # ========================================================================= #
1612
+ # === store_where?
1613
+ # ========================================================================= #
1614
+ def store_where?
1615
+ Studium.file_last_question_asked?
1616
+ end
1617
+
1618
+ # ========================================================================= #
1619
+ # === report_file_does_not_exist
1620
+ # ========================================================================= #
1621
+ def report_file_does_not_exist(
1622
+ this_file = exam_file?
1623
+ )
1624
+ opne "#{rev}No file at `#{sfile(this_file)}` exists."
1625
+ end
1626
+
1627
+ # ========================================================================= #
1628
+ # === show_how_many_exam_questions_are_available
1629
+ #
1630
+ # This method can be called by passing in 'TOTAL' as argument.
1631
+ #
1632
+ # Example:
1633
+ #
1634
+ # qa TOTAL?
1635
+ #
1636
+ # ========================================================================= #
1637
+ def show_how_many_exam_questions_are_available
1638
+ n_questions = ::Studium.n_questions_available?.to_s
1639
+ result = 'Total amount of registered questions: '.dup
1640
+ if commandline? and use_colours?
1641
+ result << simp(n_questions.to_s)
1642
+ else
1643
+ result << n_questions.to_s
1644
+ end
1645
+ e result
1646
+ end; alias total show_how_many_exam_questions_are_available # === total (total tag)
1647
+ alias n_total_questions_available? show_how_many_exam_questions_are_available # === n_total_questions_available?
1648
+
1649
+ # ========================================================================= #
1650
+ # === opnn
1651
+ # ========================================================================= #
1652
+ def opnn
1653
+ super(
1654
+ namespace: namespace?,
1655
+ use_colours: use_colours?
1656
+ )
1657
+ end
1658
+
1659
+ # ========================================================================= #
1660
+ # === colour_for_questions?
1661
+ # ========================================================================= #
1662
+ def colour_for_questions?
1663
+ @internal_hash[:colour_for_questions]
1664
+ end
1665
+
1666
+ # ========================================================================= #
1667
+ # === append_into_onto_daily_exam_questions_file
1668
+ # ========================================================================= #
1669
+ def append_into_onto_daily_exam_questions_file(
1670
+ log_dir = "#{log_dir?}daily_exam_questions/"
1671
+ )
1672
+ mkdir(log_dir) unless File.directory?(log_dir)
1673
+ target_file = "#{log_dir}#{dd_mm_yyyy}_daily_exam_questions.md"
1674
+ unless File.exist? target_file
1675
+ append_what_into(
1676
+ '# === Created on '+dd_mm_yyyy+' at '+hh_mm_ss+"\n",
1677
+ target_file
1678
+ )
1679
+ end
1680
+ append_what_into("#{line?}\n", target_file)
1681
+ end
1682
+
1683
+ # ========================================================================= #
1684
+ # === default_colour_as_escape_sequence?
1685
+ # ========================================================================= #
1686
+ def default_colour_as_escape_sequence?
1687
+ if use_colours?
1688
+ use_this_colour = USE_THESE_COLOURS[:default_colour]
1689
+ return ::Colours.remove_trailing_end_from(
1690
+ ::Colours.send(use_this_colour)
1691
+ )
1692
+ end
1693
+ end
1694
+
1695
+ # ========================================================================= #
1696
+ # === set_delay
1697
+ #
1698
+ # Set the default delay value via this method.
1699
+ # ========================================================================= #
1700
+ def set_delay(
1701
+ i = :load_from_file
1702
+ )
1703
+ case i
1704
+ # ======================================================================= #
1705
+ # === :default
1706
+ # ======================================================================= #
1707
+ when :default,
1708
+ :load_from_file,
1709
+ nil
1710
+ # ===================================================================== #
1711
+ # === :delay
1712
+ # ===================================================================== #
1713
+ if File.exist? FILE_DELAY
1714
+ i = YAML.load_file(FILE_DELAY)
1715
+ i = i['delay'] if i.respond_to?('delay')
1716
+ else
1717
+ # =================================================================== #
1718
+ # This is the default if the file can not be found/read. It
1719
+ # can be found in the file studium/constants/delay.rb.
1720
+ # =================================================================== #
1721
+ i = DEFAULT_DELAY
1722
+ end
1723
+ end
1724
+ if i.is_a? Hash
1725
+ i = i['delay']
1726
+ end
1727
+ @internal_hash[:delay] = i.to_f
1728
+ end; alias determine_the_default_delay set_delay # === determine_the_default_delay
1729
+ alias delay= set_delay # === delay=
1730
+
1731
+ # ========================================================================= #
1732
+ # === menu (menu tag)
1733
+ #
1734
+ # This is the main menu-interface of this class, the part of the code
1735
+ # where we take the commandline (if the user has done so) and evaluate
1736
+ # what is to be done.
1737
+ #
1738
+ # By default, we will assume that the user has not given any special
1739
+ # instructions, hence why the default argument is nil.
1740
+ #
1741
+ # Next we show some usage examples:
1742
+ #
1743
+ # qa "delay = 3.0"
1744
+ # qa delay?
1745
+ #
1746
+ # ========================================================================= #
1747
+ def menu(
1748
+ i = commandline_arguments?
1749
+ )
1750
+ if i.is_a? Array
1751
+ i.each {|entry| menu(entry) }
1752
+ else
1753
+ case i # case tag
1754
+ # ===================================================================== #
1755
+ # === qa --nquestions?
1756
+ # ===================================================================== #
1757
+ when /^-?-?n(_|-| )?questions\??$/i
1758
+ report_how_many_registered_questions_are_available
1759
+ exit
1760
+ # ===================================================================== #
1761
+ # === qa amg1 --also-ask-from-solved-questions
1762
+ # === qa amg1 --full-pool
1763
+ # === qa amg1 --all-questions
1764
+ # === qa amg1 --everything
1765
+ #
1766
+ # This entry point allows us to pick a random question from ALL
1767
+ # questions of the given example theme, not only from the pool
1768
+ # that does not end with a trailing "[]".
1769
+ #
1770
+ # And yet another usage example:
1771
+ #
1772
+ # qa agrarmarkt --full
1773
+ #
1774
+ # ===================================================================== #
1775
+ when /^-?-?also(-|_| )?ask(-|_| )?from(-|_| )?solved(-|_| )?questions$/i,
1776
+ /^-?-?full(-|_| )?pool$/i,
1777
+ /^-?-?full$/i,
1778
+ /^-?-?all(-|_| )?questions$/i,
1779
+ /^-?-?everything$/i
1780
+ @internal_hash[:reject_lines_that_end_with_a_done_token] = false
1781
+ # ===================================================================== #
1782
+ # === qa --last-question?
1783
+ # ===================================================================== #
1784
+ when 'LAST?', # qa LAST_QUESTION?
1785
+ /^-?-?last$/,
1786
+ /^-?-?last(_|-)?question\??$/i
1787
+ show_last_question_asked
1788
+ exit_program
1789
+ # ===================================================================== #
1790
+ # === qa --total?
1791
+ # ===================================================================== #
1792
+ when /^-?-?TOTAL\??$/i # qa TOTAL?
1793
+ show_how_many_exam_questions_are_available
1794
+ exit_program
1795
+ # ===================================================================== #
1796
+ # === SHOW_ALL
1797
+ #
1798
+ # Invocation example:
1799
+ #
1800
+ # qa ethik --show-all
1801
+ #
1802
+ # ===================================================================== #
1803
+ when /^-?-?show(_|-)?all$/i,
1804
+ /^-?-?show(_|-)?everything$/i
1805
+ show_content_of_this_topic(topic?)
1806
+ exit
1807
+ # ===================================================================== #
1808
+ # === qa --n-topics
1809
+ # ===================================================================== #
1810
+ when /^-?-?n(_|-)?topics$/i # qa N_TOPICS
1811
+ report_how_many_topics_are_available
1812
+ exit_program
1813
+ # ===================================================================== #
1814
+ # === qa --show-statistics
1815
+ # ===================================================================== #
1816
+ when /^-?-?show(_|-| )?statistics/i
1817
+ show_statistics
1818
+ exit_program
1819
+ # ===================================================================== #
1820
+ # === qa --filesize?
1821
+ # ===================================================================== #
1822
+ when /^-?-?size\??/i,
1823
+ /^-?-?filesize\??/i
1824
+ show_filesize_of_all_exams
1825
+ exit
1826
+ # ===================================================================== #
1827
+ # === qa --show-topic?
1828
+ # ===================================================================== #
1829
+ when /^-?-?show(_|-| )?topic\??/i
1830
+ report_whether_we_will_show_the_topic
1831
+ exit_program
1832
+ # ===================================================================== #
1833
+ # === qa --upload_exams
1834
+ # ===================================================================== #
1835
+ when 'examtopics?',
1836
+ 'upload_exam_topics',
1837
+ /^upload_?exams/,
1838
+ 'uexams',
1839
+ 'uexam'
1840
+ Studium.upload_exam_questions { :be_verbose }
1841
+ # ===================================================================== #
1842
+ # === qa ALL_SOLVED
1843
+ #
1844
+ # This entry point will mark all questions from a particular topic
1845
+ # to "solved", that is, to have been answered already.
1846
+ #
1847
+ # Usage example:
1848
+ #
1849
+ # qa agrarmarkt --all-solved
1850
+ #
1851
+ # ===================================================================== #
1852
+ when /^-?-?all(-|_| )?solved$/i
1853
+ set_all_questions_from_the_topic_to_solved
1854
+ exit
1855
+ # ===================================================================== #
1856
+ # === qa OPEN
1857
+ #
1858
+ # This entry point exists to edit this file here.
1859
+ # ===================================================================== #
1860
+ when 'OPEN',
1861
+ 'OPENALL',
1862
+ 'OALL',
1863
+ /^-?-?open$/
1864
+ open_this_file_in_editor
1865
+ exit_program
1866
+ # ===================================================================== #
1867
+ # === qa --ask_last_topic
1868
+ # ===================================================================== #
1869
+ when /^-?-?ask(_|-)?last(_|-)?topic$/
1870
+ target_file = "#{log_dir?}use_this_exam_topic.yml"
1871
+ if File.exist? target_file
1872
+ use_this_topic = YAML.load_file(
1873
+ target_file
1874
+ )
1875
+ set_use_this_topic(use_this_topic)
1876
+ else
1877
+ no_file_exists_at(target_file)
1878
+ end
1879
+ exit_program
1880
+ # ===================================================================== #
1881
+ # === qa ftp
1882
+ # ===================================================================== #
1883
+ when 'ftp',
1884
+ /^ftp(_|-)?upload$/
1885
+ Studium.upload_exam_questions { :be_verbose }
1886
+ exit_program
1887
+ # ===================================================================== #
1888
+ # === qa EDIT
1889
+ # ===================================================================== #
1890
+ when /^-?-?edit$/i,
1891
+ /^-?-?vim$/i
1892
+ edit_sanitize_topics_in_vim
1893
+ exit_program
1894
+ # ===================================================================== #
1895
+ # === qa --set_default_topic=phys
1896
+ # ===================================================================== #
1897
+ when /^-?-?set_default_topic=(.+)/,
1898
+ /^-?-?set-default-topic=(.+)/,
1899
+ /^-?-?topic=(.+)/,
1900
+ /^-?-?setdefaulttopic=(.+)/
1901
+ set_default_topic_for_the_gui($1.to_s)
1902
+ exit
1903
+ # ===================================================================== #
1904
+ # === qa --rename-tab?
1905
+ # ===================================================================== #
1906
+ when 'rename_tab?',
1907
+ '--rename-tab?',
1908
+ 'renametab',
1909
+ 'renametab?' # qa rename_tab?
1910
+ tell_whether_we_will_rename_the_kde_konsole_tab
1911
+ exit_program
1912
+ # ===================================================================== #
1913
+ # === qa --download-exam-topics
1914
+ # ===================================================================== #
1915
+ when /download_?exam_?topics/,
1916
+ /((_|-)+(_|-)+download(_|-)+exam(_|-)+topics)/,
1917
+ /^-?-?dexamtopics/
1918
+ download_exam_topics
1919
+ # ===================================================================== #
1920
+ # === qa --delay?
1921
+ # ===================================================================== #
1922
+ when 'del?',
1923
+ 'DELAY?',
1924
+ 'speed?', # qa delay?
1925
+ 'del',
1926
+ /^-?-?delay\??$/i
1927
+ report_the_delay
1928
+ exit_program(:no_newline)
1929
+ # ===================================================================== #
1930
+ # === qa LASTTOPIC
1931
+ # ===================================================================== #
1932
+ when /^-?-?last(_|-)?topic$/i,
1933
+ /^-?-?show(_|-)?last(_|-)?topic$/i,
1934
+ 'ltopic?'
1935
+ show_the_last_topic
1936
+ exit
1937
+ # ===================================================================== #
1938
+ # === qa --set-delay=2.8
1939
+ # ===================================================================== #
1940
+ when /^-?-?set(-|_| )?delay=(.+)/
1941
+ set_and_store_delay($2.to_s.dup)
1942
+ exit
1943
+ # ===================================================================== #
1944
+ # === qa --www
1945
+ # ===================================================================== #
1946
+ when /^-?-?www$/i
1947
+ generate_statistical_webpage
1948
+ exit
1949
+ # ===================================================================== #
1950
+ # === qa --finished?
1951
+ # ===================================================================== #
1952
+ when /^-?-?finished\??$/i
1953
+ show_all_finished_exam_topics
1954
+ exit
1955
+ # ===================================================================== #
1956
+ # === qa --help?
1957
+ # ===================================================================== #
1958
+ when 'HELP',
1959
+ 'help',
1960
+ '--help',
1961
+ '--hep',
1962
+ '--help?',
1963
+ 'help?'
1964
+ show_help_usage(:do_exit)
1965
+ # ===================================================================== #
1966
+ # === ptype --openlast
1967
+ # ===================================================================== #
1968
+ when /^OPEN(_|-)?LAST$/i,
1969
+ /^OLAST$/i
1970
+ open_the_last_file_via_your_editor
1971
+ exit
1972
+ # ===================================================================== #
1973
+ # === qa --german?
1974
+ # ===================================================================== #
1975
+ when 'SOLVED_GERMAN?',
1976
+ 'german',
1977
+ 'german?',
1978
+ 'in_german?',
1979
+ 'n_solved_in_german?',
1980
+ 'nsolved2?',
1981
+ 'n_german?',
1982
+ '--german?',
1983
+ /^-?-?solved(_|-)?in(_|-)?german$/i
1984
+ show_how_many_exam_questions_were_already_solved_in_german
1985
+ exit_program
1986
+ # ===================================================================== #
1987
+ # === qa --nsolved?
1988
+ # ===================================================================== #
1989
+ when /SOLVED/,
1990
+ 'N_SOLVED?',
1991
+ 'n_solved?',
1992
+ '--nsolved?',
1993
+ '--nsolved',
1994
+ 'nsolved',
1995
+ '--english?',
1996
+ '--english',
1997
+ 'english',
1998
+ 'english?'
1999
+ show_how_many_exam_questions_were_already_solved
2000
+ exit_program
2001
+ # ===================================================================== #
2002
+ # === qa --log-dir?
2003
+ #
2004
+ # This entry point would tell us that the log directory output is at
2005
+ # e. g. "/home/x/Temp/studium/".
2006
+ # ===================================================================== #
2007
+ when /^-?-?log\??$/i,
2008
+ /^-?-?log(-|_| )?dir\??$/i, # === qa log-dir?
2009
+ /^-?-?store(-|_| )?where\??$/i,
2010
+ /^-?-?dir\??$/i
2011
+ e "#{rev}The log directory can be found at: #{sdir(log_dir?)}"
2012
+ exit
2013
+ # ===================================================================== #
2014
+ # === qa --all-topics?
2015
+ #
2016
+ # Entry point for showing all available exam-topics:
2017
+ #
2018
+ # qa --show_topics
2019
+ #
2020
+ # ===================================================================== #
2021
+ when /^-?-?ALL/,
2022
+ /^-?-?TOPICS/,
2023
+ /^-?-?available(_|-)?topics\??$/i,
2024
+ /^-?-?topics\??$/i,
2025
+ /^-?-?show(_|-)?topics$/i,
2026
+ /^-?-?all(_|-)?topics$/i,
2027
+ /^-?-?ALL(-|_| )?TOPICS$/i,
2028
+ /^-?-?all(-|_| )?topics\??$/i,
2029
+ /^-?-?all(-|_| )?topics\??$/i,
2030
+ /^-?-?show(-|_| )?available(-|_| )?topics$/i,
2031
+ /^-?-?show(-|_| )?all(-|_| )?exam(-|_| )?topics$/i,
2032
+ 'detailed_topic'
2033
+ show_available_topics # This also includes an exit-step.
2034
+ exit
2035
+ # ===================================================================== #
2036
+ # === qa --default-topic?
2037
+ # ===================================================================== #
2038
+ when /^-?-?default(_|-)?topic\??$/i
2039
+ report_the_default_topic_in_use
2040
+ exit
2041
+ else
2042
+ if ::Studium.is_this_an_exam_topic?(i)
2043
+ set_exam_topic(i)
2044
+ end
2045
+ end
2046
+ end
2047
+ end
2048
+
2049
+ # ========================================================================= #
2050
+ # === do_not_assume_numbers_in_parens
2051
+ # ========================================================================= #
2052
+ def do_not_assume_numbers_in_parens
2053
+ @internal_hash[:numbers_in_parens] = false # Reset it here.
2054
+ end
2055
+
2056
+ # ========================================================================= #
2057
+ # === ensure_that_the_directory_for_the_daily_questions_exists
2058
+ # ========================================================================= #
2059
+ def ensure_that_the_directory_for_the_daily_questions_exists(
2060
+ i = Studium.file_daily_questions_solved?
2061
+ )
2062
+ _ = File.dirname(i)
2063
+ unless File.directory? _
2064
+ mkdir(_)
2065
+ end
2066
+ end
2067
+
2068
+ # ========================================================================= #
2069
+ # === invoke_all_the_necessary_steps_before_the_question_is_asked
2070
+ # ========================================================================= #
2071
+ def invoke_all_the_necessary_steps_before_the_question_is_asked
2072
+ ensure_that_the_directory_for_the_daily_questions_exists
2073
+ do_not_assume_numbers_in_parens
2074
+ determine_the_exam_topic
2075
+ end; alias initial_steps invoke_all_the_necessary_steps_before_the_question_is_asked # === initial_steps
2076
+ alias initialize_the_dataset invoke_all_the_necessary_steps_before_the_question_is_asked # === initialize_the_dataset
2077
+
2078
+ # ========================================================================= #
2079
+ # === notify_the_user_that_all_questions_have_been_answered_already
2080
+ # ========================================================================= #
2081
+ def notify_the_user_that_all_questions_have_been_answered_already(
2082
+ which_topic = which_topic?
2083
+ )
2084
+ opne 'All questions have already been answered '
2085
+ opne "for the topic `#{orange(which_topic)}`. "\
2086
+ "#{slateblue(cheering_person?)}"
2087
+ e
2088
+ end
2089
+
2090
+ # ========================================================================= #
2091
+ # === determine_the_exam_topic
2092
+ #
2093
+ # This variant also stores the exam-topic into a file, unless we are
2094
+ # using the www-variant of this class.
2095
+ # ========================================================================= #
2096
+ def determine_the_exam_topic
2097
+ exam_topic = first_non_hyphen_argument?
2098
+ if exam_topic.nil? or exam_topic.empty?
2099
+ opne 'Please provide an exam topic.'
2100
+ else
2101
+ exam_topic = ::Studium.expand_this_exam_topic(exam_topic)
2102
+ set_exam_topic_to_use(exam_topic)
2103
+ store_last_topic_into_file unless in_www_mode?
2104
+ end
2105
+ end; alias determine_the_topic determine_the_exam_topic # === determine_the_topic
2106
+
2107
+ # ========================================================================= #
2108
+ # === store_last_topic_into_file
2109
+ #
2110
+ # This method will store the last-exam-topic into a local file.
2111
+ #
2112
+ # By default we will not report this activity.
2113
+ # ========================================================================= #
2114
+ def store_last_topic_into_file(
2115
+ what = exam_topic?,
2116
+ into = Studium.file_last_topic? # This would store into: "/root/Studium/last_topic.md"
2117
+ )
2118
+ base_dir = File.dirname(into)
2119
+ unless File.directory?(base_dir)
2120
+ mkdir(base_dir) # This is a directory such as "/home/x/Temp/studium/last_topic/".
2121
+ end
2122
+ write_what_into(what, into)
2123
+ end
2124
+
2125
+ # ========================================================================= #
2126
+ # === dataset_from_the_chosen_exam_topic?
2127
+ # ========================================================================= #
2128
+ def dataset_from_the_chosen_exam_topic?
2129
+ @internal_hash[:dataset_from_the_chosen_exam_topic]
2130
+ end; alias dataset? dataset_from_the_chosen_exam_topic? # === dataset?
2131
+ alias dataset_from_the_file? dataset_from_the_chosen_exam_topic? # === dataset_from_the_file?
2132
+
2133
+ # ========================================================================= #
2134
+ # === determine_how_many_exam_questions_have_been_answered_and_how_many_remain_unanswered
2135
+ # ========================================================================= #
2136
+ def determine_how_many_exam_questions_have_been_answered_and_how_many_remain_unanswered(
2137
+ i = dataset_from_the_chosen_exam_topic?
2138
+ )
2139
+ # ======================================================================= #
2140
+ # === :n_exam_questions_unanswered
2141
+ # ======================================================================= #
2142
+ @internal_hash[:n_exam_questions_unanswered] = i.size
2143
+ # ======================================================================= #
2144
+ # === :n_exam_questions_answered
2145
+ # ======================================================================= #
2146
+ @internal_hash[:n_exam_questions_answered] = (
2147
+ @internal_hash[:n_exam_questions_in_total] - i.size
2148
+ )
2149
+ end
2150
+
2151
+ # ========================================================================= #
2152
+ # === set_dataset_from_the_chosen_exam_topic
2153
+ # ========================================================================= #
2154
+ def set_dataset_from_the_chosen_exam_topic(i)
2155
+ @internal_hash[:dataset_from_the_chosen_exam_topic] = i
2156
+ if i
2157
+ # ===================================================================== #
2158
+ # === :n_exam_questions_in_total
2159
+ #
2160
+ # Keep a record of the total number of exam questions here.
2161
+ # ===================================================================== #
2162
+ @internal_hash[:n_exam_questions_in_total] = i.size
2163
+ i = filter_away_invalid_questions(i)
2164
+ if @internal_hash[:reject_lines_that_end_with_a_done_token]
2165
+ i = filter_away_already_answered_questions(i)
2166
+ end
2167
+ # ===================================================================== #
2168
+ # Next we must keep track of the unanswered exam questions.
2169
+ # ===================================================================== #
2170
+ set_exam_pool(i) if i
2171
+ determine_how_many_exam_questions_have_been_answered_and_how_many_remain_unanswered(i)
2172
+ end
2173
+ end; alias set_dataset_from_the_file set_dataset_from_the_chosen_exam_topic # === set_dataset_from_the_file
2174
+ alias set_dataset set_dataset_from_the_chosen_exam_topic # === set_dataset
2175
+
2176
+ # ========================================================================= #
2177
+ # === show_the_header
2178
+ # ========================================================================= #
2179
+ def show_the_header(
2180
+ topic_to_use = topic_to_use?
2181
+ )
2182
+ e steelblue(topic_to_use)
2183
+ end
2184
+
2185
+ # ========================================================================= #
2186
+ # === default_colour?
2187
+ # ========================================================================= #
2188
+ def default_colour?
2189
+ USE_THESE_COLOURS[:default_colour]
2190
+ end
2191
+
2192
+ # ========================================================================= #
2193
+ # === colour_for_answers?
2194
+ # ========================================================================= #
2195
+ def colour_for_answers?
2196
+ @internal_hash[:colour_for_answers]
2197
+ end
2198
+
2199
+ # ========================================================================= #
2200
+ # === set_exam_pool
2201
+ #
2202
+ # The "exam pool" constitutes the available, unanswered exams.
2203
+ #
2204
+ # What this means, essentially, is that every line ending with a '[]'
2205
+ # will be disregarded.
2206
+ # ========================================================================= #
2207
+ def set_exam_pool(i = nil)
2208
+ @internal_hash[:exam_pool] = i
2209
+ end
2210
+
2211
+ # ========================================================================= #
2212
+ # === line_contains_underline_token?
2213
+ # ========================================================================= #
2214
+ def line_contains_underline_token?(i)
2215
+ @internal_hash[:exam_question].line_contains_underline_token?(i)
2216
+ end
2217
+
2218
+ # ========================================================================= #
2219
+ # === line_contains_italic_token?
2220
+ # ========================================================================= #
2221
+ def line_contains_italic_token?(i)
2222
+ @internal_hash[:exam_question].line_contains_italic_token?(i)
2223
+ end
2224
+
2225
+ # ========================================================================= #
2226
+ # === line_contains_bold_token?
2227
+ # ========================================================================= #
2228
+ def line_contains_bold_token?(i)
2229
+ @internal_hash[:exam_question].line_contains_bold_token?(i)
2230
+ end
2231
+
2232
+ # ========================================================================= #
2233
+ # === show_line
2234
+ # ========================================================================= #
2235
+ def show_line
2236
+ e exam_question_line?
2237
+ end
2238
+
2239
+ # ========================================================================= #
2240
+ # === word_wrap_at?
2241
+ # ========================================================================= #
2242
+ def word_wrap_at?
2243
+ @internal_hash[:exam_question].word_wrap_at?
2244
+ end
2245
+
2246
+ # ========================================================================= #
2247
+ # === return_colour_hash_for_the_answer
2248
+ #
2249
+ # This method will return a Hash that may look like this:
2250
+ #
2251
+ # {
2252
+ # one: :steelblue,
2253
+ # two: :dodgerblue,
2254
+ # three: :tomato,
2255
+ # four: :orange,
2256
+ # five: :olivedrab,
2257
+ # rev: colour_for_answer
2258
+ # }
2259
+ #
2260
+ # ========================================================================= #
2261
+ def return_colour_hash_for_the_answer
2262
+ new_hash = hash_use_these_colours?
2263
+ new_hash.update(
2264
+ rev: colour_for_answers?
2265
+ )
2266
+ return new_hash
2267
+ end
2268
+
2269
+ # ========================================================================= #
2270
+ # === return_colour_hash_for_the_question
2271
+ # ========================================================================= #
2272
+ def return_colour_hash_for_the_question
2273
+ new_hash = hash_use_these_colours?
2274
+ new_hash.update(
2275
+ rev: colour_for_questions?
2276
+ )
2277
+ return new_hash
2278
+ end
2279
+
2280
+ # ========================================================================= #
2281
+ # === do_ask_the_exam_question (question tag, ask tag)
2282
+ #
2283
+ # Simply display the question via this method.
2284
+ #
2285
+ # This method assumes that an instance of class ExamObject is passed
2286
+ # to it.
2287
+ # ========================================================================= #
2288
+ def do_ask_the_exam_question(
2289
+ i = exam_question_object?
2290
+ )
2291
+ question = i.question?
2292
+ answer = i.answer?
2293
+ # ======================================================================= #
2294
+ # First warn the user if there are too many exams registered. This
2295
+ # should be shown after the topic has been optionally displayed.
2296
+ # Afterwards we will begin to ask the exam-question at hand.
2297
+ # ======================================================================= #
2298
+ consider_warning_the_user_if_there_are_too_many_exams_registered
2299
+ # Store it into @internal_hash[:dataset_from_the_file].
2300
+ store_relevant_information_pertaining_to_the_last_exam_question_asked
2301
+ # ======================================================================= #
2302
+ # Next, handle the commandline situation:
2303
+ # ======================================================================= #
2304
+ if commandline?
2305
+ consider_renaming_konsole_tab # Consider renaming the konsole tab first.
2306
+ print return_either_grey_or_the_custom_colour_for_questions
2307
+ # ===================================================================== #
2308
+ # === Show the topic if the user requested us to do so. Since as of
2309
+ # April 2022 this is now embedded into the cliner-result.
2310
+ # ===================================================================== #
2311
+ if may_we_show_the_topic?
2312
+ fancy_cliner(
2313
+ Studium.find_corresponding_exam_title(exam_title?, be_verbose?)
2314
+ )
2315
+ e
2316
+ else
2317
+ fancy_cliner
2318
+ end
2319
+ end
2320
+ do_show_this_question(question) # 1) show the exam-question
2321
+ do_sleep # 2) sleep using the proper delay
2322
+ determine_whether_there_are_numbers_in_parens_in_the_answer
2323
+ do_show_this_answer(answer) # 3) reveal the exam-answer
2324
+ end; alias do_ask_the_question do_ask_the_exam_question # === do_ask_the_question
2325
+ alias ask_the_exam_question do_ask_the_exam_question # === ask_the_exam_question
2326
+ alias ask_the_question do_ask_the_exam_question # === ask_the_question
2327
+ alias ask_this_question do_ask_the_exam_question # === ask_this_question
2328
+ alias show_question do_ask_the_exam_question # === show_question
2329
+ alias ask_the_question_then_sleep_then_reveal_the_answer_to_that_question do_ask_the_exam_question # === ask_the_question_then_sleep_then_reveal_the_answer_to_that_question
2330
+ alias ask_question_then_show_the_answer_after_a_delay do_ask_the_exam_question # === ask_question_then_show_the_answer_after_a_delay
2331
+ alias do_ask_a_random_question_before_showing_the_answer do_ask_the_exam_question # === ask_question_then_show_the_answer_after_a_delay
2332
+ alias show_question_then_sleep_then_show_answer do_ask_the_exam_question # === show_question_then_sleep_then_show_answer
2333
+ alias ask_sleep_show do_ask_the_exam_question # === ask_sleep_show
2334
+ alias ask_the_question_then_reveal_the_answer do_ask_the_exam_question # === ask_the_question_then_reveal_the_answer
2335
+
2336
+ # ========================================================================= #
2337
+ # === colourize_answer
2338
+ # ========================================================================= #
2339
+ def colourize_answer(i)
2340
+ return ::Studium::Colours.send(colour_for_answers?.to_sym, i)
2341
+ end
2342
+
2343
+ # ========================================================================= #
2344
+ # === do_show_this_question
2345
+ # ========================================================================= #
2346
+ def do_show_this_question(
2347
+ this_question = exam_question?,
2348
+ use_this_colour = colour_for_questions?
2349
+ )
2350
+ # ======================================================================= #
2351
+ # First, handle the commandline situation, which is the default
2352
+ # situation:
2353
+ # ======================================================================= #
2354
+ if commandline?
2355
+ # ===================================================================== #
2356
+ # === Handle underlined text next
2357
+ # ===================================================================== #
2358
+ if line_contains_underline_token?(this_question) and use_colours?
2359
+ # =================================================================== #
2360
+ # Colourize <ud> for underline next:
2361
+ # =================================================================== #
2362
+ this_question = replace_underline_token_with_default_colour(
2363
+ this_question,
2364
+ use_this_colour
2365
+ )
2366
+ end
2367
+ # ===================================================================== #
2368
+ # === Handle italic text next
2369
+ # ===================================================================== #
2370
+ if line_contains_italic_token?(this_question) and use_colours?
2371
+ # =================================================================== #
2372
+ # Colourize <i> for italic next:
2373
+ # =================================================================== #
2374
+ this_question = replace_italic_token_with_default_colour(
2375
+ this_question,
2376
+ use_this_colour
2377
+ )
2378
+ end
2379
+ # ===================================================================== #
2380
+ # === Colourize words in quotes
2381
+ #
2382
+ # Next, consider colourizing all questions that have at the least 2
2383
+ # '"' characters. These will be colourized.
2384
+ # ===================================================================== #
2385
+ if EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_ANSWER
2386
+ if use_colours? and (this_question.count('"') > 1)
2387
+ use_this_regex = /"(.+?\s*.*?)"/ # See: http://rubular.com/r/6WK5NjMJld
2388
+ use_this_colour = ::Colours.send(colour_for_answers?) { :omit_end }
2389
+ this_question.gsub!(
2390
+ use_this_regex,
2391
+ '"'+steelblue('\1'.delete(N))+
2392
+ use_this_colour+'"'
2393
+ )
2394
+ end
2395
+ end
2396
+ # ===================================================================== #
2397
+ # We need to find the proper colour first, if we use colours that is:
2398
+ # ===================================================================== #
2399
+ if use_colours?
2400
+ if ::Studium::Colours.respond_to?(use_this_colour.to_sym)
2401
+ # =================================================================== #
2402
+ # Alright, we have this colour registered.
2403
+ # =================================================================== #
2404
+ this_question = ::Studium::Colours.send(use_this_colour.to_sym, this_question)+
2405
+ rev
2406
+ else
2407
+ e 'The argument passed ('+use_this_colour.to_s+
2408
+ ') is not supported.'
2409
+ end
2410
+ end
2411
+ # ===================================================================== #
2412
+ # Output the result finally, by making use of the toplevel method
2413
+ # Colours.replace_number_words_with_the_corresponding_html_colour().
2414
+ # ===================================================================== #
2415
+ if use_colours?
2416
+ this_question = ::Colours.replace_html_like_tokens(
2417
+ this_question
2418
+ ) { return_colour_hash_for_the_question }
2419
+ end
2420
+ if use_colours? and ::Colours.respond_to?(:fancy_parse)
2421
+ e ::Colours.fancy_parse(this_question, use_this_colour)
2422
+ else
2423
+ e this_question
2424
+ end
2425
+ e; e
2426
+ else # else tag
2427
+ # ===================================================================== #
2428
+ # === WWW mode
2429
+ #
2430
+ # Else we assume that this class is used on the web.
2431
+ # ===================================================================== #
2432
+ result = ''.dup
2433
+ result << "#{this_question}#{N}<br><br>"
2434
+ @internal_hash[:result_for_www] = result
2435
+ # ===================================================================== #
2436
+ # Next, show the question, unless we operate in WWW mode.
2437
+ # ===================================================================== #
2438
+ e result unless www_mode?
2439
+ end
2440
+ end
2441
+
2442
+ # ========================================================================= #
2443
+ # === obtain_dataset_from_this_exam_topic (obtain tag)
2444
+ # ========================================================================= #
2445
+ def obtain_dataset_from_this_exam_topic(
2446
+ i = exam_topic?,
2447
+ use_this_base_directory = Studium.directory_to_the_exam_topics?
2448
+ )
2449
+ # ======================================================================= #
2450
+ # Here we must obtain the dataset for the given exam topic.
2451
+ # ======================================================================= #
2452
+ target_file = use_this_base_directory+
2453
+ i.to_s
2454
+ set_dataset_from_the_chosen_exam_topic(nil) # Always reset it first.
2455
+ if File.exist?(target_file)
2456
+ set_exam_file(target_file) # Keep a reference to the exam-file here.
2457
+ dataset = obtain_exam_questions_from_this_file(target_file)
2458
+ set_dataset_from_the_chosen_exam_topic(dataset)
2459
+ else
2460
+ report_file_does_not_exist(target_file)
2461
+ end
2462
+ end; alias try_to_read_in_the_dataset_from_the_corresponding_exam_file obtain_dataset_from_this_exam_topic # === try_to_read_in_the_dataset_from_the_corresponding_exam_file
2463
+
2464
+ # ========================================================================= #
2465
+ # === do_show_this_answer (answer tag, answers tag, reveal tag, show tag)
2466
+ #
2467
+ # This method will show the proper answer to the given exam question at
2468
+ # hand.
2469
+ #
2470
+ # The second argument to this method, called `include_numbers_in_parens`,
2471
+ # can be used to keep track as to whether we have numbers such as (2).
2472
+ # ========================================================================= #
2473
+ def do_show_this_answer(
2474
+ use_this_answer = exam_question_object?.answer?, # 1st argument
2475
+ include_numbers_in_parens = numbers_in_parens?, # 2nd argument
2476
+ padding_to_use = ' ', # 3rd argument
2477
+ use_colours = use_colours? # 4th argument
2478
+ )
2479
+ use_this_answer = use_this_answer.dup # Always work on a copy past this point.
2480
+ # ======================================================================= #
2481
+ # Try to cut down at about 76 characters per line, or whatever the
2482
+ # limit-per-line is. We have to ignore special tags, though, such
2483
+ # as <u> or <orange>. We also have to call this BEFORE replacing
2484
+ # these tags with the corresponding escape values.
2485
+ # ======================================================================= #
2486
+ unless include_numbers_in_parens
2487
+ string_without_tags = remove_tags_from_this_input(use_this_answer.dup)
2488
+ n_characters_to_consider_in_the_line = string_without_tags.size
2489
+ if n_characters_to_consider_in_the_line > word_wrap_at?
2490
+ use_this_answer = word_wrap(use_this_answer, word_wrap_at?) # word-wrap is a value such as 85.
2491
+ use_this_answer.gsub!(/\n/, N+LEFT_PADDING) if use_this_answer.include? N # Also pad these newlines.
2492
+ end
2493
+ end
2494
+ if use_this_answer.include?(' URL:') or use_this_answer.include?(' https://')
2495
+ assign_url_or_colourize_https_substring(use_this_answer) if use_colours?
2496
+ end
2497
+ # ======================================================================= #
2498
+ # === Handle URLs next
2499
+ # ======================================================================= #
2500
+ if use_this_answer.include? ' URL:' # This is the valid form; the check is necessary.
2501
+ # ===================================================================== #
2502
+ # Since as of May 2022, if we are on a roebe-system, we will also
2503
+ # assign to the xorg-buffer next. We have to supply a regex to do
2504
+ # this for us.
2505
+ # ===================================================================== #
2506
+ use_this_regex = /URL: (https?.*)/ # See: https://rubular.com/r/xJfOSCoi0Q7TWS
2507
+ use_this_answer =~ use_this_regex
2508
+ set_xorg_buffer($1.to_s.dup)
2509
+ use_this_answer = assign_url(use_this_answer)
2510
+ # ======================================================================= #
2511
+ # === Handle entries that include the substring ' https://'
2512
+ # ======================================================================= #
2513
+ elsif use_this_answer.include? ' https://'
2514
+ use_this_answer = colourize_https_substring(use_this_answer) if use_colours?
2515
+ end
2516
+ # ======================================================================= #
2517
+ # === result
2518
+ #
2519
+ # The variable result will eventually contain what we will display to
2520
+ # the user.
2521
+ # ======================================================================= #
2522
+ result = padding_to_use.dup # Use four spaces as indent, since as of March 2023.
2523
+ use_this_answer.rstrip!
2524
+ # ======================================================================= #
2525
+ # Next we must replace the number-words with the corresponding HTML
2526
+ # colour. So, for instance, <one> will eventually become
2527
+ # <steelblue>. Before we do so, though, we will check for the
2528
+ # String "(2)". If it can be found then we first will insert newlines.
2529
+ # ======================================================================= #
2530
+ # ======================================================================= #
2531
+ # === Emphasize words in quotes in a given question
2532
+ #
2533
+ # Next, consider colourizing all questions that have at the least 2
2534
+ # '"' characters. These will be colourized if a certain constant is
2535
+ # set to true.
2536
+ # ======================================================================= #
2537
+ if EMPHASIZE_WORDS_IN_QUOTES_IN_A_GIVEN_QUESTION and use_colours and
2538
+ !include_numbers_in_parens
2539
+ if commandline? and (use_this_answer.count('"') > 1) # More than one '"'.
2540
+ use_this_answer = use_this_answer.dup
2541
+ use_this_regex = /"(.+?\s*.*?)"/ # See: https://rubular.com/r/6WK5NjMJld
2542
+ # =================================================================== #
2543
+ # Next make use of the default colour to use.
2544
+ # =================================================================== #
2545
+ use_this_colour = ::Studium::Colours.send(colour_for_questions?) { :omit_end }
2546
+ use_this_answer.gsub!(
2547
+ use_this_regex,
2548
+ '"'+forestgreen('\1'.delete(N))+ # forestgreen is the hardcoded colour to be used for now.
2549
+ use_this_colour+'"'
2550
+ )
2551
+ end
2552
+ end
2553
+ # ======================================================================= #
2554
+ # === Get rid of (2) and similar numbers
2555
+ #
2556
+ # We assume this to also include (1) and (3) and so forth here. We will
2557
+ # add newlines at the correct positions next.
2558
+ # ======================================================================= #
2559
+ if use_this_answer.include? '(2)'
2560
+ 12.times { |iteration_number_n| iteration_number_n += 1
2561
+ use_this_answer.sub!(
2562
+ /(\(#{iteration_number_n}\))/,
2563
+ "\n\\1"
2564
+ )
2565
+ }
2566
+ use_this_answer.lstrip!
2567
+ end
2568
+ # ======================================================================= #
2569
+ # Do some more text-processing next:
2570
+ # ======================================================================= #
2571
+ if use_colours? and !www_mode?
2572
+ # ===================================================================== #
2573
+ # === Handle italic text next
2574
+ # ===================================================================== #
2575
+ if line_contains_italic_token?(use_this_answer)
2576
+ if use_this_colour.nil?
2577
+ use_this_colour = ::Studium::Colours.send(colour_for_answers?) { :omit_end }
2578
+ end
2579
+ # =================================================================== #
2580
+ # Colourize <i> for italic next:
2581
+ # =================================================================== #
2582
+ use_this_answer = replace_italic_token_with_default_colour(use_this_answer)+
2583
+ use_this_colour.to_s
2584
+ end
2585
+ # ===================================================================== #
2586
+ # === Handle entries that are between <ud>foo</ud> tags
2587
+ # ===================================================================== #
2588
+ if line_contains_underline_token?(result)
2589
+ # =================================================================== #
2590
+ # Colourize <ud> for underline next:
2591
+ # =================================================================== #
2592
+ result = replace_underline_token_with_default_colour(result).to_s+
2593
+ colour_for_answers?.to_s
2594
+ end
2595
+ # ===================================================================== #
2596
+ # === Handle entries that are between <b>foo</b> tags
2597
+ # ===================================================================== #
2598
+ if line_contains_bold_token?(result) and use_colours?
2599
+ # =================================================================== #
2600
+ # Colourize <b> for bold font-style next:
2601
+ # =================================================================== #
2602
+ result = replace_bold_token_with_default_colour(result)+
2603
+ use_this_colour
2604
+ end
2605
+ # use_this_colour = ::Studium::Colours.send(colour_for_answers?) { :omit_end }
2606
+ use_this_colour = ::Colours::HtmlColoursMethods.send(colour_for_answers?,'') { :omit_end }
2607
+ # ===================================================================== #
2608
+ # Now we can colourize everything:
2609
+ # ===================================================================== #
2610
+ use_this_answer = colourize_answer(use_this_answer)
2611
+ if use_this_answer.include?(' URL:')
2612
+ use_this_answer.gsub!(/ URL:/, royalblue(' →')+use_this_colour)
2613
+ end
2614
+ # ===================================================================== #
2615
+ # Colourize the parens - and also add a leading newline. So this
2616
+ # part is only valid for the leading part, before the answer
2617
+ # is shown.
2618
+ # ===================================================================== #
2619
+ if use_this_answer.include? '(2)'
2620
+ # =================================================================== #
2621
+ # Do a word wrap if the size range from the part up to the first
2622
+ # '(' is larger than the allowed characters per line.
2623
+ #
2624
+ # Since as of August 2019 we will honour HTML colour-tags though
2625
+ # and add that to the subrange size.
2626
+ # =================================================================== #
2627
+ subrange = use_this_answer[0 .. (use_this_answer.index('(') - 1)].dup
2628
+ subrange_size = subrange.size
2629
+ if does_this_line_include_a_html_colour?(subrange)
2630
+ subrange_size += return_this_line_has_n_characters_as_html_colour_tags(subrange)
2631
+ end
2632
+ if subrange_size > word_wrap_at? # Check the subrange-size against the word-wrap threshold here.
2633
+ use_this_answer[0 .. (use_this_answer.index('(') - 1)] = ''.dup
2634
+ subrange = word_wrap(subrange, word_wrap_at?).dup+N
2635
+ use_this_answer[0,0] = subrange
2636
+ end
2637
+ 12.downto(1) { |iteration_number_n|
2638
+ if use_this_answer.include?('('+iteration_number_n.to_s+')')
2639
+ # =============================================================== #
2640
+ # Perform a .sub next:
2641
+ # =============================================================== #
2642
+ use_this_answer.sub!(
2643
+ /\((#{iteration_number_n})\)/,
2644
+ slategray('(')+
2645
+ skyblue("\\1")+
2646
+ slategray(')')+
2647
+ ::Colours::HtmlColoursMethods.send(colour_for_answers?,'') { :omit_end }
2648
+ )
2649
+ end
2650
+ }
2651
+ end
2652
+ end
2653
+ if ::Colours.is_this_replacement_worthy?(use_this_answer)
2654
+ use_this_answer = ::Colours.replace_html_like_tokens(
2655
+ use_this_answer
2656
+ ) { return_colour_hash_for_the_answer }
2657
+ end
2658
+ # ======================================================================= #
2659
+ # === Colourize https-links, if we use colours.
2660
+ #
2661
+ # This will also include links to wikipedia.
2662
+ # ======================================================================= #
2663
+ if use_this_answer.include?('https://')
2664
+ use_this_regex =
2665
+ /(https:\/\/.+)$/ # See: https://rubular.com/r/6x1Ua6Lio67IdK
2666
+ use_this_answer.sub!(
2667
+ use_this_regex,
2668
+ mediumaquamarine('\\1')+ # This is the colour to be used for links.
2669
+ use_this_colour
2670
+ )
2671
+ end
2672
+ result << use_this_answer # Append the modified answer onto the result.
2673
+ # ======================================================================= #
2674
+ # === Handle the case where the result has newlines
2675
+ # ======================================================================= #
2676
+ if result.include? "\n"
2677
+ result = result.split("\n").map {|entry|
2678
+ entry = entry.dup if entry.frozen?
2679
+ entry.lstrip!
2680
+ entry.prepend(padding_to_use) unless entry.start_with?(padding_to_use)
2681
+ entry
2682
+ }.join("\n")
2683
+ result << "\n"
2684
+ end
2685
+ result << "\n\n" # Always have two newlines appended.
2686
+ # ======================================================================= #
2687
+ # Add a <div> element if we run in www-mode.
2688
+ # ======================================================================= #
2689
+ if www_mode?
2690
+ e '<div id="answer_div">'+N
2691
+ e use_this_answer # Use the unmodified original input in this case.
2692
+ e "</div>\n"
2693
+ else
2694
+ e result
2695
+ end
2696
+ end; alias reveal_the_exam_answer do_show_this_answer # === reveal_the_exam_answer
2697
+ alias reveal_the_answer do_show_this_answer # === reveal_the_answer
2698
+ alias show_this_answer do_show_this_answer # === show_this_answer
2699
+ alias show_the_answer do_show_this_answer # === show_the_answer
2700
+ alias show_answer do_show_this_answer # === show_answer
2701
+ alias do_reveal_the_answer do_show_this_answer # === reveal_the_exam_answer
2702
+
2703
+ # ========================================================================= #
2704
+ # === register_last_modified_file
2705
+ # ========================================================================= #
2706
+ def register_last_modified_file(
2707
+ i = exam_file?
2708
+ )
2709
+ Studium.set_last_file_for_exam_questions(i) # , :be_verbose
2710
+ end
2711
+
2712
+ # ========================================================================= #
2713
+ # === run (run tag)
2714
+ # ========================================================================= #
2715
+ def run
2716
+ menu_on_the_commandline_as_a_string
2717
+ menu
2718
+ invoke_all_the_necessary_steps_before_the_question_is_asked
2719
+ exam_topic = exam_topic?
2720
+ if exam_topic and !exam_topic.nil?
2721
+ if is_this_a_registered_exam_topic?(exam_topic)
2722
+ set_topic_to_use(exam_topic)
2723
+ obtain_dataset_from_this_exam_topic(exam_topic)
2724
+ select_random_entry_from_the_exam_topic_or_warn_the_user_if_all_questions_were_already_answered
2725
+ # =================================================================== #
2726
+ # After the answer has been shown, it is time to display some statistics.
2727
+ # =================================================================== #
2728
+ show_statistics
2729
+ do_log_related_and_backup_related_actions
2730
+ # =================================================================== #
2731
+ # Register the last file that was modified.
2732
+ # =================================================================== #
2733
+ register_last_modified_file
2734
+ else
2735
+ opne sfancy(exam_topic)+' is not a registered exam topic.'
2736
+ end
2737
+ end
2738
+ end
2739
+
2740
+ # ========================================================================= #
2741
+ # === select_random_entry_from_the_exam_topic_or_warn_the_user_if_all_questions_were_already_answered
2742
+ # ========================================================================= #
2743
+ def select_random_entry_from_the_exam_topic_or_warn_the_user_if_all_questions_were_already_answered(
2744
+ i = exam_pool? # We need to ask from the exam-pool, aka the unanswered exam-questions.
2745
+ )
2746
+ if i.empty? or have_all_the_exam_questions_for_this_topic_been_answered_already?(exam_topic?)
2747
+ notify_the_user_that_all_questions_have_been_answered_already
2748
+ else
2749
+ sample = i.sample
2750
+ set_exam_question_line(sample) # Keep a reference.
2751
+ try_to_save_the_line(sample)
2752
+ @internal_hash[:exam_question].evaluate_this_line(sample)
2753
+ do_ask_the_exam_question(exam_question_object?)
2754
+ return sample # And return it, just in case we may want to use it.
2755
+ end
2756
+ end; alias pick_a_random_line_from_the_obtained_dataset select_random_entry_from_the_exam_topic_or_warn_the_user_if_all_questions_were_already_answered # === pick_a_random_line_from_the_obtained_dataset
2757
+
2758
+ # ========================================================================= #
2759
+ # === Studium::Exams::QuestionAnswer[]
2760
+ # ========================================================================= #
2761
+ def self.[](i = ARGV)
2762
+ new(i)
2763
+ end
2764
+
2765
+ end
2766
+
2767
+ # =========================================================================== #
2768
+ # === Studium::Exams[]
2769
+ #
2770
+ # This will simply use AskQuestion as defined above.
2771
+ #
2772
+ # Usage examples, including aliases:
2773
+ #
2774
+ # amg = Studium::Exams['amg']
2775
+ # qa = Exams.question_answer('yo', :dont_run_yet)
2776
+ #
2777
+ # =========================================================================== #
2778
+ def self.[](i, run_already = true)
2779
+ Studium::Exams::QuestionAnswer.new(i, run_already)
2780
+ end; self.instance_eval { alias ask_question [] } # === ::Studium::Exams.ask_question
2781
+
2782
+ # =========================================================================== #
2783
+ # === Studium::Exams.question_answer
2784
+ # =========================================================================== #
2785
+ def self.question_answer(
2786
+ topic = 'random_topic',
2787
+ run_already = true,
2788
+ &block
2789
+ )
2790
+ Studium::Exams::QuestionAnswer.new(topic, run_already, &block)
2791
+ end
2792
+
2793
+ end
2794
+
2795
+ # =========================================================================== #
2796
+ # === Studium.return_an_array_for_this_exam_topic
2797
+ #
2798
+ # This is similar to the above method, but it will only return a two-member
2799
+ # Array.
2800
+ # =========================================================================== #
2801
+ def self.return_an_array_for_this_exam_topic(i)
2802
+ _ = return_question_answer_and_the_whole_exam_line_as_array(i)
2803
+ return [_[0], _[1]]
2804
+ end
2805
+
2806
+ # =========================================================================== #
2807
+ # === Studium.delay_for_exam_questions?
2808
+ # =========================================================================== #
2809
+ def self.delay_for_exam_questions?
2810
+ ::Studium::DEFAULT_DELAY
2811
+ end
2812
+
2813
+ # =========================================================================== #
2814
+ # === Studium.random_exam_topic?
2815
+ #
2816
+ # This method will return a random exam topic when it is called.
2817
+ #
2818
+ # Usage examples:
2819
+ #
2820
+ # Studium.random_exam_topic? # => "epigenetik"
2821
+ # Studium.random_exam_topic? # => "abfall_als_ressource"
2822
+ # Studium.random_exam_topic? # => "embryologie_und_entwicklung"
2823
+ #
2824
+ # =========================================================================== #
2825
+ def self.random_exam_topic?
2826
+ ::Studium::Exams.all_topics_as_short_name.sort.sample
2827
+ end
2828
+
2829
+ # =========================================================================== #
2830
+ # === Studium.return_question_answer_and_the_whole_exam_line_as_array
2831
+ # =========================================================================== #
2832
+ def self.return_question_answer_and_the_whole_exam_line_as_array(
2833
+ topic = 'random_topic',
2834
+ &block
2835
+ )
2836
+ _ = ::Studium::Exams::QuestionAnswer.new(topic, :do_not_run_yet, &block)
2837
+ if topic.is_a?(String) and topic.include?('-')
2838
+ _.set_exam_question_line_and_then_parse_that_line(topic)
2839
+ else
2840
+ _.invoke_all_the_necessary_steps_before_the_question_is_asked
2841
+ end
2842
+ _.disable_colours
2843
+ # ========================================================================= #
2844
+ # We will return the proper Array next:
2845
+ # ========================================================================= #
2846
+ [
2847
+ _.question?,
2848
+ _.answer?.to_s.delete("\n").squeeze(' '),
2849
+ _.line?
2850
+ ]
2851
+ end
2852
+
2853
+ # =========================================================================== #
2854
+ # === Studium.return_question_answer_as_array
2855
+ #
2856
+ # This method will return the question-answer combination, as an Array.
2857
+ #
2858
+ # It will not make use of any colours; the reason for this is because
2859
+ # when this method was added as of the 13.04.2019, it was to be used
2860
+ # primarily on the www.
2861
+ #
2862
+ # If the input is a String and contains '- ' then we assume that we do
2863
+ # NOT want to find a specific topic. Instead we will use the given
2864
+ # input as exam-question + exam-answer as such.
2865
+ #
2866
+ # Invocation examples:
2867
+ #
2868
+ # x = Studium.return_question_answer_as_array('amg1')
2869
+ # x = Studium.return_question_answer_as_array('biotech1')
2870
+ # x = Studium.return_question_answer_as_array(:biotech2)
2871
+ # x = Studium.return_question_answer_as_array('- In Ruby: <one>Bundler</one> likes ... ? Gemfile.lock.')
2872
+ #
2873
+ # =========================================================================== #
2874
+ def self.return_question_answer_as_array(
2875
+ topic = 'random_topic',
2876
+ &block
2877
+ )
2878
+ _ = ::Studium::Exams::QuestionAnswer.new(topic, :do_not_run_yet, &block)
2879
+ if topic.is_a?(String) and topic.include?('-')
2880
+ pp _
2881
+ _.set_exam_question_line_and_then_parse_that_line(topic)
2882
+
2883
+ else
2884
+ _.invoke_all_the_necessary_steps_before_the_question_is_asked
2885
+ end
2886
+ _.disable_colours
2887
+ # ========================================================================= #
2888
+ # We will return the proper Array next:
2889
+ # ========================================================================= #
2890
+ [
2891
+ _.question?,
2892
+ _.answer?.to_s.delete("\n").squeeze(' ')
2893
+ ]
2894
+ end; self.instance_eval { alias determine_question_answer_from_this return_question_answer_as_array } # === Studium.determine_question_answer_from_this
2895
+ self.instance_eval { alias determine_question_answer_from_this_line return_question_answer_as_array } # === Studium.determine_question_answer_from_this_line
2896
+ self.instance_eval { alias return_question_answer_from_this_exam_topic return_question_answer_as_array } # === Studium.return_question_answer_from_this_exam_topic
2897
+
2898
+ # =========================================================================== #
2899
+ # === Studium.random_question
2900
+ #
2901
+ # This method will ask a random exam question.
2902
+ # =========================================================================== #
2903
+ def self.random_question
2904
+ ask_question(:random)
2905
+ end
2906
+
2907
+ # =========================================================================== #
2908
+ # === Studium.ask_question
2909
+ #
2910
+ # This provides an easier API to ask a question.
2911
+ #
2912
+ # Usage example:
2913
+ #
2914
+ # x = Studium.ask_question 'amg'
2915
+ # y = Studium.ask_question('amg2') { :do_not_run_yet }
2916
+ #
2917
+ # =========================================================================== #
2918
+ def self.ask_question(
2919
+ i = ARGV,
2920
+ run_already = true,
2921
+ &block
2922
+ )
2923
+ Studium::Exams::QuestionAnswer.new(i, run_already, &block)
2924
+ end; self.instance_eval { alias question_answer ask_question } # === Studium.question_answer
2925
+ self.instance_eval { alias new_exam ask_question } # === Studium.new_exam
2926
+ self.instance_eval { alias ask_question ask_question } # === Studium.ask_question
2927
+ self.instance_eval { alias ask_exam_question ask_question } # === Studium.ask_exam_question
2928
+
2929
+ end
2930
+
2931
+ if __FILE__ == $PROGRAM_NAME
2932
+ alias e puts
2933
+ Studium::Exams::QuestionAnswer.new(ARGV)
2934
+ # _ask_exam_question = Studium::Exams::QuestionAnswer.new(ARGV)
2935
+ # pp Studium.return_question_answer_as_array(:biotech2)
2936
+ end # qa amg1