[svn r14784] optional invitation through e-mail

skala
Patrick Cool 18 years ago
parent 5fdc2c74ce
commit aab7b17d1f
  1. 22
      main/survey/fillsurvey.php
  2. 8
      main/survey/question.php
  3. 61
      main/survey/survey.lib.php
  4. 6
      main/survey/survey_invite.php
  5. 6
      main/survey/survey_list.php

@ -33,15 +33,22 @@
$language_file = 'survey';
// unsetting the course id (because it is in the URL)
$cidReset = true;
if (!isset($_GET['cidReq']))
{
$cidReset = true;
}
else
{
$_cid = $_GET['cidReq'];
}
// including the global dokeos file
require ('../inc/global.inc.php');
// including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
//require_once (api_get_path(LIBRARY_PATH)."survey.lib.php");
require_once('survey.lib.php');
require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
// getting all the course information
$_course = CourseManager::get_course_information($_GET['course']);
@ -55,7 +62,10 @@ $table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION, $_course['db_name']);
// breadcrumbs
// $interbreadcrumb[] = array ("url" => 'survey_list.php', 'name' => get_lang('SurveyList'));
if (!empty($_user))
{
$interbreadcrumb[] = array ("url" => 'survey_list.php', 'name' => get_lang('SurveyList'));
}
// Header
Display :: display_header(get_lang('Survey'));
@ -99,7 +109,7 @@ if (mysql_num_rows($result) > 1)
}
else
{
echo '<form id="language" name="language" method="POST" action="'.api_get_self().'?course='.$_GET['course'].'&invitationcode='.$_GET['invitationcode'].'">';
echo '<form id="language" name="language" method="POST" action="'.api_get_self().'?course='.$_GET['course'].'&invitationcode='.$_GET['invitationcode'].'&cidReq='.$_GET['cidReq'].'">';
echo ' <select name="language">';
while ($row=mysql_fetch_assoc($result))
{
@ -309,7 +319,7 @@ else
// Displaying the form with the questions
echo '<form id="question" name="question" method="post" action="'.api_get_self().'?course='.$_GET['course'].'&invitationcode='.$_GET['invitationcode'].'&show='.$show.'">';
echo '<form id="question" name="question" method="post" action="'.api_get_self().'?course='.$_GET['course'].'&invitationcode='.$_GET['invitationcode'].'&show='.$show.'&cidReq='.$_GET['cidReq'].'">';
echo '<input type="hidden" name="language" value="'.$_POST['language'].'" />';
if(is_array($questions)){
foreach ($questions as $key=>$question)

@ -21,7 +21,7 @@
* @package dokeos.survey
* @author unknown, the initial survey that did not make it in 1.8 because of bad code
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @version $Id: question.php 14542 2008-03-07 14:48:09Z juliomontoya $
* @version $Id: question.php 14784 2008-04-08 12:58:45Z pcool $
*/
// name of the language file that needs to be included
@ -115,8 +115,7 @@ if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types))
if ($_GET['type'] == 'yesno')
{
$form_content['answers'][0]=get_lang('Yes');
$form_content['answers'][1]=get_lang('No');
$form_content['answers'][1]=get_lang('No');
}
// We are editing a question
if (isset($_GET['question_id']) AND !empty($_GET['question_id']))
@ -139,8 +138,7 @@ if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types))
unset($_SESSION['temp_answers']);
}
$form->create_form($form_content);
$form->render_form();
$form->render_form();
}
else
{

@ -3307,7 +3307,7 @@ class SurveyUtil {
*
* @todo create the survey link
*/
function save_invitations($users_array, $invitation_title, $invitation_text, $reminder=0)
function save_invitations($users_array, $invitation_title, $invitation_text, $reminder=0, $sendmail = 0)
{
global $_user;
global $_course;
@ -3409,8 +3409,10 @@ class SurveyUtil {
$sender_email = $noreply;
}
}
api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto);
//mail($recipient_email, strip_tags($invitation_title), strip_tags($invitation_text));
if ($sendmail<>0)
{
api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto);
}
$counter++;
}
}
@ -3747,5 +3749,58 @@ class SurveyUtil {
}
return $surveys;
}
/**
* Display all the active surveys for the given course user
*
* @param unknown_type $user_id
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version April 2007
*/
function survey_list_user($user_id)
{
global $_course;
// Database table definitions
$table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
$table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT * FROM $table_survey survey, $table_survey_invitation survey_invitation
WHERE survey_invitation.user = '".Database::escape_string($user_id)."'
AND survey.code = survey_invitation.survey_code
AND survey.avail_from <= '".date('Y-m-d H:i:s')."'
AND survey.avail_till >= '".date('Y-m-d H:i:s')."'
";
$result = api_sql_query($sql, __FILE__, __LINE__);
echo '<table class="data_table">';
echo '<tr>';
echo ' <th>'.get_lang('SurveyName').'</th>';
echo ' <th>'.get_lang('Anonymous').'</th>';
echo '</tr>';
$counter = 0;
while ($row = Database::fetch_array($result,'ASSOC'))
{
echo '<tr>';
if ($row['answered'] == 0)
{
echo '<td><a href="fillsurvey.php?course='.$_course['sysCode'].'&amp;invitationcode='.$row['invitation_code'].'&amp;cidReq='.$_course['sysCode'].'">'.$row['title'].'</a></td>';
}
else
{
echo '<td>'.$row['title'].'</td>';
}
echo '<td>';
echo ($row['anonymous'] == 1)?get_lang('Yes'):get_lang('No');
echo '</td>';
echo '</tr>';
}
echo '</table>';
}
}
?>

@ -128,6 +128,7 @@ $fck_attribute['ToolbarSet'] = 'Survey';
$form->addElement('html_editor', 'mail_text', get_lang('MailText'));
// some explanation of the mail
$form->addElement('static', null, null, get_lang('UseLinkSyntax'));
$form->addElement('checkbox', 'send_mail', '', get_lang('SendMail'));
// allow resending to all selected users
$form->addElement('checkbox', 'resend_to_all', '', get_lang('ReminderResendToAllUsers'));
// submit button
@ -141,7 +142,7 @@ if ($form->validate())
// save the invitation mail
SurveyUtil::save_invite_mail($values['mail_text'], $values['resend_to_all']);
// saving the invitations for the course users
$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'], $values['mail_text'], $values['resend_to_all']);
$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'], $values['mail_text'], $values['resend_to_all'], $values['send_mail']);
// saving the invitations for the additional users
$values['additional_users'] = $values['additional_users'].';'; // this is for the case when you enter only one email
$temp = str_replace(',',';',$values['additional_users']); // this is to allow , and ; as email separators
@ -150,7 +151,7 @@ if ($form->validate())
{
$additional_users[$i] = trim($additional_users[$i]);
}
$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'], $values['mail_text'], $values['resend_to_all']);
$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'], $values['mail_text'], $values['resend_to_all'], $values['send_mail']);
// updating the invited field in the survey table
SurveyUtil::update_count_invited($survey_data['code']);
$total_count = $count_course_users + $counter_additional_users;
@ -169,6 +170,7 @@ else
{
$defaults['mail_text'] = $survey_data['invite_mail'];
}
$defaults['send_mail'] = 1;
$form->setDefaults($defaults);
$form->display();

@ -21,7 +21,7 @@
* @package dokeos.survey
* @author unknown, the initial survey that did not make it in 1.8 because of bad code
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @version $Id: survey_list.php 14639 2008-03-18 05:31:08Z yannoo $
* @version $Id: survey_list.php 14784 2008-04-08 12:58:45Z pcool $
*
* @todo use quickforms for the forms
*/
@ -40,8 +40,8 @@ require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit())
{
Display :: display_header(get_lang('Survey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_header(get_lang('SurveyList'));
SurveyUtil::survey_list_user($_user['user_id']);
Display :: display_footer();
exit;
}

Loading…
Cancel
Save