Skip to content

Commit

Permalink
Forum peer scoring see #7668 (partial)
Browse files Browse the repository at this point in the history
Add db change thread_peer_qualify.
Gradebook result missing.
  • Loading branch information
jmontoyaa committed Apr 30, 2015
1 parent 2d7aaae commit 7c769e0
Show file tree
Hide file tree
Showing 18 changed files with 1,445 additions and 850 deletions.
37 changes: 20 additions & 17 deletions main/forum/editpost.php
Expand Up @@ -116,8 +116,8 @@
// The only exception is the course manager
// I have split this is several pieces for clarity.
//if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility'] == 0 OR $current_forum['visibility'] == 0) OR ($current_forum_category['locked'] <> 0 OR $current_forum['locked'] <> 0 OR $current_thread['locked'] <> 0))) {
if (!api_is_allowed_to_edit(null, true) AND
(($current_forum_category && $current_forum_category['visibility'] == 0) OR
if (!api_is_allowed_to_edit(null, true) &&
(($current_forum_category && $current_forum_category['visibility'] == 0) ||
$current_forum['visibility'] == 0)
) {
$forum_allow = forum_not_allowed_here();
Expand All @@ -126,10 +126,10 @@
}
}

if (!api_is_allowed_to_edit(null, true) AND
if (!api_is_allowed_to_edit(null, true) &&
(
($current_forum_category && $current_forum_category['locked'] <> 0 ) OR
$current_forum['locked'] <> 0 OR
($current_forum_category && $current_forum_category['locked'] <> 0 ) ||
$current_forum['locked'] <> 0 ||
$current_thread['locked'] <> 0
)
) {
Expand All @@ -139,15 +139,18 @@
}
}

if (!$_user['user_id'] AND $current_forum['allow_anonymous'] == 0) {
if (!$_user['user_id'] && $current_forum['allow_anonymous'] == 0) {
$forum_allow = forum_not_allowed_here();
if ($forum_allow === false) {
exit;
}
}
$group_id = api_get_group_id();

if (!api_is_allowed_to_edit(null, true) AND $current_forum['allow_edit'] == 0 && !GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)) {
if (!api_is_allowed_to_edit(null, true) &&
$current_forum['allow_edit'] == 0 &&
!GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)
) {
$forum_allow = forum_not_allowed_here();
if ($forum_allow === false) {
exit;
Expand All @@ -170,12 +173,10 @@
/* Display Forum Category and the Forum information */

/*New display forum div*/
echo '<div class="row">';
echo '<div class="span12">';
echo '<div class="forum_title">';
echo '<h1><a href="viewforum.php?&amp;origin='.$origin.'&amp;forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a></h1>';
echo '<p class="forum_description">'.prepare4display($current_forum['forum_comment']).'</p>';
echo '</div></div></div>';
echo '</div>';
/* End new display forum */

// Set forum attachment data into $_SESSION
Expand All @@ -184,17 +185,14 @@
$current_thread['thread_id'],
$current_post['post_id']
);
// The form for the reply
echo '<div class="row">';
echo '<div class="span12">';

$values = show_edit_post_form(
$forum_setting,
$current_post,
$current_thread,
$current_forum,
isset($_SESSION['formelements']) ? $_SESSION['formelements'] : ''
);
echo '</div></div>';

if (!empty($values) and isset($_POST['SubmitPost'])) {
store_edit_post($values);
Expand All @@ -207,8 +205,15 @@
$weight_calification = $values['weight_calification'];
$description = '';
$session_id = api_get_session_id();
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5, $id, $session_id);

$link_info = GradebookUtils::is_resource_in_course_gradebook(
api_get_course_id(),
5,
$id,
$session_id
);
$link_id = $link_info['id'];

if (!$link_info) {
GradebookUtils::add_resource_to_course_gradebook(
$values['category_id'],
Expand All @@ -228,14 +233,12 @@
}
} else {
// Only show Forum attachment ajax form when do not pass form submit
echo '<div class="row"><div class="span12">';
$attachmentAjaxForm = getAttachmentAjaxForm(
$current_forum['forum_id'],
$current_thread['thread_id'],
$current_post['post_id']
);
echo $attachmentAjaxForm;
echo '</div></div>';
}

// Footer
Expand Down
38 changes: 22 additions & 16 deletions main/forum/forumbody.inc.php
@@ -1,18 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
$current_thread = get_thread_information($_GET['thread']);
$my_cid_req = Security::remove_XSS($_GET['cidReq']);
$my_forum = Security::remove_XSS($_GET['forum']);
$my_thread = Security::remove_XSS($_GET['thread']);
$my_user_id = Security::remove_XSS($_GET['user_id']);
$user = Security::remove_XSS($_GET['user']);
$my_idtextqualify = isset($_REQUEST['idtextqualify']) ? Security::remove_XSS($_REQUEST['idtextqualify']) : $qualify;
$my_gradebook = Security::remove_XSS($_GET['gradebook']);
$to_origin = Security::remove_XSS($_GET['origin']);

$current_thread = get_thread_information($_GET['thread']);
$my_cid_req = Security::remove_XSS($_GET['cidReq']);
$my_forum = Security::remove_XSS($_GET['forum']);
$my_thread = Security::remove_XSS($_GET['thread']);
$my_user_id = Security::remove_XSS($_GET['user_id']);
$user = Security::remove_XSS($_GET['user']);
$my_idtextqualify = isset($_REQUEST['idtextqualify']) ? Security::remove_XSS($_REQUEST['idtextqualify']) : $qualify;
$my_gradebook = Security::remove_XSS($_GET['gradebook']);
$to_origin = Security::remove_XSS($_GET['origin']);

$output = <<<EOF
<div class="forum-body-form">
<table class="data_table">
<table class="table">
<form id="forum-thread-qualify" name="forum-thread-qualify" action="forumqualify.php">
<input type="hidden" name="cidReq" value="{$my_cid_req}">
<input type="hidden" name="forum" value="{$my_forum}">
Expand All @@ -24,7 +25,7 @@
<tr>
EOF;

$output .= '
$output .= '
<td width="40%" class="forum-thread-header">'.get_lang('Thread').'&nbsp;:</td >
<td width="60%" class="forum-thread-body">
<div align="left">'.$current_thread['thread_title'].'</div>
Expand All @@ -37,20 +38,19 @@
<div align="left">'.$result['user_course'].'</div>
</td>
</tr>
<tr>
<td width="40%" class="forum-thread-header">'.get_lang('PostsNumber').'&nbsp;:</td >
<td width="60%" class="forum-thread-body">
<div align="left">'.$result['post'].'</div>
</td>
</tr>
<tr>
<tr>
<td width="40%" class="forum-thread-header">'.get_lang('NumberOfPostsForThisUser').'&nbsp;:</td >
<td width="60%" class="forum-thread-body">
<div align="left">'.$result['user_post'].'</div>
</td>
</tr>
<tr>
<tr>
<td width="40%" class="forum-thread-header">'.get_lang('AveragePostPerUser').'&nbsp;:</td >
<td width="60%" class="forum-thread-body">
<div align="left">'.round($result['user_post']/$result['post'],2).'</div>
Expand All @@ -64,9 +64,15 @@
</tr>
<tr>
<td width="40%"></td>
<td width="60%"><div align="left"><button type="button" class="save" id="idbutton_qualify" name="idbutton_qualify" value="'.get_lang('QualifyThisThread').'" onclick="javascript:if(document.getElementById(\'idtextqualify\').value>=0){if(confirm(\''.get_lang('ConfirmUserQualification').'\')){document.getElementById(\'forum-thread-qualify\').submit();}else{return false;};}else{alert(\''.get_lang('InsertQualificationCorrespondingToMaxScore').'\')};" >'.get_lang('QualifyThisThread').'</button></div></td>
<td width="60%">
<div align="left">
<button type="button" class="save" id="idbutton_qualify" name="idbutton_qualify" value="'.get_lang('QualifyThisThread').'" onclick="javascript:if(document.getElementById(\'idtextqualify\').value>=0){if(confirm(\''.get_lang('ConfirmUserQualification').'\')){document.getElementById(\'forum-thread-qualify\').submit();}else{return false;};}else{alert(\''.get_lang('InsertQualificationCorrespondingToMaxScore').'\')};" >
'.get_lang('QualifyThisThread').'
</button>
</div>
</td>
</tr>
</form>
</table>
</div>';
echo $output;
echo $output;

0 comments on commit 7c769e0

Please sign in to comment.