[svn r13790] Added some code for a course-setting that allows to choose whether course admins get sent an e-mail when a new quiz is submitted.

skala
Yannick Warnier 18 years ago
parent 610e8d62e4
commit 46f3dacb67
  1. 10
      main/course_info/infocours.php
  2. 123
      main/exercice/exercise_result.php
  3. 1
      main/inc/lib/add_course.lib.inc.php

@ -1,5 +1,5 @@
<?php
// $Id: infocours.php 12219 2007-05-01 18:46:59Z yannoo $
// $Id: infocours.php 13790 2007-11-27 04:59:47Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
@ -168,6 +168,8 @@ $form->addElement('radio', 'email_alert_manager_on_new_doc', get_lang('WorkEmail
$form->addElement('radio', 'email_alert_manager_on_new_doc', null, get_lang('WorkEmailAlertDeactivate'), 0);
$form->addElement('radio', 'email_alert_on_new_doc_dropbox', get_lang('DropboxEmailAlert'), get_lang('DropboxEmailAlertActivate'), 1);
$form->addElement('radio', 'email_alert_on_new_doc_dropbox', null, get_lang('DropboxEmailAlertDeactivate'), 0);
$form->addElement('radio', 'email_alert_manager_on_new_quiz', get_lang('QuizEmailAlert'), get_lang('QuizEmailAlertActivate'), 1);
$form->addElement('radio', 'email_alert_manager_on_new_quiz', null, get_lang('QuizEmailAlertDeactivate'), 0);
$form->addElement('radio', 'allow_user_edit_agenda', get_lang('AllowUserEditAgenda'), get_lang('AllowUserEditAgendaActivate'), 1);
$form->addElement('radio', 'allow_user_edit_agenda', null, get_lang('AllowUserEditAgendaDeactivate'), 0);
$form->addElement('radio', 'allow_user_edit_announcement', get_lang('AllowUserEditAnnouncement'), get_lang('AllowUserEditAnnouncementActivate'), 1);
@ -206,6 +208,8 @@ $values['course_registration_password'] = $all_course_information['registration
$values['email_alert_manager_on_new_doc'] = api_get_course_setting('email_alert_manager_on_new_doc');
// get send_mail_setting (dropbox) from table
$values['email_alert_on_new_doc_dropbox'] = api_get_course_setting('email_alert_on_new_doc_dropbox');
// get send_mail_setting (work)from table
$values['email_alert_manager_on_new_quiz'] = api_get_course_setting('email_alert_manager_on_new_quiz');
// get allow_user_edit_agenda from table
$values['allow_user_edit_agenda'] = api_get_course_setting('allow_user_edit_agenda');
// get allow_user_edit_announcement from table
@ -244,6 +248,10 @@ if ($form->validate() && is_settings_editable())
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_on_new_doc_dropbox']." WHERE variable = 'email_alert_on_new_doc_dropbox' ";
api_sql_query($sql,__FILE__,__LINE__);
}
if($update_values['email_alert_manager_on_new_quiz'] != $values['email_alert_manager_on_new_quiz']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_manager_on_new_quiz']." WHERE variable = 'email_alert_manager_on_new_quiz' ";
api_sql_query($sql,__FILE__,__LINE__);
}
if($update_values['allow_user_edit_agenda'] != $values['allow_user_edit_agenda']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_edit_agenda']." WHERE variable = 'allow_user_edit_agenda' ";
api_sql_query($sql,__FILE__,__LINE__);

@ -25,7 +25,7 @@
* @package dokeos.exercise
* @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring
* @version $Id: exercise_result.php 13738 2007-11-21 22:03:02Z yannoo $
* @version $Id: exercise_result.php 13790 2007-11-27 04:59:47Z yannoo $
*
* @todo split more code up in functions, move functions to library?
*/
@ -648,14 +648,16 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
$lastName = $_SESSION['_user']['lastName'];
$mail = $_SESSION['_user']['mail'];
$coursecode = $_SESSION['_course']['id'];
$query1 = "SELECT user_id from $main_course_user_table where course_code= '$coursecode' and status = '1' LIMIT 0,1";
$query1 = "SELECT u.email, cu.user_id from $main_course_user_table cu, $main_user_table u where cu.course_code= '$coursecode' and cu.status = '1' and c.user_id=cu.user_id";
$result1 = api_sql_query($query1, __FILE__, __LINE__);
$to = '';
if(Database::num_rows($result1)>0)
{
$temp = mysql_result($result1,0,"user_id");
$query = "select email from $main_user_table where user_id =".intval($temp) ;
$result = api_sql_query($query, __FILE__, __LINE__);
$to = mysql_result($result,0,"email");
while($temp_row = Database::fetch_array($result1))
{
$to .= $temp_row['email'].',';
}
$to = substr($to,0,-1);
}else{
//this is a problem (it means that there is no admin for this course)
}
@ -838,98 +840,26 @@ if ($origin != 'learnpath')
//we are not in learnpath tool
Display::display_footer();
}else{
$user_id = (!empty($_SESSION['_user']['id'])?$_SESSION['_user']['id']:0);
$lp_item = Database::get_course_table('lp_item');
$lp_item_view = Database::get_course_table('lp_item_view');
$sql2 = "UPDATE $lp_item_view SET score = '$totalScore'
WHERE lp_item_id = '$learnpath_item_id'
AND lp_view_id = '".$_SESSION['scorm_view_id']."'
ORDER BY view_count DESC LIMIT 1";
api_sql_query($sql2,__FILE__,__LINE__);
$_SESSION['oLP']->save_last();
$user_id = (!empty($_SESSION['_user']['id'])?$_SESSION['_user']['id']:0);
$lp_item = Database::get_course_table('lp_item');
$lp_item_view = Database::get_course_table('lp_item_view');
$sql2 = "UPDATE $lp_item_view SET score = '$totalScore'
WHERE lp_item_id = '$learnpath_item_id'
AND lp_view_id = '".$_SESSION['scorm_view_id']."'
ORDER BY view_count DESC LIMIT 1";
api_sql_query($sql2,__FILE__,__LINE__);
$_SESSION['oLP']->save_last();
}
$send_email = api_get_course_setting('email_alert_manager_on_new_quiz');
$csspath = "http://portal.dokeos.com/demo/main/css/default.css";
if (!empty($arrques))
if ($send_email && count($arrques)>0)
{
$msg = "<html><head>
<link rel='stylesheet' href='http://www.dokeos.com/styles.css' type='text/css'>
<meta content='text/html; charset=ISO-8859-1' http-equiv='content-type'>";
/*<style type='text/css'>
<!--
.body{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: Normal;
color: #000000;
}
.style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color: #006699; }
.style10 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
.style16 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
-->
</style>*/
/*$msg .= "</head>
<body>
<br>
<p><span class='style8'>".get_lang('OpenQuestionsAttempted')."
</span></p>
<p><span class='style8'>Attempt Details : </span><br>
</p>
<table width='730' height='136' border='0' cellpadding='3' cellspacing='3'>
<tr>
<td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Course Name</span></td>
<td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#course#</span></td>
</tr>
<tr>
<td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>".get_lang('TestAttempted')."</span></td>
<td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'> #exercise#</span></td>
</tr>
<tr>
<td valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Student's Name </span></td>
<td valign='top' bgcolor='#F3F3F3'><span class='style16'> #firstName# #lastName#</span></td>
</tr>
<tr>
<td valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Student's Email ID </span></td>
<td valign='top' bgcolor='#F3F3F3'><span class='style16'> #mail#</span></td>
</tr></table>
<p><br>
<span class='style8'>".get_lang('OpenQuestionsAttemptedAre')." :</span></p>
<table width='730' height='136' border='0' cellpadding='3' cellspacing='3'>";
for($i=0;$i<sizeof($arrques);$i++)
{
$msg.="
<tr>
<td width='220' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Question</span></td>
<td width='473' valign='top' bgcolor='F3F3F3'><span class='style16'> #questionName#</span></td>
</tr>
<tr>
<td width='220' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Answer </span></td>
<td valign='top' bgcolor='F3F3F3'><span class='style16'> #answer#</span></td>
</tr>";
$msg1= str_replace("#exercise#",$exerciseTitle,$msg);
$msg= str_replace("#firstName#",$firstName,$msg1);
$msg1= str_replace("#lastName#",$lastName,$msg);
$msg= str_replace("#mail#",$mail,$msg1);
$msg1= str_replace("#questionName#",$arrques[$i],$msg);
$msg= str_replace("#answer#",$arrans[$i],$msg1);
$msg1= str_replace("#i#",$i,$msg);
$msg= str_replace("#course#",$courseName,$msg1);
}
$msg.="</table><br>*/
//
$msg .= "</head>
$msg = "<html><head>
<link rel='stylesheet' href='http://www.dokeos.com/styles.css' type='text/css'>
<meta content='text/html; charset=ISO-8859-1' http-equiv='content-type'>";
$msg .= "</head>
<body><br>
<p>".get_lang('OpenQuestionsAttempted')." :
</p>
@ -982,11 +912,10 @@ color: #000000;
<span class='style16'>".get_lang('ClickToCommentAndGiveFeedback').",<br>
<a href='#url#'>#url#</a></span></body></html>";
$msg1= str_replace("#url#",$url,$msg);
$mail_content = stripslashes($msg1);
$student_name = $_SESSION['_user']['firstName'].' '.$_SESSION['_user']['lastName'];
$subject = get_lang('OpenQuestionsAttempted');
api_mail_html($student_name, $to, $subject, $mail_content, $from_name, $from);
}
?>
?>

@ -1709,6 +1709,7 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_on_new_doc_dropbox',0,'dropbox')");
api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_edit_agenda',0,'agenda')");
api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_edit_announcement',0,'announcement')");
api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_manager_on_new_quiz',0,'quiz')");
/*
-----------------------------------------------------------
Course homepage tools for platform admin only

Loading…
Cancel
Save