forked from apluslms/a-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce46d6f
commit beae0d7
Showing
21 changed files
with
615 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
function submissions_list() { | ||
var checkedButtons = []; // Array to store data-slug of checked buttons | ||
|
||
$('button').on('click', function(event) { | ||
event.preventDefault(); | ||
var icon = $(this).find('.glyphicon'); | ||
|
||
if (icon.hasClass('glyphicon-unchecked')) { | ||
icon.removeClass('glyphicon-unchecked').addClass('glyphicon-check'); | ||
$(this).attr("data-status", "checked"); // set data-status to 'checked' | ||
checkedButtons.push($(this).attr("data-slug")); // add data-slug of the button to the array | ||
} else { | ||
icon.removeClass('glyphicon-check').addClass('glyphicon-unchecked'); | ||
$(this).attr("data-status", "unchecked"); // set data-status to 'unchecked' | ||
var index = checkedButtons.indexOf($(this).attr("data-slug")); // get the index of the button in the array | ||
if (index !== -1) { | ||
checkedButtons.splice(index, 1); // remove it from the array if it exists | ||
} | ||
} | ||
|
||
refresh_filters(); | ||
}); | ||
|
||
var filter_items = function (submissions) { | ||
const filterTags = $.makeArray($('.filter-users button.filter-tag:has(.glyphicon-check)')) | ||
.map(function (elem) { | ||
return $(elem).attr('data-tagslug'); | ||
}); | ||
const filterStatuses = $.makeArray($('.filter-users button.filter-status:has(.glyphicon-check)')) | ||
.map(function (elem) { | ||
return $(elem).attr('data-status'); | ||
}); | ||
return submissions.map(function (submission) { | ||
// Set intercetion tags ∩ filters | ||
const intersectTags = submission.tag_slugs.filter(function (tag) { | ||
return filterTags.indexOf(tag) >= 0; | ||
}); | ||
return intersectTags.length === filterTags.length | ||
}); | ||
}; | ||
|
||
function refresh_filters() { | ||
$('.filter-submissions table tr').each(function(){ | ||
$(this).hide(); // hide all rows by default | ||
|
||
$(this).find('tagging.tag').each(function(){ | ||
if (checkedButtons.includes($(this).attr("data-tagslug"))) { | ||
$(this).closest('tr').show(); // show the row if it has a checked button | ||
return false; // exit the inner loop | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
refresh_filters(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Generated by Django 4.2.11 on 2024-04-24 11:06 | ||
|
||
import colorfield | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import lib.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("course", "0058_coursemodule_model_answer_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="SubmissionTag", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"name", | ||
models.CharField(help_text="Display name for tag", max_length=20), | ||
), | ||
( | ||
"slug", | ||
models.SlugField( | ||
help_text="Slug key for tag. If left blank, one is created from name", | ||
max_length=20, | ||
), | ||
), | ||
( | ||
"description", | ||
models.CharField( | ||
blank=True, | ||
help_text="Describe the usage or meaning of this tag", | ||
max_length=155, | ||
), | ||
), | ||
( | ||
"color", | ||
colorfield.ColorField( | ||
default="#CD0000", | ||
help_text="Color that is used as background for this tag", | ||
max_length=7, | ||
), | ||
), | ||
( | ||
"visible_to_students", | ||
models.BooleanField( | ||
default=False, verbose_name="LABEL_VISIBLE_TO_STUDENTS" | ||
), | ||
), | ||
( | ||
"filter_status", | ||
models.BooleanField( | ||
default=False, verbose_name="LABEL_FILTER_STATUS" | ||
), | ||
), | ||
( | ||
"course_instance", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="submissiontags", | ||
to="course.courseinstance", | ||
verbose_name="LABEL_COURSE_INSTANCE", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "MODEL_NAME_SUBMISSION_TAG", | ||
"verbose_name_plural": "MODEL_NAME_SUBMISSION_TAG_PLURAL", | ||
"ordering": ["course_instance", "name"], | ||
}, | ||
bases=(lib.models.UrlMixin, models.Model), | ||
), | ||
] |
17 changes: 17 additions & 0 deletions
17
course/migrations/0060_remove_submissiontag_filter_status.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 4.2.11 on 2024-04-24 11:13 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("course", "0059_submissiontag"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="submissiontag", | ||
name="filter_status", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% extends "edit_course/edit_course_base.html" %} | ||
{% load i18n %} | ||
{% load bootstrap %} | ||
{% load course %} | ||
{% load editcourse %} | ||
|
||
{% block editbreadcrumblist %} | ||
{{ block.super }} | ||
<li><a href="{{ instance|url:'course-submission-tags' }}">{% translate "SUBMISSION_TAGS" %}</a></li> | ||
<li class="active">{% translate "ADD_NEW_SUBMISSION_TAG" %}</li> | ||
{% endblock %} | ||
{% block view_tag %}edit-course,course-submission-tags{% endblock %} | ||
|
||
{% block coursecontent %} | ||
<br /> | ||
<form method="post" class="well form-horizontal"> | ||
{% csrf_token %} | ||
<legend>{% translate "ADD_SUBMISSION_TAG" %}</legend> | ||
{{ form|bootstrap_horizontal }} | ||
<div class="form-group"> | ||
<div class="col-sm-10 col-sm-offset-2"> | ||
<button type="submit" class="aplus-button--default aplus-button--md">{% translate "SAVE" %}</button> | ||
<a href="{{ instance|url:'course-submission-tags' }}" class="aplus-button--secondary aplus-button--md" role="button">{% translate "CANCEL" %}</a> | ||
</div> | ||
</div> | ||
</form> | ||
{% endblock %} |
36 changes: 36 additions & 0 deletions
36
edit_course/templates/edit_course/submissiontag_delete.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{% extends "edit_course/edit_course_base.html" %} | ||
{% load i18n %} | ||
{% load bootstrap %} | ||
{% load course %} | ||
{% load editcourse %} | ||
{% load colortag %} | ||
|
||
{% block editbreadcrumblist %} | ||
{{ block.super }} | ||
<li><a href="{{ instance|url:'course-tags' }}">{% translate "TAGS" %}</a></li> | ||
<li class="active">{% translate "REMOVE_SUBMISSION_TAG" %}</li> | ||
{% endblock %} | ||
{% block view_tag %}edit-course,course-submission-tags{% endblock %} | ||
|
||
{% block coursecontent %} | ||
<br /> | ||
<form method="post" class="well form-horizontal"> | ||
{% csrf_token %} | ||
<legend> | ||
{% translate "REMOVE_SUBMISSION_TAG_CONFIRMATION" %} | ||
</legend> | ||
|
||
<div class="alert alert-danger"> | ||
{% translate "REMOVE_SUBMISSION_TAG_CONFIRMATION_ALERT" %} | ||
{{ object|colortag }} | ||
</div> | ||
|
||
<div class="form-group"> | ||
<input class="aplus-button--danger aplus-button--md" type="submit" value="{% translate 'REMOVE' %}" /> | ||
<a class="aplus-button--secondary aplus-button--md" role="button" href="{{ instance|url:'course-submission-tags' }}"> | ||
{% translate "CANCEL" %} | ||
</a> | ||
</div> | ||
</form> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% extends "edit_course/edit_course_base.html" %} | ||
{% load i18n %} | ||
{% load bootstrap %} | ||
{% load course %} | ||
{% load editcourse %} | ||
|
||
{% block editbreadcrumblist %} | ||
{{ block.super }} | ||
<li><a href="{{ instance|url:'course-submission-tags' }}">{% translate "SUBMISSION_TAGS" %}</a></li> | ||
<li class="active">{% translate "EDIT_SUBMISSION_TAG" %}</li> | ||
{% endblock %} | ||
{% block view_tag %}edit-course,course-submission-tags{% endblock %} | ||
|
||
{% block coursecontent %} | ||
<br /> | ||
<form method="post" class="well form-horizontal"> | ||
{% csrf_token %} | ||
<legend>{% translate "EDIT_SUBMISSION_TAG" %}</legend> | ||
{{ form|bootstrap_horizontal }} | ||
<div class="form-group"> | ||
<div class="col-sm-10 col-sm-offset-2"> | ||
<button type="submit" class="aplus-button--default aplus-button--md">{% translate "SAVE" %}</button> | ||
<a href="{{ instance|url:'course-submission-tags' }}" role="button" class="aplus-button--secondary aplus-button--md">{% translate "CANCEL" %}</a> | ||
</div> | ||
</div> | ||
</form> | ||
{% endblock %} |
Oops, something went wrong.