$question ) { if ( ! empty( $question['VOTES'] ) ) { $voted_array[$question['ID']] = explode( '||', $question['VOTES'] ); if ( is_array( $votes_array[$question['ID']] ) ) // Multiple. { foreach ( (array) $votes_array[$question['ID']] as $checked_box ) { $voted_array[$question['ID']][$checked_box]++; } } else // Multiple_radio. { $voted_array[$question['ID']][$votes_array[$question['ID']]]++; } } else // First vote. { $voted_array[$question['ID']] = array(); $options_array = explode( "\r", str_replace( array( "\r\n", "\n" ), "\r", $question['OPTIONS'] ) ); if ( is_array( $votes_array[$question['ID']] ) ) // Multiple. { foreach ( (array) $options_array as $option_nb => $option_label ) { $voted_array[$question['ID']][$option_nb] = 0; } foreach ( (array) $votes_array[$question['ID']] as $checked_box ) { $voted_array[$question['ID']][$checked_box]++; } } else // Multiple_radio. { foreach ( (array) $options_array as $option_nb => $option_label ) { $voted_array[$question['ID']][$option_nb] = ( $votes_array[$question['ID']] == $option_nb ? 1 : 0 ); } } } $voted_array[$question['ID']] = implode( '||', $voted_array[$question['ID']] ); // Submit query. DBQuery( "UPDATE PORTAL_POLL_QUESTIONS SET VOTES='" . $voted_array[$question['ID']] . "' WHERE ID='" . $question['ID'] . "'" ); // Update the $poll_questions_RET array with Votes. $poll_questions_RET[$key]['VOTES'] = $voted_array[$question['ID']]; } return $poll_questions_RET; } /** * @param $value * @param $name */ function PortalPollsDisplay( $value, $name ) { global $THIS_RET; $poll_id = $THIS_RET['ID']; // Get poll: $poll_RET = DBGet( "SELECT EXCLUDED_USERS,VOTES_NUMBER,DISPLAY_VOTES FROM PORTAL_POLLS WHERE ID='" . $poll_id . "'" ); require_once 'ProgramFunctions/Linkify.fnc.php'; $poll_questions_RET = DBGet( "SELECT ID,QUESTION,OPTIONS,TYPE,VOTES FROM PORTAL_POLL_QUESTIONS WHERE PORTAL_POLL_ID='" . $poll_id . "' ORDER BY ID", array( 'OPTIONS' => 'Linkify' ) ); if ( ! $poll_RET || ! $poll_questions_RET ) { // Should never be displayed, so do not translate. return ErrorMessage( array( 'Poll does not exist' ) ); } $excluded_user = GetPortalPollUser(); if ( ! $excluded_user ) { // Should never be displayed, so do not translate. return ErrorMessage( array( 'User not logged in' ) ); } // Check if user is in excluded users list (format = '|[profile_id]:[user_id]'). if ( mb_strpos( $poll_RET[1]['EXCLUDED_USERS'] . '|', $excluded_user . '|' ) !== false ) { // User already voted, display votes. return PortalPollsVotesDisplay( $poll_id, $poll_RET[1]['DISPLAY_VOTES'], $poll_questions_RET, $poll_RET[1]['VOTES_NUMBER'] ); } return PortalPollForm( $poll_id, $poll_questions_RET ); } /** * Get poll user, using the excluded users format: * |[profile_id]:[user_id] * * @since 3.4 * * @return string User, empty if no user ID. */ function GetPortalPollUser() { $profile_id = User( 'PROFILE_ID' ); if ( $profile_id !== '0' ) // FJ call right Student/Staff ID. { $user_id = $_SESSION['STAFF_ID']; } else { $user_id = $_SESSION['STUDENT_ID']; } if ( ! $user_id ) { return ''; } return '|' . $profile_id . ':' . $user_id; } /** * Function called by PortalPollsDisplay() * generates the Portal Poll's HTML form * * @param integer $poll_id Poll ID. * @param array $poll_questions_RET Poll questions. * @return string Poll HTML form. */ function PortalPollForm( $poll_id, $poll_questions_RET ) { $poll_form = ''; //FJ responsive rt td too large if ( ! isset( $_REQUEST['_ROSARIO_PDF'] ) ) { $poll_form .= '
' . $question['QUESTION'] . '
| ' . $options_array[$i] . ' | ' . $percent . '% |
' . _( 'Total Participants' ) . ': ' . $votes_number . '
'; if ( ! $js_included_is_voting ) { $votes_display .= '| ' . _( 'Visible Between' ) . ': '; $return .= DateInput( $value, 'values[' . $id . '][' . $name . ']' ) . ' ' . _( 'to' ) . ' '; $return .= DateInput( issetVal( $THIS_RET['END_DATE'] ), 'values[' . $id . '][END_DATE]' ) . ' |
| '; if ( is_null( $profiles ) ) { $profiles_RET = DBGet( "SELECT ID,TITLE FROM USER_PROFILES ORDER BY ID" ); //add Profiles with Custom permissions to profiles list $profiles = array_merge( array( array( 'ID' => 'admin', 'TITLE' => _( 'Administrator w/Custom' ) ), array( 'ID' => 'teacher', 'TITLE' => _( 'Teacher w/Custom' ) ), array( 'ID' => 'parent', 'TITLE' => _( 'Parent w/Custom' ) ), ), $profiles_RET ); } $return .= makePublishingVisibleTo( $profiles, $THIS_RET, $id ); $return .= ' |
| ' . _( 'Visible To' ) . ': | |
| ' . CheckboxInput( $checked, 'profiles[' . $id . '][' . $profile['ID'] . ']', _( $profile['TITLE'] ), '', true ); //FJ Portal Polls add students teacher if ( $profile['ID'] === '0' && $_REQUEST['modname'] == 'School_Setup/PortalPolls.php' ) //student & verify this is not a Portal Note! { $visibleTo .= ': ' . SelectInput( issetVal( $THIS_RET['STUDENTS_TEACHER_ID'] ), 'values[' . $id . '][STUDENTS_TEACHER_ID]', _( 'Limit to Teacher' ), $teachers, 'N/A', '', true ); } $visibleTo .= ' | '; if ( $i % 2 == 0 && $i != count( $profiles ) ) { $visibleTo .= '|
| '; } $visibleTo .= ' | |
' . _( 'View Online' ) . '';
$download = '
' . _( 'Download' ) . '';
if ( filter_var( $value, FILTER_VALIDATE_URL ) !== false ) //embed link
{
return '' . $view_online . '';
}
return '' . $download . '';
}
$id = 'new';
$return = '