func UpdateModifiedCourses(moodleid int, courses []Course) error {
	// Get the connection
	connection, err := db.GetDB()
	if err != nil {
		return err
	}

	tx, err := connection.Begin()
	if err != nil {
		return err
	}
	defer tx.Rollback() // The rollback will be ignored if the tx has been committed later in the function.

	stmt, err := tx.Prepare(`
		UPDATE courses
		SET shortname=?, fullname=?, summary=?, showgrades=?
		WHERE moodleid=? AND id=?`)
	if err != nil {
		return err
	}
	defer stmt.Close()

	for _, c := range courses {
		_, err := stmt.Exec(
			c.Shortname,
			c.Fullname,
			c.Summary,
			c.Showgrades,
			moodleid,
			c.ID)
		if err != nil {
			return err
		}
	}
	if err := tx.Commit(); err != nil {
		return err
	}

	return nil
}
// UpdateModifiedCourses changes the properties of already existing courses.
// NOTE: It doesn't change the unhandlednotifications status
UpdateModifiedCourses changes the properties of already existing courses.
NOTE: It doesn't change the unhandlednotifications status
// UpdateModifiedCourses changes the properties of already existing courses . // NOTE : It doesn ' t change the unhandlednotifications status
func UpdateModifiedCourses(moodleid int, courses []Course) error {
	connection, err := db.GetDB()
	if err != nil {
		return err
	}
	tx, err := connection.Begin()
	if err != nil {
		return err
	}
	defer tx.Rollback() 
	stmt, err := tx.Prepare(`
		UPDATE courses
		SET shortname=?, fullname=?, summary=?, showgrades=?
		WHERE moodleid=? AND id=?`)
	if err != nil {
		return err
	}
	defer stmt.Close()
	for _, c := range courses {
		_, err := stmt.Exec(
			c.Shortname,
			c.Fullname,
			c.Summary,
			c.Showgrades,
			moodleid,
			c.ID)
		if err != nil {
			return err
		}
	}
	if err := tx.Commit(); err != nil {
		return err
	}
	return nil
}
func UpdateModifiedCourses ( moodleid int , courses [ ] Course ) error { connection , err := db . GetDB ( ) if err != nil { return err } tx , err := connection . Begin ( ) if err != nil { return err } defer tx . Rollback ( ) stmt , err := tx . Prepare ( `
		UPDATE courses
		SET shortname=?, fullname=?, summary=?, showgrades=?
		WHERE moodleid=? AND id=?` ) if err != nil { return err } defer stmt . Close ( ) for _ , c := range courses { _ , err := stmt . Exec ( c . Shortname , c . Fullname , c . Summary , c . Showgrades , moodleid , c . ID ) if err != nil { return err } } if err := tx . Commit ( ) ; err != nil { return err } return nil }
UpdateModifiedCourses changes the properties of already existing courses.
UpdateModifiedCourses changes the properties of already existing courses .
// Get the connection // The rollback will be ignored if the tx has been committed later in the function.