package studycave.studycaverestservice.usos;


import io.restassured.response.Response;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.text.RandomStringGenerator;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import studycave.studycaverestservice.PropertiesLoader;
import studycave.studycaverestservice.model.studyGroup.GroupRepository;
import studycave.studycaverestservice.model.studyGroup.StudyGroup;
import studycave.studycaverestservice.model.studyGroupMember.StudyGroupMember;
import studycave.studycaverestservice.model.studyGroupMember.StudyGroupMemberRepository;
import studycave.studycaverestservice.model.user.User;
import studycave.studycaverestservice.model.user.UserRepository;
import studycave.studycaverestservice.model.user.UsosUser;
import studycave.studycaverestservice.utils.PasswordGenerator;

import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import static io.restassured.RestAssured.*;
import static studycave.studycaverestservice.utils.PasswordGenerator.*;

@Service
public class AuthorizationService {

    private BCryptPasswordEncoder bCryptPasswordEncoder;

    public AuthorizationService(BCryptPasswordEncoder bCryptPasswordEncoder) {
        this.bCryptPasswordEncoder = bCryptPasswordEncoder;
    }

    private static final String ENC = "UTF-8";
    private static final String HMAC_SHA1 = "HmacSHA1";
    private static Base64 base64 = new Base64();

    @Autowired
    private PropertiesLoader propertiesLoader;

    @Autowired
    private UserRepository userRepository;

    @Autowired
    private GroupRepository groupRepository;

    @Autowired
    private StudyGroupMemberRepository studyGroupMemberRepository;

    public TokenResponseDTO authorize(String oauth_token, String oauth_token_secret, String oauth_verifier) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
        List<NameValuePair> queryParams = new ArrayList<>();
        queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
        queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
        queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
        queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
        queryParams.add(new BasicNameValuePair("oauth_token", oauth_token));
        queryParams.add(new BasicNameValuePair("oauth_verifier", oauth_verifier));
        queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
        String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/oauth/access_token", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), oauth_token_secret);
        queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
        String url = "/oauth/access_token?" + URLEncodedUtils.format(queryParams, ENC);
        String response = when().get(url).body().asString();
        if (response.contains("oauth_token") && response.contains("oauth_token_secret") && response.contains("&")) {
            String[] tokens = response.split("&");
            oauth_token = tokens[0].replace("oauth_token=", "");
            oauth_token_secret = tokens[1].replace("oauth_token_secret=", "");
            TokenResponseDTO tokenResponseDTO = createUserAccountAndReturnHeaderToken(oauth_token, oauth_token_secret);
            String finalOauth_token = oauth_token;
            String finalOauth_token_secret = oauth_token_secret;
           /* Thread thread = new Thread(() -> {
                try {*/
                    //if (!checkIfEmploye(finalOauth_token, finalOauth_token_secret, tokenResponseDTO.getUserId()))
                        updateUserGroupsAndStudents(finalOauth_token, finalOauth_token_secret, tokenResponseDTO.getUserId());
          /*      } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
                    e.printStackTrace();
                }
            });
            thread.start();*/
            //logOut(oauth_token, oauth_token_secret);
            return tokenResponseDTO;
        }
        return new TokenResponseDTO("authorization failed", null, null);
    }

    private boolean checkIfEmploye(String oauth_token, String oauth_token_secret, String userId) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
        List<NameValuePair> queryParams = new ArrayList<>();
        queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
        queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
        queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
        queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
        queryParams.add(new BasicNameValuePair("oauth_token", oauth_token));
        queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
        queryParams.add(new BasicNameValuePair("user_id", userId));
        String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/users/employment_positions", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), oauth_token_secret);

        queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
        String url = "/users/employment_positions?" + URLEncodedUtils.format(queryParams, ENC);

        Response response = get(url);
        JSONArray responseJSON = new JSONArray(response.getBody().print());
        return responseJSON.length() > 0;
    }

    private void updateUserGroupsAndStudents(String oauth_token, String oauth_token_secret, String userId) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {

        RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('0', 'z')
                .filteredBy(Character::isLetterOrDigit).build();

        String semesterId;
        try {
            semesterId = getActualSemester(oauth_token, oauth_token_secret);
        } catch (ParseException e) {
            e.printStackTrace();
            return;
        }

        List<NameValuePair> queryParams = new ArrayList<>();
        queryParams.add(new BasicNameValuePair("fields", "course_unit_id|group_number|class_type|class_type_id|course_id|course_fac_id|term_id|lecturers"));
        queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
        queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
        queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
        queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
        queryParams.add(new BasicNameValuePair("oauth_token", oauth_token));
        queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
        queryParams.add(new BasicNameValuePair("user_id", userId));
        String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/groups/lecturer", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), oauth_token_secret);
        queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
        String url = "/groups/lecturer?" + URLEncodedUtils.format(queryParams, ENC);
        Response response = given().urlEncodingEnabled(false).get(url);
        JSONObject responseJSON = new JSONObject(response.getBody().print());
        //JSONObject responseJSON = new JSONObject(new StringBuilder().append("{\"groups\": {\"2012/SZ\": [{\"course_unit_id\": 118564, \"course_name\": {\"pl\":").append(" \"Projekt magisterski\", \"en\": \"Final project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": ").append("\"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"LAB\", \"course_id\": \"06-DPROUI0\", \"term_id\": ").append("\"2012/SZ\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\":").append(" 114904, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\",").append(" \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2012/SZ\", ").append("\"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 117486, \"course_name\": {\"pl\":").append(" \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"},").append(" {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": \"Maciej\"}, {\"user_id\": \"1910\", \"id\": \"1910\", \"last_name\": \"Vetulani\",").append(" \"first_name\": \"Zygmunt\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DINTUI0\", \"term_id\": \"2012/SZ\", \"class_type\": {\"pl\":").append(" \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 121955, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\":").append(" \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1,").append(" \"class_type_id\": \"WYK\", \"course_id\": \"06-ZINTUI0\", \"term_id\": \"2012/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\":").append(" \"0600000000\"}, {\"course_unit_id\": 114567, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"},").append(" \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\",").append(" \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2012/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, ").append("{\"course_unit_id\": 114568, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"},").append(" \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\",").append(" \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2012/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], ").append("\"2019/SL\": [{\"course_unit_id\": 308573, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": ").append("\"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 18, \"class_type_id\": \"CW\", \"course_id\": \"06-DSEMUA1\", ").append("\"term_id\": \"2019/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 308574, \"course_name\":").append(" {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\",").append(" \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"CW\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2019/SL\", \"class_type\": {\"pl\": ").append("\"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 308576, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", ").append("\"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], ").append("\"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2019/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\":").append(" \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2016/2017\": [{\"course_unit_id\": 250604, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, ").append("\"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 3, \"class_type_id\": \"SEM\",").append(" \"course_id\": \"06-DSEMDD3\", \"term_id\": \"2016/2017\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, ").append("{\"course_unit_id\": 250607, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": ").append("\"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"SEM\", \"course_id\": \"06-ZSEMDD1\", \"term_id\": \"2016/2017\", \"class_type\":").append(" {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}], \"2017/SZ\": [{\"course_unit_id\": 269695, \"course_name\":").append(" {\"pl\": \"Przetwarzanie j\\u0119zyka naturalnego\", \"en\": \"Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\",").append(" \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DPJNLI0\", \"term_id\":").append(" \"2017/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 271369, ").append("\"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", ").append("\"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 14, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": ").append("\"2017/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 267177, \"course_name\": ").append("{\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\":").append(" \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2017/SZ\", ").append("\"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 272493, \"course_name\": {\"pl\":").append(" \"Systemy informatyczne\", \"en\": \"IT systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\":").append(" \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DSYIUI0\", \"term_id\": \"2017/SZ\", \"class_type\": {\"pl\": ").append("\"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 272492, \"course_name\": {\"pl\": ").append("\"Systemy informatyczne\", \"en\": \"IT systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\",").append(" \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DSYIUI0\", \"term_id\": \"2017/SZ\",").append(" \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 267173, \"course_name\": ").append("{\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\":").append(" \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": \"Maciej\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", ").append("\"course_id\": \"06-DINTUI0\", \"term_id\": \"2017/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"},").append(" {\"course_unit_id\": 267338, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\",").append(" \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": ").append("\"Maciej\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DINTUN0\", \"term_id\": \"2017/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\",").append(" \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 267337, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"},").append(" \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\":").append(" \"Wygralak\", \"first_name\": \"Maciej\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DINTUN0\", \"term_id\": \"2017/SZ\", \"class_type\": {\"pl\":").append(" \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2014/SL\": [{\"course_unit_id\": 170257, \"course_name\": {\"pl\":").append(" \"Przygotowanie pracy magisterskiej\", \"en\": \"Preparation of the thesis\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\":").append(" \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 13, \"class_type_id\": \"CW\", \"course_id\": \"06-DPPMUI0\", \"term_id\": \"2014/SL\",").append(" \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 153969, \"course_name\": ").append("{\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": ").append("\"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2014/SL\", ").append("\"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 153973, \"course_name\": {\"pl\":").append(" \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", ").append("\"first_name\": \"Krzysztof\"}], \"group_number\": 13, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2014/SL\", \"class_type\": {\"pl\": ").append("\"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 153607, \"course_name\": ").append("{\"pl\": \"Zastosowania informatyki w przetwarzaniu j\\u0119zyka naturalnego\", \"en\": \"Application of Information Technology in Natural Language Processing\"},").append(" \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", ").append("\"course_id\": \"06-DZJNUI0\", \"term_id\": \"2014/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2018/SL\": ").append("[{\"course_unit_id\": 267758, \"course_name\": {\"pl\": \"Projekt magisterski\", \"en\": \"Final project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", ").append("\"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"LAB\", \"course_id\": \"06-DPROUI0\", \"term_id\": \"2018/SL\", ").append("\"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 267757, \"course_name\": ").append("{\"pl\": \"Przygotowanie pracy magisterskiej\", \"en\": \"Preparation of the thesis\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": ").append("\"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"CW\", \"course_id\": \"06-DPPMUI0\", \"term_id\": \"2018/SL\", \"class_type\":").append(" {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 267759, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\",").append(" \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\":").append(" 11, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2018/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\":").append(" \"0600000000\"}, {\"course_unit_id\": 281789, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\":").append(" \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", ").append("\"term_id\": \"2018/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 267760, \"course_name\":").append(" {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", ").append("\"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2018/SL\", \"class_type\": {\"pl\":").append(" \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}], \"2018/2019\": [{\"course_unit_id\": 306621, \"course_name\": {\"pl\": \"Seminarium\",").append(" \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1,").append(" \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMDD1\", \"term_id\": \"2018/2019\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, ").append("\"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 316617, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\":").append(" [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"SEM\", \"course_id\": \"06-ZSEMDD3\", \"term_id\": \"2018/2019\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}], \"2008/SL\": [{\"course_unit_id\": 36055, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-LIK320\", \"term_id\": \"2008/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 36055, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-LIK320\", \"term_id\": \"2008/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 36054, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-LIK320\", \"term_id\": \"2008/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 35784, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"M. Sc. Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 24, \"class_type_id\": \"SEM\", \"course_id\": \"06-SEM402\", \"term_id\": \"2008/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 35669, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"M. Sc. Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 23, \"class_type_id\": \"SEM\", \"course_id\": \"06-SEM504\", \"term_id\": \"2008/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}], \"2009/SZ\": [{\"course_unit_id\": 53955, \"course_name\": {\"pl\": \"Projekt\", \"en\": \"Project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-PRO520\", \"term_id\": \"2009/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 53730, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"M. Sc. Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 22, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM503\", \"term_id\": \"2009/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 59662, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"M. Sc. Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 22, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM523\", \"term_id\": \"2009/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 54611, \"course_name\": {\"pl\": \"Seminarium przegl\\u0105dowe\", \"en\": \"Cross-sectional seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 34, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM401\", \"term_id\": \"2009/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 53715, \"course_name\": {\"pl\": \"Technologie system\\u00f3w informatycznych\", \"en\": \"Computer Systems Technologies\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-TSI520\", \"term_id\": \"2009/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 53716, \"course_name\": {\"pl\": \"Technologie system\\u00f3w informatycznych\", \"en\": \"Computer Systems Technologies\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-TSI520\", \"term_id\": \"2009/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2018/SZ\": [{\"course_unit_id\": 301776, \"course_name\": {\"pl\": \"Projekt magisterski\", \"en\": \"Final project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"LAB\", \"course_id\": \"06-DPROUI0\", \"term_id\": \"2018/SZ\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 301757, \"course_name\": {\"pl\": \"Przetwarzanie j\\u0119zyka naturalnego\", \"en\": \"Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DPJNLI0\", \"term_id\": \"2018/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 301798, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2018/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 305227, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2018/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 301817, \"course_name\": {\"pl\": \"Systemy informatyczne\", \"en\": \"IT systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DSYIUI0\", \"term_id\": \"2018/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 301817, \"course_name\": {\"pl\": \"Systemy informatyczne\", \"en\": \"IT systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-DSYIUI0\", \"term_id\": \"2018/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 301816, \"course_name\": {\"pl\": \"Systemy informatyczne\", \"en\": \"IT systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DSYIUI0\", \"term_id\": \"2018/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2016/SL\": [{\"course_unit_id\": 230942, \"course_name\": {\"pl\": \"Przygotowanie pracy magisterskiej\", \"en\": \"Preparation of the thesis\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 13, \"class_type_id\": \"LAB\", \"course_id\": \"06-DPPMUI0\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 223180, \"course_name\": {\"pl\": \"Przygotowanie pracy magisterskiej\", \"en\": \"Preparation of the thesis\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 10, \"class_type_id\": \"CW\", \"course_id\": \"06-ZPPMUI0\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 215363, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 215019, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 8, \"class_type_id\": \"SEM\", \"course_id\": \"06-ZSEMUI1\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 215763, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 13, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 220045, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 10, \"class_type_id\": \"SEM\", \"course_id\": \"06-ZSEMUI3\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 215114, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 215114, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 215113, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2016/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2019/SZ\": [{\"course_unit_id\": 329673, \"course_name\": {\"pl\": \"Natural Language Processing\", \"en\": \"Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DPJNLI0-E\", \"term_id\": \"2019/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 327566, \"course_name\": {\"pl\": \"Projekt magisterski\", \"en\": \"Final project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"LAB\", \"course_id\": \"06-DPROUI0\", \"term_id\": \"2019/SZ\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 327686, \"course_name\": {\"pl\": \"Przetwarzanie j\\u0119zyka naturalnego\", \"en\": \"Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DPJNLI0\", \"term_id\": \"2019/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 327584, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUA2\", \"term_id\": \"2019/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 327585, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2019/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 330761, \"course_name\": {\"pl\": \"Systemy informatyczne\", \"en\": \"IT systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DSYIUA0\", \"term_id\": \"2019/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 330762, \"course_name\": {\"pl\": \"Systemy informatyczne\", \"en\": \"IT systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"LAB\", \"course_id\": \"06-DSYIUA0\", \"term_id\": \"2019/SZ\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 327598, \"course_name\": {\"pl\": \"Systemy informatyczne\", \"en\": \"IT systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DSYIUI0\", \"term_id\": \"2019/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2009/SL\": [{\"course_unit_id\": 42949, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-LIK320\", \"term_id\": \"2009/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 42948, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-LIK320\", \"term_id\": \"2009/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 43075, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"M. Sc. Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 23, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM402\", \"term_id\": \"2009/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 45893, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"M. Sc. Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM422\", \"term_id\": \"2009/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 43266, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"M. Sc. Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 22, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM504\", \"term_id\": \"2009/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2015/SL\": [{\"course_unit_id\": 189735, \"course_name\": {\"pl\": \"Przygotowanie pracy magisterskiej\", \"en\": \"Preparation of the thesis\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 14, \"class_type_id\": \"CW\", \"course_id\": \"06-DPPMUI0\", \"term_id\": \"2015/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 189271, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2015/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 189388, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 14, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2015/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 189386, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-DTSIUI0\", \"term_id\": \"2015/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 189385, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DTSIUI0\", \"term_id\": \"2015/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 188504, \"course_name\": {\"pl\": \"Zastosowania informatyki w przetwarzaniu j\\u0119zyka naturalnego\", \"en\": \"Application of Information Technology in Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DZJNUI0\", \"term_id\": \"2015/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2010/SZ\": [{\"course_unit_id\": 69981, \"course_name\": {\"pl\": \"Projekt\", \"en\": \"Project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-PRO520\", \"term_id\": \"2010/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 74901, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 17, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2010/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 69984, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"M. Sc. Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 23, \"class_type_id\": \"SEM\", \"course_id\": \"06-SEM503\", \"term_id\": \"2010/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 69985, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"M. Sc. Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 22, \"class_type_id\": \"SEM\", \"course_id\": \"06-SEM523\", \"term_id\": \"2010/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 74826, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2010/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2017/SL\": [{\"course_unit_id\": 254286, \"course_name\": {\"pl\": \"Przygotowanie pracy magisterskiej\", \"en\": \"Preparation of the thesis\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"LAB\", \"course_id\": \"06-DPPMUI0\", \"term_id\": \"2017/SL\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 247855, \"course_name\": {\"pl\": \"Przygotowanie pracy magisterskiej\", \"en\": \"Preparation of the thesis\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 8, \"class_type_id\": \"LAB\", \"course_id\": \"06-ZPPMUI0\", \"term_id\": \"2017/SL\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 237607, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2017/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 237608, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2017/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 247858, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 8, \"class_type_id\": \"SEM\", \"course_id\": \"06-ZSEMUI3\", \"term_id\": \"2017/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 237629, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2017/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 237628, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2017/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 237629, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2017/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2011/SL\": [{\"course_unit_id\": 79721, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DLIKLI0\", \"term_id\": \"2011/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 82166, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 17, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2011/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 79782, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"M. Sc. Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 23, \"class_type_id\": \"SEM\", \"course_id\": \"06-SEM504\", \"term_id\": \"2011/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 82193, \"course_name\": {\"pl\": \"Zastosowania informatyki w przetwarzaniu j\\u0119zyka naturalnego\", \"en\": \"Application of Information Technology in Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DZJNUI0\", \"term_id\": \"2011/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2013/SL\": [{\"course_unit_id\": 131304, \"course_name\": {\"pl\": \"Przygotowanie do egzaminu magisterskiego\", \"en\": \"Preparation for final exam\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"CW\", \"course_id\": \"06-DEGZUI0\", \"term_id\": \"2013/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 129622, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2013/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 126027, \"course_name\": {\"pl\": \"Seminarium magisterskie 4\", \"en\": \"Master Science Seminar 4\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI4\", \"term_id\": \"2013/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 125624, \"course_name\": {\"pl\": \"Zastosowania informatyki w przetwarzaniu j\\u0119zyka naturalnego\", \"en\": \"Application of Information Technology in Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DZJNUI0\", \"term_id\": \"2013/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 125623, \"course_name\": {\"pl\": \"Zastosowania informatyki w przetwarzaniu j\\u0119zyka naturalnego\", \"en\": \"Application of Information Technology in Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DZJNUI0\", \"term_id\": \"2013/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 141544, \"course_name\": {\"pl\": \"Zastosowanie informatyki w przetwarzaniu j\\u0119zyka naturalnego\", \"en\": \"\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"04-YZIJN-123\", \"term_id\": \"2013/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0400000000\"}], \"2007/SZ\": [{\"course_unit_id\": 29012, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"M. Sc. Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 23, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM503\", \"term_id\": \"2007/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 29040, \"course_name\": {\"pl\": \"Technologie system\\u00f3w informatycznych\", \"en\": \"Computer Systems Technologies\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-TSI520\", \"term_id\": \"2007/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 29039, \"course_name\": {\"pl\": \"Technologie system\\u00f3w informatycznych\", \"en\": \"Computer Systems Technologies\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-TSI520\", \"term_id\": \"2007/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 29027, \"course_name\": {\"pl\": \"T\\u0142umaczenie automatyczne\", \"en\": \"Machine translation\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-TAU420\", \"term_id\": \"2007/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2013/SZ\": [{\"course_unit_id\": 143676, \"course_name\": {\"pl\": \"Projekt magisterski\", \"en\": \"Final project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DPROUI0\", \"term_id\": \"2013/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 143591, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2013/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 143167, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": \"Maciej\"}, {\"user_id\": \"1910\", \"id\": \"1910\", \"last_name\": \"Vetulani\", \"first_name\": \"Zygmunt\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DINTUI0\", \"term_id\": \"2013/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 143032, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2013/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 143033, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2013/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 155768, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Development of Computer Information Systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"08-KODM-TSI\", \"term_id\": \"2013/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0800000000\"}], \"2012/SL\": [{\"course_unit_id\": 106404, \"course_name\": {\"pl\": \"Projekt magisterski\", \"en\": \"Final project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"LAB\", \"course_id\": \"06-DPROUI0\", \"term_id\": \"2012/SL\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 106286, \"course_name\": {\"pl\": \"Przygotowanie do egzaminu magisterskiego\", \"en\": \"Preparation for final exam\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"CW\", \"course_id\": \"06-DEGZUI0\", \"term_id\": \"2012/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 100217, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2012/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 100539, \"course_name\": {\"pl\": \"Seminarium magisterskie 4\", \"en\": \"Master Science Seminar 4\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI4\", \"term_id\": \"2012/SL\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 100192, \"course_name\": {\"pl\": \"Zastosowania informatyki w przetwarzaniu j\\u0119zyka naturalnego\", \"en\": \"Application of Information Technology in Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DZJNUI0\", \"term_id\": \"2012/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 100193, \"course_name\": {\"pl\": \"Zastosowania informatyki w przetwarzaniu j\\u0119zyka naturalnego\", \"en\": \"Application of Information Technology in Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-DZJNUI0\", \"term_id\": \"2012/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2008/SZ\": [{\"course_unit_id\": 39449, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"M. Sc. Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 22, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM503\", \"term_id\": \"2008/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 38727, \"course_name\": {\"pl\": \"Seminarium przegl\\u0105dowe\", \"en\": \"Cross-sectional seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 32, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM401\", \"term_id\": \"2008/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 39443, \"course_name\": {\"pl\": \"Technologie system\\u00f3w informatycznych\", \"en\": \"Computer Systems Technologies\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-TSI520\", \"term_id\": \"2008/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 39444, \"course_name\": {\"pl\": \"Technologie system\\u00f3w informatycznych\", \"en\": \"Computer Systems Technologies\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-TSI520\", \"term_id\": \"2008/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2011/SZ\": [{\"course_unit_id\": 91455, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"Master Science Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 17, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI1\", \"term_id\": \"2011/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 89194, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"Master Science Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI3\", \"term_id\": \"2011/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 91403, \"course_name\": {\"pl\": \"Tworzenie system\\u00f3w informatycznych\", \"en\": \"Developing and management of software system\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DTSIUI1\", \"term_id\": \"2011/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2015/2016\": [{\"course_unit_id\": 215968, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMDD2\", \"term_id\": \"2015/2016\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}], \"2006/SZ\": [{\"course_unit_id\": 10049, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"M. Sc. Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM503\", \"term_id\": \"2006/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 10067, \"course_name\": {\"pl\": \"Technologie system\\u00f3w informatycznych\", \"en\": \"Computer Systems Technologies\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-TSI520\", \"term_id\": \"2006/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 10057, \"course_name\": {\"pl\": \"T\\u0142umaczenie automatyczne\", \"en\": \"Machine translation\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-TAU420\", \"term_id\": \"2006/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2016/SZ\": [{\"course_unit_id\": 236118, \"course_name\": {\"pl\": \"Przetwarzanie j\\u0119zyka naturalnego\", \"en\": \"Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DPJNLI0\", \"term_id\": \"2016/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 236143, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2016/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 244170, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 8, \"class_type_id\": \"SEM\", \"course_id\": \"06-ZSEMUI2\", \"term_id\": \"2016/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 236075, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": \"Maciej\"}, {\"user_id\": \"1910\", \"id\": \"1910\", \"last_name\": \"Vetulani\", \"first_name\": \"Zygmunt\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DINTUI0\", \"term_id\": \"2016/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 238955, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": \"Maciej\"}, {\"user_id\": \"1910\", \"id\": \"1910\", \"last_name\": \"Vetulani\", \"first_name\": \"Zygmunt\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-DINTUN0\", \"term_id\": \"2016/SZ\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 238954, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": \"Maciej\"}, {\"user_id\": \"1910\", \"id\": \"1910\", \"last_name\": \"Vetulani\", \"first_name\": \"Zygmunt\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DINTUN0\", \"term_id\": \"2016/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 236176, \"course_name\": {\"pl\": \"Uczenie maszynowe\", \"en\": \"Machine learning\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"322368\", \"id\": \"322368\", \"last_name\": \"Grundkiewicz\", \"first_name\": \"Roman\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DUMZUI0\", \"term_id\": \"2016/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2014/SZ\": [{\"course_unit_id\": 173597, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 14, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2014/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 173540, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": \"Maciej\"}, {\"user_id\": \"1910\", \"id\": \"1910\", \"last_name\": \"Vetulani\", \"first_name\": \"Zygmunt\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DINTUI0\", \"term_id\": \"2014/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2015/SZ\": [{\"course_unit_id\": 207911, \"course_name\": {\"pl\": \"Projekt magisterski\", \"en\": \"Final project\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 10, \"class_type_id\": \"LAB\", \"course_id\": \"06-ZPROUI0\", \"term_id\": \"2015/SZ\", \"class_type\": {\"pl\": \"Zaj\\u0119cia laboratoryjne\", \"en\": \"laboratory\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 204609, \"course_name\": {\"pl\": \"Przetwarzanie j\\u0119zyka naturalnego\", \"en\": \"Natural Language Processing\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DPJNLI0\", \"term_id\": \"2015/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 203795, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 15, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMUI2\", \"term_id\": \"2015/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 207913, \"course_name\": {\"pl\": \"Seminarium magisterskie 2\", \"en\": \"Master Science Seminar 2\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 10, \"class_type_id\": \"SEM\", \"course_id\": \"06-ZSEMUI2\", \"term_id\": \"2015/SZ\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 203743, \"course_name\": {\"pl\": \"Systemy inteligentne\", \"en\": \"Intelligent systems\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"1878\", \"id\": \"1878\", \"last_name\": \"Wygralak\", \"first_name\": \"Maciej\"}, {\"user_id\": \"1910\", \"id\": \"1910\", \"last_name\": \"Vetulani\", \"first_name\": \"Zygmunt\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DINTUI0\", \"term_id\": \"2015/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 204307, \"course_name\": {\"pl\": \"Uczenie maszynowe\", \"en\": \"Machine learning\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}, {\"user_id\": \"314065\", \"id\": \"314065\", \"last_name\": \"Junczys-Dowmunt\", \"first_name\": \"Marcin\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DUMZUI0\", \"term_id\": \"2015/SZ\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}], \"2014/2015\": [{\"course_unit_id\": 186180, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 13, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMDD1\", \"term_id\": \"2014/2015\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 186184, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMDD4\", \"term_id\": \"2014/2015\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}], \"2013/2014\": [{\"course_unit_id\": 157421, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMDD3\", \"term_id\": \"2013/2014\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 157424, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 3, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMDD4\", \"term_id\": \"2013/2014\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}], \"2010/SL\": [{\"course_unit_id\": 61742, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-DLIKLI0\", \"term_id\": \"2010/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 60690, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"M. Sc. Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 23, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM402\", \"term_id\": \"2010/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 60610, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"M. Sc. Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 22, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM504\", \"term_id\": \"2010/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 63713, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"M. Sc. Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 2, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM524\", \"term_id\": \"2010/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}], \"2017/2018\": [{\"course_unit_id\": 280491, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 8, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMDD1\", \"term_id\": \"2017/2018\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 280515, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 3, \"class_type_id\": \"SEM\", \"course_id\": \"06-DSEMDD4\", \"term_id\": \"2017/2018\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 280669, \"course_name\": {\"pl\": \"Seminarium\", \"en\": \"Seminar\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"SEM\", \"course_id\": \"06-ZSEMDD2\", \"term_id\": \"2017/2018\", \"class_type\": {\"pl\": \"Seminarium\", \"en\": \"seminar\"}, \"course_fac_id\": \"0600000000\"}], \"2007/SL\": [{\"course_unit_id\": 23435, \"course_name\": {\"pl\": \"J\\u0119zyki programowania1\", \"en\": \"Programming languages 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-JPR121\", \"term_id\": \"2007/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 23609, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 1, \"class_type_id\": \"WYK\", \"course_id\": \"06-LIK320\", \"term_id\": \"2007/SL\", \"class_type\": {\"pl\": \"Wyk\\u0142ad\", \"en\": \"lecture\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 23610, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 11, \"class_type_id\": \"CW\", \"course_id\": \"06-LIK320\", \"term_id\": \"2007/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 23610, \"course_name\": {\"pl\": \"Lingwistyka komputerowa\", \"en\": \"Computer linguistics\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 12, \"class_type_id\": \"CW\", \"course_id\": \"06-LIK320\", \"term_id\": \"2007/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 25788, \"course_name\": {\"pl\": \"Seminarium magisterskie 1\", \"en\": \"M. Sc. Seminar 1\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 21, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM402\", \"term_id\": \"2007/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}, {\"course_unit_id\": 25340, \"course_name\": {\"pl\": \"Seminarium magisterskie 3\", \"en\": \"M. Sc. Seminar 3\"}, \"lecturers\": [{\"user_id\": \"1872\", \"id\": \"1872\", \"last_name\": \"Jassem\", \"first_name\": \"Krzysztof\"}], \"group_number\": 16, \"class_type_id\": \"CW\", \"course_id\": \"06-SEM504\", \"term_id\": \"2007/SL\", \"class_type\": {\"pl\": \"\\u0106wiczenia\", \"en\": \"classes\"}, \"course_fac_id\": \"0600000000\"}]}, \"terms\": [{\"end_date\": \"2020-02-23\", \"start_date\": \"2019-10-01\", \"id\": \"2019/SZ\", \"name\": {\"en\": \"Academic year 2019/2020, winter semester\", \"pl\": \"Semestr zimowy 2019/2020\"}, \"order_key\": 1750, \"finish_date\": \"2020-02-23\"}, {\"end_date\": \"2019-09-30\", \"start_date\": \"2019-02-22\", \"id\": \"2019/SL\", \"name\": {\"en\": \"Academic year 2018/2019, summer semester\", \"pl\": \"Semestr letni 2018/2019\"}, \"order_key\": 1730, \"finish_date\": \"2019-09-30\"}, {\"end_date\": \"2019-02-21\", \"start_date\": \"2018-10-01\", \"id\": \"2018/SZ\", \"name\": {\"en\": \"Academic year 2018/2019, winter semester\", \"pl\": \"Semestr zimowy 2018/2019\"}, \"order_key\": 1720, \"finish_date\": \"2019-02-21\"}, {\"end_date\": \"2019-09-30\", \"start_date\": \"2018-10-01\", \"id\": \"2018/2019\", \"name\": {\"en\": \"Academic year 2018/2019\", \"pl\": \"Rok akademicki 2018/2019\"}, \"order_key\": 1710, \"finish_date\": \"2019-09-30\"}, {\"end_date\": \"2018-09-30\", \"start_date\": \"2018-02-22\", \"id\": \"2018/SL\", \"name\": {\"en\": \"Academic year 2017/2018, summer semester\", \"pl\": \"Semestr letni 2017/2018\"}, \"order_key\": 1700, \"finish_date\": \"2018-09-30\"}, {\"end_date\": \"2018-02-21\", \"start_date\": \"2017-10-01\", \"id\": \"2017/SZ\", \"name\": {\"en\": \"Academic year 2017/2018, winter semester\", \"pl\": \"Semestr zimowy 2017/2018\"}, \"order_key\": 1690, \"finish_date\": \"2018-02-21\"}, {\"end_date\": \"2018-09-30\", \"start_date\": \"2017-10-01\", \"id\": \"2017/2018\", \"name\": {\"en\": \"Academic year 2017/2018\", \"pl\": \"Rok akademicki 2017/2018\"}, \"order_key\": 1680, \"finish_date\": \"2018-09-30\"}, {\"end_date\": \"2017-09-30\", \"start_date\": \"2017-02-20\", \"id\": \"2017/SL\", \"name\": {\"en\": \"Academic year 2016/2017, summer semester\", \"pl\": \"Semestr letni 2016/2017\"}, \"order_key\": 1670, \"finish_date\": \"2017-09-30\"}, {\"end_date\": \"2017-02-19\", \"start_date\": \"2016-10-01\", \"id\": \"2016/SZ\", \"name\": {\"en\": \"Academic year 2016/2017, winter semester\", \"pl\": \"Semestr zimowy 2016/2017\"}, \"order_key\": 1660, \"finish_date\": \"2017-02-19\"}, {\"end_date\": \"2017-09-30\", \"start_date\": \"2016-10-01\", \"id\": \"2016/2017\", \"name\": {\"en\": \"Academic year 2016/2017\", \"pl\": \"Rok akademicki 2016/2017\"}, \"order_key\": 1650, \"finish_date\": \"2017-09-30\"}, {\"end_date\": \"2016-09-30\", \"start_date\": \"2015-10-01\", \"id\": \"2015/2016\", \"name\": {\"en\": \"Academic year 2015/2016\", \"pl\": \"Rok akademicki 2015/2016\"}, \"order_key\": 1640, \"finish_date\": \"2016-09-30\"}, {\"end_date\": \"2016-09-30\", \"start_date\": \"2016-02-22\", \"id\": \"2016/SL\", \"name\": {\"en\": \"Academic year 2015/2016, summer semester\", \"pl\": \"Semestr letni 2015/2016\"}, \"order_key\": 1630, \"finish_date\": \"2016-09-30\"}, {\"end_date\": \"2016-02-21\", \"start_date\": \"2015-10-01\", \"id\": \"2015/SZ\", \"name\": {\"en\": \"Academic year 2015/2016, winter semester\", \"pl\": \"Semestr zimowy 2015/2016\"}, \"order_key\": 1620, \"finish_date\": \"2016-02-21\"}, {\"end_date\": \"2015-09-30\", \"start_date\": \"2014-10-01\", \"id\": \"2014/2015\", \"name\": {\"en\": \"Academic year 2014/2015\", \"pl\": \"Rok akademicki 2014/2015\"}, \"order_key\": 1610, \"finish_date\": \"2015-09-30\"}, {\"end_date\": \"2015-09-30\", \"start_date\": \"2015-02-23\", \"id\": \"2015/SL\", \"name\": {\"en\": \"Academic year 2014/2015, summer semester\", \"pl\": \"Semestr letni 2014/2015\"}, \"order_key\": 1600, \"finish_date\": \"2015-09-30\"}, {\"end_date\": \"2015-02-22\", \"start_date\": \"2014-10-01\", \"id\": \"2014/SZ\", \"name\": {\"en\": \"Academic year 2014/2015, winter semester\", \"pl\": \"Semestr zimowy 2014/2015\"}, \"order_key\": 1590, \"finish_date\": \"2015-02-22\"}, {\"end_date\": \"2014-09-30\", \"start_date\": \"2013-10-01\", \"id\": \"2013/2014\", \"name\": {\"en\": \"Academic year 2013/2014\", \"pl\": \"Rok akademicki 2013/2014\"}, \"order_key\": 1580, \"finish_date\": \"2014-09-30\"}, {\"end_date\": \"2014-09-30\", \"start_date\": \"2014-02-24\", \"id\": \"2014/SL\", \"name\": {\"en\": \"Academic year 2013/2014, summer semester\", \"pl\": \"Semestr letni 2013/2014\"}, \"order_key\": 1570, \"finish_date\": \"2014-09-30\"}, {\"end_date\": \"2014-02-23\", \"start_date\": \"2013-10-01\", \"id\": \"2013/SZ\", \"name\": {\"en\": \"Academic year 2013/2014, winter semester\", \"pl\": \"Semestr zimowy 2013/2014\"}, \"order_key\": 1560, \"finish_date\": \"2014-02-23\"}, {\"end_date\": \"2013-09-30\", \"start_date\": \"2013-02-18\", \"id\": \"2013/SL\", \"name\": {\"en\": \"Academic year 2012/2013, summer semester\", \"pl\": \"Semestr letni 2012/2013\"}, \"order_key\": 1540, \"finish_date\": \"2013-09-30\"}, {\"end_date\": \"2013-02-17\", \"start_date\": \"2012-10-01\", \"id\": \"2012/SZ\", \"name\": {\"en\": \"Academic year 2012/2013, winter semester\", \"pl\": \"Semestr zimowy 2012/2013\"}, \"order_key\": 1530, \"finish_date\": \"2013-02-17\"}, {\"end_date\": \"2012-09-30\", \"start_date\": \"2012-02-13\", \"id\": \"2012/SL\", \"name\": {\"en\": \"Academic year 2011/2012, summer semester\", \"pl\": \"Semestr Letni 2011/2012\"}, \"order_key\": 1510, \"finish_date\": \"2012-09-30\"}, {\"end_date\": \"2012-02-12\", \"start_date\": \"2011-10-01\", \"id\": \"2011/SZ\", \"name\": {\"en\": \"Academic year 2011/2012, winter semester\", \"pl\": \"Semestr Zimowy 2011/2012\"}, \"order_key\": 1500, \"finish_date\": \"2012-02-12\"}, {\"end_date\": \"2011-09-30\", \"start_date\": \"2011-02-21\", \"id\": \"2011/SL\", \"name\": {\"en\": \"Academic year 2010/2011, summer semester\", \"pl\": \"Semestr Letni 2010/2011\"}, \"order_key\": 1480, \"finish_date\": \"2011-09-30\"}, {\"end_date\": \"2011-02-20\", \"start_date\": \"2010-10-01\", \"id\": \"2010/SZ\", \"name\": {\"en\": \"Academic year 2010/2011, winter semester\", \"pl\": \"Semestr Zimowy 2010/2011\"}, \"order_key\": 1470, \"finish_date\": \"2011-02-20\"}, {\"end_date\": \"2010-09-30\", \"start_date\": \"2010-02-15\", \"id\": \"2010/SL\", \"name\": {\"en\": \"Academic year 2009/2010, summer semester\", \"pl\": \"Semestr Letni 2009/2010\"}, \"order_key\": 1450, \"finish_date\": \"2010-09-30\"}, {\"end_date\": \"2010-02-14\", \"start_date\": \"2009-10-01\", \"id\": \"2009/SZ\", \"name\": {\"en\": \"Academic year 2009/2010, winter semester\", \"pl\": \"Semestr Zimowy 2009/2010\"}, \"order_key\": 1440, \"finish_date\": \"2010-02-14\"}, {\"end_date\": \"2009-09-30\", \"start_date\": \"2009-02-23\", \"id\": \"2009/SL\", \"name\": {\"en\": \"Academic year 2008/2009, summer semester\", \"pl\": \"Semestr Letni 2008/2009\"}, \"order_key\": 1420, \"finish_date\": \"2009-09-30\"}, {\"end_date\": \"2009-02-22\", \"start_date\": \"2008-10-01\", \"id\": \"2008/SZ\", \"name\": {\"en\": \"Academic year 2008/2009, winter semester\", \"pl\": \"Semestr Zimowy 2008/2009\"}, \"order_key\": 1410, \"finish_date\": \"2009-02-22\"}, {\"end_date\": \"2008-09-30\", \"start_date\": \"2008-02-18\", \"id\": \"2008/SL\", \"name\": {\"en\": \"Academic year 2007/2008, summer semester\", \"pl\": \"Semestr Letni 2007/2008\"}, \"order_key\": 1390, \"finish_date\": \"2008-09-30\"}, {\"end_date\": \"2008-02-17\", \"start_date\": \"2007-10-01\", \"id\": \"2007/SZ\", \"name\": {\"en\": \"Academic year 2007/2008, winter semester\", \"pl\": \"Semestr Zimowy 2007/2008\"}, \"order_key\": 1380, \"finish_date\": \"2008-02-28\"}, {\"end_date\": \"2007-09-30\", \"start_date\": \"2007-02-19\", \"id\": \"2007/SL\", \"name\": {\"en\": \"Academic year 2006/2007, summer semester\", \"pl\": \"Semestr Letni 2006/2007\"}, \"order_key\": 1360, \"finish_date\": \"2007-09-30\"}, {\"end_date\": \"2007-02-18\", \"start_date\": \"2006-10-01\", \"id\": \"2006/SZ\", \"name\": {\"en\": \"Academic year 2006/2007, winter semester\", \"pl\": \"Semestr Zimowy 2006/2007\"}, \"order_key\": 1350, \"finish_date\": \"2007-02-18\"}]}\n").toString());
        //if (response.statusCode() == 200) {
        //if (true) {
            responseJSON = responseJSON.getJSONObject("groups");
                if (responseJSON.has(semesterId)) {
                    JSONArray subjects = responseJSON.getJSONArray(semesterId);
                    for (int i = 0; i < subjects.length(); i++) {
                        JSONObject subject = subjects.getJSONObject(i);
                        if (subject.getString("class_type_id").equalsIgnoreCase("WYK")) {
                            Optional<StudyGroup> group = groupRepository.findByUsosGroupId(subject.getString("course_id") + "-" + subject.getString("term_id"));
                            if (!group.isPresent()) {
                                StudyGroup studyGroup = new StudyGroup();
                                studyGroup.setName(subject.getJSONObject("course_name").getString("pl"));
                                studyGroup.setUsosGroupId(subject.getString("course_id") + "-" + subject.getString("term_id"));
                                studyGroup.setDescription("Wykład");
                                studyGroup.getMembers().add(new StudyGroupMember(studyGroup, userRepository.findByUsername(userId).get(), true));
                                String groupKey = generator.generate(10);

                                while (!this.groupRepository.findByGroupKey(groupKey).isEmpty()) {
                                    groupKey = generator.generate(10);
                                }

                                studyGroup.setGroupKey(groupKey);
                                groupRepository.save(studyGroup);
                            }
                        }
                    }
                    updateGroupStudents(oauth_token, oauth_token_secret, semesterId);
                }

    }

    private void updateGroupStudents(String oauth_token, String oauth_token_secret, String semesterId) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
        List<NameValuePair> queryParams = new ArrayList<>();
        queryParams.add(new BasicNameValuePair("fields", "course_editions[course_id|course_name|term_id|user_groups]"));
        queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
        queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
        queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
        queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
        queryParams.add(new BasicNameValuePair("oauth_token", oauth_token));
        queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
        String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/courses/user", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), oauth_token_secret);
        queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
        String url = "/courses/user?" + URLEncodedUtils.format(queryParams, ENC);

        Response response = given().urlEncodingEnabled(false).get(url);

        JSONObject jsonObject = new JSONObject(response.getBody().print());
        JSONArray array = jsonObject.getJSONObject("course_editions").getJSONArray(semesterId);
        for (int i = 0 ; i < array.length() ; i++){
            JSONObject course = array.getJSONObject(i);
            String groupId = course.getString("course_id") + "-" + course.getString("term_id");
            Optional<StudyGroup> studyGroupCheck = groupRepository.findByUsosGroupId(groupId);
            if (!studyGroupCheck.isPresent())
                continue;
            StudyGroup studyGroup = studyGroupCheck.get();
            JSONArray participants = course.getJSONArray("user_groups").getJSONObject(0).getJSONArray("participants");
            for (int j = 0 ; j < participants.length() ; j++){
                String id = participants.getJSONObject(j).getString("id");
                Optional<User> userCheck = userRepository.findByUsosUserUsosId(id);
                User user = null;
                if (userCheck.isPresent())
                    user = userCheck.get();
                else {
                    user = new User();
                    String generatedPassword = PasswordGenerator.generatePassword(16, ALPHA_CAPS + ALPHA + NUMERIC);
                    UsosUser usosUser = new UsosUser(id, bCryptPasswordEncoder.encode(generatedPassword));
                    user.setUsosUser(usosUser);
                    user.setName(participants.getJSONObject(j).getString("first_name"));
                    user.setSurname(participants.getJSONObject(j).getString("last_name"));
                    user.setUsername(id);
                    user = userRepository.save(user);
                }
                if (!studyGroupMemberRepository.findByUserUsosUserUsosIdAndGroupUsosGroupId(id, groupId).isPresent())
                    studyGroup.getMembers().add(new StudyGroupMember(studyGroup, user, false));
            }
            groupRepository.save(studyGroup);
        }
    }

    private String getActualSemester(String oauth_token, String oauth_token_secret) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException, ParseException {

        List<NameValuePair> queryParams = new ArrayList<>();
        queryParams.add(new BasicNameValuePair("fields", "terms"));
        queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
        queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
        queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
        queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
        queryParams.add(new BasicNameValuePair("oauth_token", oauth_token));
        queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
        String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/courses/user", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), oauth_token_secret);
        queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
        String url = "/courses/user?" + URLEncodedUtils.format(queryParams, ENC);

        Response response = given().urlEncodingEnabled(false).get(url);
        JSONObject jsonObject = new JSONObject(response.getBody().print());
        JSONArray jsonArray = new JSONArray(jsonObject.getJSONArray("terms").toString());

        Date currentDate = new Date(System.currentTimeMillis());

        for (int i = jsonArray.length() - 1 ; i >= 0 ; i++){
            JSONObject academicYear = jsonArray.getJSONObject(i);
            Date beginDate = new SimpleDateFormat("yyyy-MM-dd").parse(academicYear.getString("start_date"));
            Date endDate = new SimpleDateFormat("yyyy-MM-dd").parse(academicYear.getString("end_date"));
            if (currentDate.compareTo(beginDate) >= 0){
                if (currentDate.compareTo(endDate) <= 0)
                    return academicYear.getString("id");
            }
        }
        return null;
    }

    public String requestToken(String oauth_callback) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
        List<NameValuePair> queryParams = new ArrayList<>();
        queryParams.add(new BasicNameValuePair("oauth_callback", oauth_callback));
        queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
        queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
        queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
        queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
        queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
        String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/oauth/request_token", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), "");
        queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
        String url = "/oauth/request_token?" + URLEncodedUtils.format(queryParams, ENC);

        String tokens = when().get(url).body().asString();

        return propertiesLoader.getUsosApiURL() + "/oauth/authorize?" + tokens;
    }

    public String logOut(String oauth_token, String oauth_token_secret) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
        List<NameValuePair> queryParams = new ArrayList<>();
        queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
        queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
        queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
        queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
        queryParams.add(new BasicNameValuePair("oauth_token", oauth_token));
        queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
        String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/oauth/revoke_token", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), oauth_token_secret);
        queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
        String url = "/oauth/revoke_token?" + URLEncodedUtils.format(queryParams, ENC);

        String loggedOut = when().get(url).body().asString();

        return loggedOut;
    }

    private TokenResponseDTO createUserAccountAndReturnHeaderToken(String oauth_token, String oauth_token_secret) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
        List<NameValuePair> queryParams = new ArrayList<>();
        queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
        queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
        queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
        queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
        queryParams.add(new BasicNameValuePair("oauth_token", oauth_token));
        queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
        String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/users/user", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), oauth_token_secret);

        queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
        String url = "/users/user?" + URLEncodedUtils.format(queryParams, ENC);

        Response response = get(url);
        JSONObject responseJSON = new JSONObject(response.getBody().print());
        String id = null;

        id = responseJSON.getString("id");


        Optional<User> userCheck = userRepository.findByUsername(id);
        String generatedPassword = PasswordGenerator.generatePassword(16, ALPHA_CAPS + ALPHA + NUMERIC);
        if (!userCheck.isPresent()) {
            User user = new User();
            UsosUser usosUser = new UsosUser(id, bCryptPasswordEncoder.encode(generatedPassword));
            user.setUsosUser(usosUser);
            user.setName(responseJSON.getString("first_name"));
            user.setSurname(responseJSON.getString("last_name"));
            user.setUsername(id);
            user = userRepository.save(user);
            String token = getAuthToken(user.getUsername(), generatedPassword);
            return new TokenResponseDTO(token, user.getUsername(), user.getUsosUser().getUsosId());
        }
        else {
            User user = userCheck.get();
            user.getUsosUser().setPassword(bCryptPasswordEncoder.encode(generatedPassword));
            user = userRepository.save(user);
            String token = getAuthToken(user.getUsername(), generatedPassword);
            return new TokenResponseDTO(token, user.getUsername(), user.getUsosUser().getUsosId());
        }
    }




    public String getSignature(String method, String url, String params, String secret_token)
            throws UnsupportedEncodingException, NoSuchAlgorithmException,
            InvalidKeyException {

        StringBuilder base = new StringBuilder();
        base.append(method);
        base.append("&");
        base.append(url);
        base.append("&");
        base.append(params);

        byte[] keyBytes = (propertiesLoader.getSecret() + "&" + secret_token).getBytes(ENC);

        SecretKey key = new SecretKeySpec(keyBytes, HMAC_SHA1);

        Mac mac = Mac.getInstance(HMAC_SHA1);
        mac.init(key);

        // encode it, base64 it, change it to string and return.
        return new String(base64.encode(mac.doFinal(base.toString().getBytes(
                ENC))), ENC).trim();
    }

    private String getAuthToken(String username, String password) throws IOException {
        HttpClient httpClient = HttpClientBuilder.create().build();
        HttpPost request = new HttpPost("http://" + propertiesLoader.getServerAddress() + ":" + propertiesLoader.getServerPort()+ "/login");
        StringEntity params = new StringEntity("{\"username\":\"" + username + "\",\"password\":\"" + password + "\"} ");
        request.addHeader("content-type", "application/json");
        request.setEntity(params);
        HttpResponse httpResponse = httpClient.execute(request);
        String auth = httpResponse.getFirstHeader("authorization").getValue();
        return auth;
    }
}
