18 require_once SQ_PACKAGES_PATH.
'/cms/page_templates/page_asset_listing/page_asset_listing_edit_fns.inc';
19 require_once SQ_FUDGE_PATH.
'/datetime_field/datetime_field.inc';
20 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
48 parent::__construct();
66 $write_access = $asset->writeAccess(
'attributes');
68 $attr = $asset->getAttribute(
'user_details_source');
69 $attr->paint($prefix.
'_'.$attr->id, !$write_access);
71 $form = $asset->getForm();
72 if (!is_null($form)) {
73 echo
'<p>'.get_asset_tag_line($form->id,
'details').
'</p>';
75 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($form);
77 $bodycopy = $asset->getBodycopy(
'user_details');
78 if (!is_null($bodycopy)) {
79 echo
'<p>'.get_asset_tag_line($bodycopy->id,
'contents').
'</p>';
81 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($bodycopy);
101 $write_access = $asset->writeAccess(
'attributes');
104 $attr = $asset->getAttribute(
'user_details_source');
105 $attr->process($prefix.
'_'.$attr->id);
106 if (!$attr->processed || !$asset->setAttrValue($attr->name, $attr->value)) {
112 return $write_access;
130 $write_access = $asset->writeAccess(
'attributes') && $asset->writeAccess(
'links');
132 $attr = $asset->getAttribute(
'after_submit_action');
133 $attr->paint($prefix.
'_'.$attr->id, !$write_access);
135 if ($attr->value ==
'thank_you') {
136 $bodycopy = $asset->getBodycopy(
'thank_you');
137 if (!is_null($bodycopy)) {
138 echo
'<p>'.get_asset_tag_line($bodycopy->id,
'contents').
'</p>';
140 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($bodycopy);
143 return $write_access;
161 $write_access = $asset->writeAccess(
'attributes') && $asset->writeAccess(
'links');
164 $attr = $asset->getAttribute(
'after_submit_action');
165 $attr->process($prefix.
'_'.$attr->id);
166 if (!$attr->processed || !$asset->setAttrValue($attr->name, $attr->value)) {
172 $enable_bodycopy = ($attr->value ==
'thank_you');
173 $asset->setBodycopy(
'thank_you', $enable_bodycopy);
176 return $write_access;
194 $write_access = $asset->writeAccess(
'attributes') && $asset->writeAccess(
'links');
197 $attr = $asset->getAttribute(
'can_retake');
198 $attr->process($prefix.
'_'.$attr->id);
199 if (!$attr->processed || !$asset->setAttrValue($attr->name, $attr->value)) {
206 $enable_bodycopy = !($attr->value);
207 $asset->setBodycopy(
'already_taken', $enable_bodycopy);
210 return $write_access;
228 $write_access = $asset->writeAccess(
'attributes') && $asset->writeAccess(
'links');
230 $attr = $asset->getAttribute(
'can_retake');
231 $attr->setEditParam(
'true_text', translate(
'yes'));
232 $attr->setEditParam(
'false_text', translate(
'no'));
233 $attr->paint($prefix.
'_'.$attr->id, !$write_access);
235 if ($attr->value == FALSE) {
236 $bodycopy = $asset->getBodycopy(
'already_taken');
237 if (!is_null($bodycopy)) {
238 echo
'<p>'.get_asset_tag_line($bodycopy->id,
'contents').
'</p>';
240 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($bodycopy);
243 return $write_access;
261 <table
class=
"sq-backend-table">
263 <th><?php echo translate(
'edit_format') ?></th>
264 <th><?php echo translate(
'note') ?></th>
267 $bodycopies = $asset->_bodycopies;
270 unset($bodycopies[
'page_contents']);
271 unset($bodycopies[
'no_results']);
275 foreach ($bodycopies as $bodycopy_code => $bodycopy_name) {
276 $this->
_paintDefaultFormatLink($asset->id, $bodycopy_code, translate(
'online_quiz_bodycopy_'.$bodycopy_code.
'_desc'));
278 $this->
_paintDefaultFormatLink($asset->id,
'user_details', translate(
'online_quiz_form_user_details_desc'),
'simple_form',
'details');
280 $folder = $asset->getFolder(
'type_formats');
304 'min' =>
'2003-01-01 00:00:00',
305 'max' => ts_iso8601(time()),
306 'allow_circa' =>
'0',
307 'show' => Array(
'y',
'm',
'd'),
316 $parameters[
'print_format'] =
'j M Y';
318 $from_value = isset($_POST[$prefix.
'_export_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_fromvalue'][
'm'],$_POST[$prefix.
'_export_fromvalue'][
'd'],$_POST[$prefix.
'_export_fromvalue'][
'y'])) : date(
'Y-m-d', time()-7*86400).
' --:--:--';
319 $to_value = isset($_POST[$prefix.
'_export_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_tovalue'][
'm'],$_POST[$prefix.
'_export_tovalue'][
'd'],$_POST[$prefix.
'_export_tovalue'][
'y'])) : date(
'Y-m-d').
' --:--:--';
321 $from =
new Datetime_Field($prefix.
'_export_from', $from_value, $parameters);
322 $to =
new Datetime_Field($prefix.
'_export_to', $to_value, $parameters);
325 echo
' '.translate(
'to').
' ';
344 '' =>
'------- '.translate(
'please_select').
' -------',
345 'csv' => translate(
'online_quiz_download_csv'),
346 'csv_nhr' => translate(
'online_quiz_download_csv_nhr'),
349 echo combo_box($prefix.
'_export_format', $options, FALSE,
'');
350 echo hidden_field($prefix.
'_export_switch',
'0');
352 $delimiter_text = isset($_POST[$prefix.
'_delimiter']) ? $_POST[$prefix.
'_delimiter'] :
',';
353 echo
' Delimiter ';
354 echo text_box($prefix.
'_delimiter',$delimiter_text,1,1,TRUE);
372 $user_details_form = $asset->getForm();
373 $user_details_form_questions = $user_details_form->getQuestions();
374 $quiz_questions = $asset->getQuestions(TRUE, TRUE);
376 echo check_box($prefix.
'_export_fields_select_all',
'1',
'',
'sq_set_check_all(this.form, "'.$prefix.
'_export_fields[]", this.checked);').
'<b>'.translate(
'select_all').
'</b>';
379 echo
'<p><b>Submission Details</b><br>';
380 echo check_box($prefix.
'_export_fields[]',
'__time__',
'1').translate(
'submission_time').
'<br/>';
381 echo check_box($prefix.
'_export_fields[]',
'__user__',
'1').translate(
'online_quiz_user_id').
'<br/>';
382 echo check_box($prefix.
'_export_fields[]',
'__ipaddress__',
'1').translate(
'online_quiz_ip_address').
'<br/>';
383 echo check_box($prefix.
'_export_fields[]',
'__score__',
'1').translate(
'online_quiz_score').
'<br/>';
387 if (!empty($user_details_form_questions)) {
388 echo
'<p><b>User Details Form Questions</b><br>';
389 foreach ($user_details_form_questions as $user_details_form_question_assetid => $user_details_form_question_details) {
390 $user_details_form_question = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($user_details_form_question_assetid);
391 $user_details_form_questions[$user_details_form_question_assetid] = $user_details_form_question->getVal(
'title');
393 echo check_box($prefix.
'_export_fields[]', $user_details_form_question_assetid,
'1');
394 echo $user_details_form_questions[$user_details_form_question_assetid].
'<br/>';
396 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($user_details_form_question);
401 if (!empty($quiz_questions)) {
402 echo
'<p><b>Quiz Questions</b><br>';
404 foreach ($quiz_questions as $quiz_question_assetid => $quiz_question_details) {
405 $quiz_question = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($quiz_question_assetid);
406 $quiz_questions[$quiz_question_assetid] = trim(strip_tags($quiz_question->getQuestionText()));
408 echo check_box($prefix.
'_export_fields[]', $quiz_question_assetid,
'1');
409 echo
'Q'.$q_num.
'. '.$quiz_questions[$quiz_question_assetid].
'<br/>';
412 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($quiz_question);
432 if (!$asset->writeAccess(
'attributes')) {
433 $o->note(translate(
'online_quiz_form_submission_lock_required'));
446 echo normal_button($prefix.
'_export', translate(
'download_file'),
'this.form.'.$prefix.
'_export_switch.value = 1; this.form.submit(); SQ_FORM_SUBMITTED = false; this.form.'.$prefix.
'_export_switch.value = 0; return true;');
464 'min' =>
'2003-01-01 00:00:00',
465 'max' => ts_iso8601(time()),
466 'allow_circa' =>
'0',
467 'show' => Array(
'y',
'm',
'd'),
476 $parameters[
'print_format'] =
'j M Y';
478 $from_value = isset($_POST[$prefix.
'_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_fromvalue'][
'm'],$_POST[$prefix.
'_fromvalue'][
'd'],$_POST[$prefix.
'_fromvalue'][
'y'])) : date(
'Y-m-d',time()-7*86400).
' --:--:--';
479 $to_value = isset($_POST[$prefix.
'_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_tovalue'][
'm'],$_POST[$prefix.
'_tovalue'][
'd'],$_POST[$prefix.
'_tovalue'][
'y'])) : date(
'Y-m-d').
' --:--:--';
481 $from =
new Datetime_Field($prefix.
'_from', $from_value, $parameters);
482 $to =
new Datetime_Field($prefix.
'_to', $to_value, $parameters);
485 echo
' '.translate(
'to').
' ';
505 $num_per_page = array_get_index($_REQUEST, $prefix.
'_per_page', 50);
506 if ($num_per_page < 1) $num_per_page = 50;
508 text_box($prefix.
'_per_page', $num_per_page, 3);
525 $write_access = $asset->writeAccess(
'links');
526 $expand_list = isset($_POST[$prefix.
'_expand']) ? $_POST[$prefix.
'_expand'] : Array();
527 $expand_sections = isset($_POST[$prefix.
'_expand_sections']) ? $_POST[$prefix.
'_expand_sections'] : Array();
531 $num_per_page = array_get_index($_REQUEST, $prefix.
'_per_page', 50);
532 if ($num_per_page < 1) $num_per_page = 50;
534 $submission_offset = array_get_index($_REQUEST, $prefix.
'_submission_offset', 0);
536 $from_value = isset($_POST[$prefix.
'_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_fromvalue'][
'm'],$_POST[$prefix.
'_fromvalue'][
'd'],$_POST[$prefix.
'_fromvalue'][
'y'])) : date(
'Y-m-d',time()-7*86400).
' --:--:--';
537 $to_value = isset($_POST[$prefix.
'_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_tovalue'][
'm'],$_POST[$prefix.
'_tovalue'][
'd'],$_POST[$prefix.
'_tovalue'][
'y'])) : date(
'Y-m-d').
' --:--:--';
539 $from_value = iso8601_date_component($from_value).
' 00:00:00';
540 $to_value = iso8601_date_component($to_value).
' 23:59:59';
544 $from_ts = mktime(0,0,0,$from_value[1],$from_value[2],$from_value[0]);
545 $to_ts = mktime(23,59,59,$to_value[1],$to_value[2],$to_value[0]);
548 a.assetid, a.created_userid, a.created
550 ('.SQ_TABLE_RUNNING_PREFIX.
'ast a
551 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_typ_inhd i ON a.type_code = i.type_code)
552 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_lnk l
553 ON l.minorid = a.assetid';
558 ('.SQ_TABLE_RUNNING_PREFIX.
'ast a
559 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_typ_inhd i ON a.type_code = i.type_code)
560 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_lnk l
561 ON l.minorid = a.assetid';
563 $sub_folder = $asset->getSubmissionsFolder();
570 $where =
'l.majorid IN (:assetid, :subfolder_assetid)
571 AND i.inhd_type_code = :inhd_type_code
572 AND a.created BETWEEN '.$ts_from_fragment.
'
573 AND '.$ts_to_fragment;
575 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'a');
576 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'i');
577 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'l');
589 }
catch (Exception $e) {
590 throw new Exception($e.getMessage());
593 $num_pages = ceil($asset_count / $num_per_page);
596 if (($submission_offset % $num_per_page) != 0) {
597 $submission_offset = $submission_offset - ($submission_offset % $num_per_page);
600 if ($submission_offset < 0) $submission_offset = 0;
602 if ($submission_offset >= $asset_count) {
603 $submission_offset = ($num_pages - 1) * $num_per_page;
606 $sql = $sql.$where.
' ORDER BY a.created DESC';
608 $sql = db_extras_modify_limit_clause($sql,
MatrixDAL::getDbType(),$num_per_page, $submission_offset);
609 if ($asset_count == 0) {
610 ?><p><i><?php echo translate(
'online_quiz_no_submissions_during_period') ?></i></p><?php
612 ?><style type=
"text/css">
616 .sq-form-sub table.sq-backend-table {
618 margin: 0 8px 8px 8px;
620 .sq-form-sub table.sq-backend-table th {
622 text-decoration: italic;
624 table.sq-backend-table tr td.sq-form-sub-header {
625 background-color: #666;
630 <script type=
"text/javascript"><!--
631 function sq_set_check_all(form, prefix, value) {
632 set_els = form.elements[prefix];
634 if (set_els.length) {
635 for (k = 0; k < set_els.length; k++) {
636 set_els[k].checked = value;
639 set_els.checked = value;
643 function sq_test_check_all(form, prefix, set_el) {
644 test_els = form.elements[prefix];
645 set_el = form.elements[set_el];
647 if (test_els.length) {
649 for (k = 0; k < test_els.length; k++) {
650 if (!test_els[k].checked) {
656 test = test_els.checked;
659 set_el.checked = test;
662 <table
class=
"sq-backend-table">
664 <td
class=
"sq-form-sub-header" colspan=
"2"><b><?php
665 hidden_field($prefix.
'_submission_offset', $submission_offset);
666 if ($submission_offset > 0) {
667 ?><a title=
"<?php echo translate('online_quiz_submissions_go_to_first') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_submission_offset', '0'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
669 ?><span title=
"<?php echo translate('online_quiz_cannot_go_further_back') ?>" style=
"color: #333"><?php
674 if ($submission_offset > 0) {
679 ?> <?php
680 if ($submission_offset > 0) {
681 ?><a title=
"<?php echo translate('online_quiz_submissions_go_to_previous') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_submission_offset', '<?php echo $submission_offset - $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
683 ?><span title=
"<?php echo translate('online_quiz_cannot_go_further_back') ?>" style=
"color: #333"><?php
688 if ($submission_offset > 0) {
694 <?php echo translate(
'page_number', round(($submission_offset + $num_per_page) / $num_per_page), ceil($asset_count / $num_per_page)); ?>
696 if (($submission_offset + $num_per_page) < $asset_count) {
697 ?><a title=
"<?php echo translate('online_quiz_submissions_go_to_next') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_submission_offset', '<?php echo $submission_offset + $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
699 ?><span title=
"<?php echo translate('online_quiz_cannot_go_further_forward') ?>" style=
"color: #333"><?php
704 if (($submission_offset + $num_per_page) < $asset_count) {
709 ?> <?php
710 if (($submission_offset + $num_per_page) < $asset_count) {
711 ?><a title=
"<?php echo translate('online_quiz_submissions_go_to_last') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_submission_offset', '<?php echo ($num_pages - 1) * $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
713 ?><span title=
"<?php echo translate('online_quiz_cannot_go_further_forward') ?>" style=
"color: #333"><?php
718 if (($submission_offset + $num_per_page) < $asset_count) {
725 <td
class=
"sq-form-sub-header" colspan=
"5" align=
"right"><?php echo translate(
'online_quiz_submissions_during_period', $submission_offset + 1, min($asset_count, $submission_offset + $num_per_page), $asset_count) ?>
730 <?php echo translate(
'asset_id') ?>
733 <?php echo translate(
'submission_time') ?>
736 <?php echo translate(
'user') ?>
739 <?php echo translate(
'online_quiz_score') ?>
742 <input type=
"checkbox" name=
"<?php echo $prefix ?>_expand_all" value=
"" onclick=
"sq_set_check_all(this.form, '<?php echo $prefix ?>_expand[]', this.checked);"> <?php echo translate(
'expand_question') ?>
748 <input type=
"checkbox" name=
"<?php echo $prefix ?>_delete_all" value=
"" onclick=
"sq_set_check_all(this.form, '<?php echo $prefix ?>_delete[]', this.checked);"> <?php echo translate(
'delete_question') ?>
767 }
catch (Exception $e) {
768 throw new Exception($e->getMessage());
771 foreach ($result as $k => $asset_info) {
772 $assetid = $asset_info[
'assetid'];
775 $sub_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
776 $sub_user = $asset_info[
'created_userid'];
777 $sub_time = date(
'd M Y H:i:s', strtotime($asset_info[
'created']));
778 $sub_expanded = array_search($assetid, $expand_list) !== FALSE;
781 if ($num_subs > $num_per_page)
break;
784 echo ($sub_expanded) ?
' class="alt"' :
'';
787 <?php echo $assetid ?>
790 <?php echo $sub_time ?>
795 if (!empty($sub_user)) {
796 $sub_user_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sub_user);
797 if (!empty($sub_user_asset)) {
798 echo get_asset_tag_line($sub_user);
803 ?><i><?php echo translate(
'online_quiz_no_logged_in_user'); ?></i><?php
807 <td> <?php echo $sub_asset->getScore(); ?></td>
809 <input type=
"checkbox" name=
"<?php echo $prefix ?>_expand[]" value=
"<?php echo $assetid ?>" <?php
if ($sub_expanded) echo
' checked="checked"'; ?> onclick=
"sq_test_check_all(this.form, '<?php echo $prefix ?>_expand[]', '<?php echo $prefix ?>_expand_all');">
815 <input type=
"checkbox" name=
"<?php echo $prefix ?>_delete[]" value=
"<?php echo $assetid ?>" onclick=
"sq_test_check_all(this.form, '<?php echo $prefix ?>_delete[]', '<?php echo $prefix ?>_delete_all');">
820 <td>[ <a href=
"<?php echo $sub_asset->getBackendHref(); ?>"><?php echo translate(
'view') ?></a> ]</td>
827 <td colspan=
"6" class=
"sq-form-sub">
828 <table
class=
"sq-backend-table">
832 $incl_user_details = in_array(
'__user_details__',$expand_sections) ? TRUE : FALSE;
833 $incl_quiz_responses = in_array(
'__quiz_responses__', $expand_sections) ? TRUE : FALSE;
835 $elements = $sub_asset->getSummary($incl_user_details, $incl_quiz_responses);
836 if (count($elements) % 2 != 0) {
837 $elements[] = Array(
'name' =>
'',
'answer' =>
'');
839 foreach ($elements as $element) {
842 <th><?php echo $element[
'name'] ?>:</th>
843 <td><?php echo htmlspecialchars($element[
'answer']); ?></td>
845 if (($i < count($elements)) && ($i % 2 == 0)) {
862 <script type=
"text/javascript"><!--
863 sq_test_check_all(document.main_form,
'<?php echo $prefix ?>_expand[]',
'<?php echo $prefix ?>_expand_all');
886 $delete_list = isset($_POST[$prefix.
'_delete']) ? $_POST[$prefix.
'_delete'] : Array();
887 if (empty($delete_list))
return FALSE;
889 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
890 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
893 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'links')) {
894 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
895 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
899 foreach ($delete_list as $delete_assetid) {
901 if (!assert_valid_assetid($delete_assetid,
'', FALSE, FALSE)) {
902 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
903 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
908 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($delete_assetid,
'links')) {
909 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
910 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
913 $submissions_folder = $asset->getSubmissionsFolder();
914 $submission_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($submissions_folder->id, $delete_assetid, SQ_LINK_TYPE_3);
915 if (!$submission_link) {
916 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
917 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
920 if (!$submissions_folder->deleteLink($submission_link[
'linkid'])) {
921 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
922 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
928 if (!$GLOBALS[
'SQ_SYSTEM']->am->releaseLock($delete_assetid,
'links')) {
929 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
930 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
935 if (!$GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'links')) {
936 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
937 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
941 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
942 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
964 $export_button_pressed = array_get_index($_POST, $prefix.
'_export_switch');
965 if (is_null($export_button_pressed))
return TRUE;
967 $export_type = array_get_index($_POST, $prefix.
'_export_format',
'');
968 $export_delimiter = array_get_index($_POST, $prefix.
'_delimiter',
'');
971 if (isset($_POST[$prefix.
'_export_fields'])) {
972 $export_fields = $_POST[$prefix.
'_export_fields'];
974 if (!empty($export_fields)) {
975 switch ($export_type) {
977 $this->
processExportCSV($asset, $o, $prefix, $export_fields, TRUE, $export_delimiter);
981 $this->
processExportCSV($asset, $o, $prefix, $export_fields, FALSE, $export_delimiter);
1007 function processExportCSV(&$asset, &$o, $prefix, $export_fields=Array(), $header_row=TRUE, $delimiter=
',')
1009 require_once SQ_FUDGE_PATH.
'/csv/csv.inc';
1011 $csv->setFilename(
'submission_log.csv');
1012 $csv->setDeliminator($delimiter);
1015 $from_value = isset($_POST[$prefix.
'_export_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_fromvalue'][
'm'],$_POST[$prefix.
'_export_fromvalue'][
'd'],$_POST[$prefix.
'_export_fromvalue'][
'y'])) :
'---------- --:--:--';
1016 $to_value = isset($_POST[$prefix.
'_export_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_tovalue'][
'm'],$_POST[$prefix.
'_export_tovalue'][
'd'],$_POST[$prefix.
'_export_tovalue'][
'y'])) :
'---------- --:--:--';
1018 $from_value = explode(
'-',iso8601_date_component($from_value));
1019 $to_value = explode(
'-',iso8601_date_component($to_value));
1023 $from_ts = mktime(0,0,0,$from_value[1],$from_value[2],$from_value[0]);
1024 $to_ts = mktime(23,59,59,$to_value[1],$to_value[2],$to_value[0]);
1029 $export_time_field = in_array(
'__time__', $export_fields);
1030 $export_user_field = in_array(
'__user__', $export_fields);
1031 $export_ipaddress_field = in_array(
'__ipaddress__', $export_fields);
1032 $export_score_field = in_array(
'__score__', $export_fields);
1034 if ($export_time_field) {
1035 $headers[
'__time__'] = translate(
'submission_time');
1037 if ($export_user_field) {
1038 $headers[
'__user__'] = translate(
'online_quiz_user_id');
1040 if ($export_ipaddress_field) {
1041 $headers[
'__ipaddress__'] = translate(
'online_quiz_ip_address');
1043 if ($export_score_field) {
1044 $headers[
'__score__'] = translate(
'online_quiz_score');
1047 $sub_folder = $asset->getSubmissionsFolder();
1050 a.assetid, a.type_code, a.created, a.created_userid
1052 ('.SQ_TABLE_RUNNING_PREFIX.
'ast a JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_typ_inhd i ON a.type_code = i.type_code)
1053 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_lnk l
1054 ON l.minorid = a.assetid';
1058 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'a');
1059 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'i');
1060 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'l');
1072 $sql = db_extras_modify_limit_clause($base_sql.$where,
MatrixDAL::getDbType(), $chunk_size, $offset);
1076 if (count($result) == 0)
break;
1078 foreach ($result as $asset_info) {
1079 $assetid = $asset_info[
'assetid'];
1080 $type_code = $asset_info[
'type_code'];
1082 $create_time = strtotime($asset_info[
'created']);
1084 $sub_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type_code);
1085 if (!$sub_asset->attr(
'complete'))
continue;
1088 $ipaddress = $sub_asset->getIP();
1089 $score = $sub_asset->getScore();
1092 $logs[$assetid] = Array();
1094 if ($export_time_field) {
1095 $logs[$assetid][
'__time__'] = date(
'Y-m-d H:i:s', $create_time);
1097 if ($export_user_field) {
1098 $logs[$assetid][
'__user__'] = $asset_info[
'created_userid'];
1100 if ($export_ipaddress_field) {
1101 $logs[$assetid][
'__ipaddress__'] = $ipaddress;
1103 if ($export_score_field) {
1104 $logs[$assetid][
'__score__'] = $score;
1107 $submission_summary = $sub_asset->getSummary();
1110 foreach ($submission_summary as $question_id => $details) {
1112 if (in_array($question_id, $export_fields)) {
1113 if (!isset($headers[$question_id])) {
1114 $headers[$question_id] = $details[
'name'];
1116 $logs[$assetid][$question_id] = $details[
'answer'];
1123 $offset =+ count($result);
1127 if ($header_row) $csv->setFieldHeaders($headers);
1129 $csv->setValues($logs);
1152 $write_access = $asset->writeAccess(
'attributes');
1154 $root_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'root');
1155 $pool_setup = $asset->attr(
'question_pool_setup');
1158 <table
class=
"sq-backend-table">
1160 <td
class=
"sq-backend-table-header" >
1161 <?php echo translate(
'online_quiz_pool_node'); ?>
1163 <td
class=
"sq-backend-table-header">
1164 <?php echo translate(
'online_quiz_pool_size'); ?>
1166 <td
class=
"sq-backend-table-header">
1167 <?php echo translate(
'online_quiz_pool_retries_per_q'); ?>
1169 <td
class=
"sq-backend-table-header">
1170 <?php echo translate(
'online_quiz_pool_order'); ?>
1175 foreach ($root_links as $link){
1178 <td
class=
"sq-backend-table-cell">
1180 echo get_asset_tag_line($link[
'minorid'],
'details');
1183 <td
class=
"sq-backend-table-cell">
1185 $size = (!empty($pool_setup[$link[
'minorid']][
'size'])) ? $pool_setup[$link[
'minorid']][
'size'] : 0;
1187 text_box($prefix.
'_size_'.$link[
'minorid'], $size);
1193 <td
class=
"sq-backend-table-cell">
1195 $retries = (!empty($pool_setup[$link[
'minorid']][
'retries'])) ? $pool_setup[$link[
'minorid']][
'retries'] : 0;
1197 text_box($prefix.
'_retries_'.$link[
'minorid'], $retries);
1203 <td
class=
"sq-backend-table-cell">
1206 text_box($prefix.
'_order_'.$link[
'minorid'], $order);
1219 hidden_field($prefix.
'_interactive_mode',
'1');
1238 if (!$asset->writeAccess(
'attributes'))
return FALSE;
1239 if (!isset($_POST[$prefix.
'_interactive_mode']))
return TRUE;
1242 $root_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'root');
1243 foreach ($root_links as $link){
1244 $order = (isset($_POST[$prefix.
'_order_'.$link[
'minorid']])) ? (
int)$_POST[$prefix.
'_order_'.$link[
'minorid']] : $link[
'sort_order'];
1245 $GLOBALS[
'SQ_SYSTEM']->am->updateLink($link[
'linkid'], $link[
'link_type'], $link[
'value'], $order, $link[
'locked']);
1248 $pool_setup = Array();
1249 $root_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'root');
1250 foreach ($root_links as $link){
1251 $retries = (isset($_POST[$prefix.
'_retries_'.$link[
'minorid']])) ? (
int)$_POST[$prefix.
'_retries_'.$link[
'minorid']] : 0;
1252 $size = (isset($_POST[$prefix.
'_size_'.$link[
'minorid']])) ? (
int)$_POST[$prefix.
'_size_'.$link[
'minorid']] : 0;
1253 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($link[
'minorid'],
'online_quiz_question_multichoice', TRUE);
1254 if (($size + ($size*$retries)) > (count($children))){
1255 trigger_localised_error(
'CMS0113', E_USER_WARNING, $link[
'minorid']);
1258 $pool_setup[$link[
'minorid']] = Array (
1259 'retries' => $retries,
1264 $asset->setAttrValue(
'question_pool_setup', $pool_setup);
1265 $asset->saveAttributes();
1285 $expand_sections = isset($_POST[$prefix.
'_expand_sections']) ? $_POST[$prefix.
'_expand_sections'] : Array();
1288 $checked = ($expand_sections) ? in_array(
'__user_details__', $expand_sections) : TRUE;
1289 echo check_box($prefix.
'_expand_sections[]',
'__user_details__', $checked).
'User Details Form Questions<br/>';
1290 $checked = ($expand_sections) ? in_array(
'__quiz_responses__', $expand_sections) : TRUE;
1291 echo check_box($prefix.
'_expand_sections[]',
'__quiz_responses__', $checked).
'Quiz Questions<br/>';
1308 $write_access = $asset->writeAccess(
'attributes');
1310 if ($write_access) {
1311 text_area($prefix.
'_question_option_format', $asset->attr(
'question_option_format'), 0, 0, 0,
'style="width: 300px; height: 100px;"');
1313 echo htmlentities($asset->attr(
'question_option_format'));
1333 if (!$asset->writeAccess(
'attributes'))
return FALSE;
1335 if (isset($_REQUEST[$prefix.
'_question_option_format']) === TRUE) {
1336 $question_option_format = array_get_index($_REQUEST, $prefix.
'_question_option_format',
'');
1337 $asset->setAttrValue(
'question_option_format', trim($question_option_format));
1356 return $asset->writeAccess(
'attributes');
1371 return ($asset->attr(
'interactive_mode')) ? FALSE : TRUE;
1386 return ($asset->attr(
'interactive_mode')) ? TRUE : FALSE;