Exemplo n.º 1
0
class PairingsBoard(models.TimeStampedModel):
    """
    Keeps track of all pairings done in an activity.
    """

    name = models.CodeschoolNameField()
    members = models.ManyToManyField(
        models.User,
        related_name='pairing_boards',
    )
Exemplo n.º 2
0
class Kanban(models.TimeStampedModel):
    """
    Represents a Kanban board activity.
    """

    name = models.CodeschoolNameField()
    members = models.ManyToManyField(
        models.User,
        related_name='kanban_boards',
    )
Exemplo n.º 3
0
class Feature(models.Model):
    """
    A Feature in a sentiment board.
    """

    board = models.ParentalKey(SentimentBoard, related_name='features')
    name = models.CodeschoolNameField()
    description = models.CodeschoolDescriptionField(blank=True)
    image = models.ImageField(blank=True, null=True)
    icon = models.CharField(max_length=50)

    class Meta:
        unique_together = [('board', 'name')]
Exemplo n.º 4
0
class Sprint(models.TimeStampedModel):
    """
    A sprint meta-data object that can be associated with many
    projects/contexts.
    """

    index = models.PositiveSmallIntegerField()
    start_date = models.DateField(_('Starts'), )
    due_date = models.DateField(_('Ends'), )
    name = models.CodeschoolNameField(blank=True)
    description = models.CodeschoolDescriptionField(blank=True)

    def next_sprint(self, name='', description=''):
        """
        Schedule a new sprint starting at the end of the current sprint and
        keeping the same time-frame.
        """

        raise NotImplementedError
Exemplo n.º 5
0
class Task(models.TimeStampedModel):
    """
    Represents a task in a Kanban activity.
    """

    STATUS_TODO, STATUS_DOING, STATUS_DONE = range(3)
    STATUS_CHOICES = [
        (STATUS_TODO, _('To do')),
        (STATUS_DOING, _('Doing')),
        (STATUS_DONE, _('Done')),
    ]

    name = models.CodeschoolNameField()
    description = models.CodeschoolDescriptionField()
    status = models.SmallIntegerField(
        _('status'),
        choices=STATUS_CHOICES,
    )
    members = models.ManyToManyField(
        models.User,
        related_name='kanban_tasks',
    )
    created_by = models.ForeignKey(
        models.User,
        related_name='created_tasks',
        null=True,
        blank=True,
    )
    assigned_to = models.ManyToManyField(
        models.User,
        related_name='assigned_tasks',
    )
    estimated_duration_hours = models.PositiveSmallIntegerField(
        _('Estimated duration (hours)'),
        default=0,
    )

    objects = TaskQuerySet.as_manager()
Exemplo n.º 6
0
class SentimentBoard(models.TimeStampedModel):
    """
    Represents sentiments of a group of users towards a group of
    generic features.

    This is usually used to communicate the level of competence of each member
    in the team with different technologies.
    """

    name = models.CodeschoolNameField()
    members = models.ManyToManyField(
        models.User,
        related_name='sentiment_boards',
    )

    # Functions that define common features
    feature_python = feature('Python')
    feature_django = feature('Django')
    feature_elm = feature('Elm')
    feature_html5 = feature('HTML5')
    feature_js = feature('JS', 'Javascript (ES5)')
    feature_js6 = feature('ES6', 'Javascript ES6')
    feature_css = feature('CSS')
Exemplo n.º 7
0
class ActivityList(models.TimeStampedModel):
    """
    List of activities.
    """

    name = models.CodeschoolNameField()
    slug = models.CodeschoolSlugField()
    short_description = models.CodeschoolShortDescriptionField()
    long_description = models.CodeschoolDescriptionField()
    icon = models.CharField(
        _('Optional icon'),
        max_length=20,
        default='code',
        validators=[material_icon_validator],
        help_text=_('Name of the material design icon. Check full list at: '
                    'https://material.io/icons'),
    )

    class Meta:
        verbose_name = _('List of activities')
        verbose_name_plural = _('Lists of activities')

    objects = ActivityListManager()

    def score_board_total(self) -> ScoreMap:
        """
        Return a score board mapping with the total score for each user.
        """

        board = self.score_board()
        scores = ScoreMap(self.title)
        for k, L in board.items():
            scores[k] = sum(L)
        return scores

    def grades_as_csv(self) -> str:
        """
        Return a string with CSV data for the all student submissions inside
        the given section.
        """

        return self.grades_as_dataframe().to_csv()

    def grades_as_dataframe(self) -> pd.DataFrame:
        """
        Return a Pandas dataframe with the grades for all students that
        submited responses to questions in the given list.
        """

        from codeschool.lms.activities.models import Progress

        children = self.get_children()
        children_id = children.values_list('id', flat=True)
        cols = ('user__username', 'user__email', 'user__first_name',
                'user__last_name', 'activity_page__title', 'given_grade_pc')
        responses = (Progress.objects.filter(
            activity_page__in=children_id).values_list(*cols))
        responses = list(responses)

        # User data
        users_data = sorted({row[0:4] for row in responses})
        users = pd.DataFrame(
            users_data,
            columns=['username', 'email', 'first_name', 'last_name'],
        )
        users.index = users.pop('username')

        # Question data
        df = pd.DataFrame(responses, columns=cols)
        groups = df.groupby('activity_page__title')
        by_question = {
            name: group[['user__username', 'given_grade_pc']]
            for name, group in groups
        }

        # Agregate question data
        result = users.copy()
        for name, df in by_question.items():
            col = df['given_grade_pc']
            col.index = df['user__username']
            result[name] = col

        return result