-
Notifications
You must be signed in to change notification settings - Fork 0
/
chapter.php
157 lines (145 loc) · 3.84 KB
/
chapter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
require 'required.php';
include 'theme.php';
if(isset($_GET['chpid'])) {
$chpid = $_GET['chpid'];
//taking details of the chapter
$query = "select `Subj_id`, `chapterName`, `description` from `chapter` where `Chp_id` = '$chpid'";
if($query_run = mysql_query($query)) {
$exists = mysql_num_rows($query_run);
if($exists) {
$name = mysql_result($query_run, 0, 'chapterName');
$info = mysql_result($query_run, 0, 'description');
$subjid = mysql_result($query_run, 0, 'Subj_id');
$subjname = get_field('subject', 'subjName', 'Subj_id', $subjid);
}
} else echo mysql_error();
if($exists) {
//getting subj and course name
$query = "select sc.Course_id, c.courseName, sc.sem from subj_course_mapping sc
join courses c on sc.Course_id = c.Course_id
where sc.Subj_id = '$subjid'";
if($query_run = mysql_query($query)) {
$crs_cnt = mysql_num_rows($query_run);
if($crs_cnt) {
$i = 0;
while($array = mysql_fetch_assoc($query_run)) {
$course[$i]['name'] = $array['courseName'];
$course[$i]['sem'] = $array['sem'];
$course[$i]['id'] = $array['Course_id'];
$i++;
}
}
} else die(mysql_error());
if(logged_in()) {
$test_page = 'pretest01.php';
//getting user's course and id
$query = "select `sem`, `Course_id` from `student` where `L_id` = '$l_id'";
if($query_run = mysql_query($query)) {
$student_sem = mysql_result($query_run, 0, 'sem');
$student_courseid = mysql_result($query_run, 0, 'Course_id');
} else echo mysql_error();
$found = false;
//checking if chapter in user's course
if($crs_cnt) {
foreach($course as $c) {
if($student_courseid == $c['id'] && $student_sem == $c['sem']) {
$found = true;
break;
}
}
}
if(!$found) {
//checking for the chapter in user's interests
$query = "select Subj_id from interests where Subj_id = '$subjid' and L_id = '$l_id'";
if($query_run = mysql_query($query)) {
if(mysql_num_rows($query_run))
$found = true;
} else echo mysql_error();
}
} else {
$test_page = 'g_pretest02.php';
}
}
}
?>
<?php
if(isset($_GET['chpid']) && $exists) { ?>
<head>
<link rel="stylesheet" href="specific.css">
</head>
<body>
<br><br><br>
<!--chapter name-->
<div class="row">
<div class="col-md-7">
<h1><p>
<?php echo $name; ?>
</p></h1>
</div>
<?php if(!logged_in()|| $found) { ?>
<!--test link-->
<div class="col-md-3 col-md-offset-2">
<?php $redirect = $test_page.'?chpid='.$chpid; ?>
<a href="<?php echo $redirect; ?>">
<h2>give test</h2>
</a>
</div>
<?php } ?>
</div>
<!--description-->
<div class="row">
<div class="col-md-10 col-md-offset-1">
<h3><p>
<?php echo $info; ?>
</p></h3>
</div>
</div>
<hr>
<?php
if(logged_in() && !$found) { ?>
<!--note-->
<div class="row">
<div class="col-md-10 col-md-offset-1">
<h3><p>
To give test of this chapter, you will have to add this subject in your interests.<br>
Click on the subject to go to the subject page.
</p></h3>
</div>
</div>
<?php
} ?>
<br><br>
<!--subject-->
<div class="row">
<h3><div class="col-md-2">
<b>Subject:</b>
</div>
<a class="specific" href="subject.php?subjid=<?php echo $subjid; ?>">
<div class="col-md-8">
<?php echo $subjname; ?>
</div></h3>
</a>
</div>
<br>
<?php /*
<!--dept and sem-->
<div class="row">
<h3><div class="col-md-2">
<b>Course:</b>
</div>
<div class="col-md-4">
<a href="course.php?courseid=<?php echo $course ?>" class="specific">
<?php echo $coursename; ?>
</a>
</div>
<div class="col-md-2">
<b>Semester:</b>
</div>
<div class="col-md-4">
<?php echo $sem; ?>
</div></h3>
</div> */ ?>
</body>
<?php
} ?>