Commit 61f30203 authored by Marius Trautrims's avatar Marius Trautrims

Add badges view and fix initialize collections

parent 9a11d059
......@@ -4,7 +4,7 @@ ARSnova Flashcards is a digital recreation of a classic learning tool. The servi
## Getting Started
To start ARSnova Flashcards on localhost use `npm start` inside the repository. To initialize the database use `npm run init` while the app is running. You can then access ARSnova Flashcards from your host machine by opening http://localhost:3000.
To start ARSnova Flashcards on localhost use `npm start` inside the repository. You can then access ARSnova Flashcards from your host machine by opening http://localhost:3000.
## CI Pipeline
......
.badgeFooterProgress {
margin-top: 8px;
}
.badgeFooterImg {
text-align: center;
}
.badgeWell {
text-align: center;
margin-bottom: 0px;
}
......@@ -11,6 +11,9 @@
<div class="row">
{{> profileInfo}} {{> profileXp}}
</div>
<div class="row">
{{> profileBadges}}
</div>
{{else}}
<div class="row profil-header">
<div class="col-md-12">
......@@ -188,3 +191,109 @@
</div>
</div>
</template>
<!--##################################################################-->
<!--profileBadges-->
<!--##################################################################-->
<template name="profileBadges">
<div class="col-md-12" id="profile-badge-region">
<div class="panel panel-default">
<div class="panel-heading panel-heading-badges">
<h3 class="panel-title">{{_ "panel-heading-badges.badges"}}</h3>
</div>
<div class="panel-body">
<div class="row">
{{#each badge in getBadges}}
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{badge.name}}</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-4">
<div class="well well-sm badgeWell">
<div class="row">
<img src="/badges/{{badge.badge}}_3{{#unless isGained @index 3}}_gray{{/unless}}.png" height="60">
</div>
<div class="row">
<strong>{{_ "bronze"}}</strong>
</div>
<div class="row">
<p>{{badge.rank3}} {{badge.unit}}</p>
</div>
<div class="row">
<div class="col-md-12">
<div class="progress badgeFooterProgress">
<div class="progress-bar" role="progressbar" style="width: {{ getPercent @index 3}}"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="well well-sm badgeWell">
<div class="row">
<img src="/badges/{{badge.badge}}_2{{#unless isGained @index 2}}_gray{{/unless}}.png" height="60">
</div>
<div class="row">
<strong>{{_ "silver"}}</strong>
</div>
<div class="row">
<p>{{badge.rank2}} {{badge.unit}}</p>
</div>
<div class="row">
<div class="col-md-12">
<div class="progress badgeFooterProgress">
<div class="progress-bar" role="progressbar" style="width: {{ getPercent @index 2}}"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="well well-sm badgeWell">
<div class="row">
<img src="/badges/{{badge.badge}}_1{{#unless isGained @index 1}}_gray{{/unless}}.png" height="60">
</div>
<div class="row">
<strong>{{_ "gold"}}</strong>
</div>
<div class="row">
<p>{{badge.rank1}} {{badge.unit}}</p>
</div>
<div class="row">
<div class="col-md-12">
<div class="progress badgeFooterProgress">
<div class="progress-bar" role="progressbar" style="width: {{ getPercent @index 1}}"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
<div class="row">
<div class="col-md-12">
<p>{{badge.desc}}</p>
</div>
</div>
</div>
</div>
</div>
{{/each}}
</div>
</div>
</div>
</div>
</template>
Meteor.subscribe("userData");
Meteor.subscribe("experience");
Meteor.subscribe("badges");
Template.registerHelper("getUser", function() {
var user = Meteor.users.findOne(this._id);
......@@ -207,3 +208,21 @@ function xpForLevel(level) {
}
return Math.floor(points / 4);
}
/**
* ############################################################################
* profileBadges
* ############################################################################
*/
Template.profileBadges.helpers({
getBadges: function(){
return Badges.find();
},
isGained: function(index, rank){
return false;
},
getPercent: function(index, rank){
return "0%";
}
});
......@@ -5,6 +5,7 @@ Cards = new Mongo.Collection('cards');
Learned = new Mongo.Collection('learned');
Ratings = new Mongo.Collection("ratings");
Experience = new Mongo.Collection("experience");
Badges = new Mongo.Collection("badges");
Categories = new TAPi18n.Collection("categories");
CardsetsIndex = new EasySearch.Index({
......
{_id: "01", name: "Agricultural and Forestry Sciences", i18n: { de: { name: "Agrar- und Forstwissenschaften"}}}
{_id: "02", name: "Information and Telecommunications Technology", i18n: { de: { name: "Informations- und Telekommunikationstechnik"}}}
{_id: "03", name: "Engineering Sciences", i18n: { de: { name: "Ingeniuerswissenschaften"}}}
{_id: "04", name: "Cultural and Social Sciences", i18n: { de: { name: "Kultur- und Gesellschaftswissenschften"}}}
{_id: "05", name: "Art and Music", i18n: { de: { name: "Kunst und Musik"}}}
{_id: "06", name: "Mathematics and Natural Sciences", i18n: { de: { name: "Mathematik und Naturwissenschaften"}}}
{_id: "07", name: "Media", i18n: { de: { name: "Medien"}}}
{_id: "08", name: "Medicine and Health", i18n: { de: { name: "Medizin und Gesundheit"}}}
{_id: "09", name: "Education and Teaching", i18n: { de: { name: "Pädagogik und Lehre"}}}
{_id: "10", name: "Jurisprudence", i18n: { de: { name: "Rechtswissenschaften"}}}
{_id: "11", name: "Foreign Languages and Literatures", i18n: { de: { name: "Sprach- und Literaturwissenschaften"}}}
{_id: "12", name: "Social and Behavioral Sciences", i18n: { de: { name: "Sozial- und Verhaltenswissenschaften"}}}
{_id: "13", name: "Economics and Management", i18n: { de: { name: "Wirtschaft und Management"}}}
{"_id": "01", "name": "Agricultural and Forestry Sciences", "i18n": { "de": { "name": "Agrar- und Forstwissenschaften"}}}
{"_id": "02", "name": "Information and Telecommunications Technology", "i18n": { "de": { "name": "Informations- und Telekommunikationstechnik"}}}
{"_id": "03", "name": "Engineering Sciences", "i18n": { "de": { "name": "Ingeniuerswissenschaften"}}}
{"_id": "04", "name": "Cultural and Social Sciences", "i18n": { "de": { "name": "Kultur- und Gesellschaftswissenschften"}}}
{"_id": "05", "name": "Art and Music", "i18n": { "de": { "name": "Kunst und Musik"}}}
{"_id": "06", "name": "Mathematics and Natural Sciences", "i18n": { "de": { "name": "Mathematik und Naturwissenschaften"}}}
{"_id": "07", "name": "Media", "i18n": { "de": { "name": "Medien"}}}
{"_id": "08", "name": "Medicine and Health", "i18n": { "de": { "name": "Medizin und Gesundheit"}}}
{"_id": "09", "name": "Education and Teaching", "i18n": { "de": { "name": "Pädagogik und Lehre"}}}
{"_id": "10", "name": "Jurisprudence", "i18n": { "de": { "name": "Rechtswissenschaften"}}}
{"_id": "11", "name": "Foreign Languages and Literatures", "i18n": { "de": { "name": "Sprach- und Literaturwissenschaften"}}}
{"_id": "12", "name": "Social and Behavioral Sciences", "i18n": { "de": { "name": "Sozial- und Verhaltenswissenschaften"}}}
{"_id": "13", "name": "Economics and Management", "i18n": { "de": { "name": "Wirtschaft und Management"}}}
{
"name": "flashcards",
"scripts": {
"start": "meteor --settings settings-development.json",
"init": "mongoimport --db meteor --collection categories --type json --file 'i18n/categories.json' -h localhost --port 3001"
"start": "meteor --settings settings-development.json"
}
}
Meteor.startup(function() {
var categories = [{
"_id": "01",
"name": "Agricultural and Forestry Sciences",
"i18n": {
"de": {
"name": "Agrar- und Forstwissenschaften"
}
}
}, {
"_id": "02",
"name": "Information and Telecommunications Technology",
"i18n": {
"de": {
"name": "Informations- und Telekommunikationstechnik"
}
}
}, {
"_id": "03",
"name": "Engineering Sciences",
"i18n": {
"de": {
"name": "Ingeniuerswissenschaften"
}
}
}, {
"_id": "04",
"name": "Cultural and Social Sciences",
"i18n": {
"de": {
"name": "Kultur- und Gesellschaftswissenschften"
}
}
}, {
"_id": "05",
"name": "Art and Music",
"i18n": {
"de": {
"name": "Kunst und Musik"
}
}
}, {
"_id": "06",
"name": "Mathematics and Natural Sciences",
"i18n": {
"de": {
"name": "Mathematik und Naturwissenschaften"
}
}
}, {
"_id": "07",
"name": "Media",
"i18n": {
"de": {
"name": "Medien"
}
}
}, {
"_id": "08",
"name": "Medicine and Health",
"i18n": {
"de": {
"name": "Medizin und Gesundheit"
}
}
}, {
"_id": "09",
"name": "Education and Teaching",
"i18n": {
"de": {
"name": "Pädagogik und Lehre"
}
}
}, {
"_id": "10",
"name": "Jurisprudence",
"i18n": {
"de": {
"name": "Rechtswissenschaften"
}
}
}, {
"_id": "11",
"name": "Foreign Languages and Literatures",
"i18n": {
"de": {
"name": "Sprach- und Literaturwissenschaften"
}
}
}, {
"_id": "12",
"name": "Social and Behavioral Sciences",
"i18n": {
"de": {
"name": "Sozial- und Verhaltenswissenschaften"
}
}
}, {
"_id": "13",
"name": "Economics and Management",
"i18n": {
"de": {
"name": "Wirtschaft und Management"
}
}
}];
var badges = [{
"_id": "1",
"name": "Kritiker",
"desc": "Kritik ist die höchste Form der Zuneigung. Benutzer, welche sich sachlich mit den Kartensätzen anderer auseinandersetzen und konstruktives Feedback oder Lob aussprechen, werden mit diesem Badge belohnt",
"rank1": 50,
"rank2": 25,
"rank3": 10,
"unit": "Bewertungen",
"badge": "kritiker"
}, {
"_id": "2",
"name": "Liebling der Kritiker",
"desc": "Du erhälst diesen Badge, wenn deine Kartensätze von anderen Lernenden gut bewertet werden. Als Kartensätz zählen alle deine öffentlichen Kartensätze mit mindestens 5 Bewertungen bei einer durchschnittlichen Bewertung von 4,5 Sternen.",
"rank1": 30,
"rank2": 15,
"rank3": 5,
"unit": "Kartensätze",
"badge": "krone"
}, {
"_id": "3",
"name": "Stammgast",
"desc": "Besuche THMcards mehrere Tage am Stück und erhalte den Stammgast Badge!",
"rank1": 32,
"rank2": 20,
"rank3": 3,
"unit": "Tage",
"badge": "stammgast"
}, {
"_id": "4",
"name": "Streber",
"desc": "Strebsamkeit wird belohnt. Lerne unterschiedliche Kartensätze um diesen Badge zu erhalten. Es steht die frei, welche Lernmethode du wählst.",
"rank1": 30,
"rank2": 15,
"rank3": 5,
"unit": "Kartensätze",
"badge": "streber"
}, {
"_id": "5",
"name": "Wohltäter",
"desc": "Erstelle eine bestimmte Anzahl an öffentlichen Kartensätzen, die mindestens 5 Karten beinhalten.",
"rank1": 15,
"rank2": 10,
"rank3": 5,
"unit": "Kartensätze",
"badge": "autor"
}];
if (Categories.find().count() === 0) {
console.log("Initialize Categories");
for (var category in categories) {
console.log(categories[category]);
Categories.insert(categories[category]);
}
}
if (Badges.find().count() === 0) {
console.log("Initialize Badges");
for (var badge in badges) {
console.log(badges[badge]);
Badges.insert(badges[badge]);
}
}
});
......@@ -25,3 +25,7 @@ Meteor.publish("experience", function(){
Meteor.publish('userData', function() {
return Meteor.users.find();
});
Meteor.publish("badges", function(){
return Badges.find();
});
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