diff --git a/application/modules/courses/controllers/EditController.php b/application/modules/courses/controllers/EditController.php index f54b88b703b98737ce4e5fc79958c2faaffcd192..63f79621249202f2900b0ed5e8ede44cfeadaa9e 100644 --- a/application/modules/courses/controllers/EditController.php +++ b/application/modules/courses/controllers/EditController.php @@ -145,14 +145,18 @@ class Courses_EditController extends Creq_Controller_Action } if (in_array($request->getType(), array('RecertifyACE', 'RecertifyACEAndChangeCourse'))) { - $course->setAceRecertification( + // old code + /* $course->setAceRecertification( $rawIn['ace']['recertify']['semestersTaught'], $rawIn['ace']['recertify']['dataRevealed'], $rawIn['ace']['recertify']['dataFeedback'], $rawIn['ace']['recertify']['dataIncomplete'], $rawIn['ace']['recertify']['developPlan'], $rawIn['ace']['recertify']['blackboardUpload'] - ); + ); */ + + $course->setAceRecertification($rawIn['ace']['recertify']); + $course->setAceRecertificationBlackboardUpload($rawIn['ace']['blackboardUpload']); } $request->setJustification($rawIn['request']['justification']); diff --git a/application/modules/courses/models/CourseModel.php b/application/modules/courses/models/CourseModel.php index cdd014369c7db9089a48e626218872bbd8ecaae7..a2faf26aa18cad57d4a4e2d5210100ceac42a1d2 100644 --- a/application/modules/courses/models/CourseModel.php +++ b/application/modules/courses/models/CourseModel.php @@ -135,9 +135,35 @@ class Courses_CourseModel extends Unl_Model $records = $select->query()->fetchAll(); foreach ($records as $record) { - $record['semestersTaught'] = explode(',', $record['semestersTaught']); + // for each AceRecertification record, get the questions and answers + //SELECT q.*, a.* FROM creq.creqcourseacerecertifyanswers AS a + //INNER JOIN creq.creqcourseacerecertifyquestions AS q ON a.questionId = q.courseAceRecertifyQuestionId + //WHERE a.recertificationId = 785 ORDER BY q.questionSort; + $select = new Zend_Db_Select($db); + $select->from(array('a' => 'creqcourseacerecertifyanswers')); + $select->joinInner(array('q' => 'creqcourseacerecertifyquestions'), 'a.questionId = q.courseAceRecertifyQuestionId'); + $select->where('a.recertificationId = ?', $record['courseAceRecertificationId']); + $select->order('q.questionSort'); + $recordsRecertQA = $select->query()->fetchAll(); + //print_r($recordsRecertQA); + if (!$recordsRecertQA) { + // load current empty question set + //SELECT q.* FROM creq.creqcourseacerecertifyquestionsets as s + //INNER JOIN creq.creqcourseacerecertifyquestions AS q ON s.courseAceRecertifyQuestionSetId = q.questionSetId + //WHERE s.dateRetired IS NULL ORDER BY q.questionSort; + $select = new Zend_Db_Select($db); + $select->from(array('s' => 'creqcourseacerecertifyquestionsets')); + $select->joinInner(array('q' => 'creqcourseacerecertifyquestions'), 's.courseAceRecertifyQuestionSetId = q.questionSetId'); + $select->where('s.dateRetired IS NULL'); + $select->order('q.questionSort'); + $recordsRecertQA = $select->query()->fetchAll(); + //print_r($recordsRecertQA); + } + + //$record['semestersTaught'] = explode(',', $record['semestersTaught']); // original code to explode semesters text to an array + $courses[$courseId]['blackboardUpload'] = $record['blackboardUpload']; // need to carry this over from the recertification record $courseId = $record['generation']; - $courses[$courseId]['aceRecertification'] = $record; + $courses[$courseId]['aceRecertification'] = $recordsRecertQA; //$record; // oringal code was set to recertification record, where answers lived } // Activities @@ -1202,7 +1228,8 @@ class Courses_CourseModel extends Unl_Model $db = Zend_Registry::get('db'); - $sql = 'INSERT INTO creqCourseAceRecertifications (generation, semestersTaught, dataRevealed, dataFeedback, dataIncomplete, developPlan, blackboardUpload) VALUES '; + // old code + /* $sql = 'INSERT INTO creqCourseAceRecertifications (generation, semestersTaught, dataRevealed, dataFeedback, dataIncomplete, developPlan, blackboardUpload) VALUES '; $sqlParts = array(); foreach ($models as $model) { $sqlParts[] = $db->quoteInto('(?, ', $model->_data['courseGenerationId']) @@ -1224,6 +1251,24 @@ class Courses_CourseModel extends Unl_Model $model->_data['aceRecertification']['courseAceRecertificationId'] = $lastId; $lastId++; + } */ + + foreach ($models as $model) { + $sql = 'INSERT INTO creqCourseAceRecertifications (generation, blackboardUpload, semestersTaught, dataRevealed, dataFeedback, dataIncomplete, developPlan) VALUES '; + $sql .= $db->quoteInto('(?, ', $model->_data['courseGenerationId']); + $sql .= $db->quoteInto('?, ' , $model->_data['blackboardUpload']); + $sql .= "'','','','','')"; + $db->query($sql); + $lastId = $db->lastInsertId(); + + foreach ($model->_data['aceRecertification'] as $record) + { + $sql = 'INSERT INTO creqCourseAceRecertifyAnswers (questionId, recertificationId, answerText) VALUES '; + $sql .= $db->quoteInto('(?, ', $record["courseAceRecertifyQuestionId"]); + $sql .= $db->quoteInto('?, ' , $lastId); + $sql .= $db->quoteInto('?)' , $record["answerText"]); + $db->query($sql); + } } } @@ -1236,7 +1281,7 @@ class Courses_CourseModel extends Unl_Model $db = Zend_Registry::get('db'); // Update the courseAceRecertifications table - $sql = 'CREATE TEMPORARY TABLE creqCourseAceRecertificationsUpdate ' + /* $sql = 'CREATE TEMPORARY TABLE creqCourseAceRecertificationsUpdate ' . 'SELECT * FROM creqCourseAceRecertifications LIMIT 0'; $db->query($sql); @@ -1266,7 +1311,29 @@ class Courses_CourseModel extends Unl_Model . ' a.blackboardUpload = b.blackboardUpload ' . 'WHERE a.courseAceRecertificationId = b.courseAceRecertificationId '; $db->query($sql); - $db->query('DROP TABLE creqCourseAceRecertificationsUpdate'); + $db->query('DROP TABLE creqCourseAceRecertificationsUpdate'); */ + + foreach ($models as $model) { + $recert_id = ""; + + foreach ($model->_data['aceRecertification'] as $record) + { + $recert_id = $record["recertificationId"]; + $sql = 'UPDATE creqCourseAceRecertifyAnswers SET '; + $sql .= $db->quoteInto('answerText = ? ', $record["answerText"]); + $sql .= $db->quoteInto('WHERE recertificationId = ? ', $record["recertificationId"]); + $sql .= $db->quoteInto('AND questionId = ?', $record["questionId"]); + $db->query($sql); + } + + if ($recert_id != "") { + $sql = 'UPDATE creqCourseAceRecertifications SET '; + $sql .= $db->quoteInto('generation = ?, ', $model->_data['courseGenerationId']); + $sql .= $db->quoteInto('blackboardUpload = ? ', $model->_data['blackboardUpload']); + $sql .= $db->quoteInto('WHERE courseAceRecertificationId = ? ', $recert_id); + $db->query($sql); + } + } } static public function _insertAceOutcomes($models) @@ -2900,28 +2967,83 @@ class Courses_CourseModel extends Unl_Model public function getAceRecertification() { if (!is_array($this->_data['aceRecertification'])) { - return array( - 'semestersTaught' => array(), - 'dataRevealed' => NULL, - 'dataFeedback' => NULL, - 'dataIncomplete' => NULL, - 'developPlan' => NULL, - 'blackboardUpload' => 'no', - ); + // load current empty question set + //SELECT q.* FROM creq.creqcourseacerecertifyquestionsets as s + //INNER JOIN creq.creqcourseacerecertifyquestions AS q ON s.courseAceRecertifyQuestionSetId = q.questionSetId + //WHERE s.dateRetired IS NULL ORDER BY q.questionSort; + $select = new Zend_Db_Select($db); + $select->from(array('s' => 'creqcourseacerecertifyquestionsets')); + $select->joinInner(array('q' => 'creqcourseacerecertifyquestions'), 's.courseAceRecertifyQuestionSetId = q.questionSetId'); + $select->where('s.dateRetired IS NULL'); + $select->order('q.questionSort'); + $recordsRecertQA = $select->query()->fetchAll(); + return $recordsRecertQA; } return $this->_data['aceRecertification']; } - public function setAceRecertification($semestersTaught, $dataRevealed, $dataFeedback, $dataIncomplete, $developPlan, $blackboardUpload) + public function setAceRecertification($arrayRecertQA) { - $this->_data['aceRecertification'] = array( + // old code + /* $this->_data['aceRecertification'] = array( 'semestersTaught' => is_array($semestersTaught) ? $semestersTaught : array(), 'dataRevealed' => $dataRevealed, 'dataFeedback' => $dataFeedback, 'dataIncomplete' => $dataIncomplete, 'developPlan' => $developPlan, 'blackboardUpload' => in_array($blackboardUpload, array('no', 'yes')) ? $blackboardUpload : 'no', - ); + ); */ + + $questionIds = array(); + foreach ($arrayRecertQA as $key => $value) + { + $questionIds[] = $key; + } + + if ($questionIds != "") { + //SELECT q.* FROM creq.creqcourseacerecertifyquestions AS q + //WHERE q.courseAceRecertifyQuestionId IN (1,2,3,4,5) ORDER BY q.questionSort; + $db = Zend_Registry::get('db'); + $select = new Zend_Db_Select($db); + $select->from(array('q' => 'creqcourseacerecertifyquestions')); + $select->where('q.courseAceRecertifyQuestionId IN (?)', $questionIds); + $select->order('q.questionSort'); + $result = $select->query()->fetchAll(); + + $new_records = array(); + $i = 0; + foreach ($result as $record) { + $new_records[$i]["courseAceRecertifyQuestionId"] = $record["courseAceRecertifyQuestionId"]; + $new_records[$i]["questionSetId"] = $record["questionSetId"]; + $new_records[$i]["questionText"] = $record["questionText"]; + $new_records[$i]["questionType"] = $record["questionType"]; + $new_records[$i]["questionSort"] = $record["questionSort"]; + if ($record["questionType"] == "SemestersTaught") { + $new_records[$i]["answerText"] = implode(',',$arrayRecertQA[$record["courseAceRecertifyQuestionId"]]); + } else { + $new_records[$i]["answerText"] = $arrayRecertQA[$record["courseAceRecertifyQuestionId"]]; + } + $i += 1; + } + $arrayRecertQA = $new_records; + } else { + $arrayRecertQA = null; + } + + $this->_data['aceRecertification'] = $arrayRecertQA; + } + + public function getAceRecertificationBlackboardUpload() + { + if (!$this->_data['blackboardUpload']) { + return 'no'; + } + return $this->_data['blackboardUpload']; + } + + public function setAceRecertificationBlackboardUpload($blackboardUpload) + { + $this->_data['blackboardUpload'] = in_array($blackboardUpload, array('no', 'yes')) ? $blackboardUpload : 'no'; } public function removeAce() diff --git a/application/modules/courses/views/scripts/edit/index.phtml b/application/modules/courses/views/scripts/edit/index.phtml index ff6e9981cd236d7c2179172cef6ee0abf40e6816..1c732afdcd3bbd84257c46e9994d69ede46ab114 100644 --- a/application/modules/courses/views/scripts/edit/index.phtml +++ b/application/modules/courses/views/scripts/edit/index.phtml @@ -1102,92 +1102,53 @@ if (in_array($this->request->getType(), array('NewCourseWithACE', 'AddACEToCours <div class="main_section" id="recertifyAceSection"> <h2>ACE Recertification</h2> <ol> - <li> - <div class="required">Please indicate the semesters the course has been taught as an ACE certified course.</div> - <table id="semestersTaught" class="zentable primary"> - <thead> - <tr> - <th>Year</th> - <th>Fall</th> - <th>Spring</th> - <th>Summer</th> - <tr> - </thead> - <tbody> - <?php for($year = 2009; $year <= date('Y', time()); $year++) { ?> - <tr> - <td><?php echo $year . '-' . ($year+1); ?></td> - <?php foreach (array(8, 1, 5) as $season) { ?> - <?php $termCode = 1 . ($season == 8 ? substr($year, -2) : substr($year+1, -2)). $season; ?> - <td> - <?php echo $this->formCheckbox( - 'ace[recertify][semestersTaught][]', - in_array($termCode, $recertifyAceData['semestersTaught']) ? $termCode : NULL, - NULL, - array($termCode) - ); ?> - </td> - <?php } ?> - </tr> - <?php } ?> - </tbody> - </table> - </li> - - <li> - <div class="required"> - What have assessment data revealed about how the course helps students - achieve the designated Student Learning Outcome(s)? (You might be - able to complete this textbox by copying information found in the Summary - & Conclusion sections from your Department/Program ACE Assessment - Report.) - </div> - <?php echo $this->formTextarea('ace[recertify][dataRevealed]', $recertifyAceData['dataRevealed']); ?> - </li> - - <li> - <div class="required"> - How have those assessment data been used to help the course meet the - certified Student Learning Outcome(s)? (You might be able to complete - this textbox by copying information found in the Summary & Conclusion - sections from your Department/Program ACE Assessment Report.) - </div> - <?php echo $this->formTextarea('ace[recertify][dataFeedback]', $recertifyAceData['dataFeedback']); ?> - </li> - - <li> - <div class="required"> - If your assessment plan does not include a collection of student work - for all sections each time the course is taught, indicate how your - department ensures that all sections are taught in accordance with - the ACE expectations. - </div> - <?php echo $this->formTextarea('ace[recertify][dataIncomplete]', $recertifyAceData['dataIncomplete']); ?> - </li> - - <li> - <div class="required"> - If the response in the original proposal for ACE certification indicated - that the assessment process was still being developed, the University - Curriculum Committee (UCC) ACE Subcommittee expects an explanation - of the process. (You might be able to complete this textbox by copying - information found in the Methods section of the Department/Program ACE - Assessment Report.) - </div> - <?php echo $this->formTextarea( - 'ace[recertify][developPlan]', - $recertifyAceData['developPlan'], - array('style' => 'display:' . ($recertifyAceData['developPlan'] == 'N/A' ? 'none' : 'inline') . ';') - ); ?><br /> - <label> - N/A - <input type="checkbox" - id="ace-recertify-developPlan-na" - name="ace[recertify][developPlan]" - value="N/A" - <?php if ($recertifyAceData['developPlan'] == 'N/A') { ?>checked="checked"<?php } ?>> - </label> - </li> + <?php + foreach ($recertifyAceData as $question) { ?> + <li> + <div class="required"> + <?php echo htmlentities($question['questionText']); ?> + </div> + <?php + if ($question['questionType'] == "SemestersTaught") { + $semesterText = explode(',', $question['answerText']); + ?> + <table id="semestersTaught" class="zentable primary"> + <thead> + <tr> + <th>Year</th> + <th>Fall</th> + <th>Spring</th> + <th>Summer</th> + <tr> + </thead> + <tbody> + <?php for($year = 2009; $year <= date('Y', time()); $year++) { ?> + <tr> + <td><?php echo $year . '-' . ($year+1); ?></td> + <?php foreach (array(8, 1, 5) as $season) { ?> + <?php $termCode = 1 . ($season == 8 ? substr($year, -2) : substr($year+1, -2)). $season; ?> + <td> + <?php echo $this->formCheckbox( + 'ace[recertify]['.$question['courseAceRecertifyQuestionId'].'][]', + in_array($termCode, $semesterText) ? $termCode : NULL, + NULL, + array($termCode) + ); ?> + </td> + <?php } ?> + </tr> + <?php } ?> + </tbody> + </table> + <?php + } elseif ($question['questionType'] == "TextArea") { + echo $this->formTextarea('ace[recertify]['.$question['courseAceRecertifyQuestionId'].']', $question['answerText']); + } else { + echo 'Unknown question type, contact CREQ development support'; + } + ?> + </li> + <?php } ?> </ol> <fieldset class="wideOption"> @@ -1211,7 +1172,10 @@ if (in_array($this->request->getType(), array('NewCourseWithACE', 'AddACEToCours By checking this box, as the submitter of this course for ACE Recertification, you agree to upload the electronic student work samples into the Blackboard Content Collection folder. - <?php echo $this->formCheckbox('ace[recertify][blackboardUpload]', $recertifyAceData['blackboardUpload'], NULL, array('yes', 'no')); ?> + <?php + $blackboardUpload = $this->course->getAceRecertificationBlackboardUpload(); + echo $this->formCheckbox('ace[blackboardUpload]', $blackboardUpload, NULL, array('yes', 'no')); + ?> </label> </fieldset> diff --git a/application/modules/courses/views/scripts/view/course-info.phtml b/application/modules/courses/views/scripts/view/course-info.phtml index a6641011763c936906804a15b67f4e36516cec0b..6837dbba235870d8d652782d16de922f2a151d62 100644 --- a/application/modules/courses/views/scripts/view/course-info.phtml +++ b/application/modules/courses/views/scripts/view/course-info.phtml @@ -49,65 +49,30 @@ <div id="aceRecertification"> <h2>Recertification</h2> <ol class="questionList"> - <li> - <div class="question"> - Please indicate the semesters the course has been taught as an ACE certified course. - </div> - <div class="answer"> - <?php - $semestersTaught = array(); - foreach ($recertification['semestersTaught'] as $semesterTaught) { - $semestersTaught[] = $this->termDescription($semesterTaught) . ' (' . $semesterTaught . ')'; - } - echo implode(', ', $semestersTaught); - ?> - </div> - </li> - <li> - <div class="question"> - What have assessment data revealed about how the course helps students - achieve the designated Student Learning Outcome(s)? (You might be - able to complete this textbox by copying information found in the Summary - & Conclusion sections from your Department/Program ACE Assessment - Report.) - </div> - <div class="answer"> - <?php echo nl2br(htmlentities($recertification['dataRevealed'], ENT_COMPAT, 'UTF-8')); ?> - </div> - </li> - <li> - <div class="question"> - How have those assessment data been used to help the course meet the - certified Student Learning Outcome(s)? (You might be able to complete - this textbox by copying information found in the Summary & Conclusion - sections from your Department/Program ACE Assessment Report.) - </div> - <div class="answer"> - <?php echo nl2br(htmlentities($recertification['dataFeedback'], ENT_COMPAT, 'UTF-8')); ?> - </div> - </li> - <li> - <div class="question"> - If your assessment plan does not include collection of student work - from all sections each time the course is taught, indicate how your - department ensures that all sections are taught in accordance with - the ACE plan. - </div> - <div class="answer"> - <?php echo nl2br(htmlentities($recertification['dataIncomplete'], ENT_COMPAT, 'UTF-8')); ?> - </div> - </li> - <li> - <div class="question"> - If the response in the original proposal for ACE certification indicated - that the assessment process was still being developed, the UCC/ACE - subcommittee expects an explanation of the process. (May be referenced - in the Methods section of the Department ACE Assessment Report.) - </div> - <div class="answer"> - <?php echo nl2br(htmlentities($recertification['developPlan'], ENT_COMPAT, 'UTF-8')); ?> - </div> - </li> + <?php + foreach ($recertification as $question) { ?> + <li> + <div class="question"> + <?php echo htmlentities($question['questionText']); ?> + </div> + <div class="answer"> + <?php + if ($question['questionType'] == "SemestersTaught") { + $semesterText = explode(',', $question['answerText']); + $semestersTaught = array(); + foreach ($semesterText as $semesterTaught) { + $semestersTaught[] = $this->termDescription($semesterTaught) . ' (' . $semesterTaught . ')'; + } + echo implode(', ', $semestersTaught); + } elseif ($question['questionType'] == "TextArea") { + echo nl2br(htmlentities($question['answerText'], ENT_COMPAT, 'UTF-8')); + } else { + echo 'Unknown question type, contact CREQ development support'; + } + ?> + </div> + </li> + <?php } ?> </ol> </div>