diff --git a/ComSemApp/administrator/forms.py b/ComSemApp/administrator/forms.py index 720ce6c2..2212d0be 100644 --- a/ComSemApp/administrator/forms.py +++ b/ComSemApp/administrator/forms.py @@ -6,7 +6,7 @@ from django_select2.forms import Select2MultipleWidget from django.contrib.auth.models import User -from ComSemApp.models import Course, CourseType, Session, SessionType, Teacher, Student, Institution +from ComSemApp.models import * @@ -86,3 +86,16 @@ class StudentForm(ModelForm): class Meta: model = Student fields = ['country', 'language'] + +class ReplyForm(ModelForm): + message = forms.CharField( widget=forms.Textarea(attrs={'style': "width:100%", 'placeholder': 'Enter reply here.'})) + class Meta: + model = Reply + fields = ["message"] + +class TopicForm(ModelForm): + message = forms.CharField( widget=forms.Textarea(attrs={'style': "width:100%"})) + title = forms.CharField(widget=forms.TextInput(attrs={'style': "width:100%"})) + class Meta: + model = Reply + fields = ["title", "message"] \ No newline at end of file diff --git a/ComSemApp/administrator/urls.py b/ComSemApp/administrator/urls.py index 7e1730d4..38b357cd 100644 --- a/ComSemApp/administrator/urls.py +++ b/ComSemApp/administrator/urls.py @@ -2,6 +2,8 @@ from ComSemApp.administrator import views from ComSemApp.corpus import views as corpus_views +from ComSemApp.discussionBoard import view as discussion_views + app_name = 'admin' urlpatterns = [ url(r'^$', views.TeacherListView.as_view(), name='home'), @@ -37,5 +39,8 @@ url(r'^session_type/(?P[0-9]+)/delete/$', views.SessionTypeDeleteView.as_view(), name='delete_session_type'), url(r'^corpus/search$', corpus_views.corpus_search, name='corpus_search'), + url(r'^discussion_board$', discussion_views.TopicListView.as_view(), name='admin_discussion_board'), + url(r'^topic/(?P[0-9]+)/$', discussion_views.ReplyView.as_view(), name='admin_topic'), + url(r'^newtopic/$', discussion_views.CreateThreadView.as_view(),name='admin_create_topic') ] diff --git a/ComSemApp/discussionBoard/urls.py b/ComSemApp/discussionBoard/urls.py index 8163fc8c..0d267c8e 100644 --- a/ComSemApp/discussionBoard/urls.py +++ b/ComSemApp/discussionBoard/urls.py @@ -5,5 +5,5 @@ urlpatterns = [ url(r'^$', view.TopicListView.as_view(), name='topics'), url(r'^topic/(?P[0-9]+)/$', view.ReplyView.as_view(), name='topic'), - url(r'^$', view.CreateThreadView.as_view(),name='create_topic') + url(r'^newtopic/$', view.CreateThreadView.as_view(),name='create_topic') ] \ No newline at end of file diff --git a/ComSemApp/discussionBoard/view.py b/ComSemApp/discussionBoard/view.py index a40fae8e..3652101f 100644 --- a/ComSemApp/discussionBoard/view.py +++ b/ComSemApp/discussionBoard/view.py @@ -7,16 +7,20 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import user_passes_test from django.db.models import Q -from django.views.generic import ListView, DetailView, CreateView, UpdateView +from django.views.generic import ListView, DetailView, CreateView, UpdateView, FormView from django.http import JsonResponse, HttpResponseRedirect from django.urls import reverse from django.contrib import messages +from django.urls import reverse_lazy +from django import forms +from django.urls import resolve from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from ComSemApp.teacher import constants as teacher_constants from ComSemApp.models import * from ComSemApp.libs.mixins import RoleViewMixin, CourseViewMixin, WorksheetViewMixin, SubmissionViewMixin +from ComSemApp.administrator.forms import ReplyForm, TopicForm #This class deals with listing out all the topics within database @@ -28,9 +32,18 @@ class TopicListView(LoginRequiredMixin,ListView): context_object_name = 'topics' def get_queryset(self): - return Topic.objects.filter() + return Topic.objects.filter().order_by("-id") + +class ReplyMixin(LoginRequiredMixin, ListView, object): + context_object_name = 'replies' + template_name = 'ComSemApp/discussionBoard/add_reply.html' + fields = ["message", "personPosted", "topic", "hasMark"] + success_url = reverse_lazy("discussionBoard:topic") + + def get_form_kwargs(self): + kwargs = super(ReplyMixin, self).get_form_kwargs() + return kwargs -class ReplyMixin(LoginRequiredMixin, object): def dispatch(self, request, *args, **kwargs): topic_id = kwargs.get('topic_id', None) topics = Topic.objects.filter(id = topic_id) @@ -41,20 +54,118 @@ def dispatch(self, request, *args, **kwargs): -class ReplyView(ReplyMixin, ListView): +class ReplyView(ReplyMixin, FormView): model = Reply template_name = 'ComSemApp/discussionBoard/reply_page.html' context_object_name = 'replies' + fields = ["message", "personPosted", "topic", "hasMark"] def get_queryset(self): return Reply.objects.filter(topic = self.topic) - def get_context_data(self, **kwargs): + def get_context_data(self ,**kwargs): + self.object_list = self.get_queryset() context = super(ReplyView, self).get_context_data(**kwargs) context['topic_description'] = self.topic.topic context['discussion_board'] = True return context -class CreateThreadView(LoginRequiredMixin,CreateView): - print("Hello World") + def form_invalid(self, reply_form, **kwargs): + response = super().form_invalid(reply_form) + return JsonResponse(reply_form.errors, status=400) + + def get(self, request, *args, **kwargs): + allow_empty = True + reply_form = ReplyForm() + reply_form.prefix = 'reply_form' + return self.render_to_response(self.get_context_data(form=reply_form)) + + def post(self, request, *args, **kwargs): + current_url = resolve(request.path_info).url_name + reply_form = ReplyForm(self.request.POST, prefix = 'reply_form') + likeButton = request.POST.get("like") + dislikeButton = request.POST.get("dislike") + if likeButton: + print(likeButton) + reply = Reply.objects.get(id = int(likeButton)) + reply.hasMark = 1 + reply.save() + if current_url == "admin_topic": + return HttpResponseRedirect(reverse("administrator:admin_topic", kwargs={'topic_id': self.topic.id })) + elif current_url == "teacher_topic": + return HttpResponseRedirect(reverse("teacher:teacher_topic", kwargs={'topic_id': self.topic.id })) + elif current_url == "student_topic": + return HttpResponseRedirect(reverse("student:student_topic", kwargs={'topic_id': self.topic.id })) + else: + return HttpResponseRedirect(reverse("discussion_board:topic", kwargs={'topic_id': self.topic.id })) + elif dislikeButton: + print(dislikeButton) + reply = Reply.objects.get(id = int(dislikeButton)) + reply.hasMark = 0 + reply.save() + if current_url == "admin_topic": + return HttpResponseRedirect(reverse("administrator:admin_topic", kwargs={'topic_id': self.topic.id })) + elif current_url == "teacher_topic": + return HttpResponseRedirect(reverse("teacher:teacher_topic", kwargs={'topic_id': self.topic.id })) + elif current_url == "student_topic": + return HttpResponseRedirect(reverse("student:student_topic", kwargs={'topic_id': self.topic.id })) + else: + return HttpResponseRedirect(reverse("discussion_board:topic", kwargs={'topic_id': self.topic.id })) + elif reply_form.is_valid(): + print("it is giving this if statement a thing") + reply = reply_form.save(commit=False) + reply.personPosted = request.user + reply.topic = self.topic + reply.hasMark = 0 + reply.save() + + if current_url == "admin_topic": + return HttpResponseRedirect(reverse("administrator:admin_topic", kwargs={'topic_id': self.topic.id })) + elif current_url == "teacher_topic": + return HttpResponseRedirect(reverse("teacher:teacher_topic", kwargs={'topic_id': self.topic.id })) + elif current_url == "student_topic": + return HttpResponseRedirect(reverse("student:student_topic", kwargs={'topic_id': self.topic.id })) + else: + return HttpResponseRedirect(reverse("discussion_board:topic", kwargs={'topic_id': self.topic.id })) + else: + return self.form_invalid(reply_form, **kwargs) + + +class CreateThreadView(LoginRequiredMixin,FormView): + model = Reply + template_name = 'ComSemApp/discussionBoard/create_topic.html' + context_object_name = 'replies' + fields = ["message", "personPosted", "topic", "hasMark"] + + def form_invalid(self, topic_form, **kwargs): + response = super().form_invalid(form) + return JsonResponse(form.errors, status=400) + + def get(self, request, *args, **kwargs): + allow_empty = True + topic_form = TopicForm() + topic_form.prefix = "topic_form" + return self.render_to_response(self.get_context_data(form=topic_form)) + + def post(self, request, *args, **kwargs): + topic_form = TopicForm(self.request.POST, prefix = 'topic_form') + current_url = resolve(request.path_info).url_name + if topic_form.is_valid(): + topic = Topic(personPosted = request.user, topic = topic_form.cleaned_data["title"]) + topic.save() + reply = topic_form.save(commit=False) + reply.personPosted = request.user + reply.topic = topic + reply.hasMark = 0 + reply.save() + if current_url == "admin_create_topic": + return HttpResponseRedirect(reverse("administrator:admin_topic", kwargs={'topic_id': topic.id })) + elif current_url == "teacher_create_topic": + return HttpResponseRedirect(reverse("teacher:teacher_topic", kwargs={'topic_id': topic.id })) + elif current_url == "student_create_topic": + return HttpResponseRedirect(reverse("student:student_topic", kwargs={'topic_id': topic.id })) + else: + return HttpResponseRedirect(reverse("discussion_board:topic", kwargs={'topic_id': topic.id })) + else: + return self.form_invalid(topic_form, **kwargs) \ No newline at end of file diff --git a/ComSemApp/static/ComSemApp/Dyslexic/css/style.css b/ComSemApp/static/ComSemApp/Dyslexic/css/style.css new file mode 100644 index 00000000..4be5c708 --- /dev/null +++ b/ComSemApp/static/ComSemApp/Dyslexic/css/style.css @@ -0,0 +1,39 @@ +@font-face{ + font-family: "Open-Dyslexic"; + src:url('../fonts/OpenDyslexic-Regular.eot'); + src:url('../fonts/OpenDyslexic-Regular.woff') format('woff'), + url('../fonts/OpenDyslexic-Regular.ttf') format('truetype'), + url('../fonts/OpenDyslexic-Regular.svg') format('svg'); + font-weight: normal; + font-style: normal; +} + +@font-face{ + font-family: "Open-Dyslexic"; + src:url('../fonts/OpenDyslexic-Italic.eot'); + src:url('../fonts/OpenDyslexic-Italic.woff') format('woff'), + url('../fonts/OpenDyslexic-Italic.ttf') format('truetype'), + url('../fonts/OpenDyslexic-Italic.svg') format('svg'); + font-weight: normal; + font-style:italic; +} + +@font-face{ + font-family: "Open-Dyslexic"; + src:url('../fonts/OpenDyslexic-Bold.eot'); + src:url('../fonts/OpenDyslexic-Bold.woff') format('woff'), + url('../fonts/OpenDyslexic-Bold.ttf') format('truetype'), + url('../fonts/OpenDyslexic-Bold.svg') format('svg'); + font-weight: bold; + font-style: normal; +} + +@font-face{ + font-family: "Open-Dyslexic"; + src:url('../fonts/OpenDyslexic-BoldItalic.eot'); + src:url('../fonts/OpenDyslexic-BoldItalic.woff') format('woff'), + url('../fonts/OpenDyslexic-BoldItalic.ttf') format('truetype'), + url('../fonts/OpenDyslexic-BoldItalic.svg') format('svg'); + font-weight: bold; + font-style: italic; +} \ No newline at end of file diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.eot b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.eot new file mode 100644 index 00000000..03006b1b Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.eot differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.svg b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.svg new file mode 100644 index 00000000..edd7346c --- /dev/null +++ b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.svg @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.ttf new file mode 100644 index 00000000..7c97eb43 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.woff b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.woff new file mode 100644 index 00000000..755476f6 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Bold.woff differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.eot b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.eot new file mode 100644 index 00000000..7eb8d251 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.eot differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.svg b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.svg new file mode 100644 index 00000000..970c1003 --- /dev/null +++ b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.svg @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.ttf new file mode 100644 index 00000000..f949334d Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.woff b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.woff new file mode 100644 index 00000000..624d0efd Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-BoldItalic.woff differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.eot b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.eot new file mode 100644 index 00000000..f34c1820 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.eot differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.svg b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.svg new file mode 100644 index 00000000..96ec67f7 --- /dev/null +++ b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.svg @@ -0,0 +1,459 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.ttf new file mode 100644 index 00000000..2f775808 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.woff b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.woff new file mode 100644 index 00000000..f6b12fc1 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Italic.woff differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.eot b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.eot new file mode 100644 index 00000000..0e4e9713 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.eot differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.svg b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.svg new file mode 100644 index 00000000..261004ed --- /dev/null +++ b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.svg @@ -0,0 +1,616 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.ttf new file mode 100644 index 00000000..e7849348 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.woff b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.woff new file mode 100644 index 00000000..fdf9e37d Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic-Regular.woff differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic3-Bold.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic3-Bold.ttf new file mode 100644 index 00000000..395dffc3 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic3-Bold.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic3-Regular.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic3-Regular.ttf new file mode 100644 index 00000000..0ff4c0b5 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexic3-Regular.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Bold.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Bold.ttf new file mode 100644 index 00000000..e45fbff1 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Bold.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-BoldItalic.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-BoldItalic.ttf new file mode 100644 index 00000000..df23fc39 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-BoldItalic.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Italic.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Italic.ttf new file mode 100644 index 00000000..a3dbb908 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Italic.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Regular.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Regular.ttf new file mode 100644 index 00000000..edf6874c Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicAlta-Regular.ttf differ diff --git a/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicMono-Regular.ttf b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicMono-Regular.ttf new file mode 100644 index 00000000..65301ef4 Binary files /dev/null and b/ComSemApp/static/ComSemApp/Dyslexic/fonts/OpenDyslexicMono-Regular.ttf differ diff --git a/ComSemApp/student/urls.py b/ComSemApp/student/urls.py index ae073e67..9cff1083 100644 --- a/ComSemApp/student/urls.py +++ b/ComSemApp/student/urls.py @@ -1,5 +1,6 @@ from django.conf.urls import url from ComSemApp.student import views +from ComSemApp.discussionBoard import view as discussion_views app_name = 'student' urlpatterns = [ @@ -11,4 +12,8 @@ url(r'^course/(?P[0-9]+)/worksheet/(?P[0-9]+)/submission/(?P[0-9]+)/expressions/$', views.ExpressionListView.as_view(), name='worksheet_expression_list'), url(r'^course/(?P[0-9]+)/worksheet/(?P[0-9]+)/submission/(?P[0-9]+)/expression/(?P[0-9]+)/create/$', views.AttemptCreateView.as_view(), name='create_attempt'), url(r'^course/(?P[0-9]+)/worksheet/(?P[0-9]+)/submission/(?P[0-9]+)/attempt/(?P[0-9]+)/update/$', views.AttemptUpdateView.as_view(), name='update_attempt'), + + url(r'^discussion_board$', discussion_views.TopicListView.as_view(), name='student_discussion_board'), + url(r'^topic/(?P[0-9]+)/$', discussion_views.ReplyView.as_view(), name='student_topic'), + url(r'^newtopic/$', discussion_views.CreateThreadView.as_view(),name='student_create_topic') ] \ No newline at end of file diff --git a/ComSemApp/teacher/urls.py b/ComSemApp/teacher/urls.py index 70cb2d59..bb448a29 100644 --- a/ComSemApp/teacher/urls.py +++ b/ComSemApp/teacher/urls.py @@ -1,6 +1,7 @@ from django.conf.urls import url from ComSemApp.teacher import views from ComSemApp.corpus import views as corpus_views +from ComSemApp.discussionBoard import view as discussion_views app_name = 'teacher' urlpatterns = [ @@ -19,4 +20,7 @@ url(r'^course/(?P[0-9]+)/worksheet/(?P[0-9]+)/submission/(?P[0-9]+)/$', views.SubmissionView.as_view(), name='submission'), url(r'^corpus/search$', corpus_views.corpus_search, name='corpus_search'), + url(r'^discussion_board$', discussion_views.TopicListView.as_view(), name='teacher_discussion_board'), + url(r'^topic/(?P[0-9]+)/$', discussion_views.ReplyView.as_view(), name='teacher_topic'), + url(r'^newtopic/$', discussion_views.CreateThreadView.as_view(),name='teacher_create_topic') ] \ No newline at end of file diff --git a/ComSemApp/teacher/views.py b/ComSemApp/teacher/views.py index 58580199..9432e292 100644 --- a/ComSemApp/teacher/views.py +++ b/ComSemApp/teacher/views.py @@ -105,15 +105,24 @@ def get_context_data(self, **kwargs): ungraded = 0 complete = 0 incomplete = 0 + print("HERER") for submission in submissions : + print("sub") if submission.worksheet.course == self.course: + print("HHERE COURSE") if submission.status == 'ungraded': ungraded = ungraded + 1 if submission.status == 'complete': + print('Here') complete = complete + 1 if submission.status == 'incomplete': incomplete = incomplete + 1 - + print("ungraded") + print(ungraded) + print("complete") + print(complete) + print("incomplete") + print(incomplete) data['classungraded'] = ungraded data['classincomplete'] = incomplete diff --git a/ComSemApp/templates/ComSemApp/base.html b/ComSemApp/templates/ComSemApp/base.html index 01d06a97..ca09bf56 100644 --- a/ComSemApp/templates/ComSemApp/base.html +++ b/ComSemApp/templates/ComSemApp/base.html @@ -14,6 +14,8 @@ + + {% with 'ComSemApp/Minton/css-'|add:minton_style|add:'/style.css' as minton_style_css %} {% endwith %} diff --git a/ComSemApp/templates/ComSemApp/discussionBoard/add_reply.html b/ComSemApp/templates/ComSemApp/discussionBoard/add_reply.html new file mode 100644 index 00000000..5e7ec5cd --- /dev/null +++ b/ComSemApp/templates/ComSemApp/discussionBoard/add_reply.html @@ -0,0 +1,32 @@ + +
+
+
+ {% csrf_token %} + + {% for field in form %} +

+ {{ field }} + + {% if field.errors %} + {% for error in field.errors %} +

+ {% endfor %} + {% elif field.help_text %} + {{ field.help_text|safe }} + {% endif %} +

+ {% endfor %} +
+
+ +
+ +
+
+ +
+
+
\ No newline at end of file diff --git a/ComSemApp/templates/ComSemApp/discussionBoard/create_reply.html b/ComSemApp/templates/ComSemApp/discussionBoard/create_reply.html new file mode 100644 index 00000000..5c237b2e --- /dev/null +++ b/ComSemApp/templates/ComSemApp/discussionBoard/create_reply.html @@ -0,0 +1,44 @@ + +{% block content %} + + +
+ {% csrf_token %} + + +
+ +{% endblock %} \ No newline at end of file diff --git a/ComSemApp/templates/ComSemApp/discussionBoard/create_topic.html b/ComSemApp/templates/ComSemApp/discussionBoard/create_topic.html index e69de29b..3ac391d9 100644 --- a/ComSemApp/templates/ComSemApp/discussionBoard/create_topic.html +++ b/ComSemApp/templates/ComSemApp/discussionBoard/create_topic.html @@ -0,0 +1,44 @@ +{% extends 'ComSemApp/sidebar.html' %} +{% block content %} +
+
+
+

+ New Topic +

+
+
+
+
+
+ {% csrf_token %} + + {% for field in form %} +

+ {{ field.label_tag }}
+ {{ field }} + + {% if field.errors %} + {% for error in field.errors %} +

+ {% endfor %} + {% elif field.help_text %} + {{ field.help_text|safe }} + {% endif %} +

+ {% endfor %} +
+
+ +
+ +
+
+ +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/ComSemApp/templates/ComSemApp/discussionBoard/reply_page.html b/ComSemApp/templates/ComSemApp/discussionBoard/reply_page.html index 92f3a9dd..3aaec034 100644 --- a/ComSemApp/templates/ComSemApp/discussionBoard/reply_page.html +++ b/ComSemApp/templates/ComSemApp/discussionBoard/reply_page.html @@ -8,13 +8,14 @@

-
+
{% if replies %} + @@ -22,6 +23,27 @@

+ {% endfor %} {% include 'ComSemApp/tablesorter_footer.html' %} @@ -31,6 +53,9 @@

No available replies

{% endif %} +
+ {% include 'ComSemApp/discussionBoard/add_reply.html' %} +
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/ComSemApp/templates/ComSemApp/discussionBoard/topic_list.html b/ComSemApp/templates/ComSemApp/discussionBoard/topic_list.html index 65e013e4..81229e98 100644 --- a/ComSemApp/templates/ComSemApp/discussionBoard/topic_list.html +++ b/ComSemApp/templates/ComSemApp/discussionBoard/topic_list.html @@ -8,13 +8,25 @@

- - - + {% if current_role %} + {% if current_role == "teacher" %} + + + + {% elif current_role == "admin" %} + + + + {% elif current_role == "student" %} + + + + {% endif %} + {% endif %}
-
+
{% if topics %}
Person Posted MessageStarred
{{reply.personPosted}} {{reply.message}} + {% if reply.hasMark == 1 %} + + {% else %} + + {% endif %} + + {% if current_role %} + {% if current_role == "teacher" or current_role == "admin" %} +
+ {% csrf_token %} + {% if reply.hasMark == 1%} + + {% else %} + + {% endif %} +
+ + {% endif %} + {% endif %} +
@@ -30,7 +42,15 @@

{% endfor %} diff --git a/ComSemApp/templates/ComSemApp/sidebar.html b/ComSemApp/templates/ComSemApp/sidebar.html index e852e1c4..19c550b9 100644 --- a/ComSemApp/templates/ComSemApp/sidebar.html +++ b/ComSemApp/templates/ComSemApp/sidebar.html @@ -1,7 +1,7 @@ {% extends 'ComSemApp/base.html' %} {% block body %} - +
@@ -115,6 +115,9 @@
Welcome, {{ user.username }}
Logout + + This is an Error +
@@ -174,12 +177,6 @@
Welcome, {{ user.username }}
Course Types -
  • - - - Discussion Board - -
  • @@ -205,6 +202,14 @@
    Welcome, {{ user.username }}
  • + {% elif current_role == "teacher" %}
    • @@ -225,6 +230,14 @@
      Welcome, {{ user.username }}
    + {% elif current_role == "student" %}
    • @@ -234,7 +247,15 @@
      Welcome, {{ user.username }}
    - {% endif %} + + {% endif %}
    @@ -244,7 +265,7 @@
    Welcome, {{ user.username }}
    -
    +
    j
    @@ -258,6 +279,25 @@
    Welcome, {{ user.username }}
    - - + {% endblock %} diff --git a/ComSemApp/templates/ComSemApp/teacher/course.html b/ComSemApp/templates/ComSemApp/teacher/course.html index d39704d2..723b4535 100644 --- a/ComSemApp/templates/ComSemApp/teacher/course.html +++ b/ComSemApp/templates/ComSemApp/teacher/course.html @@ -88,7 +88,9 @@

    Students

    var incomplete = {{ classincomplete }}; var completed = {{ classcomplete }}; var ungraded = {{ classungraded }}; - + console.log("ungraded", ungraded); + console.log("completed", completed); + console.log("incomplete", incomplete); var data = google.visualization.arrayToDataTable([ ['Source', 'Clicks'], ['Completed', completed], diff --git a/CommunicationSeminar/settings.py b/CommunicationSeminar/settings.py index eb223160..99a70728 100644 --- a/CommunicationSeminar/settings.py +++ b/CommunicationSeminar/settings.py @@ -33,6 +33,8 @@ 'comsempython.us-east-2.elasticbeanstalk.com', 'localhost', '.comsem.net', + 'comsem.localhost.run', + 'comsem1.localhost.run', '127.0.0.1', ] @@ -106,7 +108,7 @@ 'PORT': '3306', 'NAME': 'CommunicationSeminarDjango', 'USER': 'root', - 'PASSWORD': '2017%ComSem', + 'PASSWORD': 'Ravenclaw77#', } } diff --git a/static/ComSemApp/js/edit_worksheet.js b/static/ComSemApp/js/edit_worksheet.js index 880a455a..78484c16 100644 --- a/static/ComSemApp/js/edit_worksheet.js +++ b/static/ComSemApp/js/edit_worksheet.js @@ -1,294 +1,37 @@ - -// ARRAY OF EXPRESSIONS - -var showNavigationWarning = false; - - -// because of audio, we must send a formdata object -var worksheetFormData = new FormData(); -var expressionsJSON; - -var DEBUG = false; - - -// draw table of current expressions using expressions array AND update the hidden input with jsonified version +// load the list of expressions for the worksheet function drawExpressionsTable(){ - var tableString = "" - if (expressions.length > 0) { - - tableString = "
    {{topic.personPosted}} {{topic.topic}} - Go To Thread + {% if current_role %} + {% if current_role == "teacher" %} + Go To Thread + {% elif current_role == "admin" %} + Go To Thread + {% elif current_role == "student" %} + Go To Thread + {% endif %} + {% endif %}
    " - - var expressionCounter = 1; - - for (var i = 0; i < expressions.length; i++) { - - currentExpression = expressions[i]; - - if(!currentExpression['to_delete']){ - tableString += "" - - if (currentExpression['all_do']){ - tableString += ""; - } else { - tableString +=""; - } - - if (currentExpression['student_name']){ - tableString += ""; - } else { - tableString +=""; - } - - tableString += ""; - - - tableString += ""; - - expressionCounter++; - } - - - } - - tableString += "
    #All-DoStudentExpression
    " + expressionCounter + "" + currentExpression['student_name'] + "anon." + currentExpression['expression'] + "
    "; - } else { - - tableString += "

    No Expressions

    "; - - } - - $('#expressionsTableContainer').html(tableString) - - // bind edit button to it's function - (index doesn't necessarily line up with array because of deleted expressions) - $('.editExpression').on('click', function(e){ - var index = $(this).parents('tr').attr('index') - populateEditor(index); - }); - - // bind edit button to it's function - $('.deleteExpression').on('click', function(e){ - var index = $(this).parents('tr').attr('index') - expressions[index]['to_delete'] = 1; - drawExpressionsTable(); - - showNavigationWarning = true; - - }); - - // UPDATE HIDDEN INPUT WITH JSONIFIED EXPRESSIONS - expressionsJSON = JSON.stringify(expressions); - - - + console.log("drawing expressions table") + $('#expressionsTableContainer').load(expression_list_url) } drawExpressionsTable() // initial call -function populateEditor(index){ - - initializeRecorder(); // initialize the recorder. function found in ComSemRecording-opus.js - - $('#expressionsTableContainer tr').removeClass('cs-active'); - $('#expressionsTableContainer [index=' + index + ']').addClass('cs-active'); - - // prefill the form if we are editing - if (index != -1) { - - - var currentExpression = expressions[index]; - var currentExpressionID = currentExpression['id']; - - // what should the src of the audio element be? - var audioURL = ""; - - if (currentExpression['reformulationAudioBlobSrc']){ - // editing an expression that was saved THIS TIME, not yet in db and file system - audioURL = currentExpression['reformulationAudioBlobSrc']; - - } else { - // editing an expression that was saved and in db and file system - audioURL = calculateAudioURL( {'expressionID': currentExpressionID} ) - } - +function populateEditor(url){ + // url is either expression create or update url - $('#expressionIndex').val(index); - $('#expressionID').val(currentExpressionID); - if(currentExpression['student_id']){ - $('#studentID').val(currentExpression['student_id']); - } else { - $('#studentID').val(0); - } + $("#expression_form").load(url, function(){ + $("#create_or_update_url").val(url) - $('#all_do').prop('checked', currentExpression['all_do']); - $('#expression').val(currentExpression['expression']); - $('#reformulation').val(currentExpression['reformulation']); - $('#contextVocabulary').val(currentExpression['context_vocabulary']); - $('#pronunciation').val(currentExpression['pronunciation']); + initializeRecorder(); // initialize the recorder. function found in ComSemRecording-opus.js - if( currentExpression['reformulation_audio'] == '0'){ - - $('#recordingslist').html(""); - $('#deleteRecordingButton').hide(); - - } else { - - // it's important that the audio element has id=audioElement - $('#recordingslist').html(""); - $('#deleteRecordingButton').show(); - - } - - $('#newExpressionHeader').hide() - $('#editExpressionHeader').show() - - } else { - - $('#expressionIndex').val(-1); - $('#expressionID').val(0); - $('#studentID').val(0); - $('#all_do').prop('checked', false); - $('#expression').val(""); - $('#reformulation').val(""); - $('#contextVocabulary').val(""); - $('#pronunciation').val(""); - - $('#newExpressionHeader').show(); - $('#editExpressionHeader').hide(); - $('#recordingslist').html(""); - $('#deleteRecordingButton').hide(); - - } - - // show the form - $('#ExpressionEditor').slideDown() + // show the form + $('#ExpressionEditor').slideDown() + }) } - - - - -// add the updated/created expression to the array and draw the table -$("#saveExpression").click(function(e){ - - if( $("#expression").val().trim() == "" ){ - // must have a valid expression - alert("Please enter an expression") - return; - } - - var expressionID = $("#expressionID").val(); - var expressionIndex = $("#expressionIndex").val(); - - var reformulation_audio = $("#recordingslist #audioElement").length > 0 ? 1 : 0 - - student_id = $("#studentID").val() == "0" ? null : $("#studentID").val() - - var expressionObj = { - expression: $("#expression").val(), - id: expressionID, - student_id: student_id, - all_do: $("#all_do").prop("checked"), - student_name: student_id ? $("#studentID option:selected").html() : "", // only for display purposes - context_vocabulary: $("#contextVocabulary").val(), - reformulation_text: $("#reformulation").val(), - pronunciation: $("#pronunciation").val(), - reformulation_audio: reformulation_audio, - } - - // always save blob src so that they can edit again - expressionObj['reformulationAudioBlobSrc'] = $("#recordingslist #audioElement").attr('src'); - - if (expressionIndex == -1) { - // append expression onto array - need to save the index for audio recording below - expressionIndex = expressions.push(expressionObj) - 1; - - } else { - // find the expression we are editing, replace it - expressions[expressionIndex] = expressionObj; - } - - // handle audio reformulation seperately - if(reformulation_audio){ - audioReformulationKey = 'audio_ref_' + expressionIndex; - worksheetFormData.append(audioReformulationKey, audioReformulationBlob); // audioReformulationBlob from ComSemRecording.js - - } - - // update expressions table, put expressions array into hidden input - drawExpressionsTable(); - - - // clear editor - $("#ExpressionEditor").slideUp(); - - showNavigationWarning = true; // change to worksheet, show warning if they redirect - -}); - - - $(function(){ - // call SaveWorksheet.php then redirect to myCourses page. - $('#editWorksheetForm').submit(function(e){ - e.preventDefault(); - - // populate formdata obj - worksheetFormData.append( 'course_id', $("#course_id").val() ); - worksheetFormData.append( 'worksheet_id', $("#worksheet_id").val() ); - worksheetFormData.append( 'topic', $("#topic").val() ); - worksheetFormData.append( 'display_original', $("#display_original").prop('checked') ); - worksheetFormData.append( 'display_reformulation_text', $("#display_reformulation_text").prop('checked') ); - worksheetFormData.append( 'display_reformulation_audio', $("#display_reformulation_audio").prop('checked') ); - worksheetFormData.append( 'display_all_expressions', $("[name=display_all_expressions]:checked").val() ); - worksheetFormData.append( 'expressions', expressionsJSON); - worksheetFormData.append( 'MAX_FILE_SIZE', 10000000); // 10 mb - - - // don't show the warning - showNavigationWarning = false; - - $('#uploadingMessage').slideDown(); // show the message - uploading can take a little while on live site - - $.ajax({ - type: "POST", - url: save_url, - data: worksheetFormData, - processData: false, - contentType: false, - success: function(response){ - try { - response = JSON.parse(response); - cs_notification('error', response.error) - } catch(e) { - location.href=redirect_url; - } - }, - error: function(jqXHR, textStatus, errorThrown){ - cs_ajax_error(jqXHR, textStatus, errorThrown) - }, - }); - }) - $('#newExpressionButton').on('click', function(e){ - populateEditor(-1); // -1 means new expression + $('#expressionsTableContainer tr').removeClass('cs-active'); + populateEditor(expression_create_url); }); }); -// if they have made changes without saving, warn them -window.addEventListener("beforeunload", function (e) { - if (showNavigationWarning) { - var confirmationMessage = 'It looks like you have been editing this worksheet. If you leave before saving, your changes will be lost.'; - - (e || window.event).returnValue = confirmationMessage; //Gecko + IE - return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc. - } -}); -function inspectFormData(){ +function inspectFormData(worksheetFormData){ for (var pair of worksheetFormData.entries()) { console.log(pair[0]+ ', ' + pair[1]); }