Esempio n. 1
0
    def answer(self, layer):
        """
        Creates an answer for questions about course ects.
        :param layer: Current frame layer
        :return: an answer
        """
        courseId = layer[wt.courseID]
        if len(courseId) == 1:
            json = oisCourses.coursesId(courseId[0])
            title = json["title"]["et"]
            if " " in title:
                return "Kursuse " + title + " maht on " + str(
                    json["credits"]) + " EAP."
            return synthesizeWord(title, "g").capitalize() + " maht on " + str(
                json["credits"]) + " EAP."

        else:
            response = "Selle nimega on " + str(
                len(courseId)) + " erinevat kursust."
            json = oisCourses.coursesId(courseId[0])
            response += " " + courseId[0] + " mille maht on " + str(
                json["credits"]) + " EAP"
            for i in courseId[1:-1]:
                json = oisCourses.coursesId(i)
                response += ", " + i + " mille maht on " + str(
                    json["credits"]) + " EAP"
            json = oisCourses.coursesId(courseId[-1])
            response += " ja " + courseId[-1] + " mille maht on " + str(
                json["credits"]) + " EAP."
            return response
Esempio n. 2
0
 def answer(self, layer):
     """
     Creates answer for lecturers question
     :param layer: Current frame layer
     :return: courses lecturers
     """
     results = []
     courseIds = layer[wt.courseID]
     for id in courseIds:
         json = oisCourses.coursesId(id)
         lecturers = json['participants']['lecturers']
         result = ""
         result += "Aine " + json['title']['et'] + "(" + id + ") "
         responsible = []
         otherLecturers = []
         for lecturer in lecturers:
             if lecturer['is_responsible']:
                 responsible.append(lecturer['person_name'])
             else:
                 otherLecturers.append(lecturer['person_name'])
         if len(responsible) == 1:
             result += "vastutav õppejõud on " + responsible[0] + "."
         else:
             result += "vastutavad õppejõud on " + ", ".join(
                 responsible) + "."
         if len(otherLecturers) != 0:
             result += "\nTeised õppejõud on " + ", ".join(otherLecturers)
         results.append(result)
     return "\n".join(results)
Esempio n. 3
0
 def answer(self, layer):
     """
     Creates an answer for what course has this structure code
     :param courseCode:
     :return:
     """
     json = oisCourses.coursesId(layer[wt.courseID])
     return "Antud koodi kasutab kursus: " + json["name"]["et"] + "."
Esempio n. 4
0
 def answer(self, layer):
     """
     Creates answer for website question
     :param layer: Current frame layer
     :return: courses website
     """
     results = []
     courseIds = layer[wt.courseID]
     for id in courseIds:
         json = oisCourses.coursesId(id)
         results.append("Aine " + json['title']['et'] + "(" + id + ")" +
                        " veebileht on " + json['resources']['website_url'])
     return "\n".join(results)
Esempio n. 5
0
 def answer(self, layer):
     """
     Creates answer for objectives question
     :param layer: Current frame layer
     :return: courses objective
     """
     results = []
     courseIds = layer[wt.courseID]
     for id in courseIds:
         json = oisCourses.coursesId(id)
         results.append("Aine " + json['title']['et'] + "(" + id + ")" +
                        " eesmärk:\n" +
                        json['overview']['objectives'][0]['et'])
     return "\n".join(results)
Esempio n. 6
0
 def answer(self, layer):
     """
     Creates answer for description question
     :param layer: Current frame layer
     :return: courses description
     """
     results = []
     courseIds = layer[wt.courseID]
     for id in courseIds:
         json = oisCourses.coursesId(id)
         results.append("Aine " + json['title']['et'] + "(" + id + ")" +
                        " kirjeldus:\n" +
                        json['overview']['description']['et'])
     return "\n".join(results)
Esempio n. 7
0
 def answer(self, layer):
     """
     Creates answer for language question
     :param layer: Current frame layer
     :return: courses language
     """
     courseIds = layer[wt.courseID]
     results = []
     for id in courseIds:
         json = oisCourses.coursesId(id)
         lang = json['target']['language']['et'].split(" ")
         lang[-1] = synthesize(lang[-1], "sg in", "S")[0]
         results.append("Aine " + json['title']['et'] + "(" + id + ")" +
                        " on " + " ".join(lang))
     return "\n".join(results) + "."
Esempio n. 8
0
 def answer(self, layer):
     """
     Creates answer for grade question
     :param layer: Current frame layer
     :return: courses grading
     """
     results = []
     courseIds = layer[wt.courseID]
     for id in courseIds:
         json = oisCourses.coursesId(id)
         result = "Aine " + json['title']['et'] + "(" + id + ")" + " hindamine on " + \
                  json['grading']['assessment_scale']['et']
         if "et" in json['grading']['grade_evaluation']:
             result += ".\nLõpphinne:\n" + json['grading'][
                 'grade_evaluation']['et']
         if "et" in json['grading']['debt_elimination']:
             result += "\nVõlgnevuste likvideerimine:\n" + json['grading'][
                 'debt_elimination']['et']
         results.append(result)
     return "\n".join(results)
Esempio n. 9
0
 def answer(self, layer):
     """
     Creates an answer for questions about course code. like "mis on masinõppe ainekood"
     :param layer: Current frame layer
     :return: an answer with course code(s)
     """
     courseId = layer[wt.courseID]
     if len(courseId) == 1:
         id = courseId.pop()
         json = oisCourses.coursesId(id)
         title = json["title"]["et"]
         if " " in title:
             return "Kursuse " + title + " ainekood on " + id
         return synthesizeWord(title,
                               "g").capitalize() + " ainekood on " + id
     else:
         response = "Selle nimega on " + str(
             len(courseId)) + " erinevat kursust. Nende ainekoodid on "
         for i in courseId[:-2]:
             response += i + ", "
         response += courseId[-2] + " ja "
         return response + courseId[-1] + "."
Esempio n. 10
0
    def answer(self, layer):
        """
        Creates an answer for question about prerequired courses
        :param layer: Current frame layer
        :return: An answer, that contains prerequired courses
        """
        courseId = layer[wt.courseID]
        if len(courseId) == 1:
            result = "Selle kursuse"
        else:
            result = "Selle nimega on " + str(
                len(courseId)) + " erinevat kursust."

        for id in courseId:

            json = oisCourses.coursesId(id)
            if "prerequisites" in json["additional_info"]:
                if len(courseId) > 1:
                    result += " Kursuse " + id

                preReqs = json["additional_info"]["prerequisites"]
                if len(preReqs) == 1:
                    result += " eeldusaine on"
                else:
                    result += " eeldusained on"

                for req in preReqs:
                    result += " " + req["code"] + " \"" + req["title"][
                        "et"] + "\""
                    if "alternatives" in req:
                        alternatives = req["alternatives"]
                        for alt in alternatives:
                            result += " või " + alt["code"] + " \"" + alt[
                                "title"]["et"] + "\""
            elif len(courseId) > 1:
                result += " Kursusel " + id + " eeldusained puuduvad"
            else:
                return "Sellel kursusel pole eeldusaineid."
        return result + "."