+++ /dev/null
-<?php\r
-/************************************************************************/\r
-/* ATutor */\r
-/************************************************************************/\r
-/* Copyright (c) 2002-2010 */\r
-/* Inclusive Design Institute */\r
-/* http://atutor.ca */\r
-/* This program is free software. You can redistribute it and/or */\r
-/* modify it under the terms of the GNU General Public License */\r
-/* as published by the Free Software Foundation. */\r
-/************************************************************************/\r
-\r
-/**\r
- * The Assignment Dropbox is designed for instructors to manage assignment \r
- * submissions and for students to submit assignments.\r
- *\r
- * This file contains the functions used by Assignment Dropbox.\r
- **/\r
-\r
-if (!defined('AT_INCLUDE_PATH')) { exit; }\r
-\r
-/**\r
- * given an owner_type and owner_id\r
- * returns false if user cannot read or write to this workspace\r
- * returns WORKSPACE_AUTH_READ if the user can read\r
- * returns WORKSPACE_AUTH_WRITE if the user can write\r
- */\r
-function ad_authenticate($owner_id) {\r
- if (authenticate(AT_PRIV_ASSIGNMENTS, AT_PRIV_RETURN))\r
- { \r
- // instructors have read only access to assignments\r
- return true;\r
- }\r
- else\r
- { \r
- // students have read access to their own assignments\r
- global $db;\r
- $sql = "SELECT COUNT(*) cnt FROM ".TABLE_PREFIX."files\r
- WHERE owner_id =".$owner_id."\r
- AND owner_type= ".WORKSPACE_ASSIGNMENT."\r
- AND member_id = ".$_SESSION['member_id'];\r
- $result = mysql_query($sql, $db);\r
- $row = mysql_fetch_assoc($result);\r
- \r
- if ($row['cnt'] > 0) RETURN true;\r
- \r
- // enrolled students can submit the assignments that assign to him/her\r
- if ($_SESSION['member_id'] && $_SESSION['enroll']) {\r
- // assignments that are assigned to all students\r
- $sql = "SELECT count(*) cnt FROM ".TABLE_PREFIX."assignments \r
- WHERE assignment_id = ".$owner_id."\r
- AND assign_to=0 \r
- AND course_id=".$_SESSION[course_id];\r
- $result = mysql_query($sql, $db);\r
- $row = mysql_fetch_assoc($result);\r
- \r
- if ($row['cnt'] > 0) RETURN true;\r
-\r
- // assignments that are assigned to a group, \r
- // and this group has "file storage" tool available\r
- // and the student is in this group\r
- $groups_list = implode(',',$_SESSION['groups']); // the groups that the student belongs to\r
- $sql = "SELECT count(*) cnt\r
- FROM ".TABLE_PREFIX."groups_types gt, ".TABLE_PREFIX."groups g, ".TABLE_PREFIX."assignments a\r
- WHERE g.group_id in (".$groups_list.")\r
- AND g.group_id in (SELECT group_id FROM ".TABLE_PREFIX."file_storage_groups)\r
- AND g.type_id = gt.type_id\r
- AND gt.course_id = $_SESSION[course_id]\r
- AND gt.type_id = a.assign_to\r
- AND a.assignment_id = ".$owner_id;\r
- $result = mysql_query($sql, $db);\r
- $row = mysql_fetch_assoc($result);\r
- \r
- if ($row['cnt'] > 0) RETURN true;\r
- }\r
- }\r
-\r
- return false;\r
-}\r
-\r
-?>
\ No newline at end of file