Finishing up graphs. Formatting and adding "Runs" lines.

This commit is contained in:
John Geiger
2016-05-29 17:30:49 +02:00
parent 8259097b37
commit 34c9d791f4
4 changed files with 43 additions and 254 deletions

View File

@ -37,7 +37,7 @@ gem 'tubesock'
gem 'faye-websocket'
gem 'nokogiri'
gem 'd3-rails'
gem 'rest-client
gem 'rest-client'
group :development do
gem 'better_errors', platform: :ruby

View File

@ -9,6 +9,7 @@ $(function() {
submissionsScoreAndTimeAssess = [[0,0]];
submissionsScoreAndTimeSubmits = [[0,0]];
submissionsScoreAndTimeRuns = [];
var maximumValue = 0;
var wtimes = $('#wtimes').data('working_times'); //.hidden#wtimes data-working_times=ActiveSupport::JSON.encode(working_times_until)
@ -18,43 +19,38 @@ $(function() {
for (var i = 0;i<submissions_length;i++){
var submission = submissions[i];
var workingTime;
var submissionArray;
workingTime = get_minutes(wtimes[i]);
submissionArray = [submission.score, 0];
if (workingTime > 0) {
submissionArray[1] = workingTime;
}
if(submission.score>maximumValue){
maximumValue = submission.score;
}
if(submission.cause == "assess"){
var workingTime = get_minutes(wtimes[i]);
var submissionArray = [submission.score, 0];
if (workingTime > 0) {
submissionArray[1] = workingTime;
}
if(submission.score>maximumValue){
maximumValue = submission.score;
}
submissionsScoreAndTimeAssess.push(submissionArray);
} else if(submission.cause == "submit"){
var workingTime = get_minutes(wtimes[i]);
var submissionArray = [submission.score, 0];
if (workingTime > 0) {
submissionArray[1] = workingTime;
}
if(submission.score>maximumValue){
maximumValue = submission.score;
}
submissionsScoreAndTimeSubmits.push(submissionArray);
} else if(submission.cause == "run"){
submissionsScoreAndTimeRuns.push(submissionArray[1]);
}
}
// console.log(submissionsScoreAndTimeAssess.length);
// console.log(submissionsScoreAndTimeSubmits);
// console.log(submissionsScoreAndTimeRuns);
function get_minutes (time_stamp) {
try {
hours = time_stamp.split(":")[0];
minutes = time_stamp.split(":")[1];
seconds = time_stamp.split(":")[2];
minutes = parseFloat(hours * 60) + parseInt(minutes);
seconds /= 60;
minutes = parseFloat(hours * 60) + parseInt(minutes) + seconds;
if (minutes > 0){
return minutes;
} else{
@ -82,6 +78,9 @@ $(function() {
function graph_assesses() {
// MAKE THE GRAPH
var width_ratio = .8;
if (width_ratio > 1000){
width_ratio = 1000;
}
var height_ratio = .7; // percent of height
var margin = {top: 100, right: 20, bottom: 70, left: 70},//30,50
@ -221,10 +220,21 @@ $(function() {
.attr("cx", function(d) { return x(d[1]); })
.attr("cy", function(d) { return y(d[0]); });
for (var i = 0; i < submissionsScoreAndTimeRuns.length; i++) {
svg.append("line")
.attr("stroke", "red")
.attr("stroke-width", 1)
.attr("fill", "none")// end new
.attr("y1", y(0))
.attr("y2", 0)
.attr("x1", x(submissionsScoreAndTimeRuns[i]))
.attr("x2", x(submissionsScoreAndTimeRuns[i]));
}
var color_hash = { 0 : ["Submissions", "blue"],
1 : ["Assesses", "orange"]
}
1 : ["Assesses", "orange"],
2 : ["Runs", "red"]
};
// add legend
var legend = svg.append("g")
@ -234,7 +244,8 @@ $(function() {
.attr("height", 100)
.attr("width", 100);
var dataset = [submissionsScoreAndTimeSubmits,submissionsScoreAndTimeAssess];
var dataset = [submissionsScoreAndTimeSubmits,submissionsScoreAndTimeAssess, submissionsScoreAndTimeRuns];
var yOffset = -70;
legend.selectAll('g').data(dataset)
.enter()
@ -243,14 +254,14 @@ $(function() {
var g = d3.select(this);
g.append("rect")
.attr("x", 20)
.attr("y", i*25 + 8)
.attr("y", i*25 + yOffset)// + 8
.attr("width", 10)
.attr("height", 10)
.style("fill", color_hash[String(i)][1]);
g.append("text")
.attr("x", 40)
.attr("y", i * 25 + 18)
.attr("y", i * 25 + yOffset + 10)// + 18
.attr("height",30)
.attr("width",100)
.style("fill", color_hash[String(i)][1])

View File

@ -4,7 +4,7 @@ $(function() {
if ($.isController('exercises') && $('.graph-functions').isPresent()) {
var working_times = $('#data').data('working-time');
function get_minutes (time_stamp){
try{
hours = time_stamp.split(":")[0];
@ -67,6 +67,9 @@ $(function() {
// DRAW THE LINE GRAPH ------------------------------------------------------------------------------
function draw_line_graph() {
var width_ratio = .8;
if (width_ratio > 1000){
width_ratio = 1000;
}
var height_ratio = .7; // percent of height
// currently sets as percentage of window width, however, unfortunately

View File

@ -1,225 +0,0 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160510145341) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "code_harbor_links", force: true do |t|
t.string "oauth2token"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
end
add_index "code_harbor_links", ["user_id"], name: "index_code_harbor_links_on_user_id", using: :btree
create_table "comments", force: true do |t|
t.integer "user_id"
t.integer "file_id"
t.string "user_type"
t.integer "row"
t.integer "column"
t.string "text"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "comments", ["file_id"], name: "index_comments_on_file_id", using: :btree
add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree
create_table "consumers", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "oauth_key"
t.string "oauth_secret"
end
create_table "errors", force: true do |t|
t.integer "execution_environment_id"
t.text "message"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "submission_id"
end
add_index "errors", ["submission_id"], name: "index_errors_on_submission_id", using: :btree
create_table "execution_environments", force: true do |t|
t.string "docker_image"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "run_command"
t.string "test_command"
t.string "testing_framework"
t.text "help"
t.string "exposed_ports"
t.integer "permitted_execution_time"
t.integer "user_id"
t.string "user_type"
t.integer "pool_size"
t.integer "file_type_id"
t.integer "memory_limit"
t.boolean "network_enabled"
end
create_table "exercises", force: true do |t|
t.text "description"
t.integer "execution_environment_id"
t.string "title"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
t.text "instructions"
t.boolean "public"
t.string "user_type"
t.string "token"
t.integer "team_id"
t.boolean "hide_file_tree"
t.boolean "allow_file_creation"
end
add_index "exercises", ["execution_environment_id"], name: "test3", using: :btree
create_table "external_users", force: true do |t|
t.integer "consumer_id"
t.string "email"
t.string "external_id"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "file_types", force: true do |t|
t.string "editor_mode"
t.string "file_extension"
t.integer "indent_size"
t.string "name"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "executable"
t.boolean "renderable"
t.string "user_type"
t.boolean "binary"
end
create_table "files", force: true do |t|
t.text "content"
t.integer "context_id"
t.string "context_type"
t.integer "file_id"
t.integer "file_type_id"
t.boolean "hidden"
t.string "name"
t.boolean "read_only"
t.datetime "created_at"
t.datetime "updated_at"
t.string "native_file"
t.string "role"
t.string "hashed_content"
t.string "feedback_message"
t.float "weight"
t.string "path"
end
add_index "files", ["context_id", "context_type"], name: "index_files_on_context_id_and_context_type", using: :btree
create_table "hints", force: true do |t|
t.integer "execution_environment_id"
t.string "locale"
t.text "message"
t.string "name"
t.string "regular_expression"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "internal_users", force: true do |t|
t.integer "consumer_id"
t.string "email"
t.string "name"
t.string "role"
t.datetime "created_at"
t.datetime "updated_at"
t.string "crypted_password"
t.string "salt"
t.integer "failed_logins_count", default: 0
t.datetime "lock_expires_at"
t.string "unlock_token"
t.string "remember_me_token"
t.datetime "remember_me_token_expires_at"
t.string "reset_password_token"
t.datetime "reset_password_token_expires_at"
t.datetime "reset_password_email_sent_at"
t.string "activation_state"
t.string "activation_token"
t.datetime "activation_token_expires_at"
end
add_index "internal_users", ["activation_token"], name: "index_internal_users_on_activation_token", using: :btree
add_index "internal_users", ["email"], name: "index_internal_users_on_email", unique: true, using: :btree
add_index "internal_users", ["remember_me_token"], name: "index_internal_users_on_remember_me_token", using: :btree
add_index "internal_users", ["reset_password_token"], name: "index_internal_users_on_reset_password_token", using: :btree
create_table "internal_users_teams", force: true do |t|
t.integer "internal_user_id"
t.integer "team_id"
end
add_index "internal_users_teams", ["internal_user_id"], name: "index_internal_users_teams_on_internal_user_id", using: :btree
add_index "internal_users_teams", ["team_id"], name: "index_internal_users_teams_on_team_id", using: :btree
create_table "request_for_comments", force: true do |t|
t.integer "user_id", null: false
t.integer "exercise_id", null: false
t.integer "file_id", null: false
t.datetime "requested_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "user_type"
t.text "question"
end
create_table "submissions", force: true do |t|
t.integer "exercise_id"
t.float "score"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "cause"
t.string "user_type"
end
add_index "submissions", ["exercise_id"], name: "test1", where: "((user_type)::text = 'ExternalUser'::text)", using: :btree
add_index "submissions", ["exercise_id"], name: "test2", using: :btree
create_table "teams", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "testruns", force: true do |t|
t.boolean "passed"
t.text "output"
t.integer "file_id"
t.integer "submission_id"
t.datetime "created_at"
t.datetime "updated_at"
end
end