Example #1
0
$token = $_COOKIE['uneeoscetoken'];
$formid = $_REQUEST['id'];
$authlib = new authlib();
$authresult = '';
// checking token
$loggedinuserdata = new SimpleXMLElement($authlib->getDetailsByToken($token));
if (strlen($loggedinuserdata->error) > 1) {
    // print_r($loggedinuserdata);
    //$headerStr = $loggedinuserdata->name;
    header("Location: ../index.php");
    exit;
}
// getting form definition
$titleStr = '';
$enumlib = new EnumLib();
$formdef = simplexml_load_string($enumlib->getExamInstanceQuestionsByID($formid));
$titleStr = $formdef->overview->data->instance->name;
$scaleXML = simplexml_load_string($enumlib->getCriteriaScaleItems($formdef->overview->data->instance->scale_id));
$formtable = "<table style='width:100%' id='assessment_form_table'><tr style='background-color:#F3F3F3;'><th style='width:20%'>Assessment item</th><th colspan='{$scaleXML->count()}' style='width:40%'>Quality of Performance</th><th>Comments</th></tr>";
$count = 1;
$i = 0;
$questionArr = "[";
foreach ($formdef->questiondata->question as $question) {
    switch ($question->type) {
        case '0':
            $formtable .= "<tr id='qrow_{$question->id}' style='background-color:rgba(255, 200, 200, 1)'><td><span >{$count}) {$question->text}</span></td>";
            $i = 0;
            foreach ($scaleXML->item as $item) {
                $formtable .= "<td><input type='radio' name='choice_id_{$question->id}' id='choice_id_{$question->id}_{$i}' value='{$item->value}' data-iconpos='left' data-theme='e' needs_comment='{$item->needs_comment}' onclick='markQuestion({$question->id})'/><label for='choice_id_{$question->id}_{$i}'>{$item->short_description}</label></td>";
                $i++;
            }
Example #2
0
     include 'lib/FormsLib.php';
     include 'lib/EnumLib.php';
     $enumLib = new EnumLib();
     $returnStr = $enumLib->getQuestionsBySearchStr($_REQUEST['searchstr']);
     break;
 case 'deleteassessmentitem':
     include 'lib/FormsLib.php';
     include 'lib/EnumLib.php';
     $formslib = new FormsLib();
     $returnStr = $formslib->removeQuestionFromInstance($_REQUEST['id']);
     break;
 case 'getmarkingsheetdefinition':
     include 'lib/FormsLib.php';
     include 'lib/EnumLib.php';
     $enumLib = new EnumLib();
     $returnStr = $enumLib->getExamInstanceQuestionsByID($_REQUEST['id']);
     break;
     /////////////////////////
     //Criteria types management
     //////////////////////////
 /////////////////////////
 //Criteria types management
 //////////////////////////
 case 'getcriteriaitembyid':
     include 'lib/FormsLib.php';
     include 'lib/EnumLib.php';
     $enumLib = new EnumLib();
     $returnStr = $enumLib->getCriteriaItemByID($_REQUEST['id']);
     break;
 case 'addcriteriascale':
     include 'lib/FormsLib.php';
Example #3
0
 /**
  * Gets the report for a participant session as an XML
  * @global type $CFG
  * @param type $session_ID the session ID this is from
  * @return string an XML formatted string containing summary information about teh results of an assessment session for a student
  */
 public function getReportForStudentSession($session_ID)
 {
     global $CFG;
     $additional_rating = '';
     $moderated_additional_rating = "";
     $enumLib = new EnumLib();
     $returnVal = '<data><overview>';
     try {
         $conn = new PDO("mysql:host={$CFG->db};dbname={$CFG->schema}", $CFG->dbuser, $CFG->dbuserpass);
     } catch (PDOException $e) {
         die('<data><error>failed connecting to database</error><detail>' . $e->getMessage() . '</detail></data>');
     }
     // get exam definition (and information about the actual exam instance)
     $query = "SELECT (SELECT name FROM exam_instances WHERE ID = a.form_ID) as exam, (SELECT scaleID FROM exam_instances WHERE ID = a.form_ID) as scale, a.ID as sessionid, a.form_ID, a.start_timestamp, a.overall_rating, a.moderated_overall_rating, a.additional_rating, a.moderated_additional_rating, a.comments, a.moderated_comments, b.fname, b.lname, b.ID as studentid, b.studentnum, b.email,\n            (SELECT users.name FROM users WHERE users.ID = a.created_by_ID) as examiner,\n            a.moderated_by_id as moderatedby, a.last_modified_by_ID as modifiedby\n            FROM student_exam_sessions a INNER JOIN students b ON a.student_ID = b.ID WHERE a.ID = :sessionid";
     $stmt = $conn->prepare($query);
     $stmt->bindValue(':sessionid', $session_ID, PDO::PARAM_INT);
     $stmt->execute() or die('<data><error>select query failed query failed</error><detail>' . var_dump($stmt->errorInfo()) . '</detail></data>');
     // get some details about the criteria
     $resultArr = array();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $returnVal .= "<studentname><![CDATA[{$row['fname']} {$row['lname']}]]></studentname>\n                <fname><![CDATA[{$row['fname']}]]></fname>                \n                <lname><![CDATA[{$row['lname']}]]></lname>\n                <studentid>{$row['studentid']}</studentid>\n                <sessionid>{$row['sessionid']}</sessionid>\n                <formid>{$row['form_ID']}</formid>\n                    <scaleid>{$row['scale']}</scaleid>\n                    <exam><![CDATA[{$row['exam']}]]></exam>\n                        <datetime>" . date('d/m/Y', $row['start_timestamp']) . "</datetime>\n                <studentnum>{$row['studentnum']}</studentnum>\n                    <studentemail><![CDATA[{$row['email']}]]></studentemail>\n                        <examiner><![CDATA[{$row['examiner']}]]></examiner>";
         switch ($row['additional_rating']) {
             case "2":
                 $additional_rating = "Excellent";
                 break;
             case "1":
                 $additional_rating = "Expected Standard";
                 break;
             case "0":
                 $additional_rating = "Marginal Pass";
                 break;
             default:
                 break;
         }
         switch ($row['moderated_additional_rating']) {
             case "2":
                 $moderated_additional_rating = "Excellent";
                 break;
             case "1":
                 $moderated_additional_rating = "Expected Standard";
                 break;
             case "0":
                 $moderated_additional_rating = "Marginal Pass";
                 break;
             default:
                 break;
         }
         $returnVal .= "<overall_rating>" . ($row['overall_rating'] == '1' ? 'Satisfactory' : 'Not satisfactory') . "</overall_rating>\n                            <moderated_overall_rating>" . ($row['moderated_overall_rating'] == '1' ? 'Satisfactory' : 'Not satisfactory') . "</moderated_overall_rating>\n                            <overall_rating_value>{$row['overall_rating']}</overall_rating_value>\n                            <moderated_overall_rating_value>{$row['moderated_overall_rating']}</moderated_overall_rating_value>\n                            <additional_rating>" . ($row['overall_rating'] == '1' ? "{$additional_rating}" : "n/a") . "</additional_rating>\n                            <additional_rating_value>{$row['additional_rating']}</additional_rating_value>\n                            <moderated_additional_rating>" . ($row['moderated_overall_rating'] == '1' ? "{$moderated_additional_rating}" : "n/a") . "</moderated_additional_rating>\n                            <moderated_additional_rating_value>{$row['moderated_additional_rating']}</moderated_additional_rating_value>\n                                <moderated_by>{$row['moderatedby']}</moderated_by>\n                                <modified_by>{$row['modifiedby']}</modified_by>\n                            <comments><![CDATA[{$row['comments']}]]></comments>\n                            <moderated_comments><![CDATA[{$row['moderated_comments']}]]></moderated_comments>\n                            ";
         $instanceID = $row['form_ID'];
     }
     $returnVal .= "</overview><questiondata>";
     $stmt->closeCursor();
     $formDef = simplexml_load_string($enumLib->getExamInstanceQuestionsByID($instanceID));
     // print($enumLib->getExamInstanceQuestionsByID($instanceID));
     foreach ($formDef->questiondata->question as $question) {
         $returnVal .= "<question><id>{$question->id}</id><text><![CDATA[{$question->text}]]></text><type>{$question->type}</type>";
         //    foreach ($question->criteriadata->data->criteria as $criteria) {
         $query = "SELECT ID, answer,moderated_answer, comments,moderated_comments, last_modified_timestamp, moderated_timestamp FROM student_exam_sessions_responses WHERE question_ID = :questionid  AND student_exam_session_ID = :sessionid";
         $stmt = $conn->prepare($query);
         $stmt->bindValue(':sessionid', $session_ID, PDO::PARAM_INT);
         $stmt->bindValue(':questionid', $question->id, PDO::PARAM_INT);
         $stmt->execute() or die('<data><error>select query failed query failed</error><detail>' . $stmt->errorCode() . '</detail></data>');
         while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
             $returnVal .= "<answerid>{$row['ID']}</answerid>\n                    <answer>{$row['answer']}</answer>\n                        <moderated_answer>{$row['moderated_answer']}</moderated_answer>\n                            <comment><![CDATA[{$row['comments']}]]></comment>\n                                <moderated_comment><![CDATA[{$row['moderated_comments']}]]></moderated_comment>\n                                    <moderated>{$row['moderated_timestamp']}</moderated><modified>{$row['last_modified_timestamp']}</modified>";
         }
         $stmt->closeCursor();
         $returnVal .= "</question>";
     }
     $returnVal .= "</questiondata></data>";
     return $returnVal;
 }
Example #4
0
 public function get_printable_assessment_form_as_word($id, $PHPWord)
 {
     global $CFG;
     $count = 0;
     $enumlib = new EnumLib();
     $formdef = simplexml_load_string($enumlib->getExamInstanceQuestionsByID($id));
     $scaleXML = simplexml_load_string($enumlib->getCriteriaScaleItems($formdef->overview->data->instance->scale_id));
     // Create a new PHPWord Object
     // Every element you want to append to the word document is placed in a section. So you need a section:
     $section = $PHPWord->createSection();
     // add the title
     $section->addText($formdef->overview->data->instance->name, array('name' => 'Tahoma', 'size' => 14, 'bold' => true));
     $section->addText("Student Name:\t____________________", array('name' => 'Tahoma', 'size' => 12, 'bold' => true));
     $section->addText("Student Number:\t____________________", array('name' => 'Tahoma', 'size' => 12, 'bold' => true));
     // add the table for the asessment
     $tableStyle = array('border' => 'single', 'borderColor' => '000000', 'borderSize' => 6);
     $headerCellStyle = array('bgColor' => 'D9D9D9', 'border' => 'single', 'borderColor' => '000000', 'borderSize' => 6);
     $headerSpanCellStyle = array('bgColor' => 'D9D9D9', 'border' => 'single', 'borderColor' => '000000', 'borderSize' => 6, 'gridSpan' => count($scaleXML->children()) + 1);
     $bodyCellStyle = array('border' => 'single', 'borderColor' => '000000', 'borderSize' => 6);
     $table = $section->addTable($tableStyle);
     $table->addRow();
     $table->addCell(3750, $headerCellStyle)->addText('Assessment Criteria', array('name' => 'Tahoma', 'size' => 12));
     $cell = $table->addCell(6000, $headerSpanCellStyle)->addText('Quality of Performance', array('name' => 'Tahoma', 'size' => 12));
     $table->addRow();
     $table->addCell(3750, $headerCellStyle);
     $cellwidth = 0;
     foreach ($scaleXML->item as $item) {
         $table->addCell(750, $headerCellStyle)->addText($item->short_description, array('name' => 'Tahoma', 'size' => 12));
         $cellwidth += 750;
     }
     $table->addCell(6000 - $cellwidth, $headerCellStyle)->addText('Comments', array('name' => 'Tahoma', 'size' => 12));
     foreach ($formdef->questiondata->question as $question) {
         //   if ((($count % 15) != 0) || ($count == 0)) {
         switch ($question->type) {
             case '0':
                 //  $htmlStr.="<tr><th class='form' colspan='4'>{$question->text}</th></tr>";
                 $count++;
                 $table->addRow();
                 $textrun = $table->addCell(3750, $bodyCellStyle)->addTextRun();
                 $textrun->addText("{$count}) ", array('name' => 'Tahoma', 'size' => 12));
                 $textrun->addText($question->text, array('name' => 'Tahoma', 'size' => 12 - 1 * (strlen($question->text) / 25)));
                 $cellwidth = 0;
                 foreach ($scaleXML->item as $item) {
                     $textrun = $table->addCell(750, $bodyCellStyle)->addText("□", array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
                     $cellwidth += 750;
                 }
                 // $textrun = $table->addCell(750, $bodyCellStyle)->addText("□", array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
                 // $table->addCell(750, $bodyCellStyle)->addText('□', array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
                 //   $table->addCell(6000-$cellwidth, $headerCellStyle)->addText('Comments', array('name' => 'Tahoma', 'size' => 12));
                 $table->addCell(6000 - $cellwidth, $bodyCellStyle);
                 break;
             case '1':
                 $count++;
                 $table->addRow();
                 $textrun = $table->addCell(3750, $bodyCellStyle)->addTextRun();
                 $textrun->addText("{$count}) ", array('name' => 'Tahoma', 'size' => 12));
                 $textrun->addText($question->text, array('name' => 'Tahoma', 'size' => 12 - 1 * (strlen($question->text) / 25)));
                 $textrun = $table->addCell(750, $bodyCellStyle)->addText("□", array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
                 $table->addCell(750, $bodyCellStyle)->addText('□', array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
                 $table->addCell(4500, $bodyCellStyle);
                 break;
             default:
                 break;
         }
     }
     $section->addTextBreak(1);
     $section->addText("Overall Global rating", array('name' => 'Tahoma', 'size' => 12));
     $table = $section->addTable($tableStyle);
     $table->addRow();
     $textrun = $table->addCell(4875, $headerCellStyle)->addTextRun();
     $textrun->addText('Satisfactory');
     $textrun->addText("□", array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
     $textrun = $table->addCell(4875, $headerCellStyle)->addTextRun();
     $textrun->addText('Not Satisfactory');
     $textrun->addText("□", array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
     $section->addTextBreak(1);
     $section->addText("Additional Rating if Satisfactory", array('name' => 'Tahoma', 'size' => 12));
     $table = $section->addTable($tableStyle);
     $table->addRow();
     $textrun = $table->addCell(3250, $headerCellStyle)->addTextRun();
     $textrun->addText('Excellent');
     $textrun->addText("□", array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
     $textrun = $table->addCell(3250, $headerCellStyle)->addTextRun();
     $textrun->addText('Expected Standard');
     $textrun->addText("□", array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
     $textrun = $table->addCell(3250, $headerCellStyle)->addTextRun();
     $textrun->addText('Marginal Pass');
     $textrun->addText("□", array('name' => 'Tahoma', 'size' => 20, 'bold' => true));
     $section->addTextBreak(1);
     $section->addText("Overall Comments", array('name' => 'Tahoma', 'size' => 12));
     $section->addText("____________________________________________________________________", array('name' => 'Tahoma', 'size' => 12));
     $section->addText("____________________________________________________________________", array('name' => 'Tahoma', 'size' => 12));
     $section->addTextBreak(1);
     $section->addText("Mark:\t\t\t____________________", array('name' => 'Tahoma', 'size' => 12));
     $section->addText("Examiner Name:\t____________________", array('name' => 'Tahoma', 'size' => 12));
     $section->addText("Signature:\t\t____________________    Date:_____________________", array('name' => 'Tahoma', 'size' => 12));
     // headers and footers
     $header = $section->addHeader();
     $header->addText('UNCONTROLLED DRAFT ONLY- NOT FOR USE IN EXAMINATION');
     $header = $section->addFooter();
     $header->addText('Generated:' . date("j F, Y, g:i a"));
     return $PHPWord;
 }