Exemplo n.º 1
0
    def objectives_for_selection(self, user, subject_id = None):
        """The set of 'Objectives' that are visible to the 'User' is the set of system objectives and the objectives the
        user has some self assessment for.

        :param user: is the 'User' for whom the objectives are being collected.
        :param subject_id: is the id of the `Subject` that will be used to filter the set of `Objectives` returned.
        """

        q = Objective.query.union(
                    Objective.system_objectives_q(subject_id),
                    Objective.assigned_objectives_q(user.id, user.id)
        )
        q = self._filter_on_subject(q, subject_id)
        return q
Exemplo n.º 2
0
    def create(self, objective_data, by_user):
        """Create a new Objective from the given data

        :param objective_data: is a dictionary of data used to populate the
                               initial Objective.  It must match the schema
                               defined within.
        :param by_user: the `User` who is creating the `Objective`.
        """

        creation_schema = merge(self._base_schema, {
            s.Optional('id'): None,
            'subject_id': s.Or(None, s.Use(int)),
        })

        o = s.Schema(creation_schema).validate(objective_data)
        self._validate_topic(o['topic_id'], o['subject_id'])
        self._validate_name(o['name'])

        prerequisites = self._validate_prerequisites(o['prerequisites'], by_user)

        now = datetime.utcnow()
        o['prerequisites'] = prerequisites
        o['created_by_id'] = by_user.id
        o['last_updated'] = now
        o['time_created'] = now
        objective = Objective(**o)
        db.session.add(objective)
        db.session.commit()
        return objective
Exemplo n.º 3
0
    def objectives_for_assessment(self, user, student_id, subject_id = None):
        """The set of 'Objectives' that are visible to the 'User' for the purpose of assessing a given student.

        :param user: is the 'User' for whom the objectives are being collected.
        :param student_id: is the id of the 'User' who is being assessed.
        :param subject_id: is the id of the `Subject` that will be used to filter the set of `Objectives` returned.
        """
        q = Objective.assigned_objectives_q(user.id, student_id)
        q = self._filter_on_subject(q, subject_id)
        return q
Exemplo n.º 4
0
parent = User(email="*****@*****.**",
              password="******",
              name="Parent",
              time_registered=datetime.utcnow(),
              last_seen=datetime.utcnow(),
              role=ROLE_USER)
parent.students.append(student)

db.session.add(parent)

db.session.commit()

objective = Objective(
    name="Rationalise the denominator of fractions with surds",
    subject=maths,
    topic=number,
    created_by_id=User.main_admin_user().id
    #prerequisites=[Objective.query.get(2)]
)
db.session.add(objective)
db.session.commit()

objective = Objective(name="Estimate powers and roots of any given positive",
                      subject=maths,
                      topic=number,
                      created_by_id=User.main_admin_user().id
                      #prerequisites=[Objective.query.get(2)]
                      )
db.session.add(objective)
db.session.commit()