Skip to content

Commit b86f2a8

Browse files
committed
Merge pull request #162 from SOEN341-W16/development_bryce3
Development bryce3
2 parents 24b035b + 22c5a24 commit b86f2a8

File tree

4 files changed

+198
-6
lines changed

4 files changed

+198
-6
lines changed

protected/controllers/ProfileController.php

+30
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,34 @@ public function filters()
3333
'accessControl',
3434
);
3535
}
36+
37+
38+
public function actionAddCompleted()
39+
{
40+
41+
$model = new CompletedCourses;
42+
43+
$data = $_POST['CompletedCourses'];
44+
45+
$grade_to_gpa = array("F"=>0,"D-"=>0.7,"D"=>1,"D+"=>1.3,"C-"=>1.7,"C"=>2.0,"C+"=>2.3,"B-"=>2.7,"B"=>3.0,"B+"=>3.3,"A-"=>3.7,"A"=>4.0,"A+"=>4.3,);
46+
$result=Yii::app()->db->createCommand()->select('ID,course_code')->where('course_code=:course_code', array(':course_code' => $data['courseID']))->from('course')->queryAll();
47+
if(array_key_exists($data['Grade'],$grade_to_gpa)) {
48+
if (array_key_exists(0, $result)) {
49+
50+
$model->courseID = $result[0]['ID'];
51+
$model->Grade = $data['Grade'];
52+
$model->userID = Yii::app()->user->userID;
53+
$model->GPA = $grade_to_gpa[$data['Grade']];
54+
$model->save(); // insert row
55+
$this->redirect(array('record', 'added' => '1')); // the 'added' variable should appear in URL with a '1' if course was successfully added
56+
}
57+
else{
58+
$this->redirect(array('record', 'added' => '-1'));
59+
}
60+
}
61+
else{
62+
$this->redirect(array('record', 'added' => '-2'));
63+
}
64+
}
65+
3666
}

protected/models/CompletedCourses.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function attributeLabels()
5959
return array(
6060
'ID' => 'ID',
6161
'userID' => 'User',
62-
'courseID' => 'Course',
62+
'courseID' => 'Course Code',
6363
'Grade' => 'Grade',
6464
'GPA' => 'Gpa',
6565
);

protected/runtime/application.log

+102
Original file line numberDiff line numberDiff line change
@@ -11961,3 +11961,105 @@ Stack trace:
1196111961
REQUEST_URI=/index.php?r=scheduler/DropCourse
1196211962
in C:\xampp\htdocs\ConUScheduler\protected\controllers\SchedulerController.php (306)
1196311963
in C:\xampp\htdocs\ConUScheduler\index.php (13)
11964+
2016/04/03 05:28:41 [error] [system.db.CDbCommand] CDbCommand::fetch() failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'field list'. The SQL statement executed was: SELECT `id`, `username`, `profile`
11965+
FROM `completed_courses`.
11966+
in B:\Program Files\xamp\htdocs\ConUScheduler\protected\views\profile\record.php (54)
11967+
in B:\Program Files\xamp\htdocs\ConUScheduler\protected\controllers\ProfileController.php (27)
11968+
in B:\Program Files\xamp\htdocs\ConUScheduler\index.php (13)
11969+
2016/04/03 05:28:41 [error] [exception.CDbException] exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'field list'. The SQL statement executed was: SELECT `id`, `username`, `profile`
11970+
FROM `completed_courses`' in B:\Program Files\xamp\htdocs\ConUScheduler\framework\db\CDbCommand.php:543
11971+
Stack trace:
11972+
#0 B:\Program Files\xamp\htdocs\ConUScheduler\framework\db\CDbCommand.php(415): CDbCommand->queryInternal('fetch', Array, Array)
11973+
#1 B:\Program Files\xamp\htdocs\ConUScheduler\protected\views\profile\record.php(54): CDbCommand->queryRow()
11974+
#2 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CBaseController.php(126): require('B:\Program File...')
11975+
#3 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CBaseController.php(95): CBaseController->renderInternal('B:\Program File...', Array, true)
11976+
#4 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(869): CBaseController->renderFile('B:\Program File...', Array, true)
11977+
#5 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(782): CController->renderPartial('record', Array, true)
11978+
#6 B:\Program Files\xamp\htdocs\ConUScheduler\protected\controllers\ProfileController.php(27): CController->render('record', Array)
11979+
#7 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\actions\CInlineAction.php(49): ProfileController->actionRecord()
11980+
#8 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(308): CInlineAction->runWithParams(Array)
11981+
#9 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(133): CController->runAction(Object(CInlineAction))
11982+
#10 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilter.php(40): CFilterChain->run()
11983+
#11 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(1145): CFilter->filter(Object(CFilterChain))
11984+
#12 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CInlineFilter.php(58): CController->filterAccessControl(Object(CFilterChain))
11985+
#13 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))
11986+
#14 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(291): CFilterChain->run()
11987+
#15 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
11988+
#16 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CWebApplication.php(282): CController->run('record')
11989+
#17 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CWebApplication.php(141): CWebApplication->runController('profile/record')
11990+
#18 B:\Program Files\xamp\htdocs\ConUScheduler\framework\base\CApplication.php(185): CWebApplication->processRequest()
11991+
#19 B:\Program Files\xamp\htdocs\ConUScheduler\index.php(13): CApplication->run()
11992+
#20 {main}
11993+
REQUEST_URI=/index.php?r=profile/record&added=1
11994+
HTTP_REFERER=http://localhost/index.php?r=profile/record
11995+
---
11996+
2016/04/03 05:46:45 [error] [php] Undefined index: ID (B:\Program Files\xamp\htdocs\ConUScheduler\protected\views\profile\record.php:56)
11997+
Stack trace:
11998+
#0 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(869): ProfileController->renderFile()
11999+
#1 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(782): ProfileController->renderPartial()
12000+
#2 B:\Program Files\xamp\htdocs\ConUScheduler\protected\controllers\ProfileController.php(27): ProfileController->render()
12001+
#3 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\actions\CInlineAction.php(49): ProfileController->actionRecord()
12002+
#4 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(308): CInlineAction->runWithParams()
12003+
#5 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(133): ProfileController->runAction()
12004+
#6 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilter.php(40): CFilterChain->run()
12005+
#7 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(1145): CAccessControlFilter->filter()
12006+
#8 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CInlineFilter.php(58): ProfileController->filterAccessControl()
12007+
#9 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter()
12008+
#10 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(291): CFilterChain->run()
12009+
#11 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(265): ProfileController->runActionWithFilters()
12010+
#12 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CWebApplication.php(282): ProfileController->run()
12011+
#13 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CWebApplication.php(141): CWebApplication->runController()
12012+
#14 B:\Program Files\xamp\htdocs\ConUScheduler\framework\base\CApplication.php(185): CWebApplication->processRequest()
12013+
#15 B:\Program Files\xamp\htdocs\ConUScheduler\index.php(13): CWebApplication->run()
12014+
REQUEST_URI=/index.php?r=profile/record&added=1
12015+
in B:\Program Files\xamp\htdocs\ConUScheduler\protected\views\profile\record.php (56)
12016+
in B:\Program Files\xamp\htdocs\ConUScheduler\protected\controllers\ProfileController.php (27)
12017+
in B:\Program Files\xamp\htdocs\ConUScheduler\index.php (13)
12018+
2016/04/03 05:52:20 [error] [system.db.CDbCommand] CDbCommand::fetch() failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'field list'. The SQL statement executed was: SELECT `id`, `username`, `profile`
12019+
FROM `completed_courses`.
12020+
in B:\Program Files\xamp\htdocs\ConUScheduler\protected\controllers\ProfileController.php (48)
12021+
in B:\Program Files\xamp\htdocs\ConUScheduler\index.php (13)
12022+
2016/04/03 05:52:20 [error] [exception.CDbException] exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'field list'. The SQL statement executed was: SELECT `id`, `username`, `profile`
12023+
FROM `completed_courses`' in B:\Program Files\xamp\htdocs\ConUScheduler\framework\db\CDbCommand.php:543
12024+
Stack trace:
12025+
#0 B:\Program Files\xamp\htdocs\ConUScheduler\framework\db\CDbCommand.php(415): CDbCommand->queryInternal('fetch', Array, Array)
12026+
#1 B:\Program Files\xamp\htdocs\ConUScheduler\protected\controllers\ProfileController.php(48): CDbCommand->queryRow()
12027+
#2 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\actions\CInlineAction.php(49): ProfileController->actionAddCompleted()
12028+
#3 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(308): CInlineAction->runWithParams(Array)
12029+
#4 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(133): CController->runAction(Object(CInlineAction))
12030+
#5 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilter.php(40): CFilterChain->run()
12031+
#6 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(1145): CFilter->filter(Object(CFilterChain))
12032+
#7 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CInlineFilter.php(58): CController->filterAccessControl(Object(CFilterChain))
12033+
#8 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))
12034+
#9 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(291): CFilterChain->run()
12035+
#10 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
12036+
#11 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CWebApplication.php(282): CController->run('AddCompleted')
12037+
#12 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CWebApplication.php(141): CWebApplication->runController('profile/AddComp...')
12038+
#13 B:\Program Files\xamp\htdocs\ConUScheduler\framework\base\CApplication.php(185): CWebApplication->processRequest()
12039+
#14 B:\Program Files\xamp\htdocs\ConUScheduler\index.php(13): CApplication->run()
12040+
#15 {main}
12041+
REQUEST_URI=/index.php?r=profile/AddCompleted
12042+
HTTP_REFERER=http://localhost/index.php?r=profile/record&added=1
12043+
---
12044+
2016/04/03 07:40:15 [error] [php] Undefined variable: get (B:\Program Files\xamp\htdocs\ConUScheduler\protected\views\profile\record.php:99)
12045+
Stack trace:
12046+
#0 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(869): ProfileController->renderFile()
12047+
#1 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(782): ProfileController->renderPartial()
12048+
#2 B:\Program Files\xamp\htdocs\ConUScheduler\protected\controllers\ProfileController.php(27): ProfileController->render()
12049+
#3 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\actions\CInlineAction.php(49): ProfileController->actionRecord()
12050+
#4 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(308): CInlineAction->runWithParams()
12051+
#5 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(133): ProfileController->runAction()
12052+
#6 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilter.php(40): CFilterChain->run()
12053+
#7 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(1145): CAccessControlFilter->filter()
12054+
#8 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CInlineFilter.php(58): ProfileController->filterAccessControl()
12055+
#9 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter()
12056+
#10 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(291): CFilterChain->run()
12057+
#11 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CController.php(265): ProfileController->runActionWithFilters()
12058+
#12 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CWebApplication.php(282): ProfileController->run()
12059+
#13 B:\Program Files\xamp\htdocs\ConUScheduler\framework\web\CWebApplication.php(141): CWebApplication->runController()
12060+
#14 B:\Program Files\xamp\htdocs\ConUScheduler\framework\base\CApplication.php(185): CWebApplication->processRequest()
12061+
#15 B:\Program Files\xamp\htdocs\ConUScheduler\index.php(13): CWebApplication->run()
12062+
REQUEST_URI=/index.php?r=profile/record&added=-2
12063+
in B:\Program Files\xamp\htdocs\ConUScheduler\protected\views\profile\record.php (99)
12064+
in B:\Program Files\xamp\htdocs\ConUScheduler\protected\controllers\ProfileController.php (27)
12065+
in B:\Program Files\xamp\htdocs\ConUScheduler\index.php (13)

protected/views/profile/record.php

+65-5
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,70 @@
3535
}
3636

3737
}
38-
$finalGPA=$sum/$creditTotal;
39-
$finalGPA=round($finalGPA,2);
40-
echo "<h2>";
38+
if($creditTotal>0) {
39+
$finalGPA = $sum / $creditTotal;
40+
$finalGPA = round($finalGPA, 2);
41+
echo "<h2>";
42+
43+
echo "Total GPA: $finalGPA";
44+
echo "</h2>";
45+
}
46+
47+
?>
48+
49+
50+
51+
52+
<div class="form">
53+
<?php
54+
55+
$form=$this->beginWidget('CActiveForm');
56+
57+
?>
58+
59+
<p class="note">Fields with <span class="required">*</span> are required.</p>
60+
61+
<div class="row">
62+
<?php echo $form->labelEx($model,'courseID'); ?>
63+
<?php echo $form->textField($model,'courseID'); ?>
64+
<?php echo $form->error($model,'courseID'); ?>
65+
</div>
66+
67+
<div class="row">
68+
<?php echo $form->labelEx($model,'Grade'); ?>
69+
<?php echo $form->textField($model,'Grade'); ?>
70+
<?php echo $form->error($model,'Grade'); ?>
71+
72+
</div>
73+
74+
75+
<div class="row buttons">
76+
<?php echo CHtml::button('Submit', array('submit' => array('profile/AddCompleted'))); ?>
77+
</div>
78+
79+
<?php $this->endWidget(); ?>
80+
</div>
81+
<?php
82+
/*
83+
if(isset($_REQUEST['added']))
84+
{
85+
$get=$_REQUEST['added'];
86+
echo "<div>";
87+
if($_REQUEST['added']='1')
88+
{
89+
echo "Class Successfully Added";
90+
print_r($_REQUEST);
91+
echo $_REQUEST['added'];
92+
93+
}elseif($_REQUEST['added']=-'1')
94+
{
95+
echo"Invalid Course code";
96+
}elseif($_REQUEST['added']='-2')
97+
{
98+
echo "Invalid Grade";
99+
}
100+
echo "</div";
101+
}
102+
*/
41103

42-
echo "Total GPA: $finalGPA";
43-
echo "</h2>";
44104
?>

0 commit comments

Comments
 (0)