summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFOSSEE Git User2018-11-02 19:32:18 +0530
committerFOSSEE Git User2018-11-02 19:32:18 +0530
commit01edb9311edd21031dd551153b2b8d31399d0ecd (patch)
tree6e40277e3d99b471b15eba896b5eaf4cf0257d00
parent91aa9a2845f894d6bcffc674faf9b70a9438e5fc (diff)
parent3f6123d24af7e0dd76323496e360ecdeb733ad37 (diff)
downloadnccps-2018-01edb9311edd21031dd551153b2b8d31399d0ecd.tar.gz
nccps-2018-01edb9311edd21031dd551153b2b8d31399d0ecd.tar.bz2
nccps-2018-01edb9311edd21031dd551153b2b8d31399d0ecd.zip
Merge branch 'master' of https://github.com/FOSSEE/nccps-2018
-rwxr-xr-x.gitignore3
-rw-r--r--static/website/templates/dwsim-quiz.html42
-rw-r--r--static/website/templates/job-fair.html60
-rw-r--r--static/website/templates/navbar.html5
-rw-r--r--static/website/templates/question_list.html1
-rw-r--r--static/website/templates/take_quiz.html75
-rw-r--r--static/website/templates/view_solutions.html40
-rw-r--r--website/admin.py10
-rwxr-xr-xwebsite/forms.py8
-rw-r--r--website/migrations/0005_uploadmodel.py22
-rw-r--r--website/models.py14
-rw-r--r--website/urls.py3
-rw-r--r--website/views.py153
13 files changed, 343 insertions, 93 deletions
diff --git a/.gitignore b/.gitignore
index 08cbbb1..921172a 100755
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,6 @@ db.sqlite3
#VScode
.vscode/
+
+#
+uploads/
diff --git a/static/website/templates/dwsim-quiz.html b/static/website/templates/dwsim-quiz.html
index 1265c93..a0c459a 100644
--- a/static/website/templates/dwsim-quiz.html
+++ b/static/website/templates/dwsim-quiz.html
@@ -4,12 +4,48 @@
<html lang="en">
{% include 'header.html' %}
<body data-spy="scroll" data-target="#site-nav">
-<div class="se-pre-con"></div>
+<!-- <div class="se-pre-con"></div> -->
{% include 'navbar.html' %}
{% block content %}
<section id="dwsimquiz" class="section dwsimquiz">
- <div class="container">
+ <div class="container">
+ <h2> DWSIM Flowsheeting Creation Competition</h2>
+ <br>
+ <ul>
+ <li> Top 8 participants in the leaderboard by end of 02-11-2018, 11:59 PM are eligible for this competition.</li>
+ <li> These participants will receive the problem statement to be solved in DWSIM directly through e-mail by 03-11-2018, 12:00 noon.</li>
+ <li>Participants have to propose the assigned flowsheet in the DWSIM Flowsheeting Project webpage using the proposal form
+ <a href="https://dwsim.fossee.in/flowsheeting-project/proposal" style="color: #cc0000">here.</a>
+ The proposal should be submitted by 04-11-2018, 12:00 noon.</li>
+ <li>In case of any issues regarding submission of proposal, please write to us at <a href="mailto:contact-dwsim@fossee.in" style="color: hsl(236, 95%, 50%)">contact-dwsim@fossee.in</a> before the deadline for proposal submission.</li>
+ <li>Participants can start creating the simulation for the assigned flowsheet as soon as they submit the proposal. Participants need not wait for approval of the proposal to start working on the flowsheet.</li>
+ <li>No extension in deadline will be granted for submission of proposal. If any of the participant doesn’t submit the proposal by the given deadline, flowsheet will be assigned to the next participant i.e. the 9th participant in the leaderboard and so on.</li>
+ <li>Solve the flowsheet using <u>DWSIM Version 5.4 Update 2.</u></li>
+ <li>Flowsheet and a well written abstract should be submitted <a href="https://dwsim.fossee.in/flowsheeting-project/abstract-code/upload" style="color: #cc0000">here.</a></li>
+ <li>Flowsheet creation competition would carry 50 marks in total divided in the following manner.</li>
+ <ol>
+ <li>Approach to the flowsheet - 10</li>
+ <li>Validation / Accuracy of results in the flowsheet - 20 </li>
+ <li>Presentation of the flowsheet - 10 </li>
+ <li>Abstract - 10</li>
+ </ol>
+ <li>Please adhere to the guidelines for the flowsheet development and abstract mentioned <a href="https://dwsim.fossee.in/flowsheeting-project/coding-guidelines-flowsheeting" style="color: #cc0000">here.</a></li>
+ <li>The last date for submission of flow sheet is 8-11-2018, 11:59 PM.</li>
+ <li>Submission of correct flowsheet by 04-11-2018, 11:59 PM will attract bonus of 10 marks.</li>
+ <li>Submission of correct flowsheet by 05-11-2018, 11:59 PM will attract bonus of 7 marks.</li>
+ <li> Submission of correct flowsheet by 06-11-2018, 11:59 PM will attract bonus of 5 marks.</li>
+ <li>If the flowsheet is not as per the given problem statement, participants will be given chance to correct and re-upload the flowsheet. In that case, no bonus marks will be rewarded.</li>
+ <li>Decision of the NCCPS team regarding marking of the flowsheeting competition will be final.</li>
+ <br>
+ </ul>
+ </div>
+
+ <br>
+
+
+<br><br>
+ <!-- <div class="container">
<div class="row">
<div class="col-md-12" >
@@ -47,7 +83,7 @@
<p style="text-align: center;"><strong>Link for Quiz will be active from 15-10-2018</strong></p>
</div>
</div>
- </div>
+ </div> -->
</section>
{% endblock %}
diff --git a/static/website/templates/job-fair.html b/static/website/templates/job-fair.html
new file mode 100644
index 0000000..fedf936
--- /dev/null
+++ b/static/website/templates/job-fair.html
@@ -0,0 +1,60 @@
+{% extends "base.html" %}
+{% load static %}
+<!DOCTYPE html>
+<html lang="en">
+{% include 'header.html' %}
+<body data-spy="scroll" data-target="#site-nav">
+<!-- <div class="se-pre-con"></div> -->
+
+ {% include 'navbar.html' %}
+ {% block content %}
+ <section id="jobfair" class="section jobfair" style="font-weight: 400;">
+ <h3 class="section-title" style="margin-left: 6%;">Job Fair</h3>
+ <div class="container">
+ <div class="panel-group" id="accordion">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h4 class="panel-title">
+ <a data-toggle="collapse" data-parent="#accordion" href="#employers">Employers</a>
+ </h4>
+ </div>
+ <div id="employers" class="panel-collapse collapse" style="padding: 20px;">
+ <h3>For Employers</h3>
+
+ <h4>Introduction</h4>
+ <p class="text-justify">The conference committee is excited to invite your esteemed organisation to the job fair to be conducted in connection with the National Conference on Chemical Process Simulation-2018 to be held on 26 November 2018 at IIT Bombay. </p>
+
+ <p class="text-justify">The conference will bring together people from both industry and academia. An important aim of this job fair is to offer networking opportunities with prospective recruits. Your organisation can meet bright chemical engineering students who are experts in process modelling and simulation. We have sent invites to more than 300 chemical engineering departments across the country.</p>
+ <span>What we offer?</span>
+ <ul>
+ <li>Meeting bright chemical engineering students who are experts in process modelling and simulation</li>
+ <li>Accommodation for the company/ organisation representatives (for 2 people) for one night</li>
+ <li>One room at the venue where your organization can meet and interact with prospective recruits</li>
+ </ul>
+ <!-- <p>If you are interested, please fill the <a href="" target="_blank">form</a> with the details.</p> -->
+ </div>
+ </div>
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h4 class="panel-title">
+ <a data-toggle="collapse" data-parent="#accordion" href="#students">Students</a>
+ </h4>
+ </div>
+ <div id="students" class="panel-collapse collapse" style="padding: 20px;">
+
+ <h3>For Students</h3>
+
+ <h4>Introduction</h4>
+ <p class="text-justify">The conference committee is pleased to invite to the job fair which is to be conducted in connection with the the National Conference on Chemical Process Simulation-2018 to be held at IIT Bombay on 26 November 2018.</p>
+
+ <p class="text-justify">We have invited many companies to participate in the job fair. Some of the companies who have confirmed of their presence are Equinox, Ingenero,......
+ <!-- If you are interested in meeting the companies, please fill this <a href="https://docs.google.com/forms/d/1cArwdS8mLZ45vFLpwejJaYZvnOCLWP2dsejy6bTqnmY/viewform" target="_blank">form</a>--></p>
+
+ </div>
+ </div>
+ </div>
+ </div>
+ </section>
+
+
+ {% endblock %}
diff --git a/static/website/templates/navbar.html b/static/website/templates/navbar.html
index d820d5d..15814f7 100644
--- a/static/website/templates/navbar.html
+++ b/static/website/templates/navbar.html
@@ -36,10 +36,12 @@
<!-- <li><a data-scroll href="{{SITE_URL}}/#submit">CFP</a></li> -->
<li><a data-scroll href="{{SITE_URL}}/#coc">C0C</a></li>
<li><a data-scroll href="{{SITE_URL}}/#schedule">Schedule</a></li>
- <li><a data-scroll href="{{SITE_URL}}/#location">Venue</a></li>
+
+ <!-- <li><a data-scroll href="{{SITE_URL}}/#location">Venue</a></li> -->
<!--<li><a data-scroll href="{{SITE_URL}}/#organiser">Organiser</a></li> -->
<li><a data-scroll href="{{SITE_URL}}/#contact-us">Contact Us</a></li>
<li><a href="{% url 'website:dwsimquiz' %}">DWSIM QUIZ</a></li>
+ <!-- <li><a href="{% url 'website:jobfair' %}">Job Fair</a></li> -->
<li><a href="{% url 'website:cfp' %}">cfp</a></li>
{% if user.is_authenticated %}
<li class="dropdown">
@@ -54,6 +56,7 @@
{% else %}
<!--<li><a href="{% url 'website:proposal' %}">Submit your Paper</a></li> -->
<li><a href="{% url 'website:quiz_intro' %}">Take Quiz</a></li>
+ <li><a href="{% url 'website:view_solutions' %}">View Solutions</a></li>
{% endif %}
<!-- <li><a href="{{SITE_URL}}/#registration">Book your Ticket</a></li> -->
<li><a href="{% url 'auth:logout' %}?next=/nccps-2018"><i class="fa fa-sign-out"></i>&nbsp;Logout</a></li>
diff --git a/static/website/templates/question_list.html b/static/website/templates/question_list.html
index cc11098..65b571a 100644
--- a/static/website/templates/question_list.html
+++ b/static/website/templates/question_list.html
@@ -13,7 +13,6 @@
<br>
<a href="{% url 'website:add_questions' %}" ><button class="btn-default btn-warning"> Add Question </button></a>
<a href="{% url 'website:leaderboard' %}" ><button class="btn-default btn-info"> LeaderBoard </button></a>
-
<br><br>
</div>
diff --git a/static/website/templates/take_quiz.html b/static/website/templates/take_quiz.html
index 15bb05e..3e62018 100644
--- a/static/website/templates/take_quiz.html
+++ b/static/website/templates/take_quiz.html
@@ -3,7 +3,9 @@
{% load static %}
{% block content %}
<br><br><br><br>
-<div class="container">
+
+{% if set_visible %}
+ <div class="container">
{% if messages %}
<ul class="messages">
@@ -43,6 +45,75 @@
<button class="btn btn-primary center-block" type="Submit">Submit</button> <br>
</form>
{% endif %}
+ </div>
+
+ {% else %}
+
+ <div class="container">
+ <h2> DWSIM Flowsheeting Creation Competition</h2>
+ <br>
+ <ul>
+ <li> Top 8 participants in the leaderboard by end of 02-11-2018, 11:59 PM are eligible for this competition.</li>
+ <li> These participants will receive the problem statement to be solved in DWSIM directly through e-mail by 03-11-2018, 12:00 noon.</li>
+ <li>Participants have to propose the assigned flowsheet in the DWSIM Flowsheeting Project webpage using the proposal form
+ <a href="https://dwsim.fossee.in/flowsheeting-project/proposal" style="color: #cc0000">here.</a>
+ The proposal should be submitted by 04-11-2018, 12:00 noon.</li>
+ <li>In case of any issues regarding submission of proposal, please write to us at <a href="mailto:contact-dwsim@fossee.in" style="color: hsl(236, 95%, 50%)">contact-dwsim@fossee.in</a> before the deadline for proposal submission.</li>
+ <li>Participants can start creating the simulation for the assigned flowsheet as soon as they submit the proposal. Participants need not wait for approval of the proposal to start working on the flowsheet.</li>
+ <li>No extension in deadline will be granted for submission of proposal. If any of the participant doesn’t submit the proposal by the given deadline, flowsheet will be assigned to the next participant i.e. the 9th participant in the leaderboard and so on.</li>
+ <li>Solve the flowsheet using <u>DWSIM Version 5.4 Update 2.</u></li>
+ <li>Flowsheet and a well written abstract should be submitted <a href="https://dwsim.fossee.in/flowsheeting-project/abstract-code/upload" style="color: #cc0000">here.</a></li>
+ <li>Flowsheet creation competition would carry 50 marks in total divided in the following manner.</li>
+ <ol>
+ <li>Approach to the flowsheet - 10</li>
+ <li>Validation / Accuracy of results in the flowsheet - 20 </li>
+ <li>Presentation of the flowsheet - 10 </li>
+ <li>Abstract - 10</li>
+ </ol>
+ <li>Please adhere to the guidelines for the flowsheet development and abstract mentioned <a href="https://dwsim.fossee.in/flowsheeting-project/coding-guidelines-flowsheeting" style="color: #cc0000">here.</a></li>
+ <li>The last date for submission of flow sheet is 8-11-2018, 11:59 PM.</li>
+ <li>Submission of correct flowsheet by 04-11-2018, 11:59 PM will attract bonus of 10 marks.</li>
+ <li>Submission of correct flowsheet by 05-11-2018, 11:59 PM will attract bonus of 7 marks.</li>
+ <li> Submission of correct flowsheet by 06-11-2018, 11:59 PM will attract bonus of 5 marks.</li>
+ <li>If the flowsheet is not as per the given problem statement, participants will be given chance to correct and re-upload the flowsheet. In that case, no bonus marks will be rewarded.</li>
+ <li>Decision of the NCCPS team regarding marking of the flowsheeting competition will be final.</li>
+ <br>
+ </ul>
+ </div>
+
+ <br>
+
+ <section>
+ <div class="container">
+ <h3>Leaderboard</h3>
+ <table border="1" width="90%">
+ <thead>
+ <tr>
+ <th>Participant Name</th>
+ &nbsp
+ <th>Score</th>
+ </tr>
+ </thead>
+
+ {% for participant in leaderboard %}
+ <tbody>
+ <tr>
+ <td>
+ &nbsp {{ participant.0.user.get_full_name }}
+ </td>
+
+ <td>
+ &nbsp {{ participant.1 }}
+ </td>
+ </tr>
+ </tbody>
+ {% endfor %}
+ </table>
+
+ </div>
+ </section>
+<br><br>
+
+ {% endif %}
-</div>
{% endblock %} \ No newline at end of file
diff --git a/static/website/templates/view_solutions.html b/static/website/templates/view_solutions.html
new file mode 100644
index 0000000..2074dcb
--- /dev/null
+++ b/static/website/templates/view_solutions.html
@@ -0,0 +1,40 @@
+{% extends "base.html" %}
+
+{% load static %}
+ {% block content %}
+ <br><br>
+ <br><br>
+
+ <div class="container">
+ {% if set_visible %}
+ <form method="POST">
+ {% csrf_token %}
+ <button class="btn-default btn-info btn-lg" name="Download">Download Model Files</button>
+ </form>
+ <br><br>
+
+ <table style="width:100%" class="table table-hover">
+ <thead>
+ <tr>
+ <th>Question</th>
+ <th>Answer</th>
+ </tr>
+ </thead>
+ {% for q in question_ans_list %}
+ <tbody>
+ <tr>
+ <td>{{ q.question }} </td>
+ <td>{{ q.correct_answer }} </td>
+ </tr>
+ </tbody>
+ {% endfor %}
+ </table>
+
+ {% else %}
+ <div class="jumbotron">
+ <p>This page will be visible from <strong>15-11-2018</strong></p>
+ </div>
+ {% endif %}
+</div>
+
+{% endblock %} \ No newline at end of file
diff --git a/website/admin.py b/website/admin.py
index c6a7d78..7a6ba2e 100644
--- a/website/admin.py
+++ b/website/admin.py
@@ -3,7 +3,8 @@ import csv
from django.http import HttpResponse
from .models import( Profile,
AnswerPaper,
- Question
+ Question,
+ UploadModel
)
try:
@@ -45,7 +46,12 @@ class AnswerPaperAdmin(admin.ModelAdmin):
+class UploadModelAdmin(admin.ModelAdmin):
+ list_display = ['question']
+
+
# Register your models here.
admin.site.register(Profile, ProfileAdmin)
admin.site.register(AnswerPaper, AnswerPaperAdmin)
-admin.site.register(Question, QuestionAdmin) \ No newline at end of file
+admin.site.register(Question, QuestionAdmin)
+admin.site.register(UploadModel, UploadModelAdmin) \ No newline at end of file
diff --git a/website/forms.py b/website/forms.py
index bee9ba9..9df1fcb 100755
--- a/website/forms.py
+++ b/website/forms.py
@@ -398,11 +398,3 @@ class QuestionUploadForm(forms.ModelForm):
'question_day': DateInput(),
}
-
-#To upload model for each question
-'''
-class UploadModelForm(forms.ModelForm):
- class Meta:
- model = UploadModel
- fields = ['model_file']
-'''
diff --git a/website/migrations/0005_uploadmodel.py b/website/migrations/0005_uploadmodel.py
new file mode 100644
index 0000000..a357f95
--- /dev/null
+++ b/website/migrations/0005_uploadmodel.py
@@ -0,0 +1,22 @@
+# Generated by Django 2.1 on 2018-10-31 05:40
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('website', '0004_auto_20181012_0951'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='UploadModel',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('model_file', models.FileField(upload_to='uploads/')),
+ ('question', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='website.Question')),
+ ],
+ ),
+ ]
diff --git a/website/models.py b/website/models.py
index e482453..ad6b3e4 100644
--- a/website/models.py
+++ b/website/models.py
@@ -36,10 +36,6 @@ def get_document_dir(instance, filename):
return '%s/attachment/%s/%s.%s' % (instance.user, instance.proposal_type, fname+'_'+str(instance.user), fext)
-def attachments(instance, filename):
- return os.sep.join((instance.workshoptype_name.replace(" ", '_'), filename))
-
-
class Proposal(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE,)
name_of_authors = models.CharField(max_length=200, default='None')
@@ -121,6 +117,9 @@ class Question(models.Model):
# The date for the question.
question_day = models.DateField()
+ def __str__(self):
+ return u"{0} || {1}".format(self.correct_answer, self.question_day)
+
class AnswerPaper(models.Model):
@@ -131,8 +130,7 @@ class AnswerPaper(models.Model):
#To upload model for each question
-'''
+
class UploadModel(models.Model):
- question = models.ForeignKey(Question, on_delete=models.CASCADE, blank=True, null=True)
- model_file = models.FileField(upload_to=attachments)
-''' \ No newline at end of file
+ question = models.ForeignKey(Question, on_delete=models.CASCADE, blank=True)
+ model_file = models.FileField(upload_to='uploads/')
diff --git a/website/urls.py b/website/urls.py
index f0dbe60..aaed150 100644
--- a/website/urls.py
+++ b/website/urls.py
@@ -17,10 +17,11 @@ urlpatterns = [
#path('accounts/register', views.userregister, name='userregister'),
re_path(r'^dwsimquiz/$', views.dwsimquiz, name='dwsimquiz'),
+ re_path(r'^jobfair/$', views.jobfair, name='jobfair'),
re_path(r'^cfp/$', views.cfp, name='cfp'),
#re_path(r'^quiz/$', views.quiz_view, name='quiz_view'),
re_path(r'^question_list/$', views.question_list, name='question_list'),
- #re_path(r'^uploadmodel/$', views.uploadmodel, name='uploadmodel'),
+ re_path(r'^view_solutions/$', views.view_solutions, name='view_solutions'),
re_path(r'^add_questions/$', views.add_questions, name='add_questions'),
re_path(r'^edit_question/(?P<qid>\d+)$', views.edit_question, name='edit_question'),
re_path(r'^take_quiz/$', views.take_quiz, name='take_quiz'),
diff --git a/website/views.py b/website/views.py
index a330387..e40661a 100644
--- a/website/views.py
+++ b/website/views.py
@@ -1,6 +1,6 @@
# Create your views here.
-from django.http import HttpResponse
+from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
from django.shortcuts import render_to_response, render, redirect
from django.template import loader
@@ -13,7 +13,7 @@ from django.views.decorators.csrf import (csrf_exempt, csrf_protect,
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from website.models import (Proposal, Comments, Ratings, Question,
- AnswerPaper, Profile)
+ AnswerPaper, Profile, UploadModel)
from website.forms import (ProposalForm, UserRegisterForm, UserRegistrationForm,
UserLoginForm, WorkshopForm,QuestionUploadForm
@@ -24,11 +24,16 @@ from django.contrib.auth import authenticate, login, logout
from datetime import datetime, date
from django import template
from django.core.mail import EmailMultiAlternatives
-import os
+import os, re
from nccps2018.config import *
from website.send_mails import send_email
from django.contrib.auth.models import Group
from django.contrib import messages
+from zipfile import ZipFile
+try:
+ from StringIO import StringIO as string_io
+except ImportError:
+ from io import BytesIO as string_io
@@ -57,7 +62,12 @@ def dwsimquiz(request):
context = {}
template = loader.get_template('dwsim-quiz.html')
return HttpResponse(template.render(context, request))
-
+
+def jobfair(request):
+ context = {}
+ template = loader.get_template('job-fair.html')
+ return HttpResponse(template.render(context, request))
+
# def proposal(request):
# context = {}
# template = loader.get_template('proposal.html')
@@ -739,17 +749,13 @@ def status_change(request):
Pardon the unsolicited advice but it is important that you plan your presentations carefully. 15 minutes is a good amount of time to communicate your central idea. Most really good TED talks finish in 15 minutes. Keep your talk focussed and please do rehearse your talk and slides to make sure it flows well. If you need help with this, the program chairs can try to help you by giving you some early feedback on your slides. Just upload your slides before 26th on the same submission interface and we will go over it once. For anything submitted after 26th we may not have time to comment on but will try to give you feedback. Please also keep handy a PDF version of your talk in case your own laptops have a problem.
Please confirm your participation. The schedule will be put up online by end of day. We look forward to hearing your talk.
\n\nYou will be notified regarding instructions of your talk via email.\n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay"""
- elif proposal.proposal_type == 'WORKSHOP':
- subject = "NCCPS 2018 - Workshop Proposal Accepted"
- message = """Dear """+proposal.user.first_name+""",
- Thank you for your excellent submissions! We are pleased to accept your workshop. Due to the large number of submissions, we have decided to accept 8 workshops and give all the selected workshops 2 hours each. Please plan for 1 hour and 55 minutes in order to give the participants a 10 minute break between workshops for tea.
-
-The tentative schedule will be put up on the website shortly. Please confirm your participation and do provide detailed instructions for the participants (and the organizers if they need to do something for you) by replying to this email. These instructions will be made available on the conference website. Installation is often a problem, so please make sure your instructions are simple and easy to follow. If you wish, we could allow some time on the previous day for installation help. Let us know about this. Also, do not waste too much time on installation during your workshop.
-
-We strongly suggest that you try to plan your workshops carefully and focus on doing things hands-on and not do excessive amounts of theory. Try to give your participants a decent overview so they can pick up additional details on their own. It helps to pick one or two overarching problems you plan to solve and work your way through the solution of those.
-\n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay"""
- #send_mail(subject, message, sender_email, to)
- # context.update(csrf(request))
+ #email = EmailMultiAlternatives(
+ # subject, '',
+ # sender_email, to,
+ # headers={"Content-type": "text/html;charset=iso-8859-1"}
+ #)
+ #email.attach_alternative(message, "text/html")
+ #email.send(fail_silently=True)
proposals = Proposal.objects.all()
context['proposals'] = proposals
context['user'] = user
@@ -1089,6 +1095,30 @@ def edit_question(request, qid=None):
def quiz_intro(request):
return render(request, 'quiz_intro.html')
+
+def calculate_leader():
+ profiles = Profile.objects.all()
+ leaderboard = {p:0 for p in profiles}
+ marks = {
+ '5': [date(2018, 10, 29), date(2018, 11, 4)],
+ '10': [date(2018, 11, 5), date(2018, 11, 12)]
+ }
+ answers = AnswerPaper.objects.all()
+
+ for i in leaderboard:
+ profiles = AnswerPaper.objects.filter(participant=i)
+ for p in profiles:
+ if p.validate_ans==1:
+ if marks['5'][0] <= p.answered_q.question_day <= marks['5'][1]:
+ leaderboard[i] +=5
+ else:
+ leaderboard[i] +=1
+
+
+ sorted_leaderboard = sorted(leaderboard.items(), key=lambda kv: kv[1])
+ return sorted_leaderboard
+
+
@login_required
def take_quiz(request):
user = request.user
@@ -1157,67 +1187,56 @@ def take_quiz(request):
except:
pass
+ today = datetime.today().date()
+ if today > date(2018, 11, 4):
+ set_visible = 0
+ else:
+ set_visible = 1
+ sorted_leaderboard = calculate_leader()
+
return render(request, 'take_quiz.html', {
- 'question_list' : questions
+ 'question_list' : questions,
+ 'set_visible': set_visible,
+ "leaderboard": sorted_leaderboard[::-1]
})
-def leaderboard(request):
- profiles = Profile.objects.all()
- leaderboard = {p:0 for p in profiles}
- marks = {
- '5': [date(2018, 10, 29), date(2018, 11, 4)],
- '10': [date(2018, 11, 5), date(2018, 11, 12)]
- }
- answers = AnswerPaper.objects.all()
-
- for i in leaderboard:
- profiles = AnswerPaper.objects.filter(participant=i)
- for p in profiles:
- if p.validate_ans==1:
- if marks['5'][0] <= p.answered_q.question_day <= marks['5'][1]:
- leaderboard[i] +=5
- elif marks['10'][0] <= p.answered_q.question_day <= marks['10'][1]:
- leaderboard[i] +=10
- else:
- leaderboard[i] +=1
-
- sorted_leaderboard = sorted(leaderboard.items(), key=lambda kv: kv[1])
+def leaderboard(request):
+ sorted_leaderboard = calculate_leader()
return render(request, "leaderboard.html", {'leaderboard': sorted_leaderboard[::-1]})
-'''
@login_required
-def uploadmodel(request):
+def view_solutions(request,id=None):
+ ''''Show solutions to participants after a specific date'''
+ question_ans_list = Question.objects.all()
+ today = datetime.today().date()
+ if today < date(2018, 11, 15):
+ set_visible = 0
+ else:
+ set_visible = 1
+
if request.method == 'POST':
- data = request.body.decode("utf-8").split('&')
- date = data[1].replace("qdate=", "")
- date = datetime.strptime(date, "%Y-%m-%d").date()
- question_list = Question.objects.all()
- try:
- question_obj = Question.objects.get(question_day=date)
- print(question_obj)
- messages.info(request, 'Uploaded Successfully!')
- except:
- messages.error(request, 'No question uploaded for mentioned date')
+ filename = UploadModel.objects.all()
+ attachment_path = os.path.dirname(filename[0].model_file.path)
+ zipfile_name = string_io()
+ zipfile = ZipFile(zipfile_name, "w")
+ attachments = os.listdir(attachment_path)
+ for file in attachments:
+ file_path = os.sep.join((attachment_path, file))
+ zipfile.write(file_path, os.path.basename(file_path))
+ zipfile.close()
+ zipfile_name.seek(0)
+ response = HttpResponse(content_type='application/zip')
+ response['Content-Disposition'] = 'attachment; filename={0}.zip'.format(
+ "Solutions"
+ )
+ response.write(zipfile_name.read())
+ return response
-
- form = UploadModelForm(request.POST)
- if form.is_valid():
- uploadForm = form.save(commit=False)
- try:
- question_obj = Question.objects.get(question_day=date)
- uploadForm.question = question_obj
- uploadForm.model_file
- uploadForm.save()
- messages.info(request, 'Uploaded Successfully!')
- except:
- messages.error(request, 'No question uploaded for mentioned date')
- print(question_obj)
- else:
- messages.error(request, 'Invalid Form')
-
-
- return render(request, "uploadmodel.html", {"question_list":question_list})'''
+
+ return render(request, 'view_solutions.html', {"question_ans_list": question_ans_list,
+ "set_visible": set_visible
+ })
\ No newline at end of file