Skip to content

Commit e583e01

Browse files
committed
Merge pull request #148 from SOEN341-W16/dimitir-merger_attemp_bryce
Academic Record pull request sub-branch
2 parents f4a204b + dd65743 commit e583e01

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

protected/models/CompletedCourses.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* @property integer $ID
88
* @property integer $userID
99
* @property integer $courseID
10+
* @property string $Grade
11+
* @property double $GPA
1012
*/
1113
class CompletedCourses extends CActiveRecord
1214
{
@@ -26,11 +28,13 @@ public function rules()
2628
// NOTE: you should only define rules for those attributes that
2729
// will receive user inputs.
2830
return array(
29-
array('userID, courseID', 'required'),
31+
array('userID, courseID, Grade', 'required'),
3032
array('userID, courseID', 'numerical', 'integerOnly'=>true),
33+
array('GPA', 'numerical'),
34+
array('Grade', 'length', 'max'=>3),
3135
// The following rule is used by search().
3236
// @todo Please remove those attributes that should not be searched.
33-
array('ID, userID, courseID', 'safe', 'on'=>'search'),
37+
array('ID, userID,courseID, Grade, GPA', 'safe', 'on'=>'search'),
3438
);
3539
}
3640

@@ -43,7 +47,7 @@ public function relations()
4347
// class name for the relations automatically generated below.
4448
return array(
4549

46-
'course' => array(self::BELONGS_TO, 'Course','ID'),
50+
'course' => array(self::BELONGS_TO, 'Course','courseID'),
4751
);
4852
}
4953

@@ -56,6 +60,8 @@ public function attributeLabels()
5660
'ID' => 'ID',
5761
'userID' => 'User',
5862
'courseID' => 'Course',
63+
'Grade' => 'Grade',
64+
'GPA' => 'Gpa',
5965
);
6066
}
6167

@@ -82,9 +88,12 @@ public function search()
8288
//$criteria->compare('ID',$this->ID);
8389
$criteria->compare('userID', Yii::app()->user->userID);
8490
$criteria->order = 'course.course_code';
85-
8691
$criteria->with = array('course');
8792

93+
//$criteria->compare('Grade',$this->Grade,true);
94+
//$criteria->compare('GPA',$this->GPA);
95+
96+
8897
return new CActiveDataProvider($this, array(
8998
'criteria'=>$criteria,
9099
));

protected/runtime/application.log

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11716,3 +11716,14 @@ Stack trace:
1171611716
REQUEST_URI=/index.php?r=course/view&id=71
1171711717
HTTP_REFERER=http://www.conuscheduler.localhost/index.php?r=course/create
1171811718
---
11719+
2016/04/02 21:06:25 [error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system is unable to find the requested action "admin".' in C:\xampp\htdocs\ConUScheduler\framework\web\CController.php:483
11720+
Stack trace:
11721+
#0 C:\xampp\htdocs\ConUScheduler\framework\web\CController.php(270): CController->missingAction('admin')
11722+
#1 C:\xampp\htdocs\ConUScheduler\framework\web\CWebApplication.php(282): CController->run('admin')
11723+
#2 C:\xampp\htdocs\ConUScheduler\framework\web\CWebApplication.php(141): CWebApplication->runController('profile/admin')
11724+
#3 C:\xampp\htdocs\ConUScheduler\framework\base\CApplication.php(185): CWebApplication->processRequest()
11725+
#4 C:\xampp\htdocs\ConUScheduler\index.php(13): CApplication->run()
11726+
#5 {main}
11727+
REQUEST_URI=/index.php?r=profile/admin
11728+
HTTP_REFERER=http://www.conuscheduler.localhost/index.php?r=profile/record
11729+
---

protected/views/profile/index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
$this->menu=array(
55
array('label'=>'Academic Record', 'url'=>array('record')),
6-
array('label'=>'Contact Information', 'url'=>array('admin')),
76
);
87
?>
98
<h1>Profile</h1>

protected/views/profile/record.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
11
<?php
22
$this->menu=array(
33
array('label'=>'Profile', 'url'=>array('index')),
4-
array('label'=>'Contact Information', 'url'=>array('admin')),
54
);
65
?>
76

8-
<h1>Academic Record</h1>
7+
<h1>Academic Record</h1>
98
<?php $this->widget('zii.widgets.grid.CGridView', array(
109
'id'=>'courses_completed-grid',
1110
'dataProvider'=>$model->search(),
1211
'filter'=>$model,
1312
'columns'=>array(
14-
'ID',
15-
'course.course_code'
13+
'course.course_code',
14+
'course.credits',
15+
'Grade',
16+
'GPA'
1617
),
1718
)); ?>
19+
20+
<?php
21+
22+
$sql="SELECT * FROM completed_courses LEFT JOIN course ON completed_courses.courseID=course.ID";
23+
24+
$test=Yii::app()->db->createCommand($sql);
25+
$data=$test->queryAll();
26+
$creditTotal=0;
27+
$sum=0;
28+
29+
foreach ($data as $value)
30+
{
31+
if ($value['userID']== Yii::app()->user->userID) {
32+
$sum+=$value['GPA']*$value['credits'];
33+
$creditTotal+=$value['credits'];
34+
35+
}
36+
37+
}
38+
$finalGPA=$sum/$creditTotal;
39+
$finalGPA=round($finalGPA,2);
40+
echo "<h2>";
41+
42+
echo "Total GPA: $finalGPA";
43+
echo "</h2>";
44+
?>

0 commit comments

Comments
 (0)