diff --git a/.gitignore b/.gitignore index 89d0de42..d39c25e5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ *.sublime-* /.idea /.vagrant -*.iml \ No newline at end of file +*.iml +*.DS_Store diff --git a/app/assets/javascripts/working_time_graphs.js b/app/assets/javascripts/working_time_graphs.js index 05e8fcb5..315d2c09 100644 --- a/app/assets/javascripts/working_time_graphs.js +++ b/app/assets/javascripts/working_time_graphs.js @@ -1,4 +1,6 @@ $(function() { + // http://localhost:3333/exercises/38/statistics good for testing + // originally at--> localhost:3333/exercises/69/statistics if ($.isController('exercises') && $('.graph-functions').isPresent()) { var working_times = $('#data').data('working-time'); @@ -19,23 +21,34 @@ $(function() { // GET ALL THE DATA ------------------------------------------------------------------------------ minutes_array = _.map(working_times,function(item){return get_minutes(item)}); - maximum_minutes = _.max(minutes_array); - var minutes_count = new Array(maximum_minutes + 1); + minutes_array_length = minutes_array.length; - for (var i = 0; i < maximum_minutes; i++){ - for (var j = 0; j < minutes_array[i]; j++){ + maximum_minutes = _.max(minutes_array); + var minutes_count = new Array(maximum_minutes); + + for (var i = 0; i < minutes_array_length; i++){ + var studentTime = minutes_array[i]; + + for (var j = 0; j < studentTime; j++){ if (minutes_count[j] == undefined){ - minutes_count[j] = 1; + minutes_count[j] = 0; } else{ minutes_count[j] += 1; } } } - minutes_count[(maximum_minutes + 1)] = 0; + // minutes_count[(maximum_minutes + 1)] = 0; //$('.graph-functions').html("
") - console.log(minutes_array); + // var minutes_count = new Array(10); + // var minutes_array_len = minutes_array.length; + // for (var i=0; i< minutes_count; i++){ + // + // for (var j = 0; j < minutes_array_len; j++){ + // if () + // } + // } function getWidth() { if (self.innerHeight) { @@ -51,16 +64,11 @@ $(function() { } } - // DRAW THE LINE GRAPH ------------------------------------------------------------------------------ function draw_line_graph() { - - // good to test at: localhost:3333/exercises/69/statistics - var width_ratio = .8; var height_ratio = .7; // percent of height - // currently sets as percentage of window width, however, unfortunately // is not yet responsive @@ -72,15 +80,12 @@ $(function() { var x = d3.scale.linear() .range([0, width]); - var y = d3.scale.linear() .range([height, 0]); // - (height/20 - var xAxis = d3.svg.axis() .scale(x) .orient("bottom") .ticks(20); - var yAxis = d3.svg.axis() .scale(y) .orient("left") @@ -96,14 +101,12 @@ $(function() { return y(d / minutes_count[0] * 100); }); - var svg = d3.select("#chart_1").append("svg") //PLACEMENT GOES HERE <--------------- .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - x.domain(d3.extent(minutes_count, function (d, i) { return (i); })); @@ -116,7 +119,6 @@ $(function() { .attr("transform", "translate(0," + height + ")") .call(xAxis); - svg.append("text")// x axis label .attr("class", "x axis") .attr("text-anchor", "middle") @@ -152,17 +154,17 @@ $(function() { .datum(minutes_count) .attr("class", "line") .attr('id', 'myPath')// new - .attr("stroke", "black") + .attr("stroke", "orange") .attr("stroke-width", 5) .attr("fill", "none")// end new .attr("d", line);//--- //.on("mousemove", mMove)//new again //.append("title"); - function type(d) { - d.frequency = +d.frequency; - return d; - } + // function type(d) { + // d.frequency = +d.frequency; + // return d; + // } } draw_line_graph(); @@ -184,10 +186,7 @@ $(function() { // (m[0]*(minutes_count.length/x_width)) +" Minutes");//text(m[1]); //} - - // DRAW THE SECOND GRAPH ------------------------------------------------------------------------------ - // function draw_bar_graph() { var group_incrament = 5; @@ -229,7 +228,8 @@ $(function() { var xAxis = d3.svg.axis() .scale(x) - .orient("bottom"); + .orient("bottom") + .ticks(10); var yAxis = d3.svg.axis() @@ -325,8 +325,7 @@ $(function() { .style('text-decoration', 'underline'); } - draw_bar_graph() - + // draw_bar_graph(); } }); diff --git a/app/assets/stylesheets/exercises.css.scss b/app/assets/stylesheets/exercises.css.scss index 543ec101..f348c025 100644 --- a/app/assets/stylesheets/exercises.css.scss +++ b/app/assets/stylesheets/exercises.css.scss @@ -31,8 +31,13 @@ input[type='file'] { .line { fill: none; - stroke: orange;//steelblue; - stroke-width: 4px; + //stroke: orange;//steelblue; + stroke-width: 2px; +} +.line2 { + fill: none; + //stroke: red;//steelblue; + stroke-width: 3px; } div#chart_1 { diff --git a/app/views/exercises/external_users/statistics.html.slim b/app/views/exercises/external_users/statistics.html.slim index da898ddd..56bd614b 100644 --- a/app/views/exercises/external_users/statistics.html.slim +++ b/app/views/exercises/external_users/statistics.html.slim @@ -32,7 +32,7 @@ h1 = "#{@exercise} (external user #{@external_user})" option data-submission=submission =index - index += 1 - + - working_times_until = Array.new #timeline .table-responsive table.table @@ -54,7 +54,11 @@ h1 = "#{@exercise} (external user #{@external_user})" - else .unit-test-result.negative-result td = Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0 + -working_times_until.push((Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0)) p = t('.addendum') + .hidden#wtimes data-working_times=ActiveSupport::JSON.encode(working_times_until); + div#progress_chart.col-lg-12 + .graph-functions-2 - else p = t('.no_data_available') diff --git a/app/views/exercises/statistics.html.slim b/app/views/exercises/statistics.html.slim index 0db32e79..89b7d6a1 100644 --- a/app/views/exercises/statistics.html.slim +++ b/app/views/exercises/statistics.html.slim @@ -21,11 +21,11 @@ h1 = @exercise -working_time_array.push working_time hr .hidden#data data-working-time=ActiveSupport::JSON.encode(working_time_array) + .graph-functions div#chart_1 hr - div#chart_2 - hr - .graph-functions + /div#chart_2 + /hr .table-responsive table.table.table-striped.sortable thead