Skip to content

Commit 194ede6

Browse files
committed
Merge branch 'master' into negative_marking
2 parents a05d023 + fadba4a commit 194ede6

File tree

9 files changed

+14050
-1605
lines changed

9 files changed

+14050
-1605
lines changed

app/helpers/toCsv.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { helper } from '@ember/component/helper';
2+
3+
4+
export function toCsv(param) {
5+
return param[0].reduce((acc, val) => acc + ',' + val, '')
6+
}
7+
8+
export default helper(toCsv);

app/models/question.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import DS from "ember-data";
33
export default DS.Model.extend({
44
title: DS.attr(),
55
description: DS.attr(),
6+
explanation: DS.attr(),
67
difficulty: DS.attr(),
78
positiveScore: DS.attr(),
89
negativeScore: DS.attr(),

app/pods/components/question-editor/template.hbs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030
</div>
3131
</div>
3232

33+
<div class="row justify-content-center align-items-center">
34+
<div class="col-2">
35+
<label>Question Explanation:</label>
36+
</div>
37+
<div class="col-5 input-group">
38+
{{textarea type="text" class="input-text py-4" placeholder="Edit this explanation" value=question.explanation}}
39+
</div>
40+
<div class="col-5">
41+
{{markdown-to-html question.explanation extensions='katex'}}
42+
</div>
43+
</div>
44+
3345
<div class="row justiy-content-center align-items-center">
3446
<div class="col-1">
3547
<label>Positive Score</label>

app/pods/questions/index/controller.js

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,13 @@ import { computed } from '@ember/object';
55

66
export default Controller.extend({
77
store: service(),
8-
queryParams: ['page', 'limit'],
8+
queryParams: ['page', 'limit', 'filter', 'filterTagsParam'],
99
page: 1,
1010
limit: 10,
11-
searchString: '',
11+
filter: '',
1212
pageCount: computed('limit', 'questions', function() {
1313
return Math.ceil(this.questions.meta.pagination.count / this.limit)
1414
}),
15-
searchTask: task(function * () {
16-
yield timeout(250)
17-
18-
let searchStr = this.get('searchString').trim()
19-
let selectedTags = []
20-
21-
if(this.get('filterTags')) {
22-
selectedTags = this.get('filterTags')
23-
selectedTags = selectedTags.map(t => +t.id)
24-
}
25-
26-
const questions = yield this.get('store').query('question', {
27-
include: 'user',
28-
filter: {
29-
title: {
30-
$iLike: `%${this.get('searchString')}%`
31-
},
32-
tags: selectedTags
33-
}
34-
})
35-
this.set('page', 1)
36-
this.set('questions', questions)
37-
}).restartable(),
3815
tagsFilterTask: task(function * (str) {
3916
yield timeout(250)
4017
const tags = yield this.get('store').query('tag', {
@@ -47,6 +24,10 @@ export default Controller.extend({
4724
return tags.toArray()
4825
}),
4926
actions : {
27+
selectTags (tags) {
28+
this.set('filterTagsParam', tags.length ? tags.mapBy('id').reduce((acc, val) => acc + ',' + val) : '')
29+
this.set('filterTags', tags)
30+
},
5031
deleteQuestion(question) {
5132
question.destroyRecord()
5233
}

app/pods/questions/index/route.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,32 @@ export default Route.extend({
77
},
88
limit: {
99
refreshModel: true
10+
},
11+
filter: {
12+
refreshModel: true
13+
},
14+
filterTagsParam: {
15+
refreshModel: true
1016
}
1117
},
1218
model (params) {
13-
const {page, limit} = params
19+
const { page, limit, filter = '' } = params
20+
let { filterTagsParam } = params
21+
22+
filterTagsParam = filterTagsParam ? filterTagsParam.split(',') : []
23+
1424
return this.store.query('question', {
1525
include: 'user',
26+
filter: {
27+
title: {
28+
$iLike: `%${filter}%`
29+
},
30+
...(filterTagsParam.length && {tags: filterTagsParam} )
31+
},
1632
page: {
1733
offset: (page-1)*limit > 0 ? (page-1)*limit: 0,
1834
limit: params.limit
19-
}
35+
},
2036
})
2137
},
2238
setupController (controller, model) {

app/pods/questions/index/template.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</div>
88
<div class="row justify-content-center">
99
<div class="input-search nav-search col-8 justify-content-center">
10-
{{input type="text" placeholder="Enter Question Name" key-up=(perform searchTask) value=searchString}}
10+
{{input type="text" placeholder="Enter Question Name" value=filter}}
1111
<img src="http://online.codingblocks.com/images/searchicon-06d8faf96de7c883b5440b6594e39eda.png" alt="search">
1212
</div>
1313
</div>
@@ -16,7 +16,7 @@
1616
{{#power-select-multiple
1717
search=(perform tagsFilterTask)
1818
selected=filterTags
19-
onchange=(action (pipe (action (mut filterTags)) (perform searchTask)))
19+
onchange=(action "selectTags")
2020
placeholder="Filter by tags"
2121
as |tag|}}
2222
{{tag.title}}

ember-cli-build.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ module.exports = function(defaults) {
66
let app = new EmberApp(defaults, {
77
'ember-composable-helpers': {
88
// Add conditions
9+
},
10+
babel: {
11+
plugins: ['transform-object-rest-spread']
912
}
1013
// Add options here
1114
});

0 commit comments

Comments
 (0)