Exemplo n.º 1
0
    function generate_html($attempts, $title_report = '')
    {
        global $JLMS_CONFIG;
        ob_start();
        JLMS_reporting::addCSSStyles();
        ?>
		<table>
			<tr class="title_report">
				<td>
					<?php 
        echo $title_report;
        ?>
				</td>
			</tr>
			<tr>
				<td>
					<table class="after_header_info">
						<tr>
							<td class="date_title">
								Date:
							</td>
							<td class="date_value">
								<?php 
        echo date("d F Y");
        ?>
							</td>
						</tr>
					</table>
					<br />	
				</td>
			</tr>
			<tr>
				<td>
		
					<table cellpadding="0" cellspacing="">
						<tr>
							<td colspan="10">
								<table width="100%" cellpadding="0" cellspacing="0" border="0" class="hits_data" id="reports_quiz">
									<tr>
										<th class="header_title">
											Student Name
										</th>
										<th class="header_title">
											Username
										</th>
										<th class="hit_title">
											Quiz
										</th>
										<th class="hit_title">
											User Score
										</th>
										<th class="hit_title">
											Total Score
										</th>
										<th class="hit_title">
											Date/Time
										</th>
										<th class="hit_title">
											Question
										</th>
										<th class="hit_title">
											Quiestions Options
										</th>
										<th class="hit_title">
											User Choice
										</th>
										<th class="hit_title">
											Right Answer
										</th>
									</tr>
									
									<?php 
        $k = 2;
        for ($i = 0; $i < count($attempts); $i++) {
            $row = $attempts[$i];
            $questions = $row->questions;
            $qi = 0;
            foreach ($questions as $question) {
                $answers = $question->question_information['answers'];
                $data = $question->question_information['data'];
                $k = 3 - $k;
                for ($ai = 0; $ai < count($answers); $ai++) {
                    if ($ai) {
                        ?>
													<tr class="<?php 
                        echo 'row_' . $k;
                        ?>
">
														<td colspan="7">
															
														</td>
														<?php 
                        if (in_array($question->c_type, array(1, 12, 2, 13, 3))) {
                            ?>
														<td class="hit_value">
															<?php 
                            echo isset($answers[$ai]->c_choice) ? $answers[$ai]->c_choice : '';
                            ?>
														</td>
														<td class="hit_value">
															<?php 
                            echo isset($answers[$ai]->sc_id) && $answers[$ai]->sc_id ? 'X' : '';
                            ?>
														</td>
														<td class="hit_value">
															<?php 
                            echo isset($answers[$ai]->c_right) && $answers[$ai]->c_right ? 'X' : '';
                            ?>
														</td>
														<?php 
                        } else {
                            if (in_array($question->c_type, array(4, 5, 11))) {
                                ?>
														<td class="hit_value">
															<?php 
                                echo $answers[$ai]->c_left_text;
                                ?>
														</td>
														<td class="hit_value">
															<?php 
                                echo $answers[$ai]->c_sel_text;
                                ?>
														</td>
														<td class="hit_value">
															<?php 
                                echo $answers[$ai]->c_right_text;
                                ?>
														</td>
														<?php 
                            } else {
                                if (in_array($question->c_type, array(6))) {
                                    ?>
														<td class="hit_value">
															
														</td>
														<td class="hit_value">
															<?php 
                                    echo $answers[$ai]->c_answer;
                                    ?>
														</td>
														<td class="hit_value">
															
														</td>
														<?php 
                                } else {
                                    if (in_array($question->c_type, array(7))) {
                                        ?>
														<td class="hit_value">
															<?php 
                                        echo $data['c_image'];
                                        ?>
														</td>
														<td class="hit_value">
															<?php 
                                        echo isset($data['c_right']) && $data['c_right'] ? 'right' : 'wrong';
                                        ?>
														</td>
														<td class="hit_value">
															
														</td>
														<?php 
                                    }
                                }
                            }
                        }
                        /*else
                        		if(in_array($question->c_type, array(8,9))){
                        		?>
                        		<td class="hit_value">
                        			c
                        		</td>
                        		<td class="hit_value">
                        			c
                        		</td>
                        		<td class="hit_value">
                        			c
                        		</td>
                        		<?php	
                        		}*/
                        ?>
													</tr>
													<?php 
                    } else {
                        if (!$ai && !$qi) {
                            ?>
													<tr class="<?php 
                            echo 'row_' . $k;
                            ?>
">
														<td class="header_value">
															<?php 
                            echo $row->name;
                            ?>
														</td>
														<td class="header_value">
															<?php 
                            echo $row->username;
                            ?>
														</td>
														<td class="hit_value">
															<?php 
                            echo $row->c_title;
                            ?>
														</td>
														<td class="hit_value">
															<?php 
                            echo $row->c_full_score;
                            ?>
														</td>
														<td class="hit_value">
															<?php 
                            echo $row->c_total_score;
                            ?>
														</td>
														<td class="hit_value">
															<?php 
                            echo JLMS_dateToDisplay($row->c_date_time);
                            ?>
														</td>
														<td class="hit_value">
															<?php 
                            echo $question->c_question;
                            ?>
														</td>
														<?php 
                            if (in_array($question->c_type, array(1, 12, 2, 13, 3))) {
                                ?>
														<td class="hit_value">
															<?php 
                                echo isset($answers[$ai]->c_choice) ? $answers[$ai]->c_choice : '';
                                ?>
														</td>
														<td class="hit_value">
															<?php 
                                echo isset($answers[$ai]->sc_id) && $answers[$ai]->sc_id ? 'X' : '';
                                ?>
														</td>
														<td class="hit_value">
															<?php 
                                echo isset($answers[$ai]->c_right) && $answers[$ai]->c_right ? 'X' : '';
                                ?>
														</td>
														<?php 
                            } else {
                                if (in_array($question->c_type, array(4, 5, 11))) {
                                    ?>
														<td class="hit_value">
															<?php 
                                    echo $answers[$ai]->c_left_text;
                                    ?>
														</td>
														<td class="hit_value">
															<?php 
                                    echo $answers[$ai]->c_sel_text;
                                    ?>
														</td>
														<td class="hit_value">
															<?php 
                                    echo $answers[$ai]->c_right_text;
                                    ?>
														</td>
														<?php 
                                } else {
                                    if (in_array($question->c_type, array(6))) {
                                        ?>
														<td class="hit_value">
															
														</td>
														<td class="hit_value">
															<?php 
                                        echo $answers[$ai]->c_answer;
                                        ?>
														</td>
														<td class="hit_value">
															
														</td>
														<?php 
                                    } else {
                                        if (in_array($question->c_type, array(7))) {
                                            ?>
														<td class="hit_value">
															<?php 
                                            echo $data['c_image'];
                                            ?>
														</td>
														<td class="hit_value">
															<?php 
                                            echo isset($data['c_right']) && $data['c_right'] ? 'right' : 'wrong';
                                            ?>
														</td>
														<td class="hit_value">
															
														</td>
														<?php 
                                        }
                                    }
                                }
                            }
                            /*else
                            		if(in_array($question->c_type, array(8,9))){
                            		?>
                            		<td class="hit_value">
                            			z
                            		</td>
                            		<td class="hit_value">
                            			z
                            		</td>
                            		<td class="hit_value">
                            			z
                            		</td>
                            		<?php	
                            		}*/
                            ?>
													</tr>
													<?php 
                        } else {
                            if (!$ai) {
                                ?>
													<tr class="<?php 
                                echo 'row_' . $k;
                                ?>
">
														<td colspan="6">
															
														</td>
														<td class="hit_value">
															<?php 
                                echo $question->c_question;
                                ?>
														</td>
														<?php 
                                if (in_array($question->c_type, array(1, 12, 2, 13, 3))) {
                                    ?>
														<td class="hit_value">
															<?php 
                                    echo isset($answers[$ai]->c_choice) ? $answers[$ai]->c_choice : '';
                                    ?>
														</td>
														<td class="hit_value">
															<?php 
                                    echo isset($answers[$ai]->sc_id) && $answers[$ai]->sc_id ? 'X' : '';
                                    ?>
														</td>
														<td class="hit_value">
															<?php 
                                    echo isset($answers[$ai]->c_right) && $answers[$ai]->c_right ? 'X' : '';
                                    ?>
														</td>
														<?php 
                                } else {
                                    if (in_array($question->c_type, array(4, 5, 11))) {
                                        ?>
														<td class="hit_value">
															<?php 
                                        echo $answers[$ai]->c_left_text;
                                        ?>
														</td>
														<td class="hit_value">
															<?php 
                                        echo $answers[$ai]->c_sel_text;
                                        ?>
														</td>
														<td class="hit_value">
															<?php 
                                        echo $answers[$ai]->c_right_text;
                                        ?>
														</td>
														<?php 
                                    } else {
                                        if (in_array($question->c_type, array(6))) {
                                            ?>
														<td class="hit_value">
															
														</td>
														<td class="hit_value">
															<?php 
                                            echo $answers[$ai]->c_answer;
                                            ?>
														</td>
														<td class="hit_value">
															
														</td>
														<?php 
                                        } else {
                                            if (in_array($question->c_type, array(7))) {
                                                ?>
														<td class="hit_value">
															<?php 
                                                echo $data['c_image'];
                                                ?>
														</td>
														<td class="hit_value">
															<?php 
                                                echo isset($data['c_right']) && $data['c_right'] ? 'right' : 'wrong';
                                                ?>
														</td>
														<td class="hit_value">
															
														</td>
														<?php 
                                            } else {
                                                if (in_array($question->c_type, array(8, 9))) {
                                                    ?>
														<td class="hit_value">
															
														</td>
														<td class="hit_value">
															
														</td>
														<td class="hit_value">
															
														</td>
														<?php 
                                                }
                                            }
                                        }
                                    }
                                }
                                ?>
													</tr>
													<?php 
                            }
                        }
                    }
                    $k = 3 - $k;
                }
                $k = 3 - $k;
                $qi++;
            }
        }
        ?>
								</table>
							</td>
						</tr>
					</table>
					
				</td>
			</tr>
		</table>			
		
		<?php 
        $html = ob_get_contents();
        ob_get_clean();
        return $html;
    }
Exemplo n.º 2
0
 function outputXLS($data_xls, $tmpl_name)
 {
     global $JLMS_CONFIG;
     $file_name = $tmpl_name . '_' . date("dMY");
     if (preg_match('/Opera(\\/| )([0-9].[0-9]{1,2})/', $_SERVER['HTTP_USER_AGENT'])) {
         $UserBrowser = "Opera";
     } elseif (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $_SERVER['HTTP_USER_AGENT'])) {
         $UserBrowser = "IE";
     } else {
         $UserBrowser = '';
     }
     // UTF8 support
     $header_to_xls = '<meta http-equiv="content-type" content="text/html; charset=utf-8" />' . "\n";
     //CSS
     $header_to_xls .= JLMS_reporting::addCSSStyles();
     header("Content-type: application/vnd.ms-excel");
     header("Content-Transfer-Encoding: binary");
     header('Expires: 0');
     header("Accept-Ranges: bytes");
     header("Content-Length: " . strlen(trim($header_to_xls . $data_xls)));
     header('Content-Disposition: attachment; filename="' . $file_name . '.xls"');
     if ($UserBrowser == 'IE') {
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Pragma: no-cache');
     }
     echo $header_to_xls . $data_xls;
     exit;
 }