<commit_before>/*
Description: Add, Get, Post questions to assignments
*/

function Service($http, appSettings, SessionService, Upload){
    "ngInject";
    var self = this;
    this._$http = $http;
    this._Upload = Upload;
    this._appSettings = appSettings;
    this.userRoles = appSettings.ROLES;
    this._SessionService = SessionService;
    this.courseUserIdKey = appSettings.API.PARAMS.courseUserId;
};

Service.prototype.getConfig = function(){
    var self = this;
    var params = {};
    params[self.courseUserIdKey] = self._SessionService.getCourseUserId();
    var config = {
        params : params
    };
    return config
};

Service.prototype.getQuestions = function(courseId, moduleId, pageNumber){
    var self = this;
    var config = self.getConfig();

    var url = {};
    url[self.userRoles.user] = self._appSettings.API.basePath
    + '/rest/student/course/'+ courseId +'/module/' + moduleId
    + '?page=' + pageNumber;
    url[self.userRoles.instructor] = self._appSettings.API.basePath
    + '/rest/instructor/course/'+ courseId +'/module/' + moduleId
    + '?page=' + pageNumber;
    url = self.getUrl(url);

    return this._$http
          .get(url, config)
          .then(function (res) {
            return res.data;
          });
};

//Purpose: Add a new question to the assignment
//Params: courseId - String, moduleId - String, pageNum - string
Service.prototype.addQuestion = function(courseId, moduleId, pageNum, payload){
    var self = this;
    var config = self.getConfig();
    config.params.page = pageNum;

    var url = self._appSettings.API.basePath
    + '/rest/instructor/course/' + courseId
    +'/module/' + moduleId;

    return this._$http
          .post(url, payload, config)<commit_msg>ADD: Model  for droping a quesiton<commit_after>/*
Description: Add, Get, Post questions to assignments
*/

function Service($http, appSettings, SessionService, Upload){
    "ngInject";
    var self = this;
    this._$http = $http;
    this._Upload = Upload;
    this._appSettings = appSettings;
    this.userRoles = appSettings.ROLES;
    this._SessionService = SessionService;
    this.courseUserIdKey = appSettings.API.PARAMS.courseUserId;
};

Service.prototype.getConfig = function(){
    var self = this;
    var params = {};
    params[self.courseUserIdKey] = self._SessionService.getCourseUserId();
    var config = {
        params : params
    };
    return config
};

Service.prototype.getQuestions = function(courseId, moduleId, pageNumber){
    var self = this;
    var config = self.getConfig();

    var url = {};
    url[self.userRoles.user] = self._appSettings.API.basePath
    + '/rest/student/course/'+ courseId +'/module/' + moduleId
    + '?page=' + pageNumber;
    url[self.userRoles.instructor] = self._appSettings.API.basePath
    + '/rest/instructor/course/'+ courseId +'/module/' + moduleId
    + '?page=' + pageNumber;
    url = self.getUrl(url);

    return this._$http
          .get(url, config)
          .then(function (res) {
            return res.data;
          });
};

//Purpose: Add a new question to the assignment
//Params: courseId - String, moduleId - String, pageNum - string
Service.prototype.addQuestion = function(courseId, moduleId, pageNum, payload){
    var self = this;
    var config = self.getConfig();
    config.params.page = pageNum;

    var url = self._appSettings.API.basePath
    + '/rest/instructor/course/' + courseId
    +'/module/' + moduleId;

    return this._$http
          .post(url, payload, config)
          .then(function (res) {
            return res.data;
          });
};

//Purpose: Drop a question from the assignment
//Params: courseId - String, moduleId - String, itemId = String
Service.prototype.dropQuestion = function(courseId, moduleId, itemId){
    var self = this;
    var config = self.getConfig();

    var url = self._appSettings.API.basePath
    + '/rest/instructor/course/' + courseId
    +'/module/' + moduleId
    + '/item/' + itemId;

    return this._$http
          .delete(url, config)
{'fraction_non_alphanumeric': 0.13306852035749753, 'fraction_numerical': 0.0, 'mean_word_length': 2.9040697674418605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1759669', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1222, 'n_words': 289}