# HG changeset patch # User Nattee Niparnan # Date 2015-08-27 13:31:02 # Node ID dfe79b5eef357f602b402aee5ccb0c3e0b078fd6 # Parent 662f5e0a87b8015dfe3b102d0878e0e2c61f0e25 NOT WORKING add submission view log diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,7 +78,7 @@ treetop (~> 1.4.8) mime-types (1.25.1) multi_json (1.10.1) - mysql2 (0.3.17) + mysql2 (0.3.20) polyglot (0.3.5) power_assert (0.2.2) prototype-rails (3.2.1) diff --git a/app/controllers/graders_controller.rb b/app/controllers/graders_controller.rb --- a/app/controllers/graders_controller.rb +++ b/app/controllers/graders_controller.rb @@ -86,6 +86,8 @@ @formatted_code = formatter.format(lexer.lex(@submission.source)) @css_style = Rouge::Themes::ThankfulEyes.render(scope: '.highlight') + SubmissionLogView.create(user_id: user.id,submission_id: @submission.id) + end # various grader controls diff --git a/app/models/submission_view_logs.rb b/app/models/submission_view_logs.rb new file mode 100644 --- /dev/null +++ b/app/models/submission_view_logs.rb @@ -0,0 +1,3 @@ +class SubmissionViewLogs < ActiveRecord::Base + attr_accessible :submission_id, :user_id +end diff --git a/app/views/report/cheat_scruntinize.html.haml b/app/views/report/cheat_scruntinize.html.haml new file mode 100644 --- /dev/null +++ b/app/views/report/cheat_scruntinize.html.haml @@ -0,0 +1,82 @@ +- content_for :header do + = stylesheet_link_tag 'tablesorter-theme.cafe' + = javascript_include_tag 'local_jquery' + +%script{:type=>"text/javascript"} + $(function () { + $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); + $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); + $('#my_table').tablesorter({widthFixed: true, widgets: ['zebra']}); + $('#my_table2').tablesorter({widthFixed: true, widgets: ['zebra']}); + $('#sub_table').tablesorter({widthFixed: true, widgets: ['zebra']}); + }); + +%h1 Login status + +=render partial: 'report_menu' + + += form_tag({session: :url }) do + .submitbox + %table + %tr + %td{colspan: 6, style: 'font-weight: bold'}= 'Query login & submit in the range' + %tr + %td{style: 'width: 120px; font-weight: bold'}= 'Login date range' + %td{align: 'right'} since: + %td= text_field_tag 'since_datetime', @since_time + %tr + %td + %td{align: 'right'} until: + %td= text_field_tag 'until_datetime', @until_time + %tr + %td + %td + %td Blank mean no condition + %tr + %td{style: 'width: 120px; font-weight: bold'}= "ID" + %td{colspan: 2}= text_field_tag 'SID', @sid, size: 40 + %tr + %td + %td + %td= submit_tag 'query' + + +%h2 Logs + +- if @sid + %table + %tbody + - @sid.each do |id| + - user = User.where("login = ?",id).first + %tr + //%td= link_to id, controller: :user, action: :profile, id: id + %td= link_to id, "https://www.nattee.net/java/users/profile/#{user.id}" + %td= user.full_name + +//%table.tablesorter-cafe#my_table +%table.info + %thead + %tr.info-head + %th Time + %th Action + %th IP + %th login + %th name + %th problem + %th score + %tbody + - if @logs + - @logs.each do |l| + %tr{class: cycle('info-even','info-odd')} + %td= l[:submitted_at].strftime "%Y.%b.%d %H:%M:%S" + //%td= l[:id] == -1 ? "LOGIN" : link_to("submit #{l[:id]}", controller: 'graders' , action: 'submission', id: l[:id]) + %td= l[:id] == -1 ? "LOGIN" : link_to( "submit #{l[:id]}", "https://www.nattee.net/java/graders/submission/#{l[:id]}") + %td= l[:ip_address] + //%td= link_to l[:login], controller: 'users', action: 'profile', id: l[:id] + %td= link_to( l[:login], "https://www.nattee.net/java/users/profile/#{l.user_id}") + %td= l[:full_name] + %td= l[:id] == -1 ? "" : l.problem.name + %td= l[:id] == -1 ? "" : l.points * 100/ l.problem.full_score + + diff --git a/db/migrate/20150827131927_create_submission_view_logs.rb b/db/migrate/20150827131927_create_submission_view_logs.rb new file mode 100644 --- /dev/null +++ b/db/migrate/20150827131927_create_submission_view_logs.rb @@ -0,0 +1,10 @@ +class CreateSubmissionViewLogs < ActiveRecord::Migration + def change + create_table :submission_view_logs do |t| + t.integer :user_id + t.integer :submission_id + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -11,16 +11,16 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150618085823) do +ActiveRecord::Schema.define(:version => 20150827131927) do create_table "announcements", :force => true do |t| t.string "author" - t.text "body" + t.text "body", :limit => 16777215 t.boolean "published" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "frontpage", :default => false - t.boolean "contest_only", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "frontpage", :default => false + t.boolean "contest_only", :default => false t.string "title" t.string "notes" end @@ -50,19 +50,19 @@ end create_table "descriptions", :force => true do |t| - t.text "body" + t.text "body", :limit => 16777215 t.boolean "markdowned" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "grader_configurations", :force => true do |t| t.string "key" t.string "value_type" t.string "value" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "description", :limit => 16777215 end create_table "grader_processes", :force => true do |t| @@ -97,10 +97,10 @@ t.integer "sender_id" t.integer "receiver_id" t.integer "replying_message_id" - t.text "body" + t.text "body", :limit => 16777215 t.boolean "replied" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "problems", :force => true do |t| @@ -142,7 +142,7 @@ create_table "sessions", :force => true do |t| t.string "session_id" - t.text "data" + t.text "data", :limit => 16777215 t.datetime "updated_at" end @@ -159,18 +159,25 @@ t.string "password" end + create_table "submission_view_logs", :force => true do |t| + t.integer "user_id" + t.integer "submission_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "submissions", :force => true do |t| t.integer "user_id" t.integer "problem_id" t.integer "language_id" - t.text "source" + t.text "source", :limit => 16777215 t.binary "binary" t.datetime "submitted_at" t.datetime "compiled_at" - t.text "compiler_message" + t.text "compiler_message", :limit => 16777215 t.datetime "graded_at" t.integer "points" - t.text "grader_comment" + t.text "grader_comment", :limit => 16777215 t.integer "number" t.string "source_filename" t.float "max_runtime" @@ -191,10 +198,10 @@ create_table "test_pairs", :force => true do |t| t.integer "problem_id" - t.text "input", :limit => 16777215 - t.text "solution", :limit => 16777215 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.text "input", :limit => 2147483647 + t.text "solution", :limit => 2147483647 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "test_requests", :force => true do |t| @@ -205,13 +212,13 @@ t.string "output_file_name" t.string "running_stat" t.integer "status" - t.datetime "updated_at", :null => false + t.datetime "updated_at", :null => false t.datetime "submitted_at" t.datetime "compiled_at" - t.text "compiler_message" + t.text "compiler_message", :limit => 16777215 t.datetime "graded_at" t.string "grader_comment" - t.datetime "created_at", :null => false + t.datetime "created_at", :null => false t.float "running_time" t.string "exit_status" t.integer "memory_usage" @@ -239,9 +246,9 @@ t.boolean "activated", :default => false t.datetime "created_at" t.datetime "updated_at" + t.string "section" t.boolean "enabled", :default => true t.string "remark" - t.string "last_ip" end add_index "users", ["login"], :name => "index_users_on_login", :unique => true diff --git a/spec/models/submission_view_logs_spec.rb b/spec/models/submission_view_logs_spec.rb new file mode 100644 --- /dev/null +++ b/spec/models/submission_view_logs_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe SubmissionViewLogs do + pending "add some examples to (or delete) #{__FILE__}" +end