Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1743 Usunięcie efektów kształcenia #1768

Open
wants to merge 6 commits into
base: master-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zapisy/apps/api/rest/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db import transaction
from rest_framework import serializers

from apps.effects.models import CompletedCourses
from apps.enrollment.records.models.completed_courses import CompletedCourses
from apps.enrollment.courses.models import CourseInstance, Group, Semester
from apps.enrollment.courses.models.classroom import Classroom
from apps.enrollment.courses.models.term import Term
Expand Down
2 changes: 1 addition & 1 deletion zapisy/apps/api/rest/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from apps.offer.vote.models import SingleVote, SystemState
from apps.schedule.models.specialreservation import SpecialReservation
from apps.users.models import Employee, Student
from apps.effects.models import CompletedCourses
from apps.enrollment.records.models.completed_courses import CompletedCourses


class StandardResultsSetPagination(pagination.PageNumberPagination):
Expand Down
Empty file removed zapisy/apps/effects/__init__.py
Empty file.
5 changes: 0 additions & 5 deletions zapisy/apps/effects/apps.py

This file was deleted.

Empty file.
8 changes: 0 additions & 8 deletions zapisy/apps/effects/templates/effects.html

This file was deleted.

25 changes: 1 addition & 24 deletions zapisy/apps/enrollment/courses/admin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from django.contrib import admin, messages
from django.contrib.admin import SimpleListFilter

from apps.enrollment.courses.models.classroom import Classroom
from apps.enrollment.courses.models.course_instance import CourseInstance
from apps.enrollment.courses.models.course_type import Type
from apps.enrollment.courses.models.effects import Effects
from apps.enrollment.courses.models.group import Group, GuaranteedSpots
from apps.enrollment.courses.models.semester import ChangedDay, Freeday, Semester
from apps.enrollment.courses.models.tag import Tag
Expand Down Expand Up @@ -74,26 +72,6 @@ class FreedayAdmin(admin.ModelAdmin):
ordering = ('-day',)


class EffectsListFilter(SimpleListFilter):
title = 'Grupa efektów kształcenia'

# Parameter for the filter that will be used in the URL query.
parameter_name = 'effects'

def lookups(self, request, model_admin):
result = []
for effect in Effects.objects.all():
result.append((str(effect.id), effect))

return result

def queryset(self, request, queryset):
if self.value():
return queryset.filter(effects=self.value())
else:
return queryset


class TermInline(admin.TabularInline):
model = Term
extra = 0
Expand Down Expand Up @@ -175,7 +153,7 @@ def get_queryset(self, request):
@admin.register(CourseInstance)
class CourseInstanceAdmin(admin.ModelAdmin):
list_filter = ('semester', 'course_type', ('owner', admin.RelatedOnlyFieldListFilter),
'tags', 'effects',)
'tags')
list_display = ('name', 'owner', 'course_type', 'semester',)
search_fields = ('name', 'name_en')
ordering = ('semester', 'owner', 'offer')
Expand All @@ -194,7 +172,6 @@ class TypeAdmin(admin.ModelAdmin):

admin.site.register(Group, GroupAdmin)
admin.site.register(Tag)
admin.site.register(Effects)
admin.site.register(Classroom, ClassroomAdmin)
admin.site.register(Semester, SemesterAdmin)
admin.site.register(Freeday, FreedayAdmin)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.1.14 on 2024-11-18 12:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('courses', '0036_auto_20211022_1641'),
]

operations = [
migrations.RemoveField(
model_name='courseinformation',
name='effects',
),
migrations.RemoveField(
model_name='courseinformation',
name='teaching_effects',
),
migrations.DeleteModel(
name='Effects',
),
]
6 changes: 0 additions & 6 deletions zapisy/apps/enrollment/courses/models/course_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from apps.users.models import Employee

from .course_type import Type as CourseType
from .effects import Effects
from .tag import Tag


Expand Down Expand Up @@ -56,7 +55,6 @@ class CourseInformation(models.Model):
preconditions = models.TextField("wymagania wstępne", blank=True)
objectives = models.TextField("cele przedmiotu", blank=True)
contents = models.TextField("treści programowe", blank=True)
teaching_effects = models.TextField("zakładane efekty kształcenia", blank=True)
literature = models.TextField("literatura obowiązkowa i zalecana", blank=True)
verification_methods = models.TextField(
"metody weryfikacji zakładanych efektów kształcenia", blank=True)
Expand All @@ -73,7 +71,6 @@ class CourseInformation(models.Model):
discipline = models.CharField("dyscyplina", max_length=100, default="Informatyka")

tags = models.ManyToManyField(Tag, verbose_name="tagi", blank=True)
effects = models.ManyToManyField(Effects, verbose_name="grupy efektów kształcenia", blank=True)

created = models.DateTimeField("Data utworzenia", auto_now_add=True)
modified = models.DateTimeField("Data modyfikacji", auto_now=True)
Expand Down Expand Up @@ -120,7 +117,6 @@ def __json__(self):
'courseType': self.course_type_id,
'recommendedForFirstYear': self.recommended_for_first_year,
'owner': self.owner_id,
'effects': [effect.pk for effect in self.effects.all()],
'tags': [tag.pk for tag in self.tags.all()],
}

Expand All @@ -130,13 +126,11 @@ def get_short_name(self):
@staticmethod
def prepare_filter_data(qs: models.QuerySet) -> Dict:
"""Prepares the data for course filter based on a given queryset."""
all_effects = Effects.objects.all().values_list('id', 'group_name', named=True)
all_tags = Tag.objects.all().values_list('id', 'full_name', named=True)
all_owners = qs.values_list(
'owner', 'owner__user__first_name', 'owner__user__last_name', named=True).distinct()
all_types = qs.values_list('course_type', 'course_type__name', named=True).distinct()
return {
'allEffects': {e.id: e.group_name for e in all_effects},
'allTags': {t.id: t.full_name for t in all_tags},
'allOwners': {
o.owner: [o.owner__user__first_name, o.owner__user__last_name] for o in all_owners
Expand Down
1 change: 0 additions & 1 deletion zapisy/apps/enrollment/courses/models/course_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def create_proposal_instance(cls, proposal: Proposal, semester: Semester):
instance = cls(**proposal_dict)
instance.save()
instance.tags.set(proposal.tags.all())
instance.effects.set(proposal.effects.all())
return instance

@classmethod
Expand Down
21 changes: 0 additions & 21 deletions zapisy/apps/enrollment/courses/models/effects.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@ <h1 class="d-inline-block">
</td>
</tr>
{% endif %}
{% if course.effects.all %}
<tr>
<th>Grupy efektów kształcenia</th>
<td>
{% for effect in course.effects.all %}
<span class="badge bg-info me-2">{{ effect }}</span>
{% endfor %}
</td>
</tr>
{% endif %}
</tbody>
</table>

Expand Down
6 changes: 3 additions & 3 deletions zapisy/apps/enrollment/courses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def prepare_courses_list_data(semester: Optional[Semester]):
"""Returns a dict used by course list and filter in various views."""
qs = CourseInstance.objects.filter(semester=semester).order_by('name')
courses = []
for course in qs.prefetch_related('effects', 'tags'):
for course in qs.prefetch_related('tags'):
course_dict = course.__json__()
course_dict.update({
'url': reverse('course-page', args=(course.slug,)),
Expand Down Expand Up @@ -68,7 +68,7 @@ def course_view_data(request, slug) -> Tuple[Optional[CourseInstance], Optional[
course: CourseInstance
try:
course = CourseInstance.objects.filter(slug=slug).select_related(
'semester', 'course_type').prefetch_related('tags', 'effects').get()
'semester', 'course_type').prefetch_related('tags').get()
except CourseInstance.DoesNotExist:
return None, None

Expand Down Expand Up @@ -332,7 +332,7 @@ def get_all_group_ids_for_course_slug(slug, class_type: int = None):
course = (
CourseInstance.objects.filter(slug=slug)
.select_related('semester', 'course_type')
.prefetch_related('tags', 'effects')
.prefetch_related('tags')
.get()
)
except CourseInstance.DoesNotExist:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Generated by Django 3.1.5 on 2021-02-05 10:44
# Generated by Django 3.1.14 on 2024-11-18 12:03

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('courses', '0034_auto_20201106_2039'),
('courses', '0037_auto_20241118_1203'),
('users', '0024_auto_20201029_1347'),
('records', '0011_auto_20201106_2029'),
]

operations = [
Expand Down
3 changes: 2 additions & 1 deletion zapisy/apps/enrollment/records/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from apps.enrollment.records.models.opening_times import GroupOpeningTimes, T0Times
from apps.enrollment.records.models.records import Record, RecordStatus
from apps.enrollment.records.models.completed_courses import CompletedCourses

__all__ = ['Record', 'RecordStatus', 'T0Times', 'GroupOpeningTimes']
__all__ = ['Record', 'RecordStatus', 'T0Times', 'GroupOpeningTimes', 'CompletedCourses']
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Set

from django.db import models

from apps.enrollment.courses.models.course_instance import CourseInstance
Expand All @@ -14,16 +12,3 @@ class CompletedCourses(models.Model):

class Meta:
unique_together = ('student', 'course', 'program')

def get_completed_effects(student: Student) -> Set[str]:
completed_courses = (
CompletedCourses.objects.filter(student=student, program=student.program)
.select_related('course').prefetch_related('course__effects')
)

done_effects = set()
for record in completed_courses:
for effect in record.course.effects.all():
done_effects.add(effect.group_name)

return done_effects
70 changes: 33 additions & 37 deletions zapisy/apps/enrollment/timetable/assets/components/CourseFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default Vue.extend({
},
data: function () {
return {
allEffects: {},
allTags: {},
allOwners: [] as MultiselectFilterData<number>,
allTypes: [] as MultiselectFilterData<number>,
Expand All @@ -31,7 +30,6 @@ export default Vue.extend({
const filtersData = JSON.parse(
document.getElementById("filters-data")!.innerHTML
) as FilterDataJSON;
this.allEffects = cloneDeep(filtersData.allEffects);
this.allTags = cloneDeep(filtersData.allTags);
this.allOwners = toPairs(filtersData.allOwners)
.sort(([id, [firstname, lastname]], [id2, [firstname2, lastname2]]) => {
Expand Down Expand Up @@ -71,41 +69,39 @@ export default Vue.extend({
<div class="card bg-light filters-card">
<div class="card-body" v-bind:class="{ collapsed: collapsed }">
<div class="row position-relative">
<div class="col-md">
<TextFilter
filterKey="name-filter"
property="name"
placeholder="Nazwa przedmiotu"
ref="name-filter"
/>
<hr />
<LabelsFilter
title="Tagi"
filterKey="tags-filter"
property="tags"
:allLabels="allTags"
onClass="bg-success"
ref="tags-filter"
/>
</div>
<div class="col-md">
<MultiSelectFilter
filterKey="type-filter"
property="courseType"
:options="allTypes"
title="Rodzaj przedmiotu"
placeholder="Wszystkie rodzaje"
ref="type-filter"
/>
<hr />
<LabelsFilter
title="Efekty kształcenia"
filterKey="effects-filter"
property="effects"
:allLabels="allEffects"
onClass="bg-info"
ref="effects-filter"
/>
<div class="col-md-7">
<div class="row">
<div class="col-md">
<TextFilter
filterKey="name-filter"
property="name"
placeholder="Nazwa przedmiotu"
ref="name-filter"
/>
<hr />
</div>
<div class="col-md">
<MultiSelectFilter
filterKey="type-filter"
property="courseType"
:options="allTypes"
title="Rodzaj przedmiotu"
placeholder="Wszystkie rodzaje"
ref="type-filter"
/>
<hr />
</div>
</div>
<div class="row">
<LabelsFilter
title="Tagi"
filterKey="tags-filter"
property="tags"
:allLabels="allTags"
onClass="bg-success"
ref="tags-filter"
/>
</div>
</div>
<div class="col-md">
<MultiSelectFilter
Expand Down
1 change: 0 additions & 1 deletion zapisy/apps/enrollment/timetable/assets/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export interface PersonDict {
}

export interface FilterDataJSON {
allEffects: KVDict;
allTags: KVDict;
allOwners: PersonDict;
allTypes: KVDict;
Expand Down
1 change: 0 additions & 1 deletion zapisy/apps/enrollment/timetable/assets/store/courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export interface CourseInfo {
id: number;
name: string;
url: string;
effects: Array<number>;
tags: Array<number>;
owner: number;
recommendedForFirstYear: boolean;
Expand Down
2 changes: 1 addition & 1 deletion zapisy/apps/enrollment/timetable/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def list_courses_in_semester(semester: Semester):

This list will be used in prototype.
"""
qs = CourseInstance.objects.filter(semester=semester).prefetch_related('effects', 'tags')
qs = CourseInstance.objects.filter(semester=semester).prefetch_related('tags')
courses = []
for course in qs:
course_dict = course.__json__()
Expand Down
Loading
Loading