Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Add the following functionality when the user selects vm to view all the tasks assigned to them: Display all tasks in a manner that is
Add the following functionality when the user selects vm to view all the tasks
assigned to them:
Display all tasks in a manner that is easy to read. Make sure that each
task is displayed with a corresponding number that can be used to
identify the task.
Allow the user to select either a specific task by entering a number or
input to return to the main menu.
If the user selects a specific task, they should be able to choose to either
mark the task as complete or edit the task.
If the user chooses to mark a task as complete, the YesNo
value that describes whether the task has been completed or not
should be changed to Yes
if the user chooses to edit a task, the username of the person to
whom the task is assigned or the due date of the task can be
edited. The task can only be edited if it has not yet been
completed.
code
# Notes:
# Use the following username and password to access the admin rights
# username: admin
# password: password
# Ensure you open the whole folder for this task in VS Code otherwise the
# program will look in your root directory for the text files.
#importing libraries
import os
from datetime import datetime, date
DATETIMESTRINGFORMAT Ymd
# Create tasks.txt if it doesn't exist
if not ospath.existstaskstxt:
with opentaskstxtw as defaultfile:
pass
with opentaskstxtr as taskfile:
taskdata taskfile.readsplit
taskdata t for t in taskdata if t
tasklist
for tstr in taskdata:
currt
# Split by semicolon and manually add each component
taskcomponents tstrsplit;
currtusername taskcomponents
currttitle taskcomponents
currtdescription taskcomponents
currtduedate' datetime.strptimetaskcomponents DATETIMESTRINGFORMAT
currtassigneddate' datetime.strptimetaskcomponents DATETIMESTRINGFORMAT
currtcompleted True if taskcomponents "Yes" else False
tasklist.appendcurrt
#Login Section
This code reads usernames and password from the user.txt file to
allow a user to login
# If no user.txt file, write one with a default account
if not ospath.existsusertxt:
with openusertxtw as defaultfile:
defaultfile.writeadmin;password"
# Read in userdata
with openusertxtr as userfile:
userdata userfile.readsplit
# Convert to a dictionary
usernamepassword
for user in userdata:
username, password user.split;
usernamepasswordusername password
loggedin False
while not loggedin:
printLOGIN
curruser inputUsername:
currpass inputPassword:
if curruser not in usernamepassword.keys:
printUser does not exist"
continue
elif usernamepasswordcurruser currpass:
printWrong password"
continue
else:
printLogin Successful!"
loggedin True
# user defining for menu
def reguser :
newusername inputEnter new Username: strip
if newusername in usernamepassword:
printThat username already exists please enter another one!"
else:
if newusername not in usernamepassword:
while True:
newpassword inputEnter new Password: strip
confirmnewpassword inputReenter new Password: strip
if newpassword confirmnewpassword:
printNew user added"
usernamepasswordnewusername newpassword
with openusertxtw as outfile:
userdata
for k in usernamepassword:
userdata.appendfk;usernamepasswordk
outfile.write
joinuserdata
return newusername newpassword
else:
printPasswords do no match"
def addtask :
taskusername inputName of person assigned to task:
while taskusername not in usernamepassword.keys:
printUser does not exist. Please enter a valid username"
taskusername inputEnter a user who exists please."
tasktitle inputTitle of Task:
taskdescription inputDescription of Task:
while True:
try:
taskduedate inputDue date of task YYYYMMDD:
duedatetime datetime.strptimetaskduedate, DATETIMESTRINGFORMAT
break
except ValueError:
printInvalid datetime format. Please use the format specified"
# Then get the current date.
currdate date.today
Add the data to the file task.txt and
Include No to indicate if the task is complete.
newtask
"usern
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started