def create_new_quizz(self, quiz_name):
     click(self.driver, By.PARTIAL_LINK_TEXT, "Quizzes")
     wait_until(self.wait, self.driver, By.CSS_SELECTOR,
                "a[href='#/quiz-builder']")
     click(self.driver, By.PARTIAL_LINK_TEXT, "Create New Quiz")
     type(self.driver, By.TAG_NAME, "input", quiz_name)
     self.quiz_name = quiz_name
Example #2
0
    def create_new_assignment(self, quiz_name):
        click(self.driver, By.XPATH,
              "//span[contains(text(), 'Create New Assignment')]")
        wait_until(self.wait, self.driver, By.XPATH,
                   "//span[contains(text(), 'Give Assignment')]")
        click(self.driver, By.XPATH,
              "//span[contains(text(), 'Select Quiz To Assign')]")
        wait_until(
            self.wait, self.driver, By.XPATH,
            "//mat-option[@class= 'mat-option ng-star-inserted mat-active']")
        # sleep(2)
        quiz_locator = "//mat-option/span[contains(text(),'{}')]".format(
            quiz_name)
        wait_until(self.wait, self.driver, By.XPATH, quiz_locator)
        element = self.driver.find_element_by_xpath(quiz_locator)
        self.driver.execute_script("arguments[0].scrollIntoView();", element)
        element.click()

        wait_until(self.wait, self.driver, By.XPATH, quiz_locator)
        student_locator = self.driver.find_element(
            By.XPATH,
            "//div[@class = 'mat-list-text']/*[contains(text(),'{}')]/..".
            format(student_id))
        self.driver.execute_script("arguments[0].scrollIntoView();",
                                   student_locator)
        student_locator.click()
        wait_until(self.wait, self.driver, By.XPATH,
                   "//span[contains(text(), 'Give Assignment')]")
        click(self.driver, By.XPATH,
              "//span[contains(text(), 'Give Assignment')]")
        self.wait.until(
            EC.presence_of_element_located(
                (By.XPATH,
                 "// mat-panel-title[contains(text(),'{}')]".format(quiz_name)
                 )))
 def create_multiple_choice_question(self, question, answer, *args):
     self.add_new_question()
     multiple_choice_type_locator = "//*[contains(text(), 'new empty question')]/../../..//div[contains(text(), 'Multiple-Choice')]/.."
     self.wait.until(
         EC.element_to_be_clickable(
             (By.XPATH, multiple_choice_type_locator))).click()
     question_field_locator = "//*[contains(text(), 'new empty question')]/../../..//textarea[@placeholder='Question *']"
     wait_until(self.wait, self.driver, By.XPATH, question_field_locator)
     type(self.driver, By.XPATH, question_field_locator, question)
     for arg in args:
         wait_until(
             self.wait, self.driver, By.XPATH,
             "//*[contains(text(), '{}')]/../../..//*[@placeholder='Option {}*']"
             .format(question,
                     args.index(arg) + 1))
         type(
             self.driver, By.XPATH,
             "//*[contains(text(), '{}')]/../../..//*[@placeholder='Option {}*']"
             .format(question,
                     args.index(arg) + 1), arg)
         if arg == answer:
             check_box = "//*[contains(text(), '{}')]/../../..//*[@placeholder='Option {}*']/../../../../../mat-checkbox".format(
                 question,
                 args.index(arg) + 1)
             click(self.driver, By.XPATH, check_box)
         else:
             continue
    def find_quizz(self, quiz_name):

        quiz_locator = "//ac-quizzes-list//div[@class = 'quizzes']//*[contains(text(),'{}')]".format(
            quiz_name)
        wait_until(self.wait, self.driver, By.XPATH, quiz_locator)
        element = self.driver.find_element_by_xpath(quiz_locator)
        self.driver.execute_script("arguments[0].scrollIntoView();", element)
        element.click()
 def go_to_my_assignments(self):
     # self.driver.find_element(locators["submit_button"][0], locators["submit_button"][1]).click()
     # self.wait.until(self.EC.element_to_be_clickable((locators["assignment"][0],locators["assignment"][1]))).click()
     wait_until(self.wait, self.driver, locators["assignment"][0],
                locators["assignment"][1])
     self.driver.find_element(
         By.XPATH, "//td[contains(text(), '{}')]/../..//button".format(
             quiz_name)).click()
     wait_until(self.wait, self.driver, By.XPATH,
                '//textarea[@formcontrolname="textAnswer"]')
 def save_quiz(self, quiz_name):
     by = By.XPATH
     save_btn = "//button/*[contains(text(),'Save')]"
     wait_until(self.wait, self.driver, by, save_btn)
     click(self.driver, by, save_btn)
     quiz_locator = "//ac-quizzes-list//div[@class = 'quizzes']//*[contains(text(),'{}')]".format(
         quiz_name)
     wait_until(self.wait, self.driver, By.XPATH, quiz_locator)
     element = self.driver.find_element_by_xpath(quiz_locator)
     self.driver.execute_script("arguments[0].scrollIntoView();", element)
 def create_textual_question(self, question):
     self.add_new_question()
     wait_until(self.wait, self.driver, By.CSS_SELECTOR,
                "div.left.wide mat-slider")
     text_type_locator = "//*[contains(text(), 'new empty question')]/../../..//div[contains(text(), 'Textual')]/.."
     self.wait.until(
         EC.element_to_be_clickable((By.XPATH, text_type_locator))).click()
     question_field_locator = "//*[contains(text(), 'new empty question')]/../../..//textarea[@placeholder='Question *']"
     wait_until(self.wait, self.driver, By.XPATH, question_field_locator)
     type(self.driver, By.XPATH, question_field_locator, question)
 def answer_quiz_and_submit(self, answer):
     self.driver.find_element(
         By.XPATH,
         '//textarea[@formcontrolname="textAnswer"]').send_keys(answer)
     self.wait.until(
         self.EC.element_to_be_clickable(
             (locators["radio_button"][0],
              locators["radio_button"][1]))).click()
     self.wait.until(
         self.EC.presence_of_element_located(
             (locators["check_box"][0], locators["check_box"][1]))).click()
     self.driver.find_element(
         By.XPATH,
         "//button/*[contains(text(), 'Submit My Answer')]").click()
     wait_until(self.wait, self.driver, By.XPATH,
                "//button[@aria-label = 'Close dialog']")
     self.driver.find_element(
         By.XPATH, "//button[@aria-label = 'Close dialog']").click()
     wait_until(self.wait, self.driver, By.XPATH,
                "//h4[contains(text(), 'My Assignments')]")
 def create_single_choice_question(self, question, answer, *args):
     self.add_new_question()
     wait_until(self.wait, self.driver, By.CSS_SELECTOR,
                "div.left.wide mat-slider")
     single_choice_type_locator = "//*[contains(text(), 'new empty question')]/../../..//div[contains(text(), 'Single-Choice')]/.."
     self.wait.until(
         EC.element_to_be_clickable(
             (By.XPATH, single_choice_type_locator))).click()
     question_field_locator = "//*[contains(text(), 'new empty question')]/../../..//textarea[@placeholder='Question *']"
     wait_until(self.wait, self.driver, By.XPATH, question_field_locator)
     type(self.driver, By.XPATH, question_field_locator, question)
     for arg in args:
         wait_until(
             self.wait, self.driver, By.XPATH,
             "//*[contains(text(), '{}')]/../../..//*[@placeholder='Option {}*']"
             .format(question,
                     args.index(arg) + 1))
         type(
             self.driver, By.XPATH,
             "//*[contains(text(), '{}')]/../../..//*[@placeholder='Option {}*']"
             .format(question,
                     args.index(arg) + 1), arg)
         if arg == answer:
             radio_button = "//*[contains(text(), '{}')]/../../..//*[@placeholder='Option {}*']/../../../../..//mat-radio-button".format(
                 question,
                 args.index(arg) + 1)
             click(self.driver, By.XPATH, radio_button)
         else:
             continue
 def add_new_question(self):
     by = By.CSS_SELECTOR
     locator = "div.controls.ng-star-inserted>button"
     wait_until(self.wait, self.driver, by, locator)
     click(self.driver, by, locator)
Example #11
0
 def grade_quiz(self, student_id, quiz_name):
     self.wait.until(self.EC.element_to_be_clickable((By.XPATH,
                                                      "//table//tr/td[contains(text(), '{}')]/../td[contains(text(),"
                                                      " '{}')]/..//button".format(student_id,quiz_name)))).click()
     wait_until(self.wait,self.driver,By.XPATH, "//div[@class = 'result']/div[contains(text(), 'ASSESSMENT')]")