-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(questions): Question service to use questions from server for ci…
…tizen science labels
- Loading branch information
Showing
6 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
angular | ||
.module("bawApp.models.question", []) | ||
.factory("baw.models.question", [ | ||
"baw.models.ApiBase", | ||
function (ApiBase) { | ||
|
||
class Question extends ApiBase { | ||
constructor(resource) { | ||
super(resource); | ||
this.customSettings = this.customSettings || null; | ||
} | ||
|
||
get questionData() { | ||
return JSON.parse(this.data); | ||
} | ||
|
||
set questionData(value) { | ||
this.data = JSON.stringify(value); | ||
} | ||
|
||
} | ||
|
||
return Question; | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
angular | ||
.module("bawApp.services.question", []) | ||
.factory( | ||
"Question", | ||
[ | ||
"$resource", | ||
"$http", | ||
"bawResource", | ||
"$url", | ||
"conf.paths", | ||
"baw.models.question", | ||
function ($resource, $http, bawResource, $url, paths, QuestionModel) { | ||
|
||
var resource = bawResource( | ||
paths.api.routes.question.list, | ||
{studyId: "@studyId", questionId: "@questionId"}, | ||
{}); | ||
|
||
resource.questions = function getQuestions(studyId) { | ||
var url = $url.formatUri(paths.api.routes.question.listAbsolute, {studyId: studyId}); | ||
return $http.get(url).then(x => { | ||
return QuestionModel.makeFromApi(x); | ||
}); | ||
}; | ||
|
||
resource.question = function getQuestion(questionId) { | ||
var url = $url.formatUri(paths.api.routes.datasetItem.showAbsolute, {questionId: questionId}); | ||
return $http.get(url).then(x => QuestionModel.makeFromApi(x)); | ||
}; | ||
|
||
return resource; | ||
} | ||
] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters