Exemplo n.º 1
0
        internal static bool SecurityIsAllowed(SecurityAction action, out PermissionsID maxPermID)
        {
            int userID = SharedSupport.GetUserIdentity();

            System.Data.OleDb.OleDbConnection  con = new System.Data.OleDb.OleDbConnection(SharedSupport.ConnectionString);
            System.Data.OleDb.OleDbDataAdapter cmd = new System.Data.OleDb.OleDbDataAdapter("Security_GlobalIsAllowed", con);
            System.Data.DataSet ds = new System.Data.DataSet();
            System.Data.OleDb.OleDbParameter param;

            cmd.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;

            param       = new System.Data.OleDb.OleDbParameter("@UserID", System.Data.OleDb.OleDbType.Integer);
            param.Value = userID;
            cmd.SelectCommand.Parameters.Add(param);

            param       = new System.Data.OleDb.OleDbParameter("@ActionID", System.Data.OleDb.OleDbType.Integer);
            param.Value = (int)action;
            cmd.SelectCommand.Parameters.Add(param);

            maxPermID = PermissionsID.Student;
            try
            {
                cmd.Fill(ds);
            }
            catch (System.Exception e)
            {
                SharedSupport.HandleError(e);
            }

            try
            {
                if (Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"]) == userID)
                {
                    maxPermID = (PermissionsID)Convert.ToInt32(ds.Tables[0].Rows[0]["RoleID"]);
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
        public void Submit(int assignmentID, int courseID, string xmlFileList, string pathGUID)
        {
            try
            {
                bool bBuildAssignment = false;                  // indicates if build indicated by faculty for this assignment
                bool bCheckAssignment = false;                  // indicates if check indicated by faculty for this assignment

                //For each file uploaded - move to secure directory
                this._assignmentID = assignmentID;
                this._userID       = SharedSupport.GetUserIdentity();

                //Check to see if the user has already submitted an assignment and if the assignment allows for multiple submissions.
                //If not allowed, and the user has already submitted an assignment for this assignment then throw error.
                AssignmentM assign = AssignmentM.Load(assignmentID);
                if (assign.IsValid)
                {
                    // build / check indicated for this assignment?

                    bBuildAssignment = assign.AutoCompileFlag;
                    bCheckAssignment = assign.AutoGradeFlag;

                    if (!assign.MultipleSubmitsFlag)
                    {
                        if (this.HasSubmitted)
                        {
                            throw new ApplicationException(SharedSupport.GetLocalizedString("StudentAssignment_NoMultipleSubmits"));
                        }
                    }
                }
                else
                {
                    throw new ApplicationException(SharedSupport.GetLocalizedString("StudentAssignment_NoCourseOfferingAssignment_Error"));
                }

                // delete any previous submissions
                this.ClearSubmissions();

                if (bBuildAssignment)
                {
                    this._autoCompileStatus = Constants.AUTOCOMPILE_PENDING_STATUS;
                }
                else
                {
                    this._autoCompileStatus = Constants.AUTOCOMPILE_NOTAPPLICABLE_STATUS;
                }
                if (bCheckAssignment)
                {
                    this._autoGradeStatus = Constants.AUTOGRADE_PENDING_STATUS;
                }
                else
                {
                    this._autoGradeStatus = Constants.AUTOGRADE_NOTAPPLICABLE_STATUS;
                }
                this._lastSubmitDate  = DateTime.Now;
                this._lastUpdatedDate = DateTime.Now;

                this.SaveToDatabase(StoredProcType.New);

                this.saveFileList(xmlFileList, pathGUID);

                // queue action requests
                if (bBuildAssignment || bCheckAssignment)
                {
                    try
                    {
                        SendActionToQueue(this._userAssignmentID, bBuildAssignment, bCheckAssignment);
                    }
                    catch (Exception ex)
                    {
                        // this is the student submitting, so log it and continue
                        SharedSupport.LogMessage(ex.Message, this.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                SharedSupport.HandleError(ex);
            }
        }
Exemplo n.º 3
0
 internal static bool SecurityIsAllowed(int courseID, SecurityAction action)
 {
     return(SharedSupport.SecurityIsAllowed(SharedSupport.GetUserIdentity(), courseID, action));
 }