Skip to content

Commit

Permalink
Merge pull request #95 from arielfayol37/polishing
Browse files Browse the repository at this point in the history
added status bar and improved display
  • Loading branch information
arielfayol37 authored Nov 12, 2023
2 parents ec00e74 + 9f88f57 commit bf84f35
Show file tree
Hide file tree
Showing 36 changed files with 844 additions and 569 deletions.
29 changes: 11 additions & 18 deletions astros/static/astros/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ li{
height: 60vh;
padding: 20px;
border-radius: 5px;
/*box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);*/
background-color: white;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);

position:relative;

display: flex;
flex-direction: column;

}
/* Assignment displays need less height */
.assignment-li {
Expand All @@ -279,14 +279,13 @@ li{


div.course-section {
display: flex;
flex-direction: column;
position: relative;
height: 70%;
}
/* Set the height of .image-container to 50% of the height of .course-li */
div.image-container {
position: absolute;
top: 0;
left: 0;
height: 85%;
width: 100%; /* Make the image container full-width within .course-li */
overflow: hidden; /* Ensure the image doesn't overflow the container */
Expand All @@ -295,22 +294,16 @@ div.image-container {
/* Style the image to fill the .image-container */
div.image-container img.course-image {
height: 100%;
width: 100%;
/*max-height: 100%; Ensure the image height fits within the container */
/*max-width: 100%; Ensure the image width fits within the container */
width: 100%;
object-fit: cover; /* Maintain aspect ratio and cover the container */
border-radius: 10px 10px 10px 10px; /* Optional: Add border radius to the top corners */
border-radius: 10px; /* Optional: Add border radius to the top corners */
}
div.c-text {
position: absolute;
top: 87%;
height: 30%;
.c-text {
height: 15%;
}

.a-text.c-text {
top: 25%;
.c-description {
overflow: hidden;
}

.edit-section {
bottom: 5%;
position: absolute;
Expand Down
8 changes: 2 additions & 6 deletions astros/templates/astros/prof_course_display.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
</div>
<div class="c-text">
<span class="c-name course-name"><strong>{{course.name}}</strong></span>
<p class="c-description">{% if course.description|length > 90 %}
{{ course.description|slice:":90" }}...
{% else %}
{{ course.description }}
{% endif %}</p>

<p class="c-description">
{{ course.description }}</p>
<p class="timestamp" style="display: none;">Created on {{ course.timestamp|date:"m/d/Y" }}</p>
</div>
</div>
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified deimos/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file modified deimos/__pycache__/views.cpython-311.pyc
Binary file not shown.
19 changes: 19 additions & 0 deletions deimos/migrations/0020_alter_questionstudent_num_units_attempts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.3 on 2023-11-10 23:36

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('deimos', '0019_note_title_notetemporary_title'),
]

operations = [
migrations.AlterField(
model_name='questionstudent',
name='num_units_attempts',
field=models.IntegerField(blank=True, default=0, null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
]
18 changes: 18 additions & 0 deletions deimos/migrations/0021_questionstudent_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-11 22:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('deimos', '0020_alter_questionstudent_num_units_attempts'),
]

operations = [
migrations.AddField(
model_name='questionstudent',
name='is_complete',
field=models.BooleanField(default=False),
),
]
Binary file not shown.
Binary file not shown.
60 changes: 59 additions & 1 deletion deimos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from phobos.models import Course, Question, User, Assignment, VariableInstance, QuestionChoices
from django.core.validators import MaxValueValidator, MinValueValidator
from .utils import *
from datetime import date
class Student(User):
"""
Student class to handle students in the platform.
Expand Down Expand Up @@ -115,7 +116,8 @@ class QuestionStudent(models.Model):
success = models.BooleanField(default=False)
var_instances = models.ManyToManyField(VariableInstance, related_name='question_students')
instances_created = models.BooleanField(default=False)
num_units_attempts = models.IntegerField(null=True, blank=True, validators=[MinValueValidator(0)])
num_units_attempts = models.IntegerField(default=0, null=True, blank=True, validators=[MinValueValidator(0)])
is_complete = models.BooleanField(default=False)
def create_instances(self):
"""
Get variable instances from the variables associated to the question.
Expand Down Expand Up @@ -231,6 +233,62 @@ def get_num_attempts(self):
Calculates and returns the number of attempts on a question by a user.
"""
return self.attempts.count()
def get_too_many_attempts(self):
"""
Returns True if no attempts left for this question
"""
if self.question.answer_type.startswith('STRUCT'):
return self.get_num_attempts() >= self.question.struct_settings.max_num_attempts
else:
return self.get_num_attempts() >= self.question.mcq_settings.mcq_max_num_attempts
def get_units_too_many_atempts(self):
"""
Returns True if no attempts left for units in this question.
"""
if not self.question.answer_type.startswith('STRUCT'):
return True
return self.num_units_attempts >= self.question.struct_settings.units_num_attempts
def get_status(self):
"""
Returns True if the question (including sub questions) have been completed,
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

def get_potential(self, no_unit = False):
"""
Returns the fraction of number of points the student can get for that question.
If no_unit, then we don't add the units points in the potential
"""
try:
days_overdue = max(0, (date.today() - self.question.assignment.due_date.date()).days)
overall_percentage = max(self.question.assignment.grading_scheme.floor_percentage, \
1 - days_overdue * self.question.assignment.grading_scheme.late_sub_deduct)
except:
overall_percentage = 1
# overall_percentage is the possible percentage of points a student can get.
# it is used to reduce the points in case of late submissions.
t = int(not self.get_too_many_attempts())
t_u = int(not self.get_units_too_many_atempts())
n_a = self.get_num_attempts() # number of attempts
if self.question.answer_type.startswith('STRUCT'):
p_u = self.question.struct_settings.percentage_pts_units
d = self.question.struct_settings.deduct_per_attempt # percentage deduct per attempt
if no_unit:
potential = t * (1 - p_u + ((d * n_a) * (p_u - 1)))
else:
potential = t * (1 - p_u + ((d * n_a) * (p_u - 1))) + p_u * t_u # This is the most use and general
# case for structural questions.
else:
d = self.question.mcq_settings.mcq_deduct_per_attempt
potential = t * (1 - (d * n_a))
return potential * overall_percentage

def __str__(self):
return f"Question-Student:{self.question} {self.student.username}"

Expand Down
84 changes: 45 additions & 39 deletions deimos/static/deimos/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -374,70 +374,59 @@ li{

.course-li {
/*font-family: 'Courier New', Courier, monospace;*/
display: flex;
font-family:'Nebula', 'Times New Roman', Times, serif;
flex: 1 0 calc(33.33% - 20px); /* Distribute the items equally in three columns */
height: 60vh;
padding: 20px;
border-radius: 5px;
position:relative;
background-color: white;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
position:relative;
overflow: hidden;
color:black;

}
.course-li a {
color: inherit;
width: 100%;
}
.course-li a:hover {
text-decoration: none;
color: inherit;
}
/* Assignment displays need less height */
.assignment-li {
height: 25vh;
}


div.course-section {
position: relative;
height: 70%;
max-height: 100%;
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
}
/* Set the height of .image-container to 50% of the height of .course-li */
div.image-container {
position: absolute;
top: 0;
left: 0;
height: 85%;
height: 70%;
width: 100%; /* Make the image container full-width within .course-li */
overflow: hidden; /* Ensure the image doesn't overflow the container */
/* overflow: hidden; Ensure the image doesn't overflow the container */
}
.c-text {
height: 30%;
overflow: hidden;
}

/* Style the image to fill the .image-container */
div.image-container img.course-image {
height: 100%;
width: 100%;
/*max-height: 100%; Ensure the image height fits within the container */
/*max-width: 100%; Ensure the image width fits within the container */
object-fit: cover; /* Maintain aspect ratio and cover the container */
border-radius: 10px 10px 10px 10px; /* Optional: Add border radius to the top corners */
}
div.c-text {
position: absolute;
top: 87%;
height: 30%;
}

.a-text.c-text {
top: 25%;
}

.edit-section {
bottom: 5%;
position: absolute;
border-radius: 10px;
object-fit: cover;
}
.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;
}



Expand Down Expand Up @@ -595,7 +584,24 @@ div.c-text {
justify-content:space-between;
align-items: center;
}
.question-block {
width:90%;
}
.status-container {
border-radius: 8px;
box-shadow: 13px 13px 20px #cbced1;
display: flex; /* Enable Flexbox */
flex-direction: row; /* Align children in a row */
justify-content: space-evenly; /* Distribute space around items */
align-items: center; /* Align items vertically at the center */
font-size:x-small;
width:fit-content;
}

.status-container > div {
margin: 0 10px; /* Optional: Add some space between the divs */
color: gray;
}
.image-in-formatted {
max-width: 90%; /* Limit image width to 100% of parent div's width */
max-height: 300px; /* Limit image height to 100% of parent div's height */
Expand Down Expand Up @@ -854,9 +860,6 @@ ion-icon:hover{
.question-li {
height: 30vh;
}
.a-text.c-text {
top: 15%;
}
.sf-container {
display: flex;
flex-direction: row;
Expand All @@ -872,6 +875,9 @@ ion-icon:hover{

}
@media screen and (max-width: 450px){
.status-container {
display: none;
}
div.message {
top: 14%;
left:30%;
Expand Down
Loading

0 comments on commit bf84f35

Please sign in to comment.