use of org.olat.core.gui.components.chart.BarSeries.Stringuified in project OpenOLAT by OpenOLAT.
the class QTI12AssessmentStatisticsController method initScoreStatisticPerItem.
private void initScoreStatisticPerItem(List<Item> items, double numOfParticipants) {
BarSeries d1 = new BarSeries();
BarSeries d2 = new BarSeries();
List<StatisticItem> statisticItems = qtiStatisticsManager.getStatisticPerItem(items, resourceResult.getSearchParams(), numOfParticipants);
int i = 0;
List<ItemInfos> itemInfos = new ArrayList<>(items.size());
for (StatisticItem statisticItem : statisticItems) {
Item item = statisticItem.getItem();
String label = Integer.toString(++i);
String text = item.getTitle();
d1.add(statisticItem.getAverageScore(), label);
double numOfRightAnswers = statisticItem.getNumOfCorrectAnswers();
double res = numOfRightAnswers;
d2.add(res, label);
itemInfos.add(new ItemInfos(label, text));
}
mainVC.contextPut("itemInfoList", itemInfos);
VelocityContainer averageScorePeritemVC = createVelocityContainer("hbar_average_score_per_item");
Stringuified data1 = BarSeries.getDatasAndColors(Collections.singletonList(d1), "bar_default");
averageScorePeritemVC.contextPut("datas", data1);
mainVC.put("averageScorePerItemChart", averageScorePeritemVC);
VelocityContainer percentRightAnswersPerItemVC = createVelocityContainer("hbar_right_answer_per_item");
Stringuified data2 = BarSeries.getDatasAndColors(Collections.singletonList(d2), "bar_green");
percentRightAnswersPerItemVC.contextPut("datas", data2);
percentRightAnswersPerItemVC.contextPut("numOfParticipants", Long.toString(Math.round(numOfParticipants)));
mainVC.put("percentRightAnswersPerItemChart", percentRightAnswersPerItemVC);
}
use of org.olat.core.gui.components.chart.BarSeries.Stringuified in project OpenOLAT by OpenOLAT.
the class BarChartComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
BarChartComponent chartCmp = (BarChartComponent) source;
List<BarSeries> seriesList = chartCmp.getSeries();
String yLegend = chartCmp.getYLegend();
String xLegend = chartCmp.getXLegend();
Stringuified infos = BarSeries.getDatasAndColors(seriesList, chartCmp.getDefaultBarClass());
String sum = getSum(seriesList);
String cmpId = chartCmp.getDispatchID();
sb.append("<div id='d").append(cmpId).append("d3holder' class='d3chart' style='width:600px;height:300px'></div>\n").append("<script type='text/javascript'>\n").append("/* <![CDATA[ */ ").append("jQuery(function () {\n").append("var placeholderheight = jQuery('#d").append(cmpId).append("d3holder').height();\n").append("var placeholderwidth = jQuery('#d").append(cmpId).append("d3holder').width();\n");
sb.append("var margin = {top: 20, right: 20, bottom: 30, left: 50},\n").append(" width = placeholderwidth - margin.left - margin.right,\n").append(" height = placeholderheight - margin.top - margin.bottom;\n").append("\n").append("var x = d3.scale.ordinal()\n").append(" .rangeRoundBands([0, width], .1);\n").append("\n").append("var y = d3.scale.linear()\n").append(" .range([height, 0]);\n").append("\n").append("var xAxis = d3.svg.axis()\n").append(" .scale(x)\n").append(" .orient('bottom');\n").append("\n").append("var yAxis = d3.svg.axis()\n").append(" .scale(y)\n").append(" .orient('left')\n");
sb.append("\n").append("var svg = d3.select('#d").append(cmpId).append("d3holder').append('svg')\n").append(" .attr('width', width + margin.left + margin.right)\n").append(" .attr('height', height + margin.top + margin.bottom)\n").append(" .append('g')\n").append(" .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n").append("\n").append("var data = [").append(infos.getData()).append("]\n").append("x.domain(data.map(function(d) { return d[0]; }));\n").append("y.domain([0, d3.max(data, function(d) { return ").append(sum).append("; })]);\n").append("\n");
// append x axis and legend
sb.append("svg.append('g')\n").append(" .attr('class', 'x axis')\n").append(" .attr('transform', 'translate(0,' + height + ')')\n").append(" .call(xAxis);\n");
if (StringHelper.containsNonWhitespace(xLegend)) {
sb.append(" .append('text')\n").append(" .attr('y', 0)\n").append(" .attr('x', 0 - (width / 2))\n").append(" .attr('dy', '1em')\n").append(" .style('text-anchor', 'middle')\n").append(" .text('").append(xLegend).append("');\n");
}
// append y axis and legend
sb.append("svg.append('g')\n").append(" .attr('class', 'y axis')\n").append(" .call(yAxis)\n");
if (StringHelper.containsNonWhitespace(yLegend)) {
sb.append(" .append('text')\n").append(" .attr('transform', 'rotate(-90)')\n").append(" .attr('y', 0 - margin.left)\n").append(" .attr('x', 0 - (height / 2))\n").append(" .attr('dy', '1em')\n").append(" .style('text-anchor', 'middle')\n").append(" .text('").append(yLegend).append("');\n").append("\n");
}
appendSeries(sb, infos.getColors(), chartCmp);
sb.append("});\n").append("/* ]]> */").append("</script>\n");
}
use of org.olat.core.gui.components.chart.BarSeries.Stringuified in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentTestStatisticsController method initScoreStatisticPerItem.
/**
* The 2 graphs with the score per questions and right answers per questions.
*
* @param numOfParticipants The number of participants
*/
private void initScoreStatisticPerItem(double numOfParticipants) {
BarSeries d1 = new BarSeries();
BarSeries d2 = new BarSeries();
List<AssessmentItemStatistic> statisticItems = qtiStatisticsManager.getStatisticPerItem(resourceResult.getResolvedAssessmentTest(), resourceResult.getSearchParams(), numOfParticipants);
int i = 0;
List<ItemInfos> itemInfos = new ArrayList<>(statisticItems.size());
for (AssessmentItemStatistic statisticItem : statisticItems) {
AssessmentItem item = statisticItem.getAssessmentItem();
String label = Integer.toString(++i);
String text = item.getTitle();
d1.add(statisticItem.getAverageScore(), label);
d2.add(statisticItem.getNumOfCorrectAnswers(), label);
itemInfos.add(new ItemInfos(label, text));
}
mainVC.contextPut("itemInfoList", itemInfos);
VelocityContainer averageScorePeritemVC = createVelocityContainer("hbar_average_score_per_item");
Stringuified data1 = BarSeries.getDatasAndColors(Collections.singletonList(d1), "bar_default");
averageScorePeritemVC.contextPut("datas", data1);
mainVC.put("averageScorePerItemChart", averageScorePeritemVC);
VelocityContainer percentRightAnswersPerItemVC = createVelocityContainer("hbar_right_answer_per_item");
Stringuified data2 = BarSeries.getDatasAndColors(Collections.singletonList(d2), "bar_green");
percentRightAnswersPerItemVC.contextPut("datas", data2);
percentRightAnswersPerItemVC.contextPut("numOfParticipants", Long.toString(Math.round(numOfParticipants)));
mainVC.put("percentRightAnswersPerItemChart", percentRightAnswersPerItemVC);
}
use of org.olat.core.gui.components.chart.BarSeries.Stringuified in project openolat by klemens.
the class BarChartComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
BarChartComponent chartCmp = (BarChartComponent) source;
List<BarSeries> seriesList = chartCmp.getSeries();
String yLegend = chartCmp.getYLegend();
String xLegend = chartCmp.getXLegend();
Stringuified infos = BarSeries.getDatasAndColors(seriesList, chartCmp.getDefaultBarClass());
String sum = getSum(seriesList);
String cmpId = chartCmp.getDispatchID();
sb.append("<div id='d").append(cmpId).append("d3holder' class='d3chart' style='width:600px;height:300px'></div>\n").append("<script type='text/javascript'>\n").append("/* <![CDATA[ */ ").append("jQuery(function () {\n").append("var placeholderheight = jQuery('#d").append(cmpId).append("d3holder').height();\n").append("var placeholderwidth = jQuery('#d").append(cmpId).append("d3holder').width();\n");
sb.append("var margin = {top: 20, right: 20, bottom: 30, left: 50},\n").append(" width = placeholderwidth - margin.left - margin.right,\n").append(" height = placeholderheight - margin.top - margin.bottom;\n").append("\n").append("var x = d3.scale.ordinal()\n").append(" .rangeRoundBands([0, width], .1);\n").append("\n").append("var y = d3.scale.linear()\n").append(" .range([height, 0]);\n").append("\n").append("var xAxis = d3.svg.axis()\n").append(" .scale(x)\n").append(" .orient('bottom');\n").append("\n").append("var yAxis = d3.svg.axis()\n").append(" .scale(y)\n").append(" .orient('left')\n");
sb.append("\n").append("var svg = d3.select('#d").append(cmpId).append("d3holder').append('svg')\n").append(" .attr('width', width + margin.left + margin.right)\n").append(" .attr('height', height + margin.top + margin.bottom)\n").append(" .append('g')\n").append(" .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n").append("\n").append("var data = [").append(infos.getData()).append("]\n").append("x.domain(data.map(function(d) { return d[0]; }));\n").append("y.domain([0, d3.max(data, function(d) { return ").append(sum).append("; })]);\n").append("\n");
// append x axis and legend
sb.append("svg.append('g')\n").append(" .attr('class', 'x axis')\n").append(" .attr('transform', 'translate(0,' + height + ')')\n").append(" .call(xAxis);\n");
if (StringHelper.containsNonWhitespace(xLegend)) {
sb.append(" .append('text')\n").append(" .attr('y', 0)\n").append(" .attr('x', 0 - (width / 2))\n").append(" .attr('dy', '1em')\n").append(" .style('text-anchor', 'middle')\n").append(" .text('").append(xLegend).append("');\n");
}
// append y axis and legend
sb.append("svg.append('g')\n").append(" .attr('class', 'y axis')\n").append(" .call(yAxis)\n");
if (StringHelper.containsNonWhitespace(yLegend)) {
sb.append(" .append('text')\n").append(" .attr('transform', 'rotate(-90)')\n").append(" .attr('y', 0 - margin.left)\n").append(" .attr('x', 0 - (height / 2))\n").append(" .attr('dy', '1em')\n").append(" .style('text-anchor', 'middle')\n").append(" .text('").append(yLegend).append("');\n").append("\n");
}
appendSeries(sb, infos.getColors(), chartCmp);
sb.append("});\n").append("/* ]]> */").append("</script>\n");
}
use of org.olat.core.gui.components.chart.BarSeries.Stringuified in project openolat by klemens.
the class QTI12AssessmentStatisticsController method initScoreStatisticPerItem.
private void initScoreStatisticPerItem(List<Item> items, double numOfParticipants) {
BarSeries d1 = new BarSeries();
BarSeries d2 = new BarSeries();
List<StatisticItem> statisticItems = qtiStatisticsManager.getStatisticPerItem(items, resourceResult.getSearchParams(), numOfParticipants);
int i = 0;
List<ItemInfos> itemInfos = new ArrayList<>(items.size());
for (StatisticItem statisticItem : statisticItems) {
Item item = statisticItem.getItem();
String label = Integer.toString(++i);
String text = item.getTitle();
d1.add(statisticItem.getAverageScore(), label);
double numOfRightAnswers = statisticItem.getNumOfCorrectAnswers();
double res = numOfRightAnswers;
d2.add(res, label);
itemInfos.add(new ItemInfos(label, text));
}
mainVC.contextPut("itemInfoList", itemInfos);
VelocityContainer averageScorePeritemVC = createVelocityContainer("hbar_average_score_per_item");
Stringuified data1 = BarSeries.getDatasAndColors(Collections.singletonList(d1), "bar_default");
averageScorePeritemVC.contextPut("datas", data1);
mainVC.put("averageScorePerItemChart", averageScorePeritemVC);
VelocityContainer percentRightAnswersPerItemVC = createVelocityContainer("hbar_right_answer_per_item");
Stringuified data2 = BarSeries.getDatasAndColors(Collections.singletonList(d2), "bar_green");
percentRightAnswersPerItemVC.contextPut("datas", data2);
percentRightAnswersPerItemVC.contextPut("numOfParticipants", Long.toString(Math.round(numOfParticipants)));
mainVC.put("percentRightAnswersPerItemChart", percentRightAnswersPerItemVC);
}
Aggregations