Skip to content

Commit

Permalink
Another implementation of practice test
Browse files Browse the repository at this point in the history
  • Loading branch information
NgoYves1802 committed Nov 19, 2023
2 parents b5371ee + 0c5038a commit 13265a7
Show file tree
Hide file tree
Showing 251 changed files with 278 additions and 155 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.sqlite3
__pycache__/
Binary file removed Dr_R/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file removed Dr_R/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file removed Dr_R/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file removed Dr_R/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file removed Dr_R/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file removed Dr_R/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file removed Dr_R/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.
Binary file removed Dr_R/__pycache__/wsgi.cpython-311.pyc
Binary file not shown.
Binary file removed astros/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file removed astros/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file removed astros/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file removed astros/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file removed astros/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file removed astros/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file removed astros/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file removed astros/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file removed astros/__pycache__/tests.cpython-311.pyc
Binary file not shown.
Binary file removed astros/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file removed astros/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file removed astros/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file removed astros/__pycache__/views.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file removed astros/migrations/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file removed astros/migrations/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
11 changes: 10 additions & 1 deletion astros/templates/astros/all_courses.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ <h4>All courses</h4>
<ul class="courses course-list">
{% if is_professor%}
{% for course, is_course_prof in courses__is_professor %}
{% include 'astros/prof_course_display.html' with course=course is_course_prof=is_course_prof%}
{% if course.name == "Practice_Test_Course" %}
{% else %}
{% include 'astros/prof_course_display.html' with course=course is_course_prof=is_course_prof%}
{% endif %}
{% endfor %}

{% elif is_student %}
{% for course, is_course_stud in courses__is_student %}
{% if course.name == "Practice_Test_Course" %}
{% else %}
{% include 'astros/stud_course_display.html' with course=course is_course_stud=is_course_stud %}
{% endif %}
{% endfor %}

{% else %}
{% for course in courses %}
{% if course.name == "Practice_Test_Course" %}
{% else %}
{% include 'astros/lambda_course_display.html' with course=course%}
{% endif %}
{% endfor %}
{% endif %}
</ul>
Expand Down
5 changes: 4 additions & 1 deletion astros/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def all_courses(request):
@login_required(login_url='astros:login')
def course_enroll(request, course_id, code):
# Making sure the request is done by a Student.
student = get_object_or_404(Student, pk=request.user.pk)
try:
student = get_object_or_404(Student, pk=request.user.pk)
except:
return HttpResponse(json.dumps({'state':False, 'response': 'LOGIN FIRST'}))
course = get_object_or_404(Course, pk = course_id)
if not Enrollment.objects.filter(student=student, course=course).exists():
# Checking whether code is valid.
Expand Down
Binary file removed db.sqlite3
Binary file not shown.
Binary file removed deimos/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/forms.cpython-310.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/forms.cpython-311.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/utils.cpython-311.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file removed deimos/__pycache__/views.cpython-311.pyc
Binary file not shown.
18 changes: 18 additions & 0 deletions deimos/migrations/0022_assignmentstudent_is_complete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.3 on 2023-11-13 05:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('deimos', '0021_questionstudent_is_complete'),
]

operations = [
migrations.AddField(
model_name='assignmentstudent',
name='is_complete',
field=models.BooleanField(default=False),
),
]
14 changes: 14 additions & 0 deletions deimos/migrations/0023_merge_20231119_1639.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.2.4 on 2023-11-19 15:39

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('deimos', '0020_remove_practicetestassignment_assignment_and_more'),
('deimos', '0022_assignmentstudent_is_complete'),
]

operations = [
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed deimos/migrations/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file removed deimos/migrations/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
19 changes: 14 additions & 5 deletions deimos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class AssignmentStudent(models.Model):
assignment = models.ForeignKey(Assignment, on_delete=models.CASCADE)
grade = models.FloatField(validators=[MaxValueValidator(100)], default=0, null=True)
due_date = models.DateTimeField(null=True, blank=True)
is_complete = models.BooleanField(default=False)

def get_grade(self):
"""
Expand Down Expand Up @@ -101,6 +102,10 @@ def get_grade(self):
self.grade = 0
self.assignment.num_points = total
return self.grade

def get_status(self):
return self.is_complete

def save(self, *args, **kwargs):
if not self.due_date:
self.due_date = self.assignment.due_date
Expand All @@ -118,6 +123,12 @@ class QuestionStudent(models.Model):
instances_created = models.BooleanField(default=False)
num_units_attempts = models.IntegerField(default=0, null=True, blank=True, validators=[MinValueValidator(0)])
is_complete = models.BooleanField(default=False)

def save(self, *args, **kwargs):
if self.success == True:
self.is_complete = True
super(QuestionStudent, self).save(*args, **kwargs)

def create_instances(self):
"""
Get variable instances from the variables associated to the question.
Expand Down Expand Up @@ -254,11 +265,9 @@ def get_status(self):
Otherwise False
"""
parent_question = self.question.parent_question if self.question.parent_question else self.question
question_students = QuestionStudent.objects.filter(question__parent_question=parent_question)
for qs in question_students:
if not qs.is_complete:
return False
return True
children_complete = not QuestionStudent.objects.filter(question__parent_question=parent_question, student=self.student, is_complete=False).exists()
parent_qs = QuestionStudent.objects.get(question=parent_question, student=self.student)
return parent_qs.is_complete and children_complete

def get_potential(self, no_unit = False):
"""
Expand Down
12 changes: 12 additions & 0 deletions deimos/static/deimos/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,17 @@ div.image-container img.course-image {
}


.edit-btn {
background-color: rgba(23, 137, 252, 1) !important;
transition: background-color 0.2s !important;
color: rgba(0,0,0,0.95) !important;
font-weight:400 !important;
font-family: 'Aileron', sans-serif;

}
.edit-btn:hover {
background-color: rgba(23, 137, 252, 0.7) !important;
}

/* ------------------------------Style for answer_question.html-------------*/
.formatted-mp {
Expand Down Expand Up @@ -727,6 +737,8 @@ more than assignment display */

.original-size {
font-size: initial;
width: auto;
height: auto;
}
@keyframes blink {
0%, 100% {
Expand Down
4 changes: 2 additions & 2 deletions deimos/templates/deimos/answer_question.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ <h3 class="original-size">Question {{question_dict.question.number}}</h3>
{% elif question_dict.questtype == 'mp' %}
<input type="hidden" value="mp" class="question-type"/>
{% if not question_dict.question_student.success %}
<div class="suggestion"> Match the following pairs </div>
<div class="suggestion" style="width: 100%;"> Match the following pairs </div>
{% else %}
<div class="suggestion"> You correctly matched the pairs. </div>
<div class="suggestion" style="width: 100%;"> You correctly matched the pairs. </div>
{% endif %}
<div class="mp-section">
<!--Yet to be passed attempts -->
Expand Down
13 changes: 10 additions & 3 deletions deimos/templates/deimos/assignment_display.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<!-- deimos: assignment_display.html -->
{% load my_custom_tags %}
<li class="assignment-li course-li" data-assignment-id="{{ assigment.id }}">
<a href="{% url 'deimos:assignment_management' course_id=course.id assignment_id=assignment.id %}">
<div class="course-section assigment-section">
<div>
<span class="c-name assignment-name"><strong>{{assignment.name | safe}}</strong></span>
<p class="timestamp" style="display: none;">Created on {{ assignment.timestamp|date:"m/d/Y" }}</p>
<p class="timestamp" style="display: none;">Created on {{ assignment.timestamp|format_date }}</p>
{% if assignment.assigned_date %}
<p class="timestamp">Assigned on {{ assignment.assigned_date|date:"m/d/Y" }}</p>
<p class="timestamp">Assigned on {{ assignment.assigned_date|format_date }}</p>
{% endif %}
{% if assignment.due_date %}
<p class="timestamp">Due on {{ assignment.due_date|date:"m/d/Y" }}</p>
<p class="timestamp">Due on {{ assignment.due_date|format_date }}</p>
{% endif %}
</div>
{% if status %}
<button type="button" class="btn status edit-btn" style="position: absolute; bottom: 2%;">
Completed
</button>
{% endif %}
</div>

</a>
</li>
12 changes: 1 addition & 11 deletions deimos/templates/deimos/assignment_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
{% endif %}
</ul>
</div>
<<<<<<< HEAD


<nav class="navbar navbar-expand-lg navbar-light bg-light navigation" >
Expand All @@ -39,17 +38,8 @@
{% csrf_token %}
<div id="sf-container">
<input id="search-field" type="text" name="search_question" placeholder="search question"/>
=======
<nav class="navbar-custom">
<a class="nav-link home-btn" href="{% url 'deimos:index' %}">Home </a>
<a class="nav-link" href="{% url 'deimos:course_management' course_id=assignment.course.id %}">Assignments</a>
<a class="nav-link view-notes-btn" href="{% url 'deimos:note_management' course_id=assignment.course.id%}">View notes</a>
<a class="nav-link gradebook-btn" href="{% url 'deimos:gradebook' course_id=assignment.course.id%}">GradeBook</a>
</nav>
<div class="sf-container">
<input type="text" name="search_question" class="page-search search-field w-limit-50" data-name="question-name" placeholder="search question"/>
>>>>>>> 5369dd6a128dd246c7fbd65fdb4d32983c983b6b
</div>
</form>
<br/>
<br/>
<h4 class="suggestion original-size page-title">{{assignment.course.name}}: {{assignment.name}}</h4>
Expand Down
48 changes: 38 additions & 10 deletions deimos/templates/deimos/course_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
</ul>
</div>

<<<<<<< HEAD
<nav class="navbar navbar-expand-lg navbar-light bg-light navigation" >
<div class="container-fluid">
<ul class="navbar-nav mr-auto" style="list-style: none; display:flex;">
Expand All @@ -32,13 +31,6 @@
</li>
</div>
</nav>
=======
<nav class="navbar-custom">
<a class="nav-link home-btn" href="{% url 'deimos:index' %}">Home </a>
<a class="nav-link view-notes-btn" href="{% url 'deimos:note_management' course_id=course.id%}">View notes</a>
<a class="nav-link gradebook-btn" href="{% url 'deimos:gradebook' course_id=course.id%}">GradeBook</a>
</nav>
>>>>>>> 5369dd6a128dd246c7fbd65fdb4d32983c983b6b

<div class="home">
<div class="sf-container">
Expand All @@ -50,12 +42,48 @@ <h4>{{course.name}}</h4>

<!-- Display course's assignments -->
<ul class="courses course-list">
{% for assignment in assignments %}
{% include 'deimos/assignment_display.html' with assignment=assignment course=course %}
{% for assignment, status in assignments %}
{% include 'deimos/assignment_display.html' with assignment=assignment course=course status=status %}
{% endfor %}
</ul>
</div>

<div class="gradebook" style="display: none;">
{% include 'deimos/gradebook.html' with student=student assignment_student_grade=assignment_student_grade course_score=course_score %}
</div>

<script>
const navigation = document.querySelector('.navigation');
const homeDiv = document.querySelector('.home');
const gradebookDiv = document.querySelector('.gradebook')

function initial_view() {
homeDiv.style.display = 'none';
gradebookDiv.style.display= 'none';
}

navigation.addEventListener('click', () => {
target = event.target;
if (target.classList.contains('home-btn')) {
initial_view();
homeDiv.style.display = 'block';
}
else if(target.classList.contains('gradebook-btn')){
initial_view();
gradebookDiv.style.display= 'block';
}
})

const gradebookBtn = document.querySelector('.gradebook-btn')
const show_gradebookEvent = new Event('click',{
bubbles: true,
cancelable: true,
});
if(gradebookBtn.dataset.show_gradebook === "1"){
gradebookBtn.dispatchEvent(show_gradebookEvent)
}

</script>
{% endblock %}
{% block scripts %}
<script src="{% static 'deimos/js/search_generic.js' %}"></script>
Expand Down
5 changes: 1 addition & 4 deletions deimos/templates/deimos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ <h4>My courses</h4>
{% if course.name == "Practice_Test_Course" %}
{% else %}
{% include 'deimos/course_display.html' with course=course%}
<<<<<<< HEAD
{% endif %}
=======
{% empty %}
<h5 class="suggestion original-size">You are not yet registered for any course.
<h5 class="suggestion original-size" style="width:100%">You are not yet registered for any course.
Go to <a href="{% url 'astros:all_courses' %}">All courses</a> to see available courses.
</h5>
>>>>>>> 5369dd6a128dd246c7fbd65fdb4d32983c983b6b
{% endfor %}
</ul>

Expand Down
5 changes: 5 additions & 0 deletions deimos/templates/deimos/question_display.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
{{ question.text|safe }}</p><br/>
<p class="timestamp" style="display: none;">Created on {{ question.timestamp|date:"m/d/Y" }}</p>
</div>
{% if status %}
<button type="button" class="btn status edit-btn" style="position: absolute; bottom: 2%;">
Completed
</button>
{% endif %}
</div>
</a>
</li>
2 changes: 1 addition & 1 deletion deimos/templates/deimos/search_question.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h4 class="suggestion">Search Results...</h4><hr/>
{% for similar_question in similar_questions %}
{% include 'deimos/question_display.html' with question=similar_question.question assignment_id=similar_question.question.assignment.id course_id=similar_question.question.assignment.course.id%}
{% empty %}
<h4 class="suggestion original-size"> Enter your question in the search bar and hit enter.</h4>
<h4 class="suggestion original-size" style="width:100%"> Enter your question in the search bar and hit enter.</h4>
{% endfor %}
</ul>

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 21 additions & 1 deletion deimos/templatetags/my_custom_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django import template
from datetime import datetime

register = template.Library()

Expand All @@ -24,4 +25,23 @@ def divide(value, arg):
return int(result)
return result
except (ValueError, TypeError):
return 0
return 0

@register.filter
def format_date(due_date_str):
# Check if due_date_str is already a datetime object
if isinstance(due_date_str, datetime):
due_date = due_date_str
else:
# Parsing the date string
due_date = datetime.strptime(due_date_str, '%Y-%m-%d %H:%M:%S%z')
# Getting the day with the appropriate suffix
day = int(due_date.strftime('%d'))
if 4 <= day <= 20 or 24 <= day <= 30:
suffix = 'th'
else:
suffix = ['st', 'nd', 'rd'][day % 10 - 1]

# Formatting the date in the desired format
formatted_date = due_date.strftime(f'%B {day}{suffix}, %Y at %I:%M%p')
return formatted_date
6 changes: 2 additions & 4 deletions deimos/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
path('courses/<int:course_id>', views.course_management, name='course_management'),
path('courses/<int:course_id>/assignments/<int:assignment_id>', \
views.assignment_management, name='assignment_management'),
path('courses/<int:course_id>/assignments/<int:assignment_id>/<int:previous_course_id>', \
views.assignment_management, name='assignment_management'),

path('courses/<int:course_id>/assignments/<int:assignment_id>/questions/<int:question_id>',\
views.answer_question, name='answer_question'),
path('courses/<int:course_id>/assignments/<int:assignment_id>/questions/<int:question_id>/<int:student_id>/<int:upload_note_img>',\
Expand All @@ -40,5 +37,6 @@
path('courses/generate_practice_test/<int:practice_course_id>', views.generate_practice_test, name='generate_practice_test'),
path('courses/practice_test_settings/<int:course_id>/<int:practice_course_id>', views.practice_test_settings, name='practice_test_settings'),
path('courses/practice_test_settings/<int:course_id>/<int:practice_course_id>/<str:error_message>', views.practice_test_settings, name='practice_test_settings'),
path('courses/practice_test_page/<int:course_id>', views.practice_test_page, name='practice_test_page'),
path('courses/practice_test_page/<int:course_id>', views.practice_test_page, name='practice_test_page'),
path('courses/<int:course_id>/gradebook', views.gradebook, name='gradebook')
]
8 changes: 8 additions & 0 deletions deimos/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
from urllib.parse import unquote # Import unquote for URL decoding
from sympy import symbols, simplify

def encrypt_integer(n:int)->int:
assert n >= 0
return (n + 137)**2
def decrypt_integer(k: int)->int:
assert k >= 0
n = k**0.5 - 137
assert int(n) == n
return int(n)
def transform_expression(expr):
"""Insert multiplication signs between combined characters, except within trig functions."""
expression = remove_extra_spaces_around_operators(expr)
Expand Down
Loading

0 comments on commit 13265a7

Please sign in to comment.