Commit e787fbf2 authored by Daniel Dominik Henrichs's avatar Daniel Dominik Henrichs Committed by Curtis Adam

Add "sort by rating" filter

parent 7276a420
......@@ -148,6 +148,8 @@
"everything": "Alles",
"reset": "Filter zurücksetzen",
"rating": "Bewertung",
"ratingFilter": "> 1 Stern",
"ratingFilterPlural": "> __rating__ Sterne",
"skillLevel": "Kompetenzstufe",
"moreResults": "Zeige weitere Einträge",
"learnphase": "Lernphase",
......
......@@ -150,6 +150,8 @@
"everything": "Everything",
"reset": "Reset filters",
"rating": "Rating",
"ratingFilter": "> 1 Star",
"ratingFilterPlural": "> __rating__ Stars",
"skillLevel": "Skill Level",
"moreResults": "Show more results",
"learnphase": "Learning phase",
......
......@@ -180,6 +180,37 @@
{{/each}}
</ul>
</li>
<li class="dropdown">
<a href="#" id="ratingFilter" class="dropdown-toggle ratingBtn" data-toggle="dropdown"
role="button"
aria-haspopup="true" aria-expanded="false">
{{#if hasRatingFilter}}
{{poolFilterRating}}
{{else}}
{{_ "set-list.rating"}}
{{/if}}
<span class="glyphicon glyphicon-filter"></span>
</a>
<ul class="dropdown-menu">
<li>
<a href="#" class="filterRating active" data-id="-1">{{_ "set-list.everything"}}</a>
</li>
<li><a href="#" class="filterRating" data-id="0">{{_ "set-list.ratingFilterPlural"
rating=0}}</a>
</li>
<li><a href="#" class="filterRating" data-id="1">{{_ "set-list.ratingFilter"}}</a>
</li>
<li><a href="#" class="filterRating" data-id="2">{{_ "set-list.ratingFilterPlural"
rating=2}}</a>
</li>
<li><a href="#" class="filterRating" data-id="3">{{_ "set-list.ratingFilterPlural"
rating=3}}</a>
</li>
<li><a href="#" class="filterRating" data-id="4">{{_ "set-list.ratingFilterPlural"
rating=4}}</a>
</li>
</ul>
</li>
<ul class="nav navbar-nav navbar-right">
<div id="filterCheckbox" class="btn-group" role="group" data-toggle="buttons"
aria-label="License group" style="padding-top: 20px;">
......@@ -305,11 +336,13 @@
data-id="{{this.skillLevel}}">{{getSkillLevel this.skillLevel}}</span>
</a>
<a href="#" class="filterRating"
title="{{this.name}} {{_ "set-list.rating"}}: {{getAverageRating}} {{_ "rating-field.stars"}}">
<span class="col-xs-4 col-sm-3 col-md-3 hidden-lg poolLabel poolText panelUnit">{{_ "set-list.rating"}}
title="{{this.name}} {{_ "set-list.rating"}}: {{this.relevance}} {{_ "rating-field.stars"}}"
data-id={{getRelevance}}>
<span class="col-xs-4 col-sm-3 col-md-3 hidden-lg poolLabel poolText panelUnit" data-id={{getRelevance}}>{{_
"set-list.rating"}}
:</span>
<span class="col-xs-8 col-sm-9 col-md-9 col-lg-1 poolContent poolText panelUnit">
{{> starsRating rating=getAverageRating mutable=false}}
<span class="col-xs-8 col-sm-9 col-md-9 col-lg-1 poolContent poolText panelUnit" data-id={{getRelevance}}>
{{> starsRating rating=this.relevance mutable=false}}
</span>
</a>
<span class="col-lg-2 kind-label visible-lg panelAvailability">
......@@ -371,11 +404,11 @@
</div>
<div class="modal-body">
<p>{{_ "confirm-enter-learnphase.text"}}</p>
<ul>
<li>{{_ "panel-body.givenname"}}</li>
<li>{{_ "panel-body.birthname"}}</li>
<li>{{_ "panel-body.email"}}</li>
</ul>
<ul>
<li>{{_ "panel-body.givenname"}}</li>
<li>{{_ "panel-body.birthname"}}</li>
<li>{{_ "panel-body.email"}}</li>
</ul>
<p>{{_ "confirm-enter-learnphase.text2"}}</p>
</div>
<hr>
......@@ -394,12 +427,14 @@
<template name="poolTitleContent">
<div class="tip-content">{{#markdown}}{{getMaximumText content.description}}{{/markdown}}</div>
<span class="col-xs-4 col-sm-3 col-md-3 hidden-lg poolLabel panelUnit" data-id="{{content._id}}">{{_ "set-list.topic"}}
<span class="col-xs-4 col-sm-3 col-md-3 hidden-lg poolLabel panelUnit" data-id="{{content._id}}">{{_
"set-list.topic"}}
:</span>
<span class="cell col-xs-8 col-sm-9 col-md-9 col-lg-2 poolText panelUnit" data-id="{{content._id}}">
<span class="cell col-xs-9 col-sm-10 col-md-10 col-lg-9 topicName" data-id="{{content._id}}">
{{#if content.learningActive}}
<span class="label label-info" aria-label="active learnphase label" data-id="{{content._id}}">{{_
<span class="label label-info" aria-label="active learnphase label"
data-id="{{content._id}}">{{_
"set-list.activeLearnphase"}}: {{getActiveLearners content._id}}</span>
{{/if}}
{{content.name}}
......@@ -423,7 +458,8 @@
<p>{{_ "complete-profile.text"}}</p>
<br>
<hr>
<button id="completeProfileGoToProfile" class="btn btn-default btn-block btn-raised btn-success active"
<button id="completeProfileGoToProfile"
class="btn btn-default btn-block btn-raised btn-success active"
data-dismiss="modal">{{_ "navbar-collapse.myprofile"}}</button>
<button id="completeProfileCancel" class="btn btn-default btn-block btn-raised"
data-dismiss="modal">{{_ "complete-profile.btn-txt"}}</button>
......
......@@ -4,7 +4,6 @@ import {Meteor} from "meteor/meteor";
import {Template} from "meteor/templating";
import {Session} from "meteor/session";
import {Cardsets} from "../../api/cardsets.js";
import {Ratings} from "../../api/ratings.js";
import {Learned} from "../../api/learned.js";
import "./pool.html";
......@@ -20,6 +19,7 @@ Session.setDefault('poolFilterCourse');
Session.setDefault('poolFilterModule');
Session.setDefault('poolFilterSkillLevel');
Session.setDefault('poolFilterLearnphase');
Session.setDefault('poolFilterRating', -1);
Session.setDefault('poolFilter', ["free", "edu", "pro"]);
Session.setDefault('selectedCardset');
Session.setDefault("itemsLimit", items_increment);
......@@ -55,6 +55,7 @@ function prepareQuery() {
*/
query.learningActive = Session.get('poolFilterLearnphase');
}
query.relevance = {$gt: Session.get('poolFilterRating')};
}
function checkRemainingCards() {
......@@ -129,6 +130,11 @@ function checkFilters() {
} else {
$(".filterLearnphase").removeClass('active').first();
}
if (Session.get('poolFilterRating')) {
$(".filterRatingGroup").addClass('active');
} else {
$(".filterRatingGroup").removeClass('active').first();
}
filterCheckbox();
}
......@@ -199,6 +205,19 @@ function filterLearnphase(event) {
resetInfiniteBar();
}
function filterRating(event) {
var button = $(".filterRatingGroup");
if (!$(event.target).data('id')) {
button.removeClass("active");
Session.set('poolFilterRatingVal', null);
} else {
button.addClass('active');
Session.set('poolFilterRatingVal', $(event.target).data('id'));
}
Session.set('poolFilterRating', $(event.target).data('id'));
resetInfiniteBar();
}
/*
* ############################################################################
* category
......@@ -290,6 +309,16 @@ Template.category.helpers({
poolFilterLearnphase: function () {
return Session.get('poolFilterLearnphaseVal');
},
hasRatingFilter: function () {
return Session.get('poolFilterRating') !== -1;
},
poolFilterRating: function () {
if (Session.get('poolFilterRating') === 1) {
return TAPi18n.__('set-list.ratingFilter');
} else {
return TAPi18n.__("set-list.ratingFilterPlural", {rating: Session.get('poolFilterRating')});
}
},
moreResults: function () {
return checkRemainingCards();
}
......@@ -365,22 +394,6 @@ Template.poolCardsetRow.helpers({
return false;
}
},
getAverageRating: function () {
var ratings = Ratings.find({
cardset_id: this._id
});
var count = ratings.count();
if (count !== 0) {
var amount = 0;
ratings.forEach(function (rate) {
amount = amount + rate.rating;
});
var result = (amount / count).toFixed(2);
return result;
} else {
return 0;
}
},
getKind: function () {
switch (this.kind) {
case "free":
......@@ -398,6 +411,9 @@ Template.poolCardsetRow.helpers({
return this.price + '';
}
},
getRelevance: function () {
return Math.floor(this.relevance - 1);
},
getLicense: function () {
var licenseString = "";
......@@ -446,6 +462,9 @@ Template.poolCardsetRow.events({
'click .filterSkillLevel': function (event) {
filterSkillLevel(event);
},
'click .filterRating': function (event) {
filterRating(event);
},
'click .filterCheckbox': function (event) {
Session.set('poolFilter', [$(event.target).data('id')]);
filterCheckbox();
......@@ -466,6 +485,7 @@ Template.category.events({
Session.set('poolFilterCourse');
Session.set('poolFilterModule');
Session.set('poolFilterSkillLevel');
Session.set('poolFilterRating', -1);
Session.set('poolFilter', ["free", "edu", "pro"]);
Session.set('poolFilterLearnphase');
checkFilters();
......@@ -506,6 +526,9 @@ Template.category.events({
'click .filterLearnphase': function () {
filterLearnphase(event);
},
'click .filterRating': function (event) {
filterRating(event);
},
'click .showMoreResults': function () {
Session.set("itemsLimit", Session.get("itemsLimit") + items_increment);
checkRemainingCards();
......
Feature: Sort cardsets at poolview
Background:
Given User is on the poolview
@watch
Scenario: User sorts by author
When user clicks on the filter by author button
Then he should choose an author
Then he should see the cardset list sorted by the choosen author
@watch
Scenario: User sorts by college
When user clicks on the filter by college button
Then he should choose a college
Then he should see the cardset list sorted by the choosen college
@watch
Scenario: User sorts by course
When user clicks on the filter by course button
Then he should choose a course
Then he should see the cardset list sorted by the choosen course
@watch
Scenario: User sorts by module
When user clicks on the filter by module button
Then he should choose a module
Then he should see the cardset list sorted by the choosen module
@watch
Scenario: User sorts by unselected free license group
When user clicks on the free license group button
Then he should see the cardset list filtered by the unselected free license group
@watch
Scenario: User sorts by unselected edu license group
When user clicks on the edu license group button
Then he should see the cardset list filtered by the unselected edu license group
@watch
Scenario: User sorts by unselected pro license group
When user clicks on the pro license group button
Then he should see the cardset list filtered by the unselected pro license group
\ No newline at end of file
Background:
Given User is on the poolview
@watch
Scenario: User sorts by author
When user clicks on the filter by author button
Then he should choose an author
Then he should see the cardset list sorted by the choosen author
@watch
Scenario: User sorts by college
When user clicks on the filter by college button
Then he should choose a college
Then he should see the cardset list sorted by the choosen college
@watch
Scenario: User sorts by course
When user clicks on the filter by course button
Then he should choose a course
Then he should see the cardset list sorted by the choosen course
@watch
Scenario: User sorts by module
When user clicks on the filter by module button
Then he should choose a module
Then he should see the cardset list sorted by the choosen module
@watch
Scenario: User sorts by skill level
When user clicks on the filter by skill level button
Then he should choose a skill level
Then he should see the cardset list sorted by the choosen skill level
@watch
Scenario: User sorts by unselected free license group
When user clicks on the free license group button
Then he should see the cardset list filtered by the unselected free license group
@watch
Scenario: User sorts by unselected edu license group
When user clicks on the edu license group button
Then he should see the cardset list filtered by the unselected edu license group
@watch
Scenario: User sorts by unselected pro license group
When user clicks on the pro license group button
Then he should see the cardset list filtered by the unselected pro license group
\ No newline at end of file
......@@ -109,10 +109,9 @@ module.exports = function () {
/**
* ---------------------------------------------------------------------
* Sort by module skill level
* Sort by skill level scenario
* ---------------------------------------------------------------------
*/
this.When(/^user clicks on the filter by skill level button$/, function () {
browser.waitForVisible('a[class="dropdown-toggle skillLevelBtn"]', TIMERTHRESHOLD);
browser.click('a[class="dropdown-toggle skillLevelBtn"]');
......@@ -129,7 +128,6 @@ module.exports = function () {
}, TIMERTHRESHOLD, 'expected cardset list to only contain entries with the filtered skill after ' + TIMERTHRESHOLDTEXT);
});
/**
* ---------------------------------------------------------------------
* Sort by free license scenario
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment