Follow few pylint conventions
This commit is contained in:
parent
ef88e20b1a
commit
9484d9d5a9
@ -6,14 +6,11 @@ from django.contrib.auth import update_session_auth_hash
|
|||||||
from django.views.generic import CreateView, ListView
|
from django.views.generic import CreateView, ListView
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.contrib.auth.forms import (
|
from django.contrib.auth.forms import PasswordChangeForm
|
||||||
PasswordChangeForm,
|
from app.models import Session, Semester
|
||||||
)
|
|
||||||
|
|
||||||
from .decorators import admin_required
|
|
||||||
from course.models import Course
|
from course.models import Course
|
||||||
from result.models import TakenCourse
|
from result.models import TakenCourse
|
||||||
from app.models import Session, Semester
|
from .decorators import admin_required
|
||||||
from .forms import StaffAddForm, StudentAddForm, ProfileUpdateForm, ParentAddForm
|
from .forms import StaffAddForm, StudentAddForm, ProfileUpdateForm, ParentAddForm
|
||||||
from .models import User, Student, Parent
|
from .models import User, Student, Parent
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,7 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.db import transaction
|
|
||||||
from django.conf import settings
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
|
|
||||||
from accounts.models import User
|
from accounts.models import User
|
||||||
from .models import Program, Course, CourseAllocation, Upload, UploadVideo
|
from .models import Program, Course, CourseAllocation, Upload, UploadVideo
|
||||||
|
|
||||||
# User = settings.AUTH_USER_MODEL
|
|
||||||
|
|
||||||
|
|
||||||
class ProgramForm(forms.ModelForm):
|
class ProgramForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@ -41,13 +41,13 @@ SEMESTER = (
|
|||||||
|
|
||||||
class ProgramManager(models.Manager):
|
class ProgramManager(models.Manager):
|
||||||
def search(self, query=None):
|
def search(self, query=None):
|
||||||
qs = self.get_queryset()
|
queryset = self.get_queryset()
|
||||||
if query is not None:
|
if query is not None:
|
||||||
or_lookup = Q(title__icontains=query) | Q(summary__icontains=query)
|
or_lookup = Q(title__icontains=query) | Q(summary__icontains=query)
|
||||||
qs = qs.filter(
|
queryset = queryset.filter(
|
||||||
or_lookup
|
or_lookup
|
||||||
).distinct() # distinct() is often necessary with Q lookups
|
).distinct() # distinct() is often necessary with Q lookups
|
||||||
return qs
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
class Program(models.Model):
|
class Program(models.Model):
|
||||||
@ -65,7 +65,7 @@ class Program(models.Model):
|
|||||||
|
|
||||||
class CourseManager(models.Manager):
|
class CourseManager(models.Manager):
|
||||||
def search(self, query=None):
|
def search(self, query=None):
|
||||||
qs = self.get_queryset()
|
queryset = self.get_queryset()
|
||||||
if query is not None:
|
if query is not None:
|
||||||
or_lookup = (
|
or_lookup = (
|
||||||
Q(title__icontains=query)
|
Q(title__icontains=query)
|
||||||
@ -73,10 +73,10 @@ class CourseManager(models.Manager):
|
|||||||
| Q(code__icontains=query)
|
| Q(code__icontains=query)
|
||||||
| Q(slug__icontains=query)
|
| Q(slug__icontains=query)
|
||||||
)
|
)
|
||||||
qs = qs.filter(
|
queryset = queryset.filter(
|
||||||
or_lookup
|
or_lookup
|
||||||
).distinct() # distinct() is often necessary with Q lookups
|
).distinct() # distinct() is often necessary with Q lookups
|
||||||
return qs
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
class Course(models.Model):
|
class Course(models.Model):
|
||||||
@ -169,15 +169,15 @@ class Upload(models.Model):
|
|||||||
ext = str(self.file).split(".")
|
ext = str(self.file).split(".")
|
||||||
ext = ext[len(ext) - 1]
|
ext = ext[len(ext) - 1]
|
||||||
|
|
||||||
if ext == "doc" or ext == "docx":
|
if ext in ("doc", "docx"):
|
||||||
return "word"
|
return "word"
|
||||||
elif ext == "pdf":
|
elif ext == "pdf":
|
||||||
return "pdf"
|
return "pdf"
|
||||||
elif ext == "xls" or ext == "xlsx":
|
elif ext in ("xls", "xlsx"):
|
||||||
return "excel"
|
return "excel"
|
||||||
elif ext == "ppt" or ext == "pptx":
|
elif ext in ("ppt", "pptx"):
|
||||||
return "powerpoint"
|
return "powerpoint"
|
||||||
elif ext == "zip" or ext == "rar" or ext == "7zip":
|
elif ext in ("zip", "rar", "7zip"):
|
||||||
return "archive"
|
return "archive"
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
|
|||||||
@ -9,7 +9,7 @@ from .models import (
|
|||||||
Question,
|
Question,
|
||||||
MCQuestion,
|
MCQuestion,
|
||||||
Choice,
|
Choice,
|
||||||
Essay_Question,
|
EssayQuestion,
|
||||||
Sitting,
|
Sitting,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -89,5 +89,5 @@ class EssayQuestionAdmin(admin.ModelAdmin):
|
|||||||
admin.site.register(Quiz, QuizAdmin)
|
admin.site.register(Quiz, QuizAdmin)
|
||||||
admin.site.register(MCQuestion, MCQuestionAdmin)
|
admin.site.register(MCQuestion, MCQuestionAdmin)
|
||||||
admin.site.register(Progress, ProgressAdmin)
|
admin.site.register(Progress, ProgressAdmin)
|
||||||
admin.site.register(Essay_Question, EssayQuestionAdmin)
|
admin.site.register(EssayQuestion, EssayQuestionAdmin)
|
||||||
admin.site.register(Sitting)
|
admin.site.register(Sitting)
|
||||||
|
|||||||
@ -540,7 +540,7 @@ class Choice(models.Model):
|
|||||||
verbose_name_plural = _("Choices")
|
verbose_name_plural = _("Choices")
|
||||||
|
|
||||||
|
|
||||||
class Essay_Question(Question):
|
class EssayQuestion(Question):
|
||||||
def check_if_correct(self, guess):
|
def check_if_correct(self, guess):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
import random
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.shortcuts import get_object_or_404, render, redirect
|
from django.shortcuts import get_object_or_404, render, redirect
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
@ -11,18 +9,20 @@ from django.views.generic import (
|
|||||||
FormView,
|
FormView,
|
||||||
CreateView,
|
CreateView,
|
||||||
FormView,
|
FormView,
|
||||||
DeleteView,
|
|
||||||
UpdateView,
|
UpdateView,
|
||||||
)
|
)
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.urls import reverse_lazy
|
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.forms import inlineformset_factory
|
|
||||||
from django.http import HttpResponseRedirect
|
|
||||||
|
|
||||||
from accounts.decorators import student_required, lecturer_required
|
from accounts.decorators import lecturer_required
|
||||||
from .models import *
|
from .models import Course, Progress, Sitting, EssayQuestion, Quiz, MCQuestion, Question
|
||||||
from .forms import *
|
from .forms import (
|
||||||
|
QuizAddForm,
|
||||||
|
MCQuestionForm,
|
||||||
|
MCQuestionFormSet,
|
||||||
|
QuestionForm,
|
||||||
|
EssayForm,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@method_decorator([login_required, lecturer_required], name="dispatch")
|
@method_decorator([login_required, lecturer_required], name="dispatch")
|
||||||
@ -173,7 +173,7 @@ class QuizUserProgressView(TemplateView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(QuizUserProgressView, self).get_context_data(**kwargs)
|
context = super(QuizUserProgressView, self).get_context_data(**kwargs)
|
||||||
progress, c = Progress.objects.get_or_create(user=self.request.user)
|
progress, _ = Progress.objects.get_or_create(user=self.request.user)
|
||||||
context["cat_scores"] = progress.list_all_cat_scores
|
context["cat_scores"] = progress.list_all_cat_scores
|
||||||
context["exams"] = progress.show_exams()
|
context["exams"] = progress.show_exams()
|
||||||
context["exams_counter"] = progress.show_exams().count()
|
context["exams_counter"] = progress.show_exams().count()
|
||||||
@ -275,7 +275,7 @@ class QuizTake(FormView):
|
|||||||
self.question = self.sitting.get_first_question()
|
self.question = self.sitting.get_first_question()
|
||||||
self.progress = self.sitting.progress()
|
self.progress = self.sitting.progress()
|
||||||
|
|
||||||
if self.question.__class__ is Essay_Question:
|
if self.question.__class__ is EssayQuestion:
|
||||||
form_class = EssayForm
|
form_class = EssayForm
|
||||||
else:
|
else:
|
||||||
form_class = self.form_class
|
form_class = self.form_class
|
||||||
@ -308,7 +308,7 @@ class QuizTake(FormView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
def form_valid_user(self, form):
|
def form_valid_user(self, form):
|
||||||
progress, c = Progress.objects.get_or_create(user=self.request.user)
|
progress, _ = Progress.objects.get_or_create(user=self.request.user)
|
||||||
guess = form.cleaned_data["answers"]
|
guess = form.cleaned_data["answers"]
|
||||||
is_correct = self.question.check_if_correct(guess)
|
is_correct = self.question.check_if_correct(guess)
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ from django.db import models
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from accounts.models import Student
|
from accounts.models import Student
|
||||||
from app.models import Session, Semester
|
from app.models import Semester
|
||||||
from course.models import Course
|
from course.models import Course
|
||||||
|
|
||||||
YEARS = (
|
YEARS = (
|
||||||
@ -34,29 +34,29 @@ SEMESTER = (
|
|||||||
(THIRD, "Third"),
|
(THIRD, "Third"),
|
||||||
)
|
)
|
||||||
|
|
||||||
A_plus = "A+"
|
A_PLUS = "A+"
|
||||||
A = "A"
|
A = "A"
|
||||||
A_minus = "A-"
|
A_MINUS = "A-"
|
||||||
B_plus = "B+"
|
B_PLUS = "B+"
|
||||||
B = "B"
|
B = "B"
|
||||||
B_minus = "B-"
|
B_MINUS = "B-"
|
||||||
C_plus = "C+"
|
C_PLUS = "C+"
|
||||||
C = "C"
|
C = "C"
|
||||||
C_minus = "C-"
|
C_MINUS = "C-"
|
||||||
D = "D"
|
D = "D"
|
||||||
F = "F"
|
F = "F"
|
||||||
NG = "NG"
|
NG = "NG"
|
||||||
|
|
||||||
GRADE = (
|
GRADE = (
|
||||||
(A_plus, "A+"),
|
(A_PLUS, "A+"),
|
||||||
(A, "A"),
|
(A, "A"),
|
||||||
(A_minus, "A-"),
|
(A_MINUS, "A-"),
|
||||||
(B_plus, "B+"),
|
(B_PLUS, "B+"),
|
||||||
(B, "B"),
|
(B, "B"),
|
||||||
(B_minus, "B-"),
|
(B_MINUS, "B-"),
|
||||||
(C_plus, "C+"),
|
(C_PLUS, "C+"),
|
||||||
(C, "C"),
|
(C, "C"),
|
||||||
(C_minus, "C-"),
|
(C_MINUS, "C-"),
|
||||||
(D, "D"),
|
(D, "D"),
|
||||||
(F, "F"),
|
(F, "F"),
|
||||||
(NG, "NG"),
|
(NG, "NG"),
|
||||||
@ -72,21 +72,6 @@ COMMENT = (
|
|||||||
|
|
||||||
|
|
||||||
class TakenCourseManager(models.Manager):
|
class TakenCourseManager(models.Manager):
|
||||||
def new_or_get(self, request):
|
|
||||||
cart_id = request.session.get("cart_id", None)
|
|
||||||
qs = self.get_queryset().filter(id=cart_id)
|
|
||||||
if qs.count() == 1:
|
|
||||||
new_obj = False
|
|
||||||
cart_obj = qs.first()
|
|
||||||
if request.user.is_authenticated() and cart_obj.user is None:
|
|
||||||
cart_obj.user = request.user
|
|
||||||
cart_obj.save()
|
|
||||||
else:
|
|
||||||
cart_obj = Cart.objects.new(user=request.user)
|
|
||||||
new_obj = True
|
|
||||||
request.session["cart_id"] = cart_obj.id
|
|
||||||
return cart_obj, new_obj
|
|
||||||
|
|
||||||
def new(self, user=None):
|
def new(self, user=None):
|
||||||
user_obj = None
|
user_obj = None
|
||||||
if user is not None:
|
if user is not None:
|
||||||
@ -132,23 +117,23 @@ class TakenCourse(models.Model):
|
|||||||
# total = self.get_total(assignment=assignment, mid_exam=mid_exam, quiz=quiz, attendance=attendance, final_exam=final_exam)
|
# total = self.get_total(assignment=assignment, mid_exam=mid_exam, quiz=quiz, attendance=attendance, final_exam=final_exam)
|
||||||
# total = total
|
# total = total
|
||||||
if total >= 90:
|
if total >= 90:
|
||||||
grade = A_plus
|
grade = A_PLUS
|
||||||
elif total >= 85:
|
elif total >= 85:
|
||||||
grade = A
|
grade = A
|
||||||
elif total >= 80:
|
elif total >= 80:
|
||||||
grade = A_minus
|
grade = A_MINUS
|
||||||
elif total >= 75:
|
elif total >= 75:
|
||||||
grade = B_plus
|
grade = B_PLUS
|
||||||
elif total >= 70:
|
elif total >= 70:
|
||||||
grade = B
|
grade = B
|
||||||
elif total >= 65:
|
elif total >= 65:
|
||||||
grade = B_minus
|
grade = B_MINUS
|
||||||
elif total >= 60:
|
elif total >= 60:
|
||||||
grade = C_plus
|
grade = C_PLUS
|
||||||
elif total >= 55:
|
elif total >= 55:
|
||||||
grade = C
|
grade = C
|
||||||
elif total >= 50:
|
elif total >= 50:
|
||||||
grade = C_minus
|
grade = C_MINUS
|
||||||
elif total >= 45:
|
elif total >= 45:
|
||||||
grade = D
|
grade = D
|
||||||
elif total < 45:
|
elif total < 45:
|
||||||
@ -172,23 +157,23 @@ class TakenCourse(models.Model):
|
|||||||
# point = 0
|
# point = 0
|
||||||
# for i in student:
|
# for i in student:
|
||||||
credit = self.course.credit
|
credit = self.course.credit
|
||||||
if self.grade == A_plus:
|
if self.grade == A_PLUS:
|
||||||
point = 4
|
point = 4
|
||||||
elif self.grade == A:
|
elif self.grade == A:
|
||||||
point = 4
|
point = 4
|
||||||
elif self.grade == A_minus:
|
elif self.grade == A_MINUS:
|
||||||
point = 3.75
|
point = 3.75
|
||||||
elif self.grade == B_plus:
|
elif self.grade == B_PLUS:
|
||||||
point = 3.5
|
point = 3.5
|
||||||
elif self.grade == B:
|
elif self.grade == B:
|
||||||
point = 3
|
point = 3
|
||||||
elif self.grade == B_minus:
|
elif self.grade == B_MINUS:
|
||||||
point = 2.75
|
point = 2.75
|
||||||
elif self.grade == C_plus:
|
elif self.grade == C_PLUS:
|
||||||
point = 2.5
|
point = 2.5
|
||||||
elif self.grade == C:
|
elif self.grade == C:
|
||||||
point = 2
|
point = 2
|
||||||
elif self.grade == C_minus:
|
elif self.grade == C_MINUS:
|
||||||
point = 1.75
|
point = 1.75
|
||||||
elif self.grade == D:
|
elif self.grade == D:
|
||||||
point = 1
|
point = 1
|
||||||
@ -208,23 +193,23 @@ class TakenCourse(models.Model):
|
|||||||
point = 0
|
point = 0
|
||||||
for i in student:
|
for i in student:
|
||||||
credit = i.course.credit
|
credit = i.course.credit
|
||||||
if i.grade == A_plus:
|
if i.grade == A_PLUS:
|
||||||
point = 4
|
point = 4
|
||||||
elif i.grade == A:
|
elif i.grade == A:
|
||||||
point = 4
|
point = 4
|
||||||
elif i.grade == A_minus:
|
elif i.grade == A_MINUS:
|
||||||
point = 3.75
|
point = 3.75
|
||||||
elif i.grade == B_plus:
|
elif i.grade == B_PLUS:
|
||||||
point = 3.5
|
point = 3.5
|
||||||
elif i.grade == B:
|
elif i.grade == B:
|
||||||
point = 3
|
point = 3
|
||||||
elif i.grade == B_minus:
|
elif i.grade == B_MINUS:
|
||||||
point = 2.75
|
point = 2.75
|
||||||
elif i.grade == C_plus:
|
elif i.grade == C_PLUS:
|
||||||
point = 2.5
|
point = 2.5
|
||||||
elif i.grade == C:
|
elif i.grade == C:
|
||||||
point = 2
|
point = 2
|
||||||
elif i.grade == C_minus:
|
elif i.grade == C_MINUS:
|
||||||
point = 1.75
|
point = 1.75
|
||||||
elif i.grade == D:
|
elif i.grade == D:
|
||||||
point = 1
|
point = 1
|
||||||
@ -242,10 +227,10 @@ class TakenCourse(models.Model):
|
|||||||
previousResult = Result.objects.filter(
|
previousResult = Result.objects.filter(
|
||||||
student__id=self.student.id, level__lt=self.student.level
|
student__id=self.student.id, level__lt=self.student.level
|
||||||
)
|
)
|
||||||
previousCGPA = 0
|
previous_cgpa = 0
|
||||||
for i in previousResult:
|
for i in previousResult:
|
||||||
if i.cgpa is not None:
|
if i.cgpa is not None:
|
||||||
previousCGPA += i.cgpa
|
previous_cgpa += i.cgpa
|
||||||
cgpa = 0
|
cgpa = 0
|
||||||
if str(current_semester) == SECOND:
|
if str(current_semester) == SECOND:
|
||||||
first_sem_gpa = 0.0
|
first_sem_gpa = 0.0
|
||||||
@ -269,22 +254,22 @@ class TakenCourse(models.Model):
|
|||||||
taken_courses = TakenCourse.objects.filter(
|
taken_courses = TakenCourse.objects.filter(
|
||||||
student=self.student, student__level=self.student.level
|
student=self.student, student__level=self.student.level
|
||||||
)
|
)
|
||||||
TCC = 0
|
taken_course_credits = 0
|
||||||
TCP = 0
|
taken_course_points = 0
|
||||||
for i in taken_courses:
|
for i in taken_courses:
|
||||||
TCP += float(i.point)
|
taken_course_points += float(i.point)
|
||||||
for i in taken_courses:
|
for i in taken_courses:
|
||||||
TCC += int(i.course.credit)
|
taken_course_credits += int(i.course.credit)
|
||||||
# cgpa = (first_sem_gpa + sec_sem_gpa) / 2
|
# cgpa = (first_sem_gpa + sec_sem_gpa) / 2
|
||||||
|
|
||||||
print("TCP = ", TCP)
|
print("taken_course_points = ", taken_course_points)
|
||||||
print("TCC = ", TCC)
|
print("taken_course_credits = ", taken_course_credits)
|
||||||
print("first_sem_gpa = ", first_sem_gpa)
|
print("first_sem_gpa = ", first_sem_gpa)
|
||||||
print("sec_sem_gpa = ", sec_sem_gpa)
|
print("sec_sem_gpa = ", sec_sem_gpa)
|
||||||
print("cgpa = ", round(TCP / TCC, 2))
|
print("cgpa = ", round(taken_course_points / taken_course_credits, 2))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cgpa = TCP / TCC
|
cgpa = taken_course_points / taken_course_credits
|
||||||
return round(cgpa, 2)
|
return round(cgpa, 2)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@ -1,20 +1,11 @@
|
|||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core.paginator import Paginator
|
|
||||||
|
|
||||||
from accounts.models import User, Student
|
|
||||||
from app.models import Session, Semester
|
|
||||||
from course.models import Course
|
|
||||||
from accounts.decorators import lecturer_required, student_required
|
|
||||||
from .models import TakenCourse, Result
|
|
||||||
|
|
||||||
# pdf
|
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
from django.http import HttpResponse, JsonResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
from reportlab.platypus import (
|
from reportlab.platypus import (
|
||||||
SimpleDocTemplate,
|
SimpleDocTemplate,
|
||||||
@ -23,14 +14,19 @@ from reportlab.platypus import (
|
|||||||
Table,
|
Table,
|
||||||
TableStyle,
|
TableStyle,
|
||||||
Image,
|
Image,
|
||||||
LongTable,
|
|
||||||
)
|
)
|
||||||
from reportlab.lib.styles import getSampleStyleSheet, black, ParagraphStyle
|
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
||||||
from reportlab.lib.enums import TA_JUSTIFY, TA_LEFT, TA_CENTER, TA_RIGHT
|
from reportlab.lib.enums import TA_JUSTIFY, TA_LEFT, TA_CENTER, TA_RIGHT
|
||||||
from reportlab.platypus.tables import Table
|
from reportlab.platypus.tables import Table
|
||||||
from reportlab.lib.units import inch
|
from reportlab.lib.units import inch
|
||||||
from reportlab.lib import colors
|
from reportlab.lib import colors
|
||||||
from .models import *
|
|
||||||
|
from accounts.models import Student
|
||||||
|
from app.models import Session, Semester
|
||||||
|
from course.models import Course
|
||||||
|
from accounts.decorators import lecturer_required, student_required
|
||||||
|
from .models import TakenCourse, Result, FIRST, SECOND
|
||||||
|
|
||||||
|
|
||||||
cm = 2.54
|
cm = 2.54
|
||||||
|
|
||||||
@ -42,15 +38,16 @@ cm = 2.54
|
|||||||
@lecturer_required
|
@lecturer_required
|
||||||
def add_score(request):
|
def add_score(request):
|
||||||
"""
|
"""
|
||||||
Shows a page where a lecturer will select a course allocated to him for score entry.
|
Shows a page where a lecturer will select a course allocated
|
||||||
in a specific semester and session
|
to him for score entry. in a specific semester and session
|
||||||
|
|
||||||
"""
|
"""
|
||||||
current_session = Session.objects.get(is_current_session=True)
|
current_session = Session.objects.get(is_current_session=True)
|
||||||
current_semester = get_object_or_404(
|
current_semester = get_object_or_404(
|
||||||
Semester, is_current_semester=True, session=current_session
|
Semester, is_current_semester=True, session=current_session
|
||||||
)
|
)
|
||||||
# semester = Course.objects.filter(allocated_course__lecturer__pk=request.user.id, semester=current_semester)
|
# semester = Course.objects.filter(
|
||||||
|
# allocated_course__lecturer__pk=request.user.id,
|
||||||
|
# semester=current_semester)
|
||||||
courses = Course.objects.filter(
|
courses = Course.objects.filter(
|
||||||
allocated_course__lecturer__pk=request.user.id
|
allocated_course__lecturer__pk=request.user.id
|
||||||
).filter(semester=current_semester)
|
).filter(semester=current_semester)
|
||||||
@ -66,8 +63,8 @@ def add_score(request):
|
|||||||
@lecturer_required
|
@lecturer_required
|
||||||
def add_score_for(request, id):
|
def add_score_for(request, id):
|
||||||
"""
|
"""
|
||||||
Shows a page where a lecturer will add score for students that are taking courses allocated to him
|
Shows a page where a lecturer will add score for students that
|
||||||
in a specific semester and session
|
are taking courses allocated to him in a specific semester and session
|
||||||
"""
|
"""
|
||||||
current_session = Session.objects.get(is_current_session=True)
|
current_session = Session.objects.get(is_current_session=True)
|
||||||
current_semester = get_object_or_404(
|
current_semester = get_object_or_404(
|
||||||
@ -81,9 +78,11 @@ def add_score_for(request, id):
|
|||||||
# myclass = Class.objects.get(lecturer__pk=request.user.id)
|
# myclass = Class.objects.get(lecturer__pk=request.user.id)
|
||||||
# myclass = get_object_or_404(Class, lecturer__pk=request.user.id)
|
# myclass = get_object_or_404(Class, lecturer__pk=request.user.id)
|
||||||
|
|
||||||
# students = TakenCourse.objects.filter(course__allocated_course__lecturer__pk=request.user.id).filter(
|
# students = TakenCourse.objects.filter(
|
||||||
# course__id=id).filter(student__allocated_student__lecturer__pk=request.user.id).filter(
|
# course__allocated_course__lecturer__pk=request.user.id).filter(
|
||||||
# course__semester=current_semester)
|
# course__id=id).filter(
|
||||||
|
# student__allocated_student__lecturer__pk=request.user.id).filter(
|
||||||
|
# course__semester=current_semester)
|
||||||
students = (
|
students = (
|
||||||
TakenCourse.objects.filter(
|
TakenCourse.objects.filter(
|
||||||
course__allocated_course__lecturer__pk=request.user.id
|
course__allocated_course__lecturer__pk=request.user.id
|
||||||
@ -186,12 +185,14 @@ def add_score_for(request, id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# a = Result.objects.get(student=student.student, semester=current_semester, level=student.student.level)
|
# a = Result.objects.get(student=student.student,
|
||||||
|
# semester=current_semester, level=student.student.level)
|
||||||
# a.gpa = gpa
|
# a.gpa = gpa
|
||||||
# a.cgpa = cgpa
|
# a.cgpa = cgpa
|
||||||
# a.save()
|
# a.save()
|
||||||
# except:
|
# except:
|
||||||
# Result.objects.get_or_create(student=student.student, gpa=gpa, semester=current_semester, level=student.student.level)
|
# Result.objects.get_or_create(student=student.student, gpa=gpa,
|
||||||
|
# semester=current_semester, level=student.student.level)
|
||||||
|
|
||||||
messages.success(request, "Successfully Recorded! ")
|
messages.success(request, "Successfully Recorded! ")
|
||||||
return HttpResponseRedirect(reverse_lazy("add_score_for", kwargs={"id": id}))
|
return HttpResponseRedirect(reverse_lazy("add_score_for", kwargs={"id": id}))
|
||||||
@ -723,7 +724,8 @@ def course_registration_form(request):
|
|||||||
has been duly registered for the <b>"
|
has been duly registered for the <b>"
|
||||||
+ student.level
|
+ student.level
|
||||||
+ " level </b> of study in the department\
|
+ " level </b> of study in the department\
|
||||||
of COMPUTER SICENCE & ENGINEERING and that the courses and credits registered are as approved by the senate of the University"
|
of COMPUTER SICENCE & ENGINEERING and that the courses and credits \
|
||||||
|
registered are as approved by the senate of the University"
|
||||||
)
|
)
|
||||||
certification_text = Paragraph(certification_text, certification)
|
certification_text = Paragraph(certification_text, certification)
|
||||||
Story.append(certification_text)
|
Story.append(certification_text)
|
||||||
|
|||||||
@ -1,39 +1,5 @@
|
|||||||
# from django.shortcuts import render
|
|
||||||
# from django.views.generic import ListView
|
|
||||||
# from app.models import NewsAndEvents
|
|
||||||
|
|
||||||
|
|
||||||
# class SearchNewsAndEventsView(ListView):
|
|
||||||
# template_name = "search/search_view.html"
|
|
||||||
|
|
||||||
# def get_context_data(self, *args, **kwargs):
|
|
||||||
# context = super(SearchNewsAndEventsView, self).get_context_data(*args, **kwargs)
|
|
||||||
# query = self.request.GET.get('q')
|
|
||||||
# context['query'] = query
|
|
||||||
# context['obj_counter'] = NewsAndEvents.objects.search(query).count()
|
|
||||||
# # SearchQuery.objects.create(query=query)
|
|
||||||
# return context
|
|
||||||
|
|
||||||
# def get_queryset(self, *args, **kwargs):
|
|
||||||
# request = self.request
|
|
||||||
# method_dict = request.GET
|
|
||||||
# query = method_dict.get('q', None) # method_dict['q']
|
|
||||||
# if query is not None:
|
|
||||||
# return NewsAndEvents.objects.search(query)
|
|
||||||
# return NewsAndEvents.objects.all()
|
|
||||||
# '''
|
|
||||||
# __icontains = field contains this
|
|
||||||
# __iexact = fields is exactly this
|
|
||||||
# '''
|
|
||||||
|
|
||||||
|
|
||||||
# search.views.py
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
|
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
from accounts.models import User, Student
|
|
||||||
from app.models import NewsAndEvents
|
from app.models import NewsAndEvents
|
||||||
from course.models import Program, Course
|
from course.models import Program, Course
|
||||||
from quiz.models import Quiz
|
from quiz.models import Quiz
|
||||||
@ -64,7 +30,9 @@ class SearchView(ListView):
|
|||||||
queryset_chain = chain(
|
queryset_chain = chain(
|
||||||
news_events_results, program_results, course_results, quiz_results
|
news_events_results, program_results, course_results, quiz_results
|
||||||
)
|
)
|
||||||
qs = sorted(queryset_chain, key=lambda instance: instance.pk, reverse=True)
|
queryset = sorted(
|
||||||
self.count = len(qs) # since qs is actually a list
|
queryset_chain, key=lambda instance: instance.pk, reverse=True
|
||||||
return qs
|
)
|
||||||
|
self.count = len(queryset) # since queryset is actually a list
|
||||||
|
return queryset
|
||||||
return NewsAndEvents.objects.none() # just an empty queryset as default
|
return NewsAndEvents.objects.none() # just an empty queryset as default
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user