function show_assignments() { global $m, $uid, $group_id, $langSubmit, $langDays, $langNoAssign, $tool_content, $langWorks, $course_id, $course_code, $themeimg, $langCancel, $urlServer; $gids = user_group_info($uid, $course_id); if (!empty($gids)) { $gids_sql_ready = implode(',',array_keys($gids)); } else { $gids_sql_ready = "''"; } $res = Database::get()->queryArray("SELECT *, CAST(UNIX_TIMESTAMP(deadline)-UNIX_TIMESTAMP(NOW()) AS SIGNED) AS time FROM assignment WHERE course_id = ?d AND active = '1' AND (assign_to_specific = '0' OR assign_to_specific = '1' AND id IN (SELECT assignment_id FROM assignment_to_specific WHERE user_id = ?d UNION SELECT assignment_id FROM assignment_to_specific WHERE group_id IN ($gids_sql_ready)) ) ORDER BY CASE WHEN CAST(deadline AS UNSIGNED) = '0' THEN 1 ELSE 0 END, deadline", $course_id, $uid); if (count($res) == 0) { $tool_content .= $langNoAssign; return; } $table_content = ''; foreach ($res as $row) { if (!$row->active) { continue; } $table_content .= "<tr><td width=\"1%\"> <img style='padding-top:2px;' src='$themeimg/arrow.png' alt=''></td> <td><div align='left'><a href='index.php?course=$course_code&id=$row->id'>" . q($row->title) . "</a></td> <td align='center'>" . nice_format($row->deadline); if ($row->time > 0) { $table_content .= "<br>(<small>$langDaysLeft" . format_time_duration($row->time) . "</small>)"; } else if($row->deadline){ $table_content .= "<br> (<small><span class='expired'>$m[expired]</span></small>)"; } $table_content .= "</div></td>\n <td align=\"center\">"; $subm = was_submitted($uid, $group_id, $row->id); if ($subm == 'user') { $table_content .= $m['yes']; } elseif ($subm == 'group') { $table_content .= $m['by_groupmate']; } else { $table_content .= $m['no']; } $table_content .= "</td><td align=\"center\">"; if ($row->time >= 0 and !was_graded($uid, $row->id) and is_group_assignment($row->id)) { $table_content .= "<input type='radio' name='assign' value='$row->id'>"; } else { $table_content .= '-'; } $table_content .= "</td>\n </tr>"; } $tool_content .= " <div class='form-wrapper'> <form class='form-horizontal' action='$_SERVER[SCRIPT_NAME]?course=$course_code' method='post'> <fieldset> <input type='hidden' name='file' value='" . q($_GET['submit']) . "'> <input type='hidden' name='group_id' value='$group_id'> <div class='form-group'> <label for='title' class='col-sm-2 control-label'>$langWorks ($m[select]):</label> <div class='col-sm-10'> <table class='table-default'> <tr> <th class='left' colspan='2'>$m[title]</th> <th align='center' width='30%'>$m[deadline]</th> <th align='center' width='10%'>$m[submitted]</th> <th align='center' width='10%'>$m[select]</th> </tr> $table_content </table> </div> </div> <div class='form-group'> <label for='title' class='col-sm-2 control-label'>$m[comments]:</label> <div class='col-sm-10'> <textarea name='comments' rows='4' cols='60' class='form-control'></textarea> </div> </div> <div class='form-group'> <div class='col-sm-10 col-sm-offset-2'> <input class='btn btn-primary' type='submit' name='submit' value='$langSubmit'> <a class='btn btn-default' href='$urlServer/modules/group/document.php?course=$course_code&group_id=$group_id'>$langCancel</a> </div> </div> </fieldset> </form> </div>"; }
$objExerciseTmp->save(); Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_EXERCISE, $exerciseId); redirect_to_home_page('modules/exercise/index.php?course='.$course_code); case 'clone': // make exercise limited $objExerciseTmp->duplicate(); Session::Messages($langCopySuccess, 'alert-success'); redirect_to_home_page('modules/exercise/index.php?course='.$course_code); } } // destruction of Exercise unset($objExerciseTmp); } $result = Database::get()->queryArray("SELECT id, title, description, type, active, public, ip_lock, password_lock FROM exercise WHERE course_id = ?d ORDER BY id LIMIT ?d, ?d", $course_id, $from, $limitExPage); $qnum = Database::get()->querySingle("SELECT COUNT(*) as count FROM exercise WHERE course_id = ?d", $course_id)->count; } else { $gids = user_group_info($uid, $course_id); if (!empty($gids)) { $gids_sql_ready = implode(',',array_keys($gids)); } else { $gids_sql_ready = "''"; } $result = Database::get()->queryArray("SELECT id, title, description, type, active, public, start_date, end_date, time_constraint, attempts_allowed, score, ip_lock, password_lock " . "FROM exercise WHERE course_id = ?d AND active = 1 " . "AND (assign_to_specific = '0' OR assign_to_specific != '0' AND id IN (SELECT exercise_id FROM exercise_to_specific WHERE user_id = ?d UNION SELECT exercise_id FROM exercise_to_specific WHERE group_id IN ($gids_sql_ready)) ) " ."ORDER BY id LIMIT ?d, ?d", $course_id, $uid, $from, $limitExPage); $qnum = Database::get()->querySingle("SELECT COUNT(*) as count FROM exercise WHERE course_id = ?d AND active = 1", $course_id)->count; } $paused_exercises = Database::get()->queryArray("SELECT eurid, eid, title, attempt, password_lock FROM exercise_user_record a " . "JOIN exercise b ON a.eid = b.id WHERE b.course_id = ?d AND a.uid = ?d "
function printPolls() { global $tool_content, $course_id, $course_code, $langTitle, $langCancel, $langPollStart, $langPollEnd, $langPollNone, $is_editor, $langAnswers, $langEditChange, $langDelete, $langSurveyNotStarted, $langDeactivate, $langPollHasEnded, $langActivate, $langParticipate, $langHasParticipated, $langSee, $langHasNotParticipated, $uid, $langConfirmDelete, $langPurgeExercises, $langPurgeExercises, $langConfirmPurgeExercises, $langCreateDuplicate, $head_content, $langCreateDuplicateIn, $langCurrentCourse, $langUsage, $langNoAccessPrivilages; $my_courses = Database::get()->queryArray("SELECT a.course_id Course_id, b.title Title FROM course_user a, course b WHERE a.course_id = b.id AND a.course_id != ?d AND a.user_id = ?d AND a.status = 1", $course_id, $uid); $courses_options = ""; foreach ($my_courses as $row) { $courses_options .= "'<option value=\"$row->Course_id\">".q($row->Title)."</option>'+"; } $head_content .= " <script> $(document).on('click', '.warnLink', function() { var pid = $(this).data('pid'); bootbox.dialog({ title: '$langCreateDuplicateIn', message: '<form action=\"$_SERVER[SCRIPT_NAME]\" method=\"POST\" id=\"clone_form\">'+ '<select class=\"form-control\" id=\"course_id\" name=\"clone_to_course_id\">'+ '<option value=\"$course_id\">--- $langCurrentCourse ---</option>'+ $courses_options '</select>'+ '</form>', buttons: { success: { label: '$langCreateDuplicate', className: 'btn-success', callback: function (d) { $('#clone_form').attr('action', '$_SERVER[SCRIPT_NAME]?pid=' + pid); $('#clone_form').submit(); } }, cancel: { label: '$langCancel', className: 'btn-default' } } }); }); </script> "; $poll_check = 0; $query = "SELECT * FROM poll WHERE course_id = ?d"; $query_params[] = $course_id; //Bring only those assigned to the student if (!$is_editor) { $gids = user_group_info($uid, $course_id); if (!empty($gids)) { $gids_sql_ready = implode(',',array_keys($gids)); } else { $gids_sql_ready = "''"; } $query .= " AND (assign_to_specific = '0' OR assign_to_specific != '0' AND pid IN (SELECT poll_id FROM poll_to_specific WHERE user_id = ?d UNION SELECT poll_id FROM poll_to_specific WHERE group_id IN ($gids_sql_ready)) )"; $query_params[] = $uid; } $result = Database::get()->queryArray($query, $query_params); $num_rows = count($result); if ($num_rows > 0) ++$poll_check; if (!$poll_check) { $tool_content .= "\n <div class='alert alert-warning'>" . $langPollNone . "</div><br>"; } else { // Print active polls $tool_content .= " <div class='table-repsonsive'> <table class='table-default'> <tr class='list-header'> <th><div align='left'> $langTitle</div></th> <th class='text-center'>$langPollStart</th> <th class='text-center'>$langPollEnd</th>"; if ($is_editor) { $tool_content .= "<th class='text-center' width='16'>$langAnswers</th>"; } else { $tool_content .= "<th class='text-center'>$langParticipate</th>"; } $tool_content .= "<th class='text-center'>".icon('fa-cogs')."</th>"; $tool_content .= "</tr>"; $index_aa = 1; $k = 0; foreach ($result as $thepoll) { $total_participants = Database::get()->querySingle("SELECT COUNT(DISTINCT user_id) AS total FROM poll_answer_record WHERE pid = ?d", $thepoll->pid)->total; $visibility = $thepoll->active; if (($visibility) or ($is_editor)) { if ($visibility) { $visibility_css = ""; $visibility_gif = "fa-eye"; $visibility_func = "deactivate"; $arrow_png = "arrow"; $k++; } else { $visibility_css = " class=\"not_visible\""; $visibility_gif = "fa-eye-slash"; $visibility_func = "activate"; $arrow_png = "arrow"; $k++; } $tool_content .= "<tr $visibility_css>"; $temp_CurrentDate = date("Y-m-d H:i"); $temp_StartDate = $thepoll->start_date; $temp_EndDate = $thepoll->end_date; $temp_StartDate = mktime(substr($temp_StartDate, 11, 2), substr($temp_StartDate, 14, 2), 0, substr($temp_StartDate, 5, 2), substr($temp_StartDate, 8, 2), substr($temp_StartDate, 0, 4)); $temp_EndDate = mktime(substr($temp_EndDate, 11, 2), substr($temp_EndDate, 14, 2), 0, substr($temp_EndDate, 5, 2), substr($temp_EndDate, 8, 2), substr($temp_EndDate, 0, 4)); $temp_CurrentDate = mktime(substr($temp_CurrentDate, 11, 2), substr($temp_CurrentDate, 14, 2), 0, substr($temp_CurrentDate, 5, 2), substr($temp_CurrentDate, 8, 2), substr($temp_CurrentDate, 0, 4)); $creator_id = $thepoll->creator_id; $theCreator = uid_to_name($creator_id); $pid = $thepoll->pid; $countAnswers = Database::get()->querySingle("SELECT COUNT(DISTINCT(user_id)) as counter FROM poll_answer_record WHERE pid = ?d", $pid)->counter; // check if user has participated $has_participated = Database::get()->querySingle("SELECT COUNT(*) as counter FROM poll_answer_record WHERE user_id = ?d AND pid = ?d", $uid, $pid)->counter; // check if poll has ended OR not strarted yet $poll_ended = 0; $poll_not_started = 0; if($temp_CurrentDate < $temp_StartDate) { $poll_not_started = 1; } else if ($temp_CurrentDate >= $temp_EndDate) { $poll_ended = 1; } if ($is_editor) { $tool_content .= " <td><a href='pollparticipate.php?course=$course_code&UseCase=1&pid=$pid'>".q($thepoll->name)."</a>"; } else { $tool_content .= " <td>"; if (($has_participated == 0) and $poll_ended == 0) { $tool_content .= "<a href='pollparticipate.php?course=$course_code&UseCase=1&pid=$pid'>".q($thepoll->name)."</a>"; } else { $tool_content .= q($thepoll->name); } } $tool_content .= " <td class='text-center'>" . nice_format(date("Y-m-d H:i", strtotime($thepoll->start_date)), true) . "</td> <td class='text-center'>" . nice_format(date("Y-m-d H:i", strtotime($thepoll->end_date)), true) . "</td>"; if ($is_editor) { $tool_content .= " <td class='text-center'>$countAnswers</td> <td class='text-center option-btn-cell'>" .action_button(array( array( 'title' => $langEditChange, 'icon' => 'fa-edit', 'url' => "admin.php?course=$course_code&pid=$pid" ), array( 'title' => $visibility? $langDeactivate : $langActivate, 'icon' => $visibility ? 'fa-toggle-off' : 'fa-toggle-on', 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&visibility=$visibility_func&pid={$pid}" ), array( 'title' => $langUsage, 'icon' => 'fa-line-chart', 'url' => "pollresults.php?course=$course_code&pid=$pid", 'show' => $total_participants > 0 ), array( 'title' => $langSee, 'icon' => 'fa-search', 'url' => "pollparticipate.php?course=$course_code&UseCase=1&pid=$pid" ), array( 'title' => $langCreateDuplicate, 'icon' => 'fa-copy', 'icon-class' => 'warnLink', 'icon-extra' => "data-pid='$pid'", 'url' => "#" ), array( 'title' => $langPurgeExercises, 'icon' => 'fa-eraser', 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&delete_results=yes&pid=$pid", 'confirm' => $langConfirmPurgeExercises, 'show' => $total_participants > 0 ), array( 'title' => $langDelete, 'icon' => 'fa-times', 'class' => 'delete', 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&delete=yes&pid=$pid", 'confirm' => $langConfirmDelete ) ))."</td></tr>"; } else { $tool_content .= " <td class='text-center'>"; if ($has_participated == 0 && $poll_ended == 0 && $poll_not_started == 0) { $tool_content .= "$langHasNotParticipated"; } else { if ($poll_ended == 1) { $tool_content .= $langPollHasEnded; } elseif($poll_not_started == 1) { $tool_content .= $langSurveyNotStarted; } else { $tool_content .= $langHasParticipated; } } $tool_content .= "</td>"; $line_chart_link = ($has_participated && $thepoll->show_results)? "<a href='pollresults.php?course=$course_code&pid=$pid'><span class='fa fa-line-chart'></span></a>" : "<span class='fa fa-line-chart' data-toggle='tooltip' title='$langNoAccessPrivilages'></span>" ; $tool_content .= "<td class='text-center option-btn-cell'><div style='padding-top:7px;padding-bottom:7px;'>$line_chart_link</div></td></tr>"; // $tool_content .= " // <td class='text-center option-btn-cell'>" .action_button(array( // array( // 'title' => $langUsage, // 'icon' => 'fa-line-chart', // 'url' => "pollresults.php?course=$course_code&pid=$pid", // 'show' => $has_participated // ) // ))."</td></tr>"; } } $index_aa ++; } $tool_content .= "</table></div>"; } }
function groups_with_no_submissions($id) { global $course_id; $q = Database::get()->queryArray('SELECT group_id FROM assignment_submit WHERE assignment_id = ?d', $id); $groups = user_group_info(null, $course_id, $id); if (count($q) > 0) { foreach ($q as $row) { unset($groups[$row->group_id]); } } return $groups; }
/** * * returns whether the user has submitted an assignment */ function submitted($uid, $assignment_id, $lesson_id) { // find prefix $prefix = './modules'; if (!file_exists($prefix) && file_exists('../group') && file_exists('../work')) { $prefix = '..'; } require_once $prefix . '/group/group_functions.php'; require_once $prefix . '/work/work_functions.php'; $gids = user_group_info($uid, $lesson_id); $GLOBALS['course_id'] = $lesson_id; if ($submission = find_submissions(is_group_assignment($assignment_id), $uid, $assignment_id, $gids)) { return true; } else { return false; } }