示例#1
0
    def _initialize(self):
        """
        Handle instantiating and loading repositories
        :return:
        """
        self.workRepo = WorkRepositoryLoaderFactory.make(
            course=environment.CONFIG.course,
            activity=self.activity,
            rest_timeout=self.wait)

        self.assignment = environment.CONFIG.course.get_assignment(
            self.activity.id)

        self.subRepo = AssignmentSubmissionRepository(self.assignment)
        # shove the activity onto a sub repo so it will resemble
        # a quizrepo for the grader
        self.subRepo.activity = self.activity

        # Filter previously graded
        self.subRepo.data = [
            s for s in self.subRepo.data if s.workflow_state != 'complete'
        ]
        self.workRepo.data = self.workRepo.data[
            self.workRepo.data.workflow_state != 'complete'].copy(deep=True)

        self.workRepo.data.reset_index(inplace=True)

        # We will need the association repo if the activity can be
        # blocked or graded by another student
        self.association_repo = None
        if isinstance(self.activity, BlockableActivity):
            dao = SqliteDAO()
            self.association_repo = AssociationRepository(dao, self.activity)
示例#2
0
    def setUp(self):
        self.config_for_test()
        self.dao = SqliteDAO()

        self.course = MagicMock()
        # review = Review(**activity_data_factory())
        self.unit = unit_factory()
    def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        self.activity = self.unit.discussion_forum
        self.course = MagicMock()

        # student recieiving the message
        self.author = student_factory()
        self.reviewer = student_factory()

        # This would be the content unit
        self.work = fake.text()
        # Set to none so that loader thinks not a quiz
        self.activity_id = self.unit.discussion_forum.id
        self.dao = SqliteDAO()
        self.session = self.dao.session
        self.create_new_and_preexisting_students()
        # Prepare fake work repo to give values to calling  objects

        # self.studentRepo = StudentRepository()
        # self.studentRepo.get_student = MagicMock( return_value=self.reviewer )
        self.contentRepo = ContentRepositoryMock()
        self.contentRepo.get_formatted_work_by = MagicMock(
            return_value=self.work)
        self.review_assign = MagicMock(assessor_id=self.reviewer.id,
                                       assessee_id=self.author.id)
        self.statusRepo = MagicMock()
        # Prepare fake work repo to give values to calling  objects
        self.workRepo = ContentRepositoryMock()
        self.workRepo.create_test_content(self.student_ids)
        self.workRepo.add_students_to_data(self.student_ids,
                                           make_dataframe=True)
示例#4
0
class DaoMixin:
    """
    Provides database access initialization.
    Requires that self.unit be set
    """
    def _initialize_db(self):
        try:
            unit_number = self.unit.unit_number
        except AttributeError:
            unit_number = self.activity.unit_number

        try:
            t = 'TEST-' if env.CONFIG.is_test else ""
            self.db_filepath = "{}/{}{}-Unit-{}-review-assigns.db".format(
                env.LOG_FOLDER, t, env.CONFIG.semester_name, unit_number)
        except AttributeError as e:
            # This is likely to happen during testing
            print(e)

        if env.CONFIG.is_test:
            try:
                if CanvasHacks.testglobals.TEST_WITH_FILE_DB:
                    # testing: file db
                    self._initialize_file_db()
                    print("Connected to TEST db file. {}".format(
                        self.db_filepath))
                else:
                    # testing: in memory db
                    self._initialize_memory_db()
            except (NameError, AttributeError) as e:
                print(e)
                # The variable might not be defined under in any
                # number of circumstances. So default to the in-memory db
                self._initialize_memory_db()

        else:
            # real: file db
            self._initialize_file_db()
            print("Connected to REAL db. {}".format(self.db_filepath))

    def _initialize_file_db(self):
        self.dao = SqliteDAO(self.db_filepath)
        self.dao.initialize_db_file()

    def _initialize_memory_db(self):
        self.dao = SqliteDAO()
        print("Connected to in-memory testing db")
    def setUp(self):
        dao = SqliteDAO()
        self.session = dao.session
        # self.student_ids = [i for i in range(0,5)]
        self.create_new_and_preexisting_students()

        self.unit = unit_factory()
        self.activity = self.unit.initial_work
        self.activity_id = self.activity.id
        self.obj = AssociationRepository(dao, self.activity)
    def setUp(self):
        self.config_for_test()
        self.dao = SqliteDAO()
        print("Connected to testing db")
        self.session = self.dao.session

        self.student = student_factory()
        self.unit = unit_factory()
        self.activity = fake.random.choice(self.unit.components)

        self.obj = StatusRepository(self.dao, self.activity)
示例#7
0
    def setUp(self):
        self.config_for_test()
        self.dao = SqliteDAO()
        print("Connected to testing db")
        self.session = self.dao.session

        self.activity_data = activity_data_factory()
        self.target_student = student_factory()
        self.reviewing_student = student_factory()
        self.reviewed_student = student_factory()
        self.activity_id = fake.random.randint(1111, 99999)
    def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        self.activity = self.unit.discussion_forum
        self.activity_id = self.activity.id

        self.dao = SqliteDAO()
        self.session = self.dao.session
        self.create_new_and_preexisting_students()
        # self.create_preexisting_review_pairings(self.activity_id, self.students)

        # ids of authors previously notified
        self.previously_submitted = []
        # ids of reviewers corresponding to previously notified authors

        self.obj = SubmissionRecordRepository(self.dao, self.activity)
示例#9
0
    def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        self.course = MagicMock()

        # Set to none so that loader thinks not a quiz
        self.unit.initial_work.quiz_id = None
        self.activity_id = self.unit.initial_work.id
        self.dao = SqliteDAO()
        self.session = self.dao.session
        self.create_new_and_preexisting_students()
        # Prepare fake work repo to give values to calling  objects
        self.workRepo = ContentRepositoryMock()
        self.workRepo.create_test_content(self.student_ids)
        self.workRepo.add_students_to_data(self.student_ids,
                                           make_dataframe=True)
示例#10
0
    def _initialize(self):
        """
        Handle instantiating and loading repositories
        :return:
        """
        self.workRepo = WorkRepositoryLoaderFactory.make(
            course=environment.CONFIG.course,
            activity=self.activity,
            rest_timeout=self.wait)

        try:
            self.quiz = environment.CONFIG.course.get_quiz(
                self.activity.quiz_id)
        except AttributeError:
            # todo dev hope this doesn't cause problems!
            self.quiz = environment.CONFIG.course.get_quiz(self.activity.id)

        self.subRepo = QuizSubmissionRepository(self.quiz)

        # If this is a quiz type assignment, we need to get the quiz submission objects
        # not the regular submission object so we can use them for uploading
        self.qsubs = [s for s in self.quiz.get_submissions()]

        # Filter previously graded
        self.subRepo.data = [
            s for s in self.subRepo.data if s.workflow_state != 'complete'
        ]
        self.workRepo.data = self.workRepo.data[
            self.workRepo.data.workflow_state != 'complete'].copy(deep=True)

        self.workRepo.data.reset_index(inplace=True)

        # We will need the association repo if the activity can be
        # blocked or graded by another student
        self.association_repo = None
        if isinstance(self.activity, BlockableActivity):
            dao = SqliteDAO()
            self.association_repo = AssociationRepository(dao, self.activity)
    def setUp( self ):
        self.config_for_test()
        self.dao = SqliteDAO()

        self.course = MagicMock()
        self.unit = unit_factory()
示例#12
0
 def _initialize_memory_db( self ):
     self.dao = SqliteDAO()
     print( "Connected to in-memory testing db" )
示例#13
0
 def _initialize_file_db( self ):
     self.dao = SqliteDAO( self.db_filepath )
     self.dao.initialize_db_file()
示例#14
0
class IStep:
    """Parent of all steps in a Skaa"""

    def __init__( self, course=None, unit=None, is_test=None, send=True ):
        """
        :param course:
        :param unit:
        :param is_test:
        :param send: Whether to actually send the messages
        """
        self.course = env.CONFIG.course if course is None else course
        self.unit = env.CONFIG.unit if unit is None else unit
        self.is_test = env.CONFIG.is_test if is_test is None else is_test
        self.send = send



    def _initialize( self ):
        """Creates and populates all relevant repositories and db access points"""
        self.studentRepo = StudentRepository( self.course )
        self.studentRepo.download()
        self._initialize_db()
        self.associationRepo = AssociationRepository( self.dao, self.activity_for_review_pairings)

        self.display_manager = DisplayManager(self.activity)

        # Moved to child classes while working on CAN-53
        # if isinstance(self.activity, MetaReview) and isinstance(self.activity_notifying_about, MetaReview):
        #     # If both of these are the metareview, then we are on the final
        #     # step (sending the metareview results to the reviewer). Thus
        #     # we need a special status repository since the notified field
        #     # for the metareview will have already been populated in the previous step
        #     self.statusRepos = FeedbackStatusRepository( self.dao, self.activity_notifying_about )
        # elif isinstance(self.activity, DiscussionReview) and isinstance(self.activity_notifying_about, DiscussionReview):
        #     # If both of these are the discussion review, then we are on the final
        #     # step (sending the review results to the poster). Thus
        #     # we need a special status repository since the notified field
        #     # for the review will have already been populated in the previous step
        #     self.statusRepos = FeedbackStatusRepository( self.dao, self.activity_notifying_about )
        # else:
        #     self.statusRepos = StatusRepository( self.dao, self.activity_notifying_about )

    def _initialize_db( self ):
        try:
            t = 'TEST-' if env.CONFIG.is_test else ""
            self.db_filepath = "{}/{}{}-Unit-{}-review-assigns.db".format( env.LOG_FOLDER, t, env.CONFIG.semester_name, self.unit.unit_number )
        except AttributeError as e:
            # This is likely to happen during testing
            print(e)

        if env.CONFIG.is_test:
            try:
                if CanvasHacks.testglobals.TEST_WITH_FILE_DB:
                    # testing: file db
                    self._initialize_file_db()
                    print( "Connected to TEST db file. {}".format( self.db_filepath ) )
                else:
                    # testing: in memory db
                    self._initialize_memory_db()
            except (NameError, AttributeError) as e:
                print(e)
                # The variable might not be defined under in any
                # number of circumstances. So default to the in-memory db
                self._initialize_memory_db()

        else:
            # real: file db
            self._initialize_file_db()
            print( "Connected to REAL db. {}".format( self.db_filepath ) )

    def _initialize_file_db( self ):
        self.dao = SqliteDAO( self.db_filepath )
        self.dao.initialize_db_file()

    def _initialize_memory_db( self ):
        self.dao = SqliteDAO()
        print( "Connected to in-memory testing db" )

    def run( self ):
        raise NotImplementedError