diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -6,7 +6,7 @@ before_action :admin_authorization, only: [:login_stat,:submission, :submission_query, :login, :login_detail_query, :login_summary_query, - :stuck, :cheat_report, :cheat_scruntinize, :show_max_score, :current_score] + :stuck, :cheat_report, :cheat_scrutinize, :show_max_score, :current_score] before_action(only: [:problem_hof]) { |c| return false unless check_valid_login @@ -453,7 +453,7 @@ end - def cheat_scruntinize + def cheat_scrutinize #convert date & time date_and_time = '%Y-%m-%d %H:%M' begin @@ -473,7 +473,7 @@ @sid = params[:SID].split(/[,\s]/) if params[:SID] unless @sid and @sid.size > 0 return - redirect_to actoin: :cheat_scruntinize + redirect_to actoin: :cheat_scrutinize flash[:notice] = 'Please enter at least 1 student id' end mark = Array.new(@sid.size,'?') diff --git a/app/views/report/cheat_scruntinize.html.haml b/app/views/report/cheat_scruntinize.html.haml deleted file mode 100644 --- a/app/views/report/cheat_scruntinize.html.haml +++ /dev/null @@ -1,82 +0,0 @@ -- 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/app/views/report/cheat_scrutinize.html.haml b/app/views/report/cheat_scrutinize.html.haml new file mode 100644 --- /dev/null +++ b/app/views/report/cheat_scrutinize.html.haml @@ -0,0 +1,107 @@ +- 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 + +.panel.panel-primary + .panel-heading + User ID and time rnage + .panel-body + = form_tag({session: :url }) do + .row.form-group + .col-md-2 + From Date: + .col-md-4 + .input-group.date + = text_field_tag :since_datetime, @since_time, class: 'form-control' + %span.input-group-addon + %span.glyphicon.glyphicon-calendar + .row.form-group + .col-md-2 + Until Date: + .col-md-4 + .input-group.date + = text_field_tag :until_datetime, @until_time, class: 'form-control' + %span.input-group-addon + %span.glyphicon.glyphicon-calendar + .row.form-group + .col-md-2 + IDs (separated by space): + .col-md-10 + = text_field_tag 'SID', @sid, size: 40, class: 'form-control' + .row.form-group + .col-md-2 + .col-md-10 + =submit_tag 'query', class: 'btn btn-primary' + + -# + %table + %tr + %td{style: 'width: 120px; font-weight: bold'}= 'Login date range' + %td{align: 'right'} since: + %td= text_field_tag 'since_datetime', @since_time, class: 'form-control datetimepicker' + %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/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -150,8 +150,8 @@ get 'stuck' get 'cheat_report' post 'cheat_report' - get 'cheat_scruntinize' - post 'cheat_scruntinize' + get 'cheat_scrutinize' + post 'cheat_scrutinize' get 'submission' post 'submission_query' get 'login_stat'