Module: Studium::Exams
- Extended by:
- Colours
- Defined in:
- lib/studium/exams/frozen.rb,
lib/studium/exams/cycle.rb,
lib/studium/exams/exams.rb,
lib/studium/exams/exam/exam.rb,
lib/studium/exams/next_exam.rb,
lib/studium/project/project.rb,
lib/studium/exams/next_exams.rb,
lib/studium/exams/exam_topics.rb,
lib/studium/exams/solved/solved.rb,
lib/studium/exams/remote_ftp_url.rb,
lib/studium/exams/dataset/dataset.rb,
lib/studium/exams/exams_this_week.rb,
lib/studium/exams/show_themes/menu.rb,
lib/studium/exams/show_themes/misc.rb,
lib/studium/exams/show_themes/reset.rb,
lib/studium/exams/upload_exam_topics.rb,
lib/studium/exams/timetable/constants.rb,
lib/studium/exams/timetable/timetable.rb,
lib/studium/exams/repeat_last_question.rb,
lib/studium/exams/last_exams/last_exams.rb,
lib/studium/exams/show_themes/constants.rb,
lib/studium/exams/upcoming_exams_dataset.rb,
lib/studium/exams/ask_exam_topic_question.rb,
lib/studium/exams/exam_bubble/exam_bubble.rb,
lib/studium/exams/exam_registration_at/help.rb,
lib/studium/exams/exam_registration_at/menu.rb,
lib/studium/exams/exam_registration_at/reset.rb,
lib/studium/exams/average_grade/average_grade.rb,
lib/studium/exams/exam_question/exam_question.rb,
lib/studium/exams/lectures_without_exam_entry.rb,
lib/studium/exams/not_completed/not_completed.rb,
lib/studium/toplevel_methods/toplevel_methods.rb,
lib/studium/exams/push_solved_questions_on_top.rb,
lib/studium/exams/show_exams_for/show_exams_for.rb,
lib/studium/exams/upcoming_exams/upcoming_exams.rb,
lib/studium/exams/exam_registration_at/constants.rb,
lib/studium/exams/question_answer/question_answer.rb,
lib/studium/exams/upcoming_exams_at_the_boku/html.rb,
lib/studium/exams/csv/create_csv_passed_exams_file.rb,
lib/studium/exams/exam_bubble/menu_for_the_main_loop.rb,
lib/studium/exams/exam_registration_at/report_and_show.rb,
lib/studium/exams/upcoming_exams_at_the_boku/constants.rb,
lib/studium/exams/ask_exam_from_the_upcoming_exams_pool.rb,
lib/studium/exams/exam_registration_at/exam_registration_at.rb,
lib/studium/toplevel_methods/find_exam_topic_and_exam_title.rb,
lib/studium/utility_scripts/publish_my_exams/publish_my_exams.rb,
lib/studium/exams/open_last_exam_question_asked_file/constants.rb,
lib/studium/exams/open_last_exam_question_asked_file/initialize.rb,
lib/studium/exams/open_exam_associated_url/open_exam_associated_url.rb,
lib/studium/exams/ask_question_from_any_of_the_still_missing_lectures.rb,
lib/studium/exams/upcoming_registered_exams/upcoming_registered_exams.rb,
lib/studium/exams/upcoming_exams_at_the_boku/upcoming_exams_at_the_boku.rb,
lib/studium/exams/exam_statistics_from_this_file/exam_statistics_from_this_file.rb,
lib/studium/exams/mandatory_continuous_assessment/mandatory_continuous_assessment.rb,
lib/studium/exams/designate_ten_random_exam_topics/designate_ten_random_exam_topics.rb,
lib/studium/exams/questions_solved_from_day_to_day/questions_solved_from_day_to_day.rb,
lib/studium/exams/open_last_exam_question_asked_file/open_last_exam_question_asked_file.rb
Overview
Studium::Exams
Defined Under Namespace
Modules: Dataset Classes: AskExamFromTheUpcomingExamsPool, AskExamTopicQuestion, AskQuestionFromAnyOfTheStillMissingLectures, AverageGrade, CreateCsvPassedExamsFile, Cycle, DesignateTenRandomExamTopics, Exam, ExamBubble, ExamQuestion, ExamRegistrationAt, ExamStatisticsFromThisFile, ExamTopics, LastExams, LecturesWithoutExamEntry, MandatoryContinuousAssessment, NextExam, NextExams, NotCompleted, OpenExamAssociatedUrl, OpenLastExamQuestionAskedFile, PublishMyExams, PushSolvedQuestionsOnTop, QuestionAnswer, QuestionsSolvedFromDayToDay, RepeatLastQuestion, ShowExamsFor, ShowThemes, Solved, ThisWeek, Timetable, UpcomingExams, UpcomingExamsAtTheBoku, UpcomingExamsDataset, UpcomingRegisteredExams, UploadExamTopics
Constant Summary collapse
- PROJECT_BASE_DIRECTORY =
#
Studium::Exams::PROJECT_BASE_DIRECTORY
#
"#{::Studium.project_base_directory?}exams/"
- NAMESPACE =
#
NAMESPACE
#
inspect
Constants included from Colours
Class Method Summary collapse
-
.[](i, run_already = true) ⇒ Object
# === Studium::Exams[].
-
.all_topics_as_short_name ⇒ Object
# === Studium::Exams.all_topics_as_short_name.
-
.available_topics? ⇒ Boolean
# === Studium::Exams.available_topics? (available tag).
-
.dataset ⇒ Object
# === Studium::Exams.dataset =========================================================================== #.
-
.dataset? ⇒ Boolean
# === Studium::Exams.dataset?.
-
.display_available_topics(optional_limit_to_this = nil) ⇒ Object
# === Studium::Exams.display_available_topics ========================================================================= #.
-
.do_freeze ⇒ Object
# === Studium::Exams.do_freeze ========================================================================= #.
-
.frozen? ⇒ Boolean
# === Studium::Exams.frozen? ========================================================================= #.
-
.initialize_dataset ⇒ Object
# === Studium::Exams.initialize_dataset ========================================================================= #.
-
.n_questions_already_solved_in_this_topic(this_topic) ⇒ Object
# === Studium::Exams.n_questions_already_solved_in_this_topic ========================================================================= #.
-
.n_questions_available? ⇒ Boolean
# === Studium::Exams.n_questions_available?.
-
.n_questions_available_in_this_topic(this_topic) ⇒ Object
# === Studium::Exams.n_questions_available_in_this_topic ========================================================================= #.
-
.n_topics_available? ⇒ Boolean
# === Studium::Exams.n_topics_available?.
-
.names_of_all_solved_exams(optional_show_only_n_entries = nil) ⇒ Object
# === Studium::Exams.names_of_all_solved_exams.
-
.new(i = 'amg', run_already = true) ⇒ Object
# === Studium::Exams.new =========================================================================== #.
-
.project_base_dir? ⇒ Boolean
# === Studium::Exams.project_base_dir?.
-
.question_answer(topic = 'random_topic', run_already = true, &block) ⇒ Object
# === Studium::Exams.question_answer =========================================================================== #.
-
.random_short_name_topic ⇒ Object
# === Studium::Exams.random_short_name_topic ========================================================================= #.
-
.random_topic ⇒ Object
# === Studium::Exams.random_topic.
-
.read_delay_from_file(i = DELAY_CONSTANT_STORED_HERE) ⇒ Object
# === Studium::Exams.read_delay_from_file (load delay).
-
.remote_ftp_url? ⇒ Boolean
# === Studium::Exams.remote_ftp_url? ========================================================================= #.
-
.remote_url? ⇒ Boolean
# === Studium::Exams.remote_url?.
-
.report_all_lectures_matching_this_lecture_type(i) ⇒ Object
# === Studium::Exams.report_all_lectures_matching_this_lecture_type ========================================================================= #.
-
.report_how_many_exam_questions_were_already_solved(report_in_which_language = :default, report_or_return = :report) ⇒ Object
# === Studium::Exams.report_how_many_exam_questions_were_already_solved.
-
.report_nquestions_of(i) ⇒ Object
# === Studium::Exams.report_nquestions_of.
-
.return_n_exam_questions_were_already_solved ⇒ Object
# === Studium::Exams.return_n_exam_questions_were_already_solved ========================================================================= #.
-
.return_n_percent_solved_from_this_topic(this_topic) ⇒ Object
# === Studium::Exams.return_n_percent_solved_from_this_topic.
-
.return_n_questions_in_this_topic(topic, also_return_n_answers = false) ⇒ Object
# === Studium::Exams.return_n_questions_in_this_topic.
-
.return_n_questions_solved_in_total ⇒ Object
# === Studium::Exams.return_n_questions_solved_in_total.
-
.return_n_questions_were_answered_for_this_topic(this_topic) ⇒ Object
# === Studium::Exams.return_n_questions_were_answered_for_this_topic.
-
.set_dataset(i = Dataset.new) ⇒ Object
# === Studium::Exams.set_dataset.
-
.set_remote_exams_url(i = @remote_ftp_url+'exam_topics/') ⇒ Object
# === Studium::Exams.set_remote_exams_url ========================================================================= #.
-
.show_passed_exams(i = ARGV, &block) ⇒ Object
# === Studium::Exams.show_passed_exams.
-
.total_ects_points_passed(use_this_file = Studium.file_passed_exams_per_month) ⇒ Object
# === Studium::Exams.total_ects_points_passed.
Instance Method Summary collapse
-
#n_questions_available? ⇒ Boolean
# === n_questions_available?.
Methods included from Colours
bold_blue, bold_red, bold_yellow, cadetblue, cadetblue, chartreuse, coral, coral, cornflowerblue, cornflowerblue, crimson, cyan, cyan, darkgoldenrod, darkgoldenrod, darkgray, darkgreen, darkolivegreen, darkseagreen, darkslateblue, darkslateblue, darkslategray, darkslategray, darkturquoise, darkturquoise, deepskyblue, deepskyblue, default_colour, dimgray, disable_colours, dodgerblue, e, efancy, enable_colours, erev, ewarn, forestgreen, forestgreen, gold, goldenrod, goldenrod, grey, grey, indianred, indianred, khaki, khaki, lawngreen, lawngreen, lightblue, lightgreen, lightsalmon, lightseagreen, lightseagreen, lightskyblue, lightskyblue, lightslategray, lightslategray, lightsteelblue, lime, lime, limegreen, limegreen, mediumaquamarine, mediumaquamarine, mediumorchid, mediumpurple, mediumpurple, mediumseagreen, mediumseagreen, mediumslateblue, mediumslateblue, mediumspringgreen, mediumspringgreen, mediumturquoise, mediumturquoise, oldlace, olive, olive, olivedrab, olivedrab, orange, orangered, orchid, orchid, palegreen, palegreen, paleturquoise, paleturquoise, palevioletred, papayawhip, peru, peru, plum, plum, powderblue, powderblue, rev, rev?, royalblue, saddlebrown, saddlebrown, sandybrown, sandybrown, sdir, sdir, seagreen, seagreen, sfancy, sfancy, sfile, sfile, simp, simp, skyblue, skyblue, slateblue, slategray, slategray, springgreen, springgreen, steelblue, steelblue, swarn, swarn, tan, tan, teal, teal, tomato, tomato, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, yellow, yellowgreen, yellowgreen
Class Method Details
.[](i, run_already = true) ⇒ Object
#
Studium::Exams[]
This will simply use AskQuestion as defined above.
Usage examples, including aliases:
amg = Studium::Exams['amg']
qa = Exams.question_answer('yo', :dont_run_yet)
#
2778 2779 2780 |
# File 'lib/studium/exams/question_answer/question_answer.rb', line 2778 def self.[](i, run_already = true) Studium::Exams::QuestionAnswer.new(i, run_already) end |
.all_topics_as_short_name ⇒ Object
#
Studium::Exams.all_topics_as_short_name
Note that since as of September 2021 this method will return a sorted Array.
#
6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6407 def self.all_topics_as_short_name # ======================================================================= # # Obtain the numbers for the entries at hand. # ======================================================================= # array = (1 .. ::Studium::N_TOPICS_REGISTERED).to_a # ======================================================================= # # Here we have an Array consisting of the main numbers in use. # ======================================================================= # array.map! {|entry| entry = ::Studium.find_corresponding_exam_topic(entry) entry } return array.sort end |
.available_topics? ⇒ Boolean
#
Studium::Exams.available_topics? (available tag)
This method can tell us which topics are available.
It will return an Array that holds all the available topics at hand. The topics are kept in a variant that is prettier to read, such as Strings like “Medizinische Chemie” and similar.
If you would rather use the shorter, downcased names, see the method Studium::Exams.all_topics_as_short_name().
Returns: An Array.
#
6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6352 def self.available_topics? # ======================================================================= # # The following constant is defined in # studium/toplevel_methods/find_corresponding_exam_topic.rb # ======================================================================= # range = (1 .. ::Studium::N_TOPICS_REGISTERED).to_a range.map! {|entry| entry = ::Studium.find_corresponding_exam_topic(entry) new_entry = ::Studium.find_corresponding_exam_title(entry) if new_entry.nil? # Error handling. ::Studium.opnn(NAMESPACE); puts "There is an unknown entry called: #{entry}" ::Studium.opnn(NAMESPACE); puts 'Please correct this entry.' exit # Better to exit rather than continue. end new_entry } return range end |
.dataset ⇒ Object
#
Studium::Exams.dataset
#
88 89 90 |
# File 'lib/studium/exams/dataset/dataset.rb', line 88 def self.dataset ::Studium::Exams::Dataset[] end |
.dataset? ⇒ Boolean
#
Studium::Exams.dataset?
Just a query method.
#
31 32 33 |
# File 'lib/studium/exams/dataset/dataset.rb', line 31 def self.dataset? @dataset end |
.display_available_topics(optional_limit_to_this = nil) ⇒ Object
#
Studium::Exams.display_available_topics
#
6377 6378 6379 6380 6381 6382 6383 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6377 def self.display_available_topics(optional_limit_to_this = nil) dataset = Exams.available_topics? if optional_limit_to_this and optional_limit_to_this.is_a?(Integer) dataset = dataset[0..(optional_limit_to_this-1)] end dataset.each {|entry| e entry } # Display it here. end |
.do_freeze ⇒ Object
#
Studium::Exams.do_freeze
#
28 29 30 |
# File 'lib/studium/exams/frozen.rb', line 28 def self.do_freeze @frozen = true end |
.frozen? ⇒ Boolean
#
Studium::Exams.frozen?
#
21 22 23 |
# File 'lib/studium/exams/frozen.rb', line 21 def self.frozen? @frozen end |
.initialize_dataset ⇒ Object
#
Studium::Exams.initialize_dataset
#
49 50 51 |
# File 'lib/studium/exams/dataset/dataset.rb', line 49 def self.initialize_dataset set_dataset end |
.n_questions_already_solved_in_this_topic(this_topic) ⇒ Object
#
Studium::Exams.n_questions_already_solved_in_this_topic
#
6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6425 def self.n_questions_already_solved_in_this_topic(this_topic) n_questions_already_solved = 0 # ======================================================================= # # First, we must find the real name of the exam-file at hand: # ======================================================================= # this_topic = Studium.find_corresponding_exam_topic(this_topic) file_path = "#{Studium.exam_topics?}#{this_topic}" if File.exist? file_path dataset = File.readlines(file_path) # Here we assume that the file must exist. dataset = Studium.filter_away_invalid_questions(dataset) selection = dataset.select {|line| line.strip.end_with? ' []' } else e 'No file exists at `'+sfile(file_path)+'`.' end n_questions_already_solved = selection.size return n_questions_already_solved end |
.n_questions_available? ⇒ Boolean
#
Studium::Exams.n_questions_available?
This method will return a number. This number reflects how many questions are available in total, querying all registered exam questions.
In order to determine this number, the method has to go through all the topics and simply count up how many questions there are.
#
6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6494 def self.n_questions_available? n_questions_available = 0 array = ::Studium.return_array_for_n_topics_registered array.each {|entry| entry = ::Studium.find_corresponding_exam_topic(entry) file_path = "#{Studium.exam_topics?}#{entry}" dataset = File.readlines(file_path) dataset = Studium.filter_away_invalid_questions(dataset) n_questions_available += dataset.size } return n_questions_available end |
.n_questions_available_in_this_topic(this_topic) ⇒ Object
#
Studium::Exams.n_questions_available_in_this_topic
#
6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6321 def self.n_questions_available_in_this_topic(this_topic) n_questions_available = 0 # ======================================================================= # # First, we must find the real name of the exam-file at hand: # ======================================================================= # this_topic = ::Studium.find_corresponding_exam_topic(this_topic) file_path = "#{Studium.exam_topics?}#{this_topic}".to_s if File.exist? file_path dataset = File.readlines(file_path) # Here we assume that the file must exist. dataset = ::Studium.filter_away_invalid_questions(dataset, file_path) n_questions_available += dataset.size return n_questions_available else 0 end end |
.n_topics_available? ⇒ Boolean
#
Studium::Exams.n_topics_available?
This method will return a number, which tells us how many topics are available. We “cheat” here a little bit in that we will simply count the amount of files in the exam_topics/ directory.
#
21 22 23 |
# File 'lib/studium/toplevel_methods/find_exam_topic_and_exam_title.rb', line 21 def self.n_topics_available? Dir["#{Studium.exam_topics?}*"].size end |
.names_of_all_solved_exams(optional_show_only_n_entries = nil) ⇒ Object
#
Studium::Exams.names_of_all_solved_exams
This method will return an Array containing all the names of the exams that were already solved/finished successfully.
An example for this output follows next, showing 3 elements of the Array:
"Oncology for biotechnologists (in Eng.)",
"Die Zelle im Elektronenmikroskop",
"Protein Transport u. Sortierung in Säugetierzellen"
Note that this is deliberately NOT sorted so that we know which exams were the most recently ones that were passed. First entry thus is the “most recent exam” that was passed.
#
6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6462 def self.names_of_all_solved_exams( optional_show_only_n_entries = nil ) require 'studium/toplevel_methods/toplevel_methods.rb' array = [] dataset = ::Studium.return_sanitized_dataset_from_the_file_lecture_information.select {|name_of_the_lecture, inner_hash| inner_hash.has_key?(:already_solved) and (inner_hash[:already_solved] == true) } sorted = dataset.sort_by {|a, b| already_solved_at = b[:already_solved_at] if already_solved_at ::Time.parse(already_solved_at) else puts 'Incomplete entry for `'+a+'`.' Time.parse('01.01.1970') end }.reverse sorted.each {|a, b| array << a } return array end |
.new(i = 'amg', run_already = true) ⇒ Object
#
Studium::Exams.new
#
122 123 124 |
# File 'lib/studium/exams/exam/exam.rb', line 122 def self.new(i = 'amg', run_already = true) Exams::Exam.new(i, run_already) end |
.project_base_dir? ⇒ Boolean
#
Studium::Exams.project_base_dir?
Prefer to use this method if you need to find out the project base directory.
#
76 77 78 |
# File 'lib/studium/project/project.rb', line 76 def self.project_base_dir? ::Studium.project_base_dir? end |
.question_answer(topic = 'random_topic', run_already = true, &block) ⇒ Object
#
Studium::Exams.question_answer
#
2785 2786 2787 2788 2789 2790 2791 |
# File 'lib/studium/exams/question_answer/question_answer.rb', line 2785 def self.question_answer( topic = 'random_topic', run_already = true, &block ) Studium::Exams::QuestionAnswer.new(topic, run_already, &block) end |
.random_short_name_topic ⇒ Object
#
Studium::Exams.random_short_name_topic
#
6397 6398 6399 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6397 def self.random_short_name_topic ::Studium::Exams.all_topics_as_short_name.sample end |
.random_topic ⇒ Object
#
Studium::Exams.random_topic
This method will return a random topic.
#
6390 6391 6392 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6390 def self.random_topic ::Studium::Exams.available_topics?.sample.to_s end |
.read_delay_from_file(i = DELAY_CONSTANT_STORED_HERE) ⇒ Object
#
Studium::Exams.read_delay_from_file (load delay)
Use this method here, read_delay_from_file(), to read in the default delay from a stored file.
#
6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6563 def self.read_delay_from_file( i = DELAY_CONSTANT_STORED_HERE ) if File.exist? i _ = YAML.load_file(i) result = _['delay'] else # Else the file does not exist, so we use the default delay. result = DEFAULT_DELAY end return result end |
.remote_ftp_url? ⇒ Boolean
#
Studium::Exams.remote_ftp_url?
#
19 20 21 |
# File 'lib/studium/exams/remote_ftp_url.rb', line 19 def self.remote_ftp_url? @remote_ftp_url end |
.remote_url? ⇒ Boolean
#
Studium::Exams.remote_url?
Query method to determine the remote URL for the exam topics. This is a module-level instance variable which you can overrule - see the next method for this.
#
30 31 32 |
# File 'lib/studium/exams/remote_ftp_url.rb', line 30 def self.remote_url? @remote_exams_url end |
.report_all_lectures_matching_this_lecture_type(i) ⇒ Object
#
Studium::Exams.report_all_lectures_matching_this_lecture_type
#
6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6707 def self.report_all_lectures_matching_this_lecture_type(i) if i.is_a? Array i.each {|entry| report_all_lectures_matching_this_lecture_type(entry) } else dataset = Studium.dataset_from_file_lecture_information selection = dataset.select {|name, inner_hash| type = inner_hash[:type] type == i } if selection.empty? e "No lectures match towards #{i}." else e e Colours.rev+ 'The following '+ +Studium::Colours.sfancy(selection.keys.size.to_s)+ ' entries match towards the lecture type '+ Studium::Colours.sfancy(i)+':' e selection.each_pair {|name, inner_hash| # ================================================================= # # Report these entries next: # ================================================================= # e " #{name.ljust(20)}" }; e end end end |
.report_how_many_exam_questions_were_already_solved(report_in_which_language = :default, report_or_return = :report) ⇒ Object
#
Studium::Exams.report_how_many_exam_questions_were_already_solved
The first argument tells us which language we should use.
By default, we will report on the commandline, in english.
#
6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6743 def self.report_how_many_exam_questions_were_already_solved( report_in_which_language = :default, report_or_return = :report ) n_total_questions = ::Studium.n_total_questions_available? n_total_answers = return_n_exam_questions_were_already_solved percentage = ((n_total_answers * 100.0) / n_total_questions).round(2) percentage = Studium::Colours.deepskyblue("#{percentage}%") # ======================================================================= # # Next, add proper '.' token into the n_total_questions variable, # which helps a bit in reading. # ======================================================================= # n_total_questions = n_total_questions.to_s.reverse.scan(/.{3}|.+/).join('.').reverse n_total_answers = n_total_answers.to_s colourized_n_total_answers = Studium::Colours.deepskyblue(n_total_answers) result = ''.dup result << Studium::Colours.grey('') case report_in_which_language # case tag # ======================================================================= # # === :english # ======================================================================= # when :english, :default # Use the english language here, which is the default. result << Studium::Colours.grey('We already solved ')+ colourized_n_total_answers+ Studium::Colours.grey(' of ')+ Studium::Colours.mediumseagreen(n_total_questions.to_s)+ Studium::Colours.grey(' available questions ('+percentage)+ Studium::Colours.grey(' solved, on the ')+ Studium::Colours.darkolivegreen(::Studium.dd_mm_yyyy)+ Studium::Colours.grey(').') # ======================================================================= # # === :german # ======================================================================= # when :german # Use the german language here. result << 'Am '+::Studium.datum?+' waren es '+ Studium::Colours.simp(n_total_questions.to_s)+ ' Fragen - davon waren '+colourized_n_total_answers+ ' beantwortet. '+'('+percentage+')' end # ======================================================================= # # Since as of December 2016, we will also save this information in # a file. We have to ensure that the base-directory exists, though. # ======================================================================= # save_into_this_file = "#{Studium.log_dir?}nsolved.md" Studium.ensure_that_the_log_directory_exists Studium.save_what_into( n_total_answers.to_s, save_into_this_file ) if report_or_return == :report Studium.e result else return report_or_return end end |
.report_nquestions_of(i) ⇒ Object
#
Studium::Exams.report_nquestions_of
This method can be used to report, on the commandline, how many questions are in the specific topic at hand.
#
6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6827 def self.report_nquestions_of(i) i = [i] unless i.is_a? Array i.flatten! i.map! {|topic| Studium::Exams.return_n_questions_in_this_topic(topic, :also_return_n_answers) } # ======================================================================= # # The variable i may now look like this here: # [[752, 204], [800, 223], [265, 143], [228, 78], [271, 262], [60, 25], [85, 20]] # ======================================================================= # n_questions = i.flatten.select.with_index {|entry, index| entry if index % 2 == 0 }.sum n_answers = i.flatten.select.with_index {|entry, index| entry if index % 2 != 0 }.sum ::Studium.e ::Colours.rev+ 'We have a total of '+ Colours.sfile(n_questions.to_s)+ ::Colours.rev+' questions in '\ 'these '+ Colours.sfile((i.flatten.size / 2).to_s)+ ::Colours.rev+' topics at hand.' ::Studium.e Colours.simp(n_answers.to_s)+' of these questions have '\ 'already been answered. ('+ Colours.simp((n_answers.to_f * 100 / n_questions).round(2).to_s+'%')+')' end |
.return_n_exam_questions_were_already_solved ⇒ Object
#
Studium::Exams.return_n_exam_questions_were_already_solved
#
6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6693 def self.return_n_exam_questions_were_already_solved # ======================================================================= # # Determine the questions that are available, in total: # ======================================================================= # dataset = ::Studium::Exams::Dataset[].select {|entry| entry.end_with?("[]\n") } n_total_answers = dataset.size return n_total_answers end |
.return_n_percent_solved_from_this_topic(this_topic) ⇒ Object
#
Studium::Exams.return_n_percent_solved_from_this_topic
This method will return a number, which denotes how much percent of that topic, already contains a proper answer.
So for example, if this method returns 75, then this means that we have already solved 75% of that given topic at hand.
The first (mandatory) argument to this method should be the topic you are looking for, such as ‘amg1’.
Obviously, if this topic does not exist, then the method here can not work properly.
Usage examples:
Studium::Exams.return_n_percent_solved_from_this_topic('phys')
Studium::Exams.return_n_percent_solved_from_this_topic('amg1')
#
6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6617 def self.return_n_percent_solved_from_this_topic( this_topic ) require 'studium/statistics/report_how_many_exam_questions_were_answered.rb' i = this_topic.to_s.dup i.downcase! i.delete!(' ') if i.include? ' ' i = ::Studium.find_corresponding_exam_topic(i) percentage = 0 # Use a default value. # ======================================================================= # # Next, we have to tap into the Statistics class. # ======================================================================= # statistics = Studium::Statistics::ReportHowManyExamQuestionsWereAnswered.new { :be_quiet }.hash? if i.respond_to?(:to_sym) statistics = statistics[i.to_sym] percentage = statistics[:percentage_of_questions_answered] else if i.is_a?(String) or i.is_a?(Symbol) puts 'Possible problem, so debugging stuff.' puts 'The variable this_topic was: '+this_topic.to_s puts 'The modified variable is: '+i.to_s end end return percentage end |
.return_n_questions_in_this_topic(topic, also_return_n_answers = false) ⇒ Object
#
Studium::Exams.return_n_questions_in_this_topic
This method will return a number (Integer) that tells us how many questions are part of the given topic at hand.
If the optional second argument is set to true, then we will also keep track of how many of these questions have been answered. The last entry then tells us how many of these questions have been answered already.
The second argument can be used to also return how many questons were answered as of yet.
Invocation examples:
Studium::Exams.return_n_questions_in_this_topic 'amg1' # => 1000
Studium::Exams.return_n_questions_in_this_topic "advanced_biotechnology" # => 94
#
6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6663 def self.return_n_questions_in_this_topic( topic, also_return_n_answers = false ) case also_return_n_answers when :also_return_n_answers also_return_n_answers = true end return_value = 0 topic = ::Studium.find_corresponding_exam_topic(topic) path = "#{::Studium.directory_to_the_exam_topics?}#{topic}" # ======================================================================= # # Ok, now we have the path, we can find out how many questions # are registered there. # ======================================================================= # if File.exist? path dataset = ::Studium.default_readlines(path) dataset = ::Studium.filter_away_invalid_questions(dataset) return_value = dataset.size n_answers = dataset.count {|line| line.chomp.end_with? ' []' } end if also_return_n_answers return [return_value, n_answers] else return return_value end end |
.return_n_questions_solved_in_total ⇒ Object
6810 6811 6812 6813 6814 6815 6816 6817 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6810 def self.return_n_questions_solved_in_total dataset = ::Studium::Exams::Dataset[] n_total_questions = dataset.size # We have that many questions. dataset.reject! {|entry| entry.end_with?("[]\n") } n_total_unsolved_questions = dataset.size n_questions_solved = n_total_questions - n_total_unsolved_questions return n_questions_solved end |
.return_n_questions_were_answered_for_this_topic(this_topic) ⇒ Object
#
Studium::Exams.return_n_questions_were_answered_for_this_topic
This method will return a number, which indicates how many questions were already answered for a given topic at hand.
#
6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6581 def self.return_n_questions_were_answered_for_this_topic( this_topic ) if this_topic.is_a? Array this_topic = this_topic.first end n_answers = ::Studium::Exams.return_n_questions_in_this_topic( this_topic, :also_return_n_answers ) n_answers = n_answers.last # This will obtain the correct number. return n_answers end |
.set_dataset(i = Dataset.new) ⇒ Object
#
Studium::Exams.set_dataset
Use the given exam-dataset.
#
40 41 42 43 44 |
# File 'lib/studium/exams/dataset/dataset.rb', line 40 def self.set_dataset( i = Dataset.new ) @dataset = i end |
.set_remote_exams_url(i = @remote_ftp_url+'exam_topics/') ⇒ Object
#
Studium::Exams.set_remote_exams_url
#
37 38 39 |
# File 'lib/studium/exams/remote_ftp_url.rb', line 37 def self.set_remote_exams_url(i = @remote_ftp_url+'exam_topics/') @remote_exams_url = i end |
.show_passed_exams(i = ARGV, &block) ⇒ Object
#
Studium::Exams.show_passed_exams
Simply show all passed exams, in a colourful manner.
#
442 443 444 445 446 447 448 449 450 |
# File 'lib/studium/exams/last_exams/last_exams.rb', line 442 def self.show_passed_exams( i = ARGV, &block ) if i.empty? Studium.show_n_last_exams(:show_all_passed_exams) else Studium::Exams::LastExams.new(i, &block) end end |
.total_ects_points_passed(use_this_file = Studium.file_passed_exams_per_month) ⇒ Object
#
Studium::Exams.total_ects_points_passed
This will return a number, such as 548.0, which tells us how many ECTS points were completed successfully, in total, so far.
Note that this will be always calculated from scratch again whenever you call this method.
#
6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6527 def self.total_ects_points_passed( use_this_file = Studium.file_passed_exams_per_month ) result = 0.0 # ======================================================================= # # Must still check whether the file exists or not, as it may be # unavailable on some systems. # ======================================================================= # if File.exist? use_this_file dataset = Studium.read_this_file_through_default_encoding(use_this_file) # An Array. dataset.select! {|line| line =~ /^\d+/ # Only entries that start with a number. } # ======================================================================= # # Next, grab the ECTS entry from there, which is at third position, # hence [2]. # ======================================================================= # dataset.map! {|line| splitted = line.split('|').map(&:strip) splitted[2].to_f } result = dataset.inject(0) {|sum,x| sum + x } return result.to_f else ::Studium.e "No dataset is available at `#{Colours.sfile(use_this_file)}`." ::Studium.e '(The method was Studium::Exams.total_ects_points_passed().)' ::Studium.e end end |
Instance Method Details
#n_questions_available? ⇒ Boolean
#
n_questions_available?
I recommend that you use Exams.n_questions_available? instead of this method here.
#
6514 6515 6516 |
# File 'lib/studium/toplevel_methods/toplevel_methods.rb', line 6514 def n_questions_available? Exams.n_questions_available? end |