{"id":226869,"date":"2014-06-21T14:07:02","date_gmt":"2014-06-21T10:07:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=226869"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=226869","title":{"rendered":"<span class=\"post_title\">\u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043d\u0430 ruby \u0434\u043b\u044f web<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0414\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f ruby \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f web. \u0412\u0432\u0438\u0434\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0437\u043d\u0430\u043d\u0438\u0439 \u0438 \u043e\u043f\u044b\u0442\u0430 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"http:\/\/sinatraruby.ru\/\">sinatra<\/a>. <a name=\"habracut\"><\/a> \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0432 \u043c\u043e\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u043e mutaAlim.json, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443 \u043d\u0430\u0441 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 json \u0444\u043e\u0440\u043c\u0430\u0442\u0435. <\/p>\n<h5>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432:<\/h5>\n<p>  <\/p>\n<pre><code class=\"ruby\">[     {         &quot;id&quot; : 1,         &quot;question&quot; : &quot;\u0410\u0441\u0441\u0430\u043b\u0430\u043c\u0443 \u0410\u043b\u0435\u0439\u043a\u0443\u043c!&quot;,         &quot;answers&quot; : [&quot;\u0412\u0430\u0430\u043b\u0435\u0439\u043a\u0443\u043c \u0410\u0441\u0441\u0430\u043b\u0430\u043c&quot;, &quot;\u041f\u0440\u0438\u0432\u0435\u0442&quot;, &quot;\u0417\u0434\u043e\u0440\u043e\u0432\u043e&quot;, &quot;\u0425\u0430\u0439&quot;]     },     {          &quot;id&quot; : 2,         &quot;question&quot; : &quot;\u041a\u0430\u043a \u0434\u0435\u043b\u0430?&quot;,         &quot;answers&quot; : [&quot;\u0430\u043b\u044c\u0445\u0430\u043c\u0434\u0443\u041b\u0438\u043b\u044f\u0433\u044c&quot;, &quot;\u041f\u043b\u043e\u0445\u043e&quot;, &quot;\u0445\u043e\u0440\u043e\u0448\u043e&quot;, &quot;\u0448\u0438\u043a\u0430\u0440\u043d\u043e&quot;]     }, \u2026..(\u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432 \u0442\u0430\u043a\u043e\u043c \u0436\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0435)  ] <\/code><\/pre>\n<p>  \u0423 \u043d\u0430\u0441 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 json \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0445\u0435\u0448 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<br \/>  \u041e\u0442\u0432\u0435\u0442\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 answers, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c.<\/p>\n<h5> \u0412\u0442\u043e\u0440\u043e\u0439 \u0444\u0430\u0439\u043b mutaAlim.rb \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/h5>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u043e\u0431\u043b\u0438\u0436\u0435. \u041f\u0435\u0440\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0433\u0435\u043c\u044b sinatra \u0438 json:<\/p>\n<pre><code class=\"ruby\">require 'sinatra' require 'json' <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 <\/p>\n<pre><code class=\"ruby\">get '\/' do      erb :index end <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043f\u043e <a href=\"http:\/\/localhost:4567\/\">\u0430\u0434\u0440\u0435\u0441\u0443<\/a> \u0443 \u043d\u0430\u0441 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0444\u0430\u0439\u043b\u0435:<\/p>\n<pre><code class=\"html\">@@index &lt;!DOCTYPE html&gt; &lt;html&gt;     &lt;head&gt;         &lt;title&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/title&gt;     &lt;\/head&gt;     &lt;body&gt;         &lt;h1&gt; \u0410\u0441\u0441\u0430\u043b\u0430\u043c\u0443 \u0433I\u0430\u043b\u0430\u0439\u043a\u0443\u043c \u0432\u0430 \u0440\u0430h\u043c\u0430\u0442\u0443\u041b\u043b\u0430h\u0438 \u0432\u0430 \u0431\u0430\u0440\u0430\u043a\u0430\u0442\u0443h\u0443!&lt;\/h1&gt;             &lt;h1&gt; \u041c\u0438\u0440\u0430 \u0432\u0430\u043c, \u041c\u0438\u043b\u043e\u0441\u0442\u0438 \u0438 \u0411\u043b\u0430\u0433\u043e\u0441\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0412\u0441\u0435\u0432\u044b\u0448\u043d\u0435\u0433\u043e!&lt;\/h1&gt;             &lt;h1&gt; \u0421\u0430\u0439\u0442 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u043d\u0438\u0439&lt;\/h1&gt;             &lt;h2&gt;\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 &lt;\/h2&gt;         &lt;div&gt;             &lt;p&gt;    \u042d\u0442\u043e\u0442 \u0441\u0430\u0439\u0442 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u043d\u0438\u044f. &lt;\/p&gt;          &lt;\/div&gt;         &lt;input  value=&quot;\u041d\u0430\u0447\u0430\u0442\u044c \u0442\u0435\u0441\u0442&quot; name=&quot;test_begin&quot; onclick=&quot;location.href='\/test'&quot; type=&quot;button&quot;&gt;     &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0430 \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443 \u0442\u0435\u0441\u0442\u043e\u0432. \u0414\u0430\u043b\u0435\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0443 \u043d\u0430\u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"ruby\">#\u0445\u0435\u0448 \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 @@test_hash #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432 @@kol_testov = 13 #\u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 @@mas_test_number = Array.new(@@kol_testov) #\u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043e\u0442\u0432\u0435\u0442\u0430\u043c\u0438, -1 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043e\u0442\u0432\u0435\u0442\u0438\u043b\u0438 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438\u043d\u0430\u0447\u0435 \u043d\u043e\u043c\u0435\u0440 \u043e\u0442\u0432\u0435\u0442\u0430 @@mas_test_answer  #\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438  test_file = File.open('mutaAlim.json',&quot;rb&quot;) @@test_hash = JSON.parse(test_file.read) test_file.close  #\u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 @@not_answer = &quot;\u0412\u044b \u043d\u0435 \u0434\u0430\u043b\u0438 \u043e\u0442\u0432\u0435\u0442&quot; #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0432\u0435\u0442\u043e\u0432 @@answers #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 @@ball #\u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 @@procent_tru_answers  #\u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435, \u0438\u043d\u0430\u0447\u0435 \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u0432 erb \u0431\u044b\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043d\u0435 \u0441\u043c\u043e\u0433 \u043f\u043e\u043d\u044f\u0442\u044c \u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u0414\u0430\u043b\u0435\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u043e \u043a\u043e\u0434 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"ruby\"># \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 get '\/test' do      if params[:var] == nil         @@mas_test_answer = Array.new(@@kol_testov) { |i| -1}         # \u0437\u0430\u043d\u043e\u0441\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 @@mas_test_number         @@mas_test_number[0] = Random.rand(@@test_hash.length)         @@mas_test_number.each_index do |i|              begin                 flag = true                 buf = Random.rand(@@test_hash.length)                 0..i.times do |j|                     if @@mas_test_number[j]==buf                         flag = false                     end                 end                 if flag                     @@mas_test_number[i] = buf                 end             end until flag==true         end         @@test_number = 0;                  # \u0437\u0430\u043d\u043e\u0441\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 @@mas_random_variants         @@mas_random_variants =  Array.new(@@kol_testov)         @@mas_random_variants.each_index do |i|              @@mas_random_variants[i] = Array.new(@@test_hash[@@mas_test_number[i]][&quot;answers&quot;].size)         end         @@mas_random_variants.each_index do |i|             @@mas_random_variants[i][0] = Random.rand(@@test_hash[@@mas_test_number[i]][&quot;answers&quot;].size)             @@mas_random_variants[i].each_index do |j|                 begin                     flag = true                     buf = Random.rand(@@test_hash[@@mas_test_number[i]][&quot;answers&quot;].size)                     0..j.times do |k|                         if @@mas_random_variants[i][k]==buf                             flag = false                         end                     end                     if flag                         @@mas_random_variants[i][j] = buf                     end                 end until flag==true             end         end     else         #\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 @@mas_test_answer         @@mas_test_answer[@@test_number] = params[:var].to_i         #\u0435\u0441\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0430\u0435\u043c \u0441\u043b\u0435\u0434 \u0432\u043e\u043f\u0440\u043e\u0441         if @@test_number != @@kol_testov - 1             @@test_number += 1         end     end     erb :test end <\/code><\/pre>\n<p>  \u041f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e <code>params[:var] == nil<\/code> \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0435 \u0438 \u00ab\u0433\u043e\u0442\u043e\u0432\u0438\u043c\u00bb \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435(\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u0438\u0437 \u0431\u0430\u0437\u044b, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u00ab\u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0438\u0432\u0430\u0435\u043c\u00bb \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432), \u0438\u043d\u0430\u0447\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432. \u0412\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 get \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445, \u0430 \u043c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b \u0432 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0438\u0441\u0430\u043b\u043e\u0441\u044c \u043e\u043d\u043e \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u00ab\u043b\u0438\u0448\u044c \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e\u00bb. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"http:\/\/localhost:4567\/test?var=0\">http:\/\/localhost:4567\/test?var=0<\/a> \u0442\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0.<\/p>\n<h5>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 <\/h5>\n<p>  <\/p>\n<pre><code class=\"html\">@@test &lt;!DOCTYPE html&gt; &lt;html&gt;     &lt;head&gt;         &lt;title&gt;\u0422\u0435\u0441\u0442\u044b&lt;\/title&gt;     &lt;\/head&gt;     &lt;body&gt;         &lt;div&gt;             &lt;h2&gt; \u0412\u043e\u043f\u0440\u043e\u0441 \u2116&lt;%= @@test_number +1 %&gt; &lt;h2&gt;             &lt;h3&gt;                 &lt;%= @@test_hash[@@mas_test_number[@@test_number]][&quot;question&quot;] %&gt;             &lt;\/h3&gt;             &lt;\/div&gt;         &lt;p&gt;              &lt;form method=&quot;get&quot; action=&quot;\/test&quot;&gt;                 &lt;% @@test_hash[@@mas_test_number[@@test_number]][&quot;answers&quot;].each_index do |i| %&gt;                     &lt;input type=&quot;radio&quot; name=&quot;var&quot; value=&quot;&lt;%= @@mas_random_variants[@@test_number][i] %&gt;&quot;&gt;                         &lt;%= @@test_hash[@@mas_test_number[@@test_number]][&quot;answers&quot;][@@mas_random_variants[@@test_number][i]] %&gt;                  &lt;% end %&gt;                 &lt;input type=&quot;submit&quot; value=&quot;\u041e\u0442\u0432\u0435\u0442\u0438\u0442\u044c&quot;\/&gt;             &lt;\/form&gt;         &lt;\/p&gt;                  &lt;div&gt;             &lt;input type=&quot;button&quot; name=&quot;next_question&quot; value=&quot;\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441&quot; onclick=&quot;location.href='\/test\/pred'&quot;&gt;             &lt;% @@mas_test_number.each_index do |i| %&gt;                 &lt;a href='\/test\/question\/&lt;%= i + 1 %&gt;'&gt; \u2116 &lt;%= i + 1 %&gt; &lt;\/a&gt;             &lt;% end %&gt;             &lt;input type=&quot;button&quot; name=&quot;pred_question&quot; value=&quot;\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441&quot; onclick=&quot;location.href='\/test\/next'&quot;&gt;                 &lt;\/div&gt;                  &lt;input type=&quot;button&quot; name=&quot;result&quot; value=&quot;\u0417\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435&quot; onclick=&quot;location.href='\/test\/result'&quot;&gt;     &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u043a\u043e\u0434\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443 \u043f\u0440\u043e\u0438c\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 erb \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c <code>&lt;%= #\u043a\u043e\u0434 \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 %&gt;<\/code> \u0438 <code>&lt;% \u043a\u043e\u0434 \u0431\u0435\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 %&gt; <\/code>. \u041d\u0430 \u0441\u0430\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0435 \u0432\u043e\u043f\u0440\u043e\u0441, \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432(radiobutton), \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0432\u0441\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b. \u043a\u043d\u043e\u043f\u043a\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043f\u043e \u0442\u0435\u0441\u0442\u0430\u043c \u0438 \u043a\u043d\u043e\u043f\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u0430. <\/p>\n<h5>\u0420\u0430\u0431\u043e\u0442\u0430 \u043a\u043d\u043e\u043f\u043e\u043a \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0438 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/h5>\n<p>  <\/p>\n<pre><code class=\"ruby\"># \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 get '\/test\/question\/:id' do     @@test_number = params[:id].to_i - 1     erb :test end  # \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 get '\/test\/next' do     if @@test_number != @@kol_testov - 1             @@test_number += 1     end     erb :test end  # \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 get '\/test\/pred' do     if @@test_number != 0             @@test_number -= 1     end     erb :test end <\/code><\/pre>\n<h5>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u0434 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0442\u043e\u0433\u0438 <\/h5>\n<p>  <\/p>\n<pre><code class=\"ruby\"># \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 get '\/test\/result' do     @@ball = 0     @@answers = 0     #\u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432      @@mas_test_answer.each do |i|          if i == 0              @@ball += 1          end         if i != -1              @@answers += 1          end     end     @@procent_tru_answers = (100\/@@kol_testov) * @@ball          erb :result end <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418 \u043a\u043e\u0434 \u043d\u0430 html + erb <\/h5>\n<p>  <\/p>\n<pre><code class=\"ruby\">@@result &lt;!DOCTYPE html&gt; &lt;html&gt;     &lt;head&gt;         &lt;title&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442&lt;\/title&gt;     &lt;\/head&gt;     &lt;body&gt;         &lt;h1&gt; \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u0430\u0448\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430 &lt;\/h1&gt;                      &lt;div&gt;             &lt;table  cellspacing=&quot;2&quot; border=&quot;1&quot; cellpadding=&quot;5&quot;&gt;                 &lt;tr&gt; &lt;td&gt; \u2116 &lt;\/td&gt; &lt;td&gt; \u0412\u043e\u043f\u0440\u043e\u0441 &lt;\/td&gt; &lt;td&gt; \u0412\u0430\u0448 \u043e\u0442\u0432\u0435\u0442 &lt;\/td&gt; &lt;td&gt; \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 &lt;\/td&gt; &lt;tr&gt;                 &lt;% @@mas_test_answer.each_index do |i| %&gt;                     &lt;tr&gt;                          &lt;td&gt; &lt;%= i+1 %&gt; &lt;\/td&gt;                          &lt;td&gt; &lt;%= @@test_hash[@@mas_test_number[i]][&quot;question&quot;] %&gt; &lt;\/td&gt;                          &lt;td&gt; &lt;%=     if (@@mas_test_answer[i] == -1)                                           @@not_answer                                      else @@test_hash[@@mas_test_number[i]][&quot;answers&quot;][@@mas_test_answer[i]] end %&gt; &lt;\/td&gt;                         &lt;td&gt; &lt;%= @@test_hash[@@mas_test_number[i]][&quot;answers&quot;][0] %&gt; &lt;\/td&gt;                      &lt;tr&gt;                 &lt;% end %&gt;             &lt;\/table&gt;         &lt;\/div&gt;         &lt;div&gt;             &lt;h3&gt; \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432 =                  &lt;%= @@kol_testov %&gt; &lt;\/h3&gt;             &lt;h3&gt; \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0432\u0435\u0442\u043e\u0432 =      &lt;%= @@answers %&gt; &lt;\/h3&gt;             &lt;h3&gt; \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 =      &lt;%= @@ball %&gt; &lt;\/h3&gt;             &lt;h3&gt; \u041f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 =          &lt;%= @@procent_tru_answers %&gt; %&lt;\/h3&gt;         &lt;div&gt;         &lt;div&gt;             &lt;p&gt;    \u042d\u0442\u043e\u0442 \u0441\u0430\u0439\u0442 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u043d\u0438\u044f.             &lt;\/p&gt;          &lt;\/div&gt;         &lt;input  value=&quot;\u041f\u0440\u043e\u0439\u0442\u0438 \u0441\u043d\u043e\u0432\u0430&quot; name=&quot;test_begin&quot; onclick=&quot;location.href='\/test'&quot; type=&quot;button&quot;&gt;     &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u042f \u043f\u043e\u043d\u0438\u043c\u0430\u044e \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043b\u0435\u0433\u0447\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043d\u0435\u0436\u0435\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u044c \u0438\u043b\u0438 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0442\u044c \u044d\u0442\u043e. \u042f\u0437\u044b\u043a ruby \u044f \u043d\u0430\u0447\u0430\u043b \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0440\u043e\u0432\u043d\u043e \u043a\u0430\u043a \u0434\u0432\u0438\u0436\u043e\u043a sinatra, \u044f\u0437\u044b\u043a \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 erb \u0438 \u0444\u043e\u0440\u043c\u0430\u0442 json, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0448\u0443 \u0441\u0442\u0440\u043e\u0433\u043e \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u043e, \u0447\u0442\u043e \u0438 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b. <br \/>  \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 sinatra \u043a ror, \u043e\u0442 json \u043a \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0442 erb \u043a haml, \u043e\u0442 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432(radiobutton) \u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c 5-6 \u0442\u0438\u043f\u043e\u0432, \u043e\u0442 \u0442\u0435\u0441\u0442\u043e\u0432 \u043a \u0438\u0433\u0440\u0435 \u0438 \u043f\u043b\u044e\u0441 \u0434\u0438\u0437\u0430\u0439\u043d \u0441 \u0432\u0435\u0440\u0441\u0442\u043a\u043e\u0439. <\/p>\n<p>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0432\u0438\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 <a href=\"http:\/\/daavat-ru.herokuapp.com\/\">\u0441\u0430\u0439\u0442\u0435<\/a>.<br \/>  \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 <a href=\"https:\/\/github.com\/asker1327\/mutaAlim\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/226869\/\"> http:\/\/habrahabr.ru\/post\/226869\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0414\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f ruby \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f web. \u0412\u0432\u0438\u0434\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0437\u043d\u0430\u043d\u0438\u0439 \u0438 \u043e\u043f\u044b\u0442\u0430 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"http:\/\/sinatraruby.ru\/\">sinatra<\/a>. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-226869","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/226869","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=226869"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/226869\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=226869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=226869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=226869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}