Module: Studium::Exams

Extended by:
Colours
Defined in:
lib/studium/exams/frozen.rb,
lib/studium/exams/class.rb,
lib/studium/exams/cycle.rb,
lib/studium/exams/dataset.rb,
lib/studium/exams/pruefung.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/help.rb,
lib/studium/exams/solved/menu.rb,
lib/studium/exams/solved/reset.rb,
lib/studium/exams/solved/solved.rb,
lib/studium/exams/remote_ftp_url.rb,
lib/studium/exams/show_themes/menu.rb,
lib/studium/exams/show_themes/misc.rb,
lib/studium/exams/solved/constants.rb,
lib/studium/exams/show_themes/reset.rb,
lib/studium/exams/solved/initialize.rb,
lib/studium/toplevel_methods/report.rb,
lib/studium/exams/exam_question/menu.rb,
lib/studium/exams/exam_question/misc.rb,
lib/studium/exams/upcoming_exams/run.rb,
lib/studium/exams/upload_exam_topics.rb,
lib/studium/exams/exam_question/reset.rb,
lib/studium/exams/upcoming_exams/help.rb,
lib/studium/exams/upcoming_exams/menu.rb,
lib/studium/exams/upcoming_exams/misc.rb,
lib/studium/exams/exam_question/answer.rb,
lib/studium/exams/repeat_last_question.rb,
lib/studium/exams/upcoming_exams/reset.rb,
lib/studium/exams/last_exams/last_exams.rb,
lib/studium/exams/show_themes/constants.rb,
lib/studium/exams/exam_question/question.rb,
lib/studium/exams/new_questions_per_year.rb,
lib/studium/exams/upcoming_exams_dataset.rb,
lib/studium/exams/ask_exam_topic_question.rb,
lib/studium/exams/exam_question/constants.rb,
lib/studium/exams/open_exam_associated_url.rb,
lib/studium/exams/upcoming_exams/constants.rb,
lib/studium/toplevel_methods/exams_dataset.rb,
lib/studium/exams/exam_registration_at/help.rb,
lib/studium/exams/exam_registration_at/menu.rb,
lib/studium/exams/passed_exams/passed_exams.rb,
lib/studium/exams/upcoming_exams/initialize.rb,
lib/studium/exams/exam_registration_at/reset.rb,
lib/studium/utility_scripts/publish_my_exams.rb,
lib/studium/exams/exam_question/exam_question.rb,
lib/studium/exams/exam_registration_at/report.rb,
lib/studium/exams/lectures_without_exam_entry.rb,
lib/studium/toplevel_methods/available_topics.rb,
lib/studium/exams/push_solved_questions_on_top.rb,
lib/studium/exams/upcoming_exams/upcoming_exams.rb,
lib/studium/toplevel_methods/n_topics_available.rb,
lib/studium/exams/exam_registration_at/constants.rb,
lib/studium/exams/upcoming_exams_at_the_boku/html.rb,
lib/studium/toplevel_methods/report_nquestions_of.rb,
lib/studium/exams/csv/create_csv_passed_exams_file.rb,
lib/studium/exams/questions_solved_from_day_to_day.rb,
lib/studium/toplevel_methods/n_questions_available.rb,
lib/studium/exams/mandatory_continuous_assessment/run.rb,
lib/studium/toplevel_methods/total_ects_points_passed.rb,
lib/studium/exams/mandatory_continuous_assessment/help.rb,
lib/studium/exams/mandatory_continuous_assessment/menu.rb,
lib/studium/exams/mandatory_continuous_assessment/misc.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/mandatory_continuous_assessment/reset.rb,
lib/studium/exams/mandatory_continuous_assessment/compare.rb,
lib/studium/exams/exam_registration_at/exam_registration_at.rb,
lib/studium/exams/mandatory_continuous_assessment/constants.rb,
lib/studium/exams/mandatory_continuous_assessment/initialize.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/mandatory_continuous_assessment/show_and_report.rb,
lib/studium/toplevel_methods/read_delay_between_questions_from_file.rb,
lib/studium/toplevel_methods/return_n_percent_solved_from_this_topic.rb,
lib/studium/exams/ask_question_from_any_of_the_still_missing_lectures.rb,
lib/studium/exams/upcoming_exams_at_the_boku/upcoming_exams_at_the_boku.rb,
lib/studium/toplevel_methods/return_n_questions_were_answered_for_this_topic.rb,
lib/studium/exams/mandatory_continuous_assessment/set_title_of_the_curriculum.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/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, CreateCsvPassedExamsFile, Cycle, DesignateTenRandomExamTopics, Exam, ExamQuestion, ExamRegistrationAt, ExamStatisticsFromThisFile, ExamTopics, LastExams, LecturesWithoutExamEntry, MandatoryContinuousAssessment, NewQuestionsPerYear, NextExam, NextExams, OpenExamAssociatedUrl, OpenLastExamQuestionAskedFile, Pruefung, PublishMyExams, PushSolvedQuestionsOnTop, QuestionsSolvedFromDayToDay, RepeatLastQuestion, ShowThemes, Solved, UpcomingExams, UpcomingExamsAtTheBoku, UpcomingExamsDataset, UploadExamTopics

Constant Summary collapse

PROJECT_BASE_DIRECTORY =
#

Studium::Exams::PROJECT_BASE_DIRECTORY

#
"#{::Studium.project_base_directory?}exams/"
NAMESPACE =
#

NAMESPACE

#
inspect

Constants included from Colours

Colours::COLOURS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Colours

bold_blue, bold_red, bold_yellow, cadetblue, chartreuse, crimson, darkgray, darkgreen, darkseagreen, deepskyblue, deepskyblue, default_colour, dimgray, disable_colours, dodgerblue, e, efancy, enable_colours, ewarn, forestgreen, gold, grey, lightblue, lightgreen, lightslategray, lightsteelblue, mediumorchid, mediumseagreen, oldlace, olivedrab, orange, orangered, orchid, palevioletred, papayawhip, rev, royalblue, sdir, sdir, sfancy, sfancy, sfile, sfile, simp, simp, slateblue, steelblue, steelblue, swarn, swarn, teal, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, yellow

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)
#


1022
1023
1024
# File 'lib/studium/exams/exam_question/exam_question.rb', line 1022

def self.[](i, run_already = true)
  Studium::Exams::ExamQuestion.new(i, run_already)
end

.all_topics_as_short_nameObject

#

Studium::Exams.all_topics_as_short_name

Note that since as of September 2021 this method will return a sorted Array.

#


93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/studium/toplevel_methods/available_topics.rb', line 93

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.

#

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/studium/toplevel_methods/available_topics.rb', line 38

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

.datasetObject

#

Studium::Exams.dataset

#


57
58
59
# File 'lib/studium/exams/dataset.rb', line 57

def self.dataset
  ::Studium::Exams::Dataset[]
end

.dataset?Boolean

#

Studium::Exams.dataset?

Just a query method.

#

Returns:

  • (Boolean)


23
24
25
# File 'lib/studium/toplevel_methods/exams_dataset.rb', line 23

def self.dataset?
  @dataset
end

.display_available_topics(optional_limit_to_this = nil) ⇒ Object

#

Studium::Exams.display_available_topics

#


63
64
65
66
67
68
69
# File 'lib/studium/toplevel_methods/available_topics.rb', line 63

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_freezeObject

#

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?

#

Returns:

  • (Boolean)


21
22
23
# File 'lib/studium/exams/frozen.rb', line 21

def self.frozen?
  @frozen
end

.initialize_datasetObject

#

Studium::Exams.initialize_dataset

#


41
42
43
# File 'lib/studium/toplevel_methods/exams_dataset.rb', line 41

def self.initialize_dataset
  Exams.set_dataset
end

.n_questions_already_solved_in_this_topic(this_topic) ⇒ Object

#

Studium::Exams.n_questions_already_solved_in_this_topic

#


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/studium/toplevel_methods/n_questions_available.rb', line 44

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 = "#{EXAM_TOPICS}#{this_topic}"
  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? ' []'
  }
  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.

#

Returns:

  • (Boolean)


70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/studium/toplevel_methods/n_questions_available.rb', line 70

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 = "#{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

#


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/studium/toplevel_methods/n_questions_available.rb', line 24

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 = "#{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.

#

Returns:

  • (Boolean)


21
22
23
# File 'lib/studium/toplevel_methods/n_topics_available.rb', line 21

def self.n_topics_available?
  Dir["#{Studium.exam_topics?}*"].size
end

.new(i = 'amg', run_already = true) ⇒ Object

#

Studium::Exams.new

#


119
120
121
# File 'lib/studium/exams/class.rb', line 119

def self.new(i = 'amg', run_already = true)
  Exams::Exam.new(i, run_already)
end

.project_base_dir?Boolean

#

Studium::Exams.project_base_dir?

#

Returns:

  • (Boolean)


64
65
66
# File 'lib/studium/project/project.rb', line 64

def self.project_base_dir?
  ::Studium.project_base_dir?
end

.question_answer(topic = 'random_topic', run_already = true, &block) ⇒ Object

#

Studium::Exams.question_answer

#


1003
1004
1005
1006
1007
1008
1009
# File 'lib/studium/exams/exam_question/exam_question.rb', line 1003

def self.question_answer(
    topic       = 'random_topic',
    run_already = true,
    &block
  )
  Studium::Exams::ExamQuestion.new(topic, run_already, &block)
end

.random_short_name_topicObject

#

Studium::Exams.random_short_name_topic

#


83
84
85
# File 'lib/studium/toplevel_methods/available_topics.rb', line 83

def self.random_short_name_topic
  ::Studium::Exams.all_topics_as_short_name.sample
end

.random_topicObject

#

Studium::Exams.random_topic

This method will return a random topic.

#


76
77
78
# File 'lib/studium/toplevel_methods/available_topics.rb', line 76

def self.random_topic
  ::Studium::Exams.available_topics?.sample.to_s
end

.read_delay_from_fileObject

#

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.

#


20
21
22
23
24
25
26
27
28
# File 'lib/studium/toplevel_methods/read_delay_between_questions_from_file.rb', line 20

def self.read_delay_from_file
  if File.exist? DELAY_CONSTANT_STORED_HERE
    _ = YAML.load_file(DELAY_CONSTANT_STORED_HERE)
    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?

#

Returns:

  • (Boolean)


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.

#

Returns:

  • (Boolean)


30
31
32
# File 'lib/studium/exams/remote_ftp_url.rb', line 30

def self.remote_url?
  @remote_exams_url
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.

#


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/studium/toplevel_methods/report.rb', line 42

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 = ::Colours::AllColourMethods.deepskyblue(n_total_answers)
  result = ''.dup
  result << ::Colours::AllColourMethods.grey('')
  case report_in_which_language # case tag
  # ======================================================================= #
  # === :english
  # ======================================================================= #
  when :english,
       :default # Use the english language here, which is the default.
    result << ::Colours::AllColourMethods.grey('We already solved ')+
              colourized_n_total_answers+
              ::Colours::AllColourMethods.grey(' of ')+
              ::Studium::Colours.sfancy(n_total_questions.to_s)+
              ::Colours::AllColourMethods.grey(' available questions. ('+percentage)+
              ::Colours::AllColourMethods.grey(' solved).')
  # ======================================================================= #
  # === :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.

#


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/studium/toplevel_methods/report_nquestions_of.rb', line 72

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)+' questions in '\
    'these '+Colours.sfile((i.flatten.size / 2).to_s)+' 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_solvedObject

#

Studium::Exams.return_n_exam_questions_were_already_solved

#


24
25
26
27
28
29
30
31
32
33
# File 'lib/studium/toplevel_methods/report.rb', line 24

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')
#


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/studium/toplevel_methods/return_n_percent_solved_from_this_topic.rb', line 39

def self.return_n_percent_solved_from_this_topic(
    this_topic
  )
  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
#


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/studium/toplevel_methods/report_nquestions_of.rb', line 39

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 = File.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_totalObject

#

Studium::Exams.return_n_questions_solved_in_total

This method will return a number, telling us how many questions were solved in total.

Example:

Studium::Exams.return_n_questions_solved_in_total # => 116
#


107
108
109
110
111
112
113
114
# File 'lib/studium/toplevel_methods/report.rb', line 107

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.

#


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/studium/toplevel_methods/return_n_questions_were_answered_for_this_topic.rb', line 20

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.

#


32
33
34
35
36
# File 'lib/studium/toplevel_methods/exams_dataset.rb', line 32

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) ⇒ Object

#

Studium::Exams.show_passed_exams

#


23
24
25
26
27
28
29
# File 'lib/studium/exams/passed_exams/passed_exams.rb', line 23

def self.show_passed_exams(i = ARGV)
  if i.empty?
    Studium.show_n_last_exams(:show_all_passed_exams)
  else
    Studium::Exams::LastExams.new(i)
  end
end

.total_ects_points_passed(use_this_file = 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.

#


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/studium/toplevel_methods/total_ects_points_passed.rb', line 24

def self.total_ects_points_passed(
    use_this_file = 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
    puts "No dataset is available at `#{Colours.sfile(use_this_file)}`."
    puts '(The method was Studium::Exams.total_ects_points_passed().)'
    puts
  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.

#

Returns:

  • (Boolean)


90
91
92
# File 'lib/studium/toplevel_methods/n_questions_available.rb', line 90

def n_questions_available?
  Exams.n_questions_available?
end