Skip to content

Commit

Permalink
Merge pull request #37 from Elthan/feature-33
Browse files Browse the repository at this point in the history
Feature #33
  • Loading branch information
torgeirl committed Jul 23, 2018
2 parents bc2bdad + 8847097 commit a3ef131
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 27 deletions.
1 change: 1 addition & 0 deletions trix/trix_admin/views/assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def get_buttons(self):
button.flat_attrs = flatatt({'formnovalidate': True}) + button.flat_attrs
return buttons


class AssignmentCreateView(AssignmentCreateUpdateMixin, create.CreateView):
"""
View used to create new assignments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ angular.module('trixStudent.assignments.controllers', [])
currentUrl = new Url()
tags = currentUrl.query.tags
if tags? and tags != ''
tags = '#{tags},#{$scope.tagToAdd}'
tags = tags + ',' + $scope.tagToAdd
else
tags = $scope.tagToAdd
currentUrl.query.tags = tags
Expand Down
9 changes: 8 additions & 1 deletion trix/trix_student/static/trix_student/src/less/trix.less
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ body {
}

.controls .textinput,
.controls .textarea {
.controls .textarea,
.controls .select {
max-width: 60%;
border-right: 1px dashed #ccc;
border: none;
Expand All @@ -170,12 +171,18 @@ body {
height: auto;
font-size: 24px;
text-align: left;
float: left;
}

.controls .textarea {
font-size: @font-size-base;
}

.controls .select {
padding: 10px 0px 10px 50px;
font-size: @font-size-base;
}

.controls .textinput:focus,
.controls .textarea:focus {
background-color: #e1edf4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="container">
<div class="row">
<div id="assignments-taggingbox" class="col-sm-3 col-sm-push-9 col-md-3 col-md-push-9">
{% if request.user.is_authenticated %}
{% if request.user.is_authenticated and assignmentlist_with_howsolved %}
<div ng-controller="AssignmentListProgressController"
class="assignments-progressbox"
ng-cloak>
Expand Down Expand Up @@ -80,6 +80,8 @@ <h3>{% trans "Print" %}:</h3>
{% if assignment.hidden is False or assignment.hidden is None or user_is_admin %}
{% include "trix_student/include/assignment.django.html" %}
{% endif %}
{% empty %}
<h2>No assignments found</h2>
{% endfor %}
{% include "trix_student/include/pager.django.html" %}
</div>
Expand Down
22 changes: 5 additions & 17 deletions trix/trix_student/templates/trix_student/assignments.django.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
{% extends "trix_student/base.django.html" %}
{% extends "trix_student/assignment_list_base.django.html" %}
{% load i18n %}
{% block title %}{% trans "Assignments" %}{% endblock title %}

{% block body %}
<div class="container">
<div class="page-header">
{% block pageheader %}
<div id="assignments-heading" class="page-header">
<div class="container">
<h1>{% trans "Assignments" %}</h1>
</div>
</div>

<div class="container">
<div class="assignment-list">
{% for assignment in object_list %}
<h1>{{ assignment.title }}</h1>
<p class="assignment-text"> {{ assignment.text }}</p>
<p class="assignment-solution"> {{ assignment.solution }}</p>
{% empty %}
<h2>No assigments for the chosen tags</h2>
{% endfor %}
</div>
</div>
{% endblock body %}
{% endblock pageheader %}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
assignment_id='{{ assignment.id }}';
howsolved='{{ howsolved }}';
">
{% if user_is_admin %}
{% if user_is_admin and course.id %}
<a href="{% url 'trix_courseadmin-assignments-edit' course.id assignment.id %}?{{ urlencoded_success_url }}"
class="btn btn-trix-admin pull-right trix-no-print">
<span class="fa fa-edit"></span>
{% trans "Edit" %}
</a>
{% endif %}
<h2 id="assignment-{{ assignment.id }}">
{{ assignment }}
<a href="{% url 'trix_assignments_view' assignment.id %}" style="color:black;">
{{ assignment }}
</a>
</h2>

{% if not disable_tags %}
Expand Down
5 changes: 4 additions & 1 deletion trix/trix_student/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from trix.trix_student.views import login
from trix.trix_student.views import dashboard
# from trix.trix_student.views import assignments
from trix.trix_student.views import assignments
from trix.trix_student.views import course
from trix.trix_student.views import howsolved
from trix.trix_student.views import permalink
Expand All @@ -18,6 +18,9 @@
url('^assignment/howsolved/(?P<assignment_id>\d+)$',
login_required(howsolved.HowsolvedView.as_view()),
name='trix_student_howsolved'),
url('^assignments/(?P<assignment_ids>[\d+&*]+)$',
assignments.AssignmentListView.as_view(),
name='trix_assignments_view'),
url('^course/(?P<course_id>\d+)$',
course.CourseDetailView.as_view(),
name='trix_student_course'),
Expand Down
24 changes: 23 additions & 1 deletion trix/trix_student/views/assignments.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
from django.views.generic import ListView

from trix.trix_core import models
from trix.trix_student.views.common import AssignmentListViewBase


class AssignmentListView(ListView):
class AssignmentListView(AssignmentListViewBase):
model = models.Assignment
template_name = "trix_student/assignments.django.html"
paginate_by = 20

def _get_user_is_admin(self):
if self.request.user.is_authenticated():
if self.request.user.is_admin:
return True
else:
return False
else:
return False

def get_all_available_assignments(self):
assignment_ids = filter(None, self.kwargs['assignment_ids'].split('&'))
return models.Assignment.objects.filter(id__in=assignment_ids)

def get_already_selected_tags(self):
return []

def get_nonremoveable_tags(self):
return []
6 changes: 3 additions & 3 deletions trix/trix_student/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ def get_queryset(self):
assignments = assignments.order_by('title')
return assignments

def _get_user_is_admin(self):
raise NotImplementedError()

def _get_progress(self):
"""
Gets the progress a user has made. Hidden tasks are not counted unless user is an admin.
Expand Down Expand Up @@ -116,6 +113,9 @@ def get_context_data(self, **kwargs):
'currently selected tags.')
return context

def _get_user_is_admin(self):
raise NotImplementedError()

def get_all_available_assignments(self):
raise NotImplementedError()

Expand Down

0 comments on commit a3ef131

Please sign in to comment.