Class: Studium::Sinatra
- Inherits:
-
Cyberweb::Sinatra
- Object
- Cyberweb::Sinatra
- Studium::Sinatra
- Defined in:
- lib/studium/sinatra/app.rb,
lib/studium/sinatra/misc.rb
Constant Summary collapse
- USE_THIS_UNIFORM_CSS_STYLE =
#
USE_THIS_UNIFORM_CSS_STYLE
#
'margin-left:3.5em; font-weight: bold;'- CSS_FOR_THE_WEBPAGE =
#
ANSWER_DIV
#
' .answer_div { color: gold; background-color: black; padding: 0.6em; border: 2px solid black; } a:link { padding: 1px; background-color: white; color: black; border: 1px solid black; text-decoration: none; } a:visited { padding: 1px; background-color: white; border: 1px solid black; text-decoration: none; } a:hover { padding: 1px; color: hotpink; background-color: white; text-decoration: none; border: 1px solid black; } a:active { padding: 1px; background-color: white; border: 1px solid black; } .hide { display: none; } '- JAVASCRIPT_CODE =
" <script> function delay_before_reveal() { setTimeout(function(){ document.getElementById('id_footer').classList.remove('hide'); }, 100); } </script> "
Instance Method Summary collapse
-
#create_index_of_hyperlinks ⇒ Object
# === create_index_of_hyperlinks.
-
#initialize ⇒ Sinatra
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#return_html_code_for_this_exam_topic(this_topic) ⇒ Object
# === return_html_code_for_this_exam_topic ========================================================================= #.
-
#return_link_to_the_root_entry ⇒ Object
# === return_link_to_the_root_entry (home tag) ========================================================================= #.
-
#return_paragraph_of_hyperlinks ⇒ Object
(also: #footer)
# === return_paragraph_of_hyperlinks ========================================================================= #.
-
#return_show_the_answer_button ⇒ Object
# === return_show_the_answer_button ========================================================================= #.
-
#return_view_string ⇒ Object
(also: #return_root_string)
# === return_view_string ========================================================================= #.
-
#sorted_exam_topics? ⇒ Boolean
# === sorted_exam_topics? ========================================================================= #.
-
#title(i) ⇒ Object
# === title ========================================================================= #.
Constructor Details
#initialize ⇒ Sinatra
#
initialize
#
101 102 103 104 |
# File 'lib/studium/sinatra/app.rb', line 101 def initialize super() reset end |
Instance Method Details
#create_index_of_hyperlinks ⇒ Object
#
create_index_of_hyperlinks
Create our index of hyperlinks next.
#
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/studium/sinatra/misc.rb', line 43 def create_index_of_hyperlinks @index_of_hyperlinks = a( '/n_ects_points_passed', css_style: USE_THIS_UNIFORM_CSS_STYLE )+ '<br>'+ a( '/curricula', css_style: USE_THIS_UNIFORM_CSS_STYLE )+ '<br>'.dup # ======================================================================= # # Keep the exam-topics sorted. # ======================================================================= # sorted_exam_topics?.each {|this_topic| @index_of_hyperlinks << a('/'+this_topic, css_style: USE_THIS_UNIFORM_CSS_STYLE)+ '<br>'.dup } @index_of_hyperlinks << a('/questions_solved_from_day_to_day', css_style: USE_THIS_UNIFORM_CSS_STYLE) end |
#reset ⇒ Object
#
reset
#
109 110 111 112 113 114 115 |
# File 'lib/studium/sinatra/app.rb', line 109 def reset @root_string = p('You can also ask exam questions.') # ======================================================================= # # Create the hyperlinks-section next: # ======================================================================= # create_index_of_hyperlinks end |
#return_html_code_for_this_exam_topic(this_topic) ⇒ Object
#
return_html_code_for_this_exam_topic
#
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/studium/sinatra/app.rb', line 167 def return_html_code_for_this_exam_topic(this_topic) css_style = '<head><style>'+CSS_FOR_THE_WEBPAGE+'</style><title>'+ this_topic.to_s+ '</title></head>' result = Studium.return_question_answer_string_from_this_topic(this_topic).to_s result = ::Studium.question_answer(result) question = result.first answer = result.last HtmlTags.html( css_style+ HtmlTags.h2( question )+ # ===================================================================== # # The <div> tag containing the answer. # ===================================================================== # HtmlTags.div( answer,'answer_div hide', 'id_footer' )+ JAVASCRIPT_CODE+ + '<a style="border:1px solid black; margin-left:4px" href=""><b>Reload</b></a>'\ '<br><br>'+ return_link_to_the_root_entry+ '<br>' ) end |
#return_link_to_the_root_entry ⇒ Object
#
return_link_to_the_root_entry (home tag)
#
206 207 208 209 210 211 212 213 |
# File 'lib/studium/sinatra/app.rb', line 206 def return_link_to_the_root_entry a( '/', content: '[HOME]', css_style: 'colour: darkblue; margin-left: 2em; '\ 'font-weight: bold; font-size: larger' ) end |
#return_paragraph_of_hyperlinks ⇒ Object Also known as:
#
return_paragraph_of_hyperlinks
#
127 128 129 130 131 132 133 |
# File 'lib/studium/sinatra/app.rb', line 127 def return_paragraph_of_hyperlinks p( 'These options are available for the Studium-sinatra '\ 'interface: <br><br>'+ return_index_of_hyperlinks ) end |
#return_show_the_answer_button ⇒ Object
#
return_show_the_answer_button
#
198 199 200 201 |
# File 'lib/studium/sinatra/app.rb', line 198 def '<button style="border:1px solid black" accesskey="s" onclick="delay_before_reveal()"> <b>Show the answer</b></button>' end |
#return_view_string ⇒ Object Also known as: return_root_string
#
return_view_string
#
138 139 140 141 142 143 144 |
# File 'lib/studium/sinatra/app.rb', line 138 def return_view_string h1('Studium', css_style: 'margin-left:0.25em;')+ p( "The <b>following entry points</b> are currently available." )+ return_index_of_hyperlinks end |
#sorted_exam_topics? ⇒ Boolean
#
sorted_exam_topics?
#
120 121 122 |
# File 'lib/studium/sinatra/app.rb', line 120 def sorted_exam_topics? Studium.available_exam_topics?.sort end |
#title(i) ⇒ Object
#
title
#
79 80 81 |
# File 'lib/studium/sinatra/misc.rb', line 79 def title(i) HtmlTags.title(i) end |