summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/templates/yaksh/course_detail.html29
-rw-r--r--yaksh/templates/yaksh/course_detail_options.html149
-rw-r--r--yaksh/templates/yaksh/courses.html533
-rw-r--r--yaksh/test_views.py12
-rw-r--r--yaksh/urls.py2
-rw-r--r--yaksh/views.py71
6 files changed, 399 insertions, 397 deletions
diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html
index 8661aea..04a11e8 100644
--- a/yaksh/templates/yaksh/course_detail.html
+++ b/yaksh/templates/yaksh/course_detail.html
@@ -58,35 +58,6 @@
{% elif is_upload_download_md %}
{% include "yaksh/upload_download_course_md.html" %}
{% else %}
- <div class="jumbotron">
- <h1 class="display-4">Manage Course</h1>
- <hr class="my-4">
- <p>
- <ul>
- <li>
- Students enrollments
- </li>
- <li>
- Add and View Modules, Lessons and Quizzes
- </li>
- <li>
- Send mail to the students
- </li>
- <li>
- View Students course progress
- </li>
- <li>
- Add and View Teachers/TAs
- </li>
- </ul>
- </p>
- <p class="lead">
- <a class="btn btn-primary btn-lg" href="https://yaksh.readthedocs.io/en/latest/moderator_docs/creating_course.html" role="button" target="blank">
- <i class="fa fa-info-circle"></i>
- Learn more
- </a>
- </p>
- </div>
{% endif %}
</div>
</div>
diff --git a/yaksh/templates/yaksh/course_detail_options.html b/yaksh/templates/yaksh/course_detail_options.html
index f9393ed..0910c01 100644
--- a/yaksh/templates/yaksh/course_detail_options.html
+++ b/yaksh/templates/yaksh/course_detail_options.html
@@ -1,51 +1,104 @@
-<a href="{% url 'yaksh:courses' %}" class="btn btn-primary" title="View all the courses" data-placement="top" data-toggle="tooltip">
- <i class="fa fa-arrow-left"></i>&nbsp;Back
+<a
+ href="{% url 'yaksh:courses' %}"
+ class="btn btn-primary"
+ title="View all the courses"
+ data-placement="top"
+ data-toggle="tooltip">
+ <i class="fa fa-arrow-left"></i>&nbsp;Back
</a>
<br><br>
-<ul class="nav nav-pills nav-fill flex-column flex-sm-row" role="tablist">
- <li class="nav-item">
- <a href="{% url 'yaksh:course_students' course.id %}" id="enroll-students" class="nav-link {% if is_students %} active {% endif %}" title="View the course requested, rejected and enrolled students" data-placement="top" data-toggle="tooltip">
- Enrollments
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link {% if is_modules %} active {% endif %}" href="{% url 'yaksh:get_course_modules' course.id %}" title="View modules added to the course" data-placement="top" data-toggle="tooltip">
- Course Modules
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link {% if is_design_course %} active {% endif %}" href="{% url 'yaksh:design_course' course.id %}" title="Additional course settings" data-placement="top" data-toggle="tooltip">
- Design Course
- </a>
- </li>
- <li class="nav-item">
- <a href="{% url 'yaksh:course_status' course.id %}" class="nav-link {% if is_progress %} active {% endif %}" title="View Students course progress" data-placement="top" data-toggle="tooltip">
- Course Progress
- </a>
- </li>
- <li class="nav-item">
- <a href="{% url 'yaksh:send_mail' course.id %}" class="nav-link {% if is_mail %} active {% endif %}" title="Send mail to course students" data-placement="top" data-toggle="tooltip">
- Send Mail
- </a>
- </li>
- <li class="nav-item">
- <a href="{% url 'yaksh:course_forum' course.id %}" class="nav-link" title="Discussion forum of this course" data-placement="top" data-toggle="tooltip">
- Discussion Forum
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link {% if is_add_teacher %} active {% endif %}" href="{% url 'yaksh:search_teacher' course.id %}" data-toggle="tooltip" title="Add Teachers/TAs to this course" data-placement="top">
- Add Teachers/TAs
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link {% if is_teachers %} active {% endif %}" href="{% url 'yaksh:course_teachers' course.id %}" data-toggle="tooltip" title="View all the Teachers/TAs for this course" data-placement="top">
- Current Teachers/TAs
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link list-group-item {% if is_upload_download_md %} active {% endif %}" href="{% url 'yaksh:upload_download_course_md' course.id %}" data-toggle="tooltip" title="Upload / Download MD files" data-placement="top">
- Upload / Download MD
- </a>
- </li>
+<ul
+ class="nav nav-pills nav-fill flex-column flex-sm-row"
+ role="tablist">
+ <li class="nav-item">
+ <a
+ href="{% url 'yaksh:course_detail' course.id %}"
+ id="enroll-students"
+ class="nav-link {% if is_students %} active {% endif %}"
+ title="View the course requested, rejected and enrolled students"
+ data-placement="top"
+ data-toggle="tooltip">
+ Enrollments
+ </a>
+ </li>
+ <li class="nav-item">
+ <a
+ class="nav-link {% if is_modules %} active {% endif %}"
+ href="{% url 'yaksh:get_course_modules' course.id %}"
+ title="View modules added to the course"
+ data-placement="top"
+ data-toggle="tooltip">
+ Course Modules
+ </a>
+ </li>
+ <li class="nav-item">
+ <a
+ class="nav-link {% if is_design_course %} active {% endif %}"
+ href="{% url 'yaksh:design_course' course.id %}"
+ title="Additional course settings"
+ data-placement="top"
+ data-toggle="tooltip">
+ Design Course
+ </a>
+ </li>
+ <li class="nav-item">
+ <a
+ href="{% url 'yaksh:course_status' course.id %}"
+ class="nav-link {% if is_progress %} active {% endif %}"
+ title="View Students course progress"
+ data-placement="top"
+ data-toggle="tooltip">
+ Course Progress
+ </a>
+ </li>
+ <li class="nav-item">
+ <a
+ href="{% url 'yaksh:send_mail' course.id %}"
+ class="nav-link {% if is_mail %} active {% endif %}"
+ title="Send mail to course students"
+ data-placement="top"
+ data-toggle="tooltip">
+ Send Mail
+ </a>
+ </li>
+ <li class="nav-item">
+ <a
+ href="{% url 'yaksh:course_forum' course.id %}"
+ class="nav-link"
+ title="Discussion forum of this course"
+ data-placement="top"
+ data-toggle="tooltip">
+ Discussion Forum
+ </a>
+ </li>
+ <li class="nav-item">
+ <a
+ class="nav-link {% if is_add_teacher %} active {% endif %}"
+ href="{% url 'yaksh:search_teacher' course.id %}"
+ data-toggle="tooltip"
+ title="Add Teachers/TAs to this course"
+ data-placement="top">
+ Add Teachers/TAs
+ </a>
+ </li>
+ <li class="nav-item">
+ <a
+ class="nav-link {% if is_teachers %} active {% endif %}"
+ href="{% url 'yaksh:course_teachers' course.id %}"
+ data-toggle="tooltip"
+ title="View all the Teachers/TAs for this course"
+ data-placement="top">
+ Current Teachers/TAs
+ </a>
+ </li>
+ <li class="nav-item">
+ <a
+ class="nav-link list-group-item {% if is_upload_download_md %} active {% endif %}"
+ href="{% url 'yaksh:upload_download_course_md' course.id %}"
+ data-toggle="tooltip"
+ title="Upload / Download MD files"
+ data-placement="top">
+ Upload / Download MD
+ </a>
+ </li>
</ul> \ No newline at end of file
diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html
index b9e48d6..264101c 100644
--- a/yaksh/templates/yaksh/courses.html
+++ b/yaksh/templates/yaksh/courses.html
@@ -4,292 +4,285 @@
{% block pagetitle %} Courses {% endblock pagetitle %}
{% block script %}
-<script type="text/javascript" src="{% static 'yaksh/js/show_courses.js' %}">
-</script>
+ <script type="text/javascript" src="{% static 'yaksh/js/show_courses.js' %}">
+ </script>
{% endblock %}
{% block content %}
<div class="container-fluid">
- <div class="row">
- <div class="col-md-8">
- <ul class="nav nav-pills" id="course_tabs">
- <li class="nav-item">
- <a class="nav-link {% if created %}active{% endif %}" href="{% url 'yaksh:courses' %}">
- My Courses
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="{% url 'yaksh:add_course' %}">
- Add/Edit Course
- </a>
- </li>
- <li class="nav-item">
- <a href="{% url 'grades:grading_systems'%}" class="nav-link" >
- Add/View Grading Systems
- </a>
- </li>
- </ul>
- </div>
+ <div class="row">
+ <div class="col-md-8">
+ <ul class="nav nav-pills" id="course_tabs">
+ <li class="nav-item">
+ <a class="nav-link {% if created %}active{% endif %}" href="{% url 'yaksh:courses' %}">
+ My Courses
+ </a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="{% url 'yaksh:add_course' %}">
+ Add/Edit Course
+ </a>
+ </li>
+ <li class="nav-item">
+ <a href="{% url 'grades:grading_systems'%}" class="nav-link" >
+ Add/View Grading Systems
+ </a>
+ </li>
+ </ul>
</div>
- <br>
- <div>
- {% if not objects %}
- <br><br>
- <div class="alert alert-info">
- <center> <h3> No Courses Found </h3> </center>
- </div>
- {% else %}
- <div class="row">
- <div class="col">
- <form name=frm action="" method="get">
- <div class="card">
- <div class="card-header">
- <h3>Search/Filter Courses</h3>
- </div>
- <div class="card-body">
- <div>
- {{form.search_tags}}
- <br>
- {{form.search_status}}
- </div>
- <br>
- <button class="btn btn-outline-success" type="submit">
- <i class="fa fa-search"></i>&nbsp;Search
- </button>
- <a class="btn btn-outline-danger" href="{% url 'yaksh:courses' %}">
- <i class="fa fa-times"></i>&nbsp;Clear
- </a>
- </div>
- </div>
- </form>
+ </div>
+ <br>
+ <div>
+ {% if not objects %}
+ <br><br>
+ <div class="alert alert-info">
+ <center> <h3> No Courses Found </h3> </center>
+ </div>
+ {% else %}
+ <div class="row">
+ <div class="col">
+ <form name=frm action="" method="get">
+ <div class="card">
+ <div class="card-header">
+ <h3>Search/Filter Courses</h3>
+ </div>
+ <div class="card-body">
+ <div>
+ {{form.search_tags}}
+ <br>
+ {{form.search_status}}
</div>
- <div id="course-list">
- <center><h4 class="badge badge-success">{{ courses_found }} Course(s) Available</h4></center>
+ <br>
+ <button class="btn btn-outline-success" type="submit">
+ <i class="fa fa-search"></i>&nbsp;Search
+ </button>
+ <a class="btn btn-outline-danger" href="{% url 'yaksh:courses' %}">
+ <i class="fa fa-times"></i>&nbsp;Clear
+ </a>
+ </div>
+ </div>
+ </form>
+ </div>
+ <div id="course-list">
+ <center><h4 class="badge badge-success">{{ courses_found }} Course(s) Available</h4></center>
+ {% if messages %}
+ {% for message in messages %}
+ <div class="alert alert-dismissible alert-{{ message.tags }}">
+ <button type="button" class="close" data-dismiss="alert">
+ <i class="fa fa-close"></i>
+ </button>
+ <strong>{{ message }}</strong>
+ </div>
+ {% endfor %}
+ {% endif %}
+ {% with objects as courses %}
+ <div class="row">
+ <div class="col-md-4">
+ {% include "yaksh/paginator.html" %}
+ </div>
+ <div class="ml-auto">
+ <div class="nav nav-pills" role="tablist" aria-orientation="vertical">
+ <a id="listbtn" class="nav-link" data-toggle="pill" role="tab" aria-controls="show" aria-selected="true">
+ <i class="fa fa-list"></i>
+ </a>
+ <a id="gridbtn" class="nav-link" data-toggle="pill" role="tab" aria-controls="updown" aria-selected="false">
+ <i class="fa fa-columns"></i>
+ </a>
+ </div>
+ </div>
+ </div>
- {% if messages %}
- {% for message in messages %}
- <div class="alert alert-dismissible alert-{{ message.tags }}">
- <button type="button" class="close" data-dismiss="alert">
- <i class="fa fa-close"></i>
- </button>
- <strong>{{ message }}</strong>
- </div>
- {% endfor %}
- {% endif %}
- {% with objects as courses %}
- <div class="row">
- <div class="col-md-4">
- {% include "yaksh/paginator.html" %}
+ <div class="tab-content">
+ <div class="tab-pane active" id="gridview" role="tabpanel" aria-labelledby="gridbtn">
+ <!-- GridView -->
+ <br>
+ <div class="row">
+ <br>
+ {% for course in courses %}
+ <div class="col-md-6">
+ <div class="card">
+ <div class="card-header" style="height: 150px">
+ <strong>
+ <a href="{% url 'yaksh:course_detail' course.id %}">
+ <i class="fa fa-edit"></i>&nbsp;
+ {{course.name}}
+ </a>
+ </strong>
+ <div>
+ {% if user.id != course.creator.id %}
+ <span class="badge badge-pill badge-warning">
+ Allotted Course
+ </span>
+ {% else %}
+ <span class="badge badge-pill badge-primary">
+ Created Course
+ </span>
+ {% endif %}
</div>
- <div class="ml-auto">
- <div class="nav nav-pills" role="tablist" aria-orientation="vertical">
- <a id="listbtn" class="nav-link" data-toggle="pill" role="tab" aria-controls="show" aria-selected="true">
- <i class="fa fa-list"></i>
- </a>
- <a id="gridbtn" class="nav-link" data-toggle="pill" role="tab" aria-controls="updown" aria-selected="false">
- <i class="fa fa-columns"></i>
- </a>
+ <div>
+ <div class="nav-item dropdown">
+ <a
+ class="dropdown-toggle nav-link"
+ data-toggle="dropdown"
+ href="#"
+ style="color: blue;"
+ >
+ More
+ </a>
+ <div class="dropdown-menu dropdown-menu-right">
+ <a
+ class="dropdown-item"
+ href="{% url 'yaksh:edit_course' course.id %}">
+ <i class="fa fa-tasks"></i>
+ Edit Course
+ </a>
+ <div class="dropdown-divider"></div>
+ <a
+ class="dropdown-item"
+ href="{% url 'yaksh:duplicate_course' course.id %}">
+ <i class="fa fa-clone"></i>
+ Clone Course
+ </a>
+ <div class="dropdown-divider"></div>
+ <a
+ class="dropdown-item"
+ href="{% url 'yaksh:download_course_csv' course.id %}">
+ <i class="fa fa-download"></i>
+ Download CSV
+ </a>
+ <div class="dropdown-divider"></div>
+ <a
+ class="dropdown-item"
+ href="{% url 'yaksh:download_course' course.id %}">
+ <i class="fa fa-download"></i>
+ Download Course
+ </a>
</div>
+ </div>
</div>
- </div>
-
- <div class="tab-content">
- <div class="tab-pane active" id="gridview" role="tabpanel" aria-labelledby="gridbtn">
- <!-- GridView -->
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col-md-8">
+ <strong>Status:</strong>
+ {% if course.active %}
+ <span class="badge badge-pill badge-success">
+ Active
+ </span>
+ {% else %}
+ <span class="badge badge-pill badge-danger">
+ Inactive
+ </span>
+ {% endif %}
<br>
- <div class="row">
- <br>
- {% for course in courses %}
- <div class="col-md-6">
- <div class="card">
- <div class="card-header" style="height: 150px">
- <strong>
- <a href="{% url 'yaksh:edit_course' course.id %}">
- <i class="fa fa-edit"></i>&nbsp;
- {{course.name}}
- </a>
- </strong>
- <div>
- {% if user.id != course.creator.id %}
- <span class="badge badge-pill badge-warning">
- Allotted Course
- </span>
- {% else %}
- <span class="badge badge-pill badge-primary">
- Created Course
- </span>
- {% endif %}
- </div>
- <div>
- <div class="nav-item dropdown">
- <a class="dropdown-toggle nav-link" data-toggle="dropdown" href="#" style="color: blue;">More
- </a>
- <div class="dropdown-menu dropdown-menu-right">
- <a class="dropdown-item" href="{% url 'yaksh:toggle_course_status' course.id %}">
- {% if course.active %}
- <i class="fa fa-toggle-on fa-2x"></i>
- Deactivate Course
- {% else %}
- <i class="fa fa-toggle-off fa-2x"></i>
- Activate Course
- {% endif %}
- </a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="{% url 'yaksh:course_detail' course.id %}">
- <i class="fa fa-tasks"></i>
- Manage Course
- </a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="{% url 'yaksh:duplicate_course' course.id %}">
- <i class="fa fa-clone"></i>
- Clone Course
- </a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="{% url 'yaksh:download_course_csv' course.id %}">
- <i class="fa fa-download"></i>
- Download CSV
- </a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="{% url 'yaksh:download_course' course.id %}">
- <i class="fa fa-download"></i>
- Download Course
- </a>
- </div>
- </div>
- </div>
- </div>
- <div class="card-body">
- <div class="row">
- <div class="col-md-8">
- <strong>Status:</strong>
- {% if course.active %}
- <span class="badge badge-pill badge-success">
- Active
- </span>
- {% else %}
- <span class="badge badge-pill badge-danger">
- Inactive
- </span>
- {% endif %}
- <br>
- <strong>Creator:</strong>
- {{course.creator.get_full_name}}
- <br>
- <strong>Starts On:</strong>
- {{course.start_enroll_time}}
- <br>
- <strong>Ends On:</strong>
- {{course.end_enroll_time}}
- </div>
- </div>
- </div>
- </div>
- </div>
- {% endfor %}
- <br>
- </div>
- </div>
- <div class="tab-pane" id="listview" role="tabpanel" aria-labelledby="gridbtn">
- <!-- ListView -->
+ <strong>Creator:</strong>
+ {{course.creator.get_full_name}}
<br>
- {% for course in courses %}
- <div class="card">
- <div class="card-header bg-secondary">
- <div class="row">
- <div class="col-md-7">
- <strong>
- <a href="{% url 'yaksh:edit_course' course.id %}">
- <i class="fa fa-edit"></i>
- {{course.name}}
- </a>
- </strong>
- </div>
- <div class="col-md-3">
- {% if user.id != course.creator.id %}
- <span class="badge badge-pill badge-warning">
- Allotted Course
- </span>
- {% else %}
- <span class="badge badge-pill badge-primary">
- Created Course
- </span>
- {% endif %}
- </div>
- <div class="col">
- <li class="nav-item dropdown">
- <a class="dropdown-toggle nav-link" id="user_dropdown" data-toggle="dropdown" href="#" style="color: blue;">More
- </a>
- <div class="dropdown-menu dropdown-menu-right">
- <a class="dropdown-item" href="{% url 'yaksh:toggle_course_status' course.id %}">
- {% if course.active %}
- <i class="fa fa-toggle-on fa-2x"></i>
- Deactivate Course
- {% else %}
- <i class="fa fa-toggle-off fa-2x"></i>
- Activate Course
- {% endif %}
- </a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="{% url 'yaksh:course_detail' course.id %}">
- <i class="fa fa-tasks"></i>
- Manage Course
- </a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="{% url 'yaksh:duplicate_course' course.id %}">
- <i class="fa fa-clone"></i>
- Clone Course
- </a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="{% url 'yaksh:download_course_csv' course.id %}">
- <i class="fa fa-download"></i>
- Download CSV
- </a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="{% url 'yaksh:download_course' course.id %}">
- <i class="fa fa-download"></i>
- Download Course
- </a>
- </div>
- </li>
- </div>
- </div>
- </div>
- <div class="card-body">
- <div class="row">
- <div class="col">
- <strong>Status:</strong>
- {% if course.active %}
- <span class="badge badge-pill badge-success">
- Active
- </span>
- {% else %}
- <span class="badge badge-pill badge-danger">
- Inactive
- </span>
- {% endif %}
- <br>
- <strong>Creator:</strong>
- {{course.creator.get_full_name}}
- <br>
- <strong>Starts On:</strong>
- {{course.start_enroll_time}}
- <br>
- <strong>Ends On:</strong>
- {{course.end_enroll_time}}
- </div>
- </div>
- </div>
- </div>
- <br>
- {% endfor %}
+ <strong>Starts On:</strong>
+ {{course.start_enroll_time}}
<br>
+ <strong>Ends On:</strong>
+ {{course.end_enroll_time}}
+ </div>
</div>
+ </div>
</div>
- {% include "yaksh/paginator.html" %}
- {% endwith %}
+ </div>
+ {% endfor %}
+ <br>
+ </div>
+ </div>
+ <div class="tab-pane" id="listview" role="tabpanel" aria-labelledby="gridbtn">
+ <!-- ListView -->
+ <br>
+ {% for course in courses %}
+ <div class="card">
+ <div class="card-header bg-secondary">
+ <div class="row">
+ <div class="col-md-7">
+ <strong>
+ <a href="{% url 'yaksh:course_detail' course.id %}">
+ <i class="fa fa-edit"></i>
+ {{course.name}}
+ </a>
+ </strong>
+ </div>
+ <div class="col-md-3">
+ {% if user.id != course.creator.id %}
+ <span class="badge badge-pill badge-warning">
+ Allotted Course
+ </span>
+ {% else %}
+ <span class="badge badge-pill badge-primary">
+ Created Course
+ </span>
+ {% endif %}
+ </div>
+ <div class="col">
+ <li class="nav-item dropdown">
+ <a class="dropdown-toggle nav-link" id="user_dropdown" data-toggle="dropdown" href="#" style="color: blue;">More
+ </a>
+ <div class="dropdown-menu dropdown-menu-right">
+ <a class="dropdown-item" href="{% url 'yaksh:edit_course' course.id %}">
+ <i class="fa fa-tasks"></i>
+ Edit Course
+ </a>
+ <div class="dropdown-divider"></div>
+ <a class="dropdown-item" href="{% url 'yaksh:duplicate_course' course.id %}">
+ <i class="fa fa-clone"></i>
+ Clone Course
+ </a>
+ <div class="dropdown-divider"></div>
+ <a class="dropdown-item" href="{% url 'yaksh:download_course_csv' course.id %}">
+ <i class="fa fa-download"></i>
+ Download CSV
+ </a>
+ <div class="dropdown-divider"></div>
+ <a class="dropdown-item" href="{% url 'yaksh:download_course' course.id %}">
+ <i class="fa fa-download"></i>
+ Download Course
+ </a>
+ </div>
+ </li>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <strong>Status:</strong>
+ {% if course.active %}
+ <span class="badge badge-pill badge-success">
+ Active
+ </span>
+ {% else %}
+ <span class="badge badge-pill badge-danger">
+ Inactive
+ </span>
+ {% endif %}
+ <br>
+ <strong>Creator:</strong>
+ {{course.creator.get_full_name}}
+ <br>
+ <strong>Starts On:</strong>
+ {{course.start_enroll_time}}
+ <br>
+ <strong>Ends On:</strong>
+ {{course.end_enroll_time}}
+ </div>
+ </div>
+ </div>
</div>
+ <br>
+ {% endfor %}
+ <br>
</div>
- {% endif %}
- </div>
+ </div>
+ {% include "yaksh/paginator.html" %}
+ {% endwith %}
+ </div>
+ </div>
+ {% endif %}
+ </div>
</div>
{% endblock %} \ No newline at end of file
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 8c79085..ef9863c 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -3886,7 +3886,7 @@ class TestCourseStudents(TestCase):
username=self.user1.username,
password=self.user1_plaintext_pass
)
- url = reverse('yaksh:course_students', kwargs={
+ url = reverse('yaksh:course_detail', kwargs={
'course_id': self.user1_course.id
})
response = self.client.get(url)
@@ -3898,7 +3898,7 @@ class TestCourseStudents(TestCase):
username=self.user1.username,
password=self.user1_plaintext_pass
)
- url = reverse('yaksh:course_students', kwargs={
+ url = reverse('yaksh:course_detail', kwargs={
'course_id': self.user1_course.id
})
response = self.client.get(url)
@@ -3910,7 +3910,7 @@ class TestCourseStudents(TestCase):
username=self.user1.username,
password=self.user1_plaintext_pass
)
- url = reverse('yaksh:course_students', kwargs={
+ url = reverse('yaksh:course_detail', kwargs={
'course_id': self.user1_course.id
})
response = self.client.get(url)
@@ -3922,7 +3922,7 @@ class TestCourseStudents(TestCase):
username=self.user1.username,
password=self.user1_plaintext_pass
)
- url = reverse('yaksh:course_students', kwargs={
+ url = reverse('yaksh:course_detail', kwargs={
'course_id': self.user1_course.id
})
response = self.client.get(url)
@@ -3936,7 +3936,7 @@ class TestCourseStudents(TestCase):
username=self.user2.username,
password=self.user2_plaintext_pass
)
- url = reverse('yaksh:course_students', kwargs={
+ url = reverse('yaksh:course_detail', kwargs={
'course_id': self.user1_course.id,
})
response = self.client.get(url)
@@ -3947,7 +3947,7 @@ class TestCourseStudents(TestCase):
username=self.student1,
password=self.student1_plaintext_pass
)
- url = reverse('yaksh:course_students', kwargs={
+ url = reverse('yaksh:course_detail', kwargs={
'course_id': self.user1_course.id,
})
response = self.client.get(url)
diff --git a/yaksh/urls.py b/yaksh/urls.py
index a1aa607..f31e450 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -220,8 +220,6 @@ urlpatterns = [
views.download_course, name="download_course"),
url(r'^download_course/(?P<course_id>\d+)/$',
views.download_course, name="download_course"),
- url(r'^manage/course/enrollments/(?P<course_id>\d+)',
- views.course_students, name="course_students"),
url(r'^manage/course/all/modules/(?P<course_id>\d+)',
views.get_course_modules, name="get_course_modules"),
url(r'^manage/course/teachers/(?P<course_id>\d+)',
diff --git a/yaksh/views.py b/yaksh/views.py
index 4a6f462..3727514 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1182,17 +1182,27 @@ def courses(request):
@email_verified
def course_detail(request, course_id):
user = request.user
-
if not is_moderator(user):
raise Http404('You are not allowed to view this page')
- course = get_object_or_404(Course, pk=course_id)
+ course = Course.objects.prefetch_related(
+ 'students', 'requests', 'rejected'
+ ).get(id=course_id)
if not course.is_creator(user) and not course.is_teacher(user):
raise Http404('This course does not belong to you')
- return my_render_to_response(
- request, 'yaksh/course_detail.html', {'course': course}
- )
+ enrolled_users = course.get_enrolled()
+ requested_users = course.get_requests()
+ rejected_users = course.get_rejected()
+ context = {
+ "enrolled_users": enrolled_users,
+ "requested_users": requested_users,
+ "course": course,
+ "rejected_users": rejected_users,
+ "is_students": True
+ }
+
+ return my_render_to_response(request, 'yaksh/course_detail.html', context)
@login_required
@@ -1210,7 +1220,7 @@ def enroll_user(request, course_id, user_id=None, was_rejected=False):
'instructor/administrator.'
)
messages.warning(request, msg)
- return redirect('yaksh:course_students', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
if not course.is_creator(user) and not course.is_teacher(user):
raise Http404('This course does not belong to you')
@@ -1218,7 +1228,7 @@ def enroll_user(request, course_id, user_id=None, was_rejected=False):
user = User.objects.get(id=user_id)
course.enroll(was_rejected, user)
messages.success(request, 'Enrolled student successfully')
- return redirect('yaksh:course_students', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
@login_required
@@ -1233,7 +1243,7 @@ def reject_user(request, course_id, user_id=None, was_enrolled=False):
user = User.objects.get(id=user_id)
course.reject(was_enrolled, user)
messages.success(request, "Rejected students successfully")
- return redirect('yaksh:course_students', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
@login_required
@@ -1252,7 +1262,7 @@ def enroll_reject_user(request,
'instructor/administrator.'
)
messages.warning(request, msg)
- return redirect('yaksh:course_students', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
if not course.is_creator(user) and not course.is_teacher(user):
raise Http404('This course does not belong to you')
@@ -1262,21 +1272,21 @@ def enroll_reject_user(request,
enroll_ids = request.POST.getlist('check')
if not enroll_ids:
messages.warning(request, "Please select atleast one student")
- return redirect('yaksh:course_students', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
users = User.objects.filter(id__in=enroll_ids)
course.enroll(was_rejected, *users)
messages.success(request, "Enrolled student(s) successfully")
- return redirect('yaksh:course_students', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
if 'reject' in request.POST:
reject_ids = request.POST.getlist('check')
if not reject_ids:
messages.warning(request, "Please select atleast one student")
- return redirect('yaksh:course_students', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
users = User.objects.filter(id__in=reject_ids)
course.reject(was_enrolled, *users)
messages.success(request, "Rejected students successfully")
- return redirect('yaksh:course_students', course_id=course_id)
- return redirect('yaksh:course_students', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
+ return redirect('yaksh:course_detail', course_id=course_id)
@login_required
@@ -2433,13 +2443,13 @@ def upload_users(request, course_id):
if request.method == 'POST':
if 'csv_file' not in request.FILES:
messages.warning(request, "Please upload a CSV file.")
- return my_redirect(reverse('yaksh:course_students',
+ return my_redirect(reverse('yaksh:course_detail',
args=[course_id]))
csv_file = request.FILES['csv_file']
is_csv_file, dialect = is_csv(csv_file)
if not is_csv_file:
messages.warning(request, "The file uploaded is not a CSV file.")
- return my_redirect(reverse('yaksh:course_students',
+ return my_redirect(reverse('yaksh:course_detail',
args=[course_id]))
required_fields = ['firstname', 'lastname', 'email']
try:
@@ -2448,7 +2458,7 @@ def upload_users(request, course_id):
dialect=dialect)
except TypeError:
messages.warning(request, "Bad CSV file")
- return my_redirect(reverse('yaksh:course_students',
+ return my_redirect(reverse('yaksh:course_detail',
args=[course_id]))
stripped_fieldnames = [
field.strip().lower() for field in reader.fieldnames]
@@ -2456,11 +2466,11 @@ def upload_users(request, course_id):
if field not in stripped_fieldnames:
msg = "The CSV file does not contain the required headers"
messages.warning(request, msg)
- return my_redirect(reverse('yaksh:course_students',
+ return my_redirect(reverse('yaksh:course_detail',
args=[course_id]))
reader.fieldnames = stripped_fieldnames
_read_user_csv(request, reader, course)
- return my_redirect(reverse('yaksh:course_students', args=[course_id]))
+ return my_redirect(reverse('yaksh:course_detail', args=[course_id]))
def _read_user_csv(request, reader, course):
@@ -3348,29 +3358,6 @@ def download_course(request, course_id):
@login_required
@email_verified
-def course_students(request, course_id):
- user = request.user
- if not is_moderator(user):
- raise Http404('You are not allowed to view this page!')
- course = get_object_or_404(Course, pk=course_id)
- if not course.is_creator(user) and not course.is_teacher(user):
- raise Http404("You are not allowed to view {0}".format(
- course.name))
- enrolled_users = course.get_enrolled()
- requested_users = course.get_requests()
- rejected_users = course.get_rejected()
- context = {
- "enrolled_users": enrolled_users,
- "requested_users": requested_users,
- "course": course,
- "rejected_users": rejected_users,
- "is_students": True
- }
- return my_render_to_response(request, 'yaksh/course_detail.html', context)
-
-
-@login_required
-@email_verified
def course_teachers(request, course_id):
user = request.user
if not is_moderator(user):